Skip to content

fix(mcp): migrate the last-read fallback on identity rename, purge, and channel rename/delete - #84

Open
Lafnaps wants to merge 1 commit into
bcurts:mainfrom
Lafnaps:fix/mcp-last-read-migration
Open

fix(mcp): migrate the last-read fallback on identity rename, purge, and channel rename/delete#84
Lafnaps wants to merge 1 commit into
bcurts:mainfrom
Lafnaps:fix/mcp-last-read-migration

Conversation

@Lafnaps

@Lafnaps Lafnaps commented Aug 1, 2026

Copy link
Copy Markdown

The #58 fallback (chat_send with no channel goes to the sender's last-read channel or job) is keyed by sender name and channel name, but none of the existing migration hooks move that state:

  • migrate_identity() moves the read cursors but not _last_read_channel/_last_read_job_id. After claude becomes claude-1 (happens automatically when a second instance registers), its next bare chat_send falls back to #general instead of the channel it was just reading — the exact misfire Gemini switches chat channel in between sessions #58 was about.
  • migrate_cursors_rename()/migrate_cursors_delete() leave stale channel values behind, so after a channel rename a fallback send posts into the old name and resurrects it as a ghost tab; after a delete it posts into a channel that no longer exists.
  • purge_identity() leaks both maps, so an agent that later registers under the reused name inherits someone else's fallback.

The fix wires the maps into those four hooks, under the existing _last_read_lock: identity migrate rekeys both, purge pops both, channel rename rewrites matching channel values, channel delete resets them to general. (Job-id fallbacks are untouched by the channel hooks — job ids don't change when a channel is renamed.) +20/-2 in mcp_bridge.py.

Tests: four new cases in tests/test_channel_fallback.py following its existing state-map pattern, one per hook; the rename case also checks that other senders' fallbacks are left alone. python -m pytest -q tests/test_channel_fallback.py → 12 passed (8 on main). Full suite: 85 passed (81 on current main).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant