fix(mcp): migrate the last-read fallback on identity rename, purge, and channel rename/delete - #84
Open
Lafnaps wants to merge 1 commit into
Open
fix(mcp): migrate the last-read fallback on identity rename, purge, and channel rename/delete#84Lafnaps wants to merge 1 commit into
Lafnaps wants to merge 1 commit into
Conversation
…nd channel rename/delete
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The #58 fallback (
chat_sendwith 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. Afterclaudebecomesclaude-1(happens automatically when a second instance registers), its next barechat_sendfalls 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 togeneral. (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.pyfollowing 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).