Skip to content

Fix draft loss and cache eviction after server switches - #1114

Merged
ivanfenenko merged 1 commit into
mainfrom
fix/server-switch-followups
Nov 23, 2026
Merged

ivanfenenko merged 1 commit into
mainfrom
fix/server-switch-followups

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Three follow-up fixes for server switching:

  • Lost drafts (Android): when two equal composer draft saves were queued, cleanup from the first could drop the second, so the draft never reached disk. Cleanup now compares by identity.
  • Transcript cache (iOS and Android): empty placeholder rows counted toward the 200-transcript limit and could evict real transcripts. Placeholders are now evicted first.
  • Event stream (Android): an SSE rebuild could close a client already opened for the new server, causing a needless stream drop. The switch now rebinds and keeps a client or dial that already serves the bound connection.

Checks

  • iOS and Android both covered. The cache fix changes both platforms. The draft and SSE fixes change Android code only.
  • No UI change
  • Tests run

Unit tests:

  • Android testDebugUnitTest: 4631 passed, 0 failed.
  • iOS OpenCode MobileTests: 3931 passed, 0 failed.
  • With each fix temporarily removed, the Android draft test, the Android SSE test, and both iOS placeholder tests fail.
  • RoomSessionCacheStoreTest uses a fake DAO with its own copy of the ordering, so it does not exercise the changed Room query. That query was run directly in SQLite with one real row and one placeholder: the old query evicts the real row and the new query evicts the placeholder.

Live check, once per platform, against two local scenario harness servers running protocol v2: added the second server, switched between them, and confirmed a session draft was still present after switching back and after an app relaunch.

Issue

Follow-up to #1104.

Risks / Follow-ups

  • Local tests and live checks ran on 86cb95406. main then gained Fix Android Scroll to end moving up inside tall replies #1103, which touches two Android scroll files that do not overlap this change and merges cleanly. It was not retested locally with Fix Android Scroll to end moving up inside tall replies #1103.
  • Protocol v1 was not run live. No v1 server was available, so v1 is covered by unit tests only.
  • The live check did not reproduce the three original races or force a transcript eviction. Those are covered by the tests above.
  • The Room query change has no automated test against a real database.
  • When two profiles share an address and username, whichever migrates first takes the old drafts. This is intentional and unchanged.

Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Keep an equal queued draft save when an earlier detached save cleans up.
Evict empty transcript placeholders before committed transcripts.
Keep an SSE client already opened for the new server during a rebuild.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: no finding that 2+ of 3 passes agreed on.

opencode pr-review · passes: muse-spark-1.3-contributor, glm-5.3-flash, deepseek-v4.1-flash · $0.105

@ivanfenenko
ivanfenenko added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit 3d9a903 Nov 23, 2026
@ivanfenenko
ivanfenenko deleted the fix/server-switch-followups branch November 23, 2026 11:52
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