Skip to content

Fix blocking and major v2 issues found by the simulation test run - #337

Merged
ivanfenenko merged 12 commits into
mainfrom
fix/sim-run-major-issues
Oct 2, 2026
Merged

ivanfenenko merged 12 commits into
mainfrom
fix/sim-run-major-issues

Conversation

@ivanfenenko

@ivanfenenko ivanfenenko commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes the blocking and major issues found by a device test run of both apps against the real opencode v2 (beta) server in simulation mode. 32 checks were run on the iOS simulator and the Android emulator. Every fix below was re-verified on both devices, with before/after screenshots.

  • K1 (blocker, both): v2 permission replies failed with a 400. The reply now sends {"decision": "once" | "reject"} instead of {"reply": …}.

  • Live timeline corruption on v2 (major, both): B2-1, B1-1, K3, B4-1, B5-2. Text from different steps or turns overwrote each other, replies were merged or out of order, and a catch-up after backgrounding merged replies newest-first.

    • Live text and reasoning parts are now keyed <assistantMessageID>:text|reasoning:<ordinal> (it was text-<ordinal>), and REST v2 uses the same IDs, so a reload replaces live parts in place.
    • Live replies are timestamped when their step starts, and queued or steered prompts move to where they were delivered.
    • A full reload lets REST info win.
    • Inbox items read time.created, so a queued prompt no longer gets an epoch timestamp.
  • B4-2 (major, both): reverted messages stayed in the timeline after the revert was committed, even after a relaunch. Both apps now handle session.revert.committed and drop the reverted messages. A full reload removes rows the server no longer returns, but only within the reloaded window.

  • B4-3 (major, both): the compaction summary rendered as raw markdown inside the previous reply. The summary now sits on the compaction part. The timeline shows a "Compacting…" / "Context compacted" card, driven by the live session.compaction.* events, and tapping the card opens the summary.

  • B4-5 (major, both): forks were treated as subagent children, so they were hidden from Home and couldn't be prompted. parentID now comes only from the real field, not from fork.sessionID. session.forked refreshes Home live, and iOS "Open" after forking no longer passes a parent.

  • B5-1 (major, iOS; also fixed on Android): the model list was empty after the server restarted. The composer now refetches the catalog on model.updated / provider.updated and when the event stream reconnects, and retries an empty catalog after 1 s, 2 s and 4 s.

  • CI flake (iOS): SyncCoordinatorTests.loaderFailureRetriesWithBackoffUntilSuccess. The cause is a real ordering race in DefaultSyncCoordinator: a state was changed under the lock but sent to observers after unlocking, so a fast-failing load could leave observers on .syncing. The coordinator now sends each state in the same critical section that sets it. 10 repeated runs of the suite and the full iOS target pass.

v1 code paths are unchanged: v1 part IDs, times and events are untouched, and the v1 suites pass.

Checks

  • Android: ./gradlew :app:testDebugUnitTest, 1605 tests, 0 failures. :app:assembleDebug succeeds.

  • iOS: full OpenCode MobileTests target, 1545 tests. The only failures are 2 known SessionChatViewModelTests cases that read the simulator's chipTimeline default; they fail the same way on main. The app builds.

  • New regression suites: V2LiveTurnTimelineTest (Android) and V2LiveTurnTimelineTests (iOS), plus adapter, store, reload, compaction, fork and catalog tests on both platforms.

  • On-device verification, using debug builds of 0913be6d against the opencode v2 simulation server:

    • every finding's repro steps re-run on both the iOS simulator and the Android emulator
    • 5 server restarts for B5-1
    • steer/queue sent from each app in turn, with the other app watching
    • spot checks that explore, Allow once, the question tool, Stop and single-turn streaming still work

    All 10 findings are fixed.

  • Findings report with before/after screenshots for every fix (LAN artifact server): http://ivan-m2.local:8787/2026-10-02/1404-simulation-test-findings-all-fixed/

Risks / Follow-ups

  • Transcripts cached before this change still have the old text-0 IDs. They can look wrong until the first REST reload corrects them, and forks in an old cache can show as children until the next session-list refresh.
  • A reload now drops a cached row the server doesn't return, within the reloaded window. In a rare race this could briefly hide a message that just arrived.
  • If a reconnect happens mid-compaction, a duplicate compaction card can appear until the next reload.
  • A reconnect now costs up to about 3 extra /api/model requests.
  • The minor and cosmetic findings from the run are not in this PR. They include B4-4 (an early "Context compacted · 0% → 0%" snackbar), the raw markdown in the summary sheet, B2-5 (the queued bar lingers after delivery), and B2-9 ("Ready" pill).

🤖 Generated with Claude Code

ivanfenenko and others added 11 commits October 1, 2026 22:50
v2 text and reasoning events carry no part id, only an ordinal that
restarts at 0 in every assistant message. Both event adapters built the
live id as `text-<ordinal>`, so every step of a turn produced `text-0`.
The chip timeline merges a turn's assistant messages into one body and
keys paragraphs and their markdown by part id, so step texts were
duplicated, swapped or lost until a cold relaunch.

Live ids are now `<assistantMessageID>:<kind>:<ordinal>`, and the REST v2
projection numbers text and reasoning per kind the same way, so a reload
replaces live parts in place. v1 part ids are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
v2 has no assistant message.updated, so the adapters synthesize partial
infos without `time`. Timeline order sorts by time.created and puts
untimed rows last, so a live reply sorted below the next prompt: the new
prompt rendered above the previous reply, and the two replies became
adjacent and were merged into one chip-timeline block.

- step.started now stamps the assistant info with the event time.
- The store keeps the cached time (or the REST-seeded message's time)
  when a partial info omits it.
- A queued v2 prompt (`waiting`) is appended when enqueued and moved to
  its delivery position when delivered, so steer/queue follow-ups land
  after the reply that was running when they were sent.

v1 infos always carry time and never `waiting`, so v1 behavior is
unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An authoritative merge kept every cached live info for messages the
reload returned, and the store builds a message from its cached info
before the REST copy. After a background catch-up, a v2 prompt whose
delivery the app missed stayed `waiting` (hidden in the queued bar), so
the two replies around it became adjacent and merged into one block;
partial v2 assistant infos also hid the REST times.

The merge now drops cached infos; REST messages carry the full info and
later live infos layer on top again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The beta server's POST /api/session/{id}/permission/{requestID}/reply
requires {"decision": "once" | "always" | "reject"} and rejects the old
{"reply": ...} body with 400 "Missing key decision". Rename the v2 DTO
field on both apps; Allow once maps to "once", Deny to "reject". The v1
permission route and the v2 form reply body are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A v2 fork carries "fork": {"sessionID": <source>, "boundary": ...} and no
parentID, but both session adapters fell back to fork.sessionID for
parentID. Every fork then read as a subagent child: hidden from Home and
locked with "Child sessions cannot be prompted". Map parentID only from
the real parentID field.

The server announces a fork only as session.forked, whose parentID is the
fork source. Project it as session.created (without parentID) so Home
refreshes and shows the fork live.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After an opencode server restart, the first GET /api/model can return
before the server's catalog is ready (an empty list). The server emits
provider.updated / model.updated about 100 ms later, but the composer
never refetched, so Session Chat stayed on "No usable models are
available" until the user tapped Model.

The Session Chat composer now refetches the catalog when either event
arrives, on both apps for parity (Android had the same gap and only
avoided it through timing). A newer catalog request always wins over an
older one. An event-driven refresh that fails keeps a catalog that has
already loaded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
v2 announces a committed revert only as `session.revert.committed {to}`;
neither app handled it, so the reverted prompt, its reply and everything
after stayed in the timeline. Both adapters now project it, and the
message store drops `to` and every later message (a REST catch-up runs
when `to` is outside the loaded window). v1 keeps its per-message
`message.removed`.

The reload could not heal it either: the tail-acceptance guard scored the
cached window, reverted rows included, against the REST tail, judged the
shorter server tail stale and kept the cache, also after a cold relaunch
(iOS stayed on Syncing…). Local rows the tail lacks inside its window are
now left out of that comparison. iOS also kept every cached row past the
newest overlap; like Android it now keeps only rows newer than the tail's
newest message. Older-than-window rows and paged history are untouched.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The v2 REST projection turned a `compaction` item's summary into a text
part; the chip timeline then merged that assistant row into the previous
reply, so the `## Objective …` markdown read as part of it. Live, the
compaction events carried no message id (v2 sends `inputID` on started
and nothing on ended), so their parts were dropped and nothing showed.

The summary now rides on the compaction part. An assistant (v2) message
with a compaction part renders a "Context compacted" card ("Compacting…"
while running) whose summary opens in the tool detail sheet, and it never
merges with neighbouring assistant rows. Live, `compaction.started`
creates the item (inputID, else the envelope id as msg_), `ended` /
`failed` complete it with the summary, and deltas are dropped. The
running part also lets the existing presence check show Compacting….
The session cache keeps compaction parts. v1 compaction (a part on the
user message plus a summary reply) renders as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The sending app reloads REST after every POST, so its follow-ups reach
the store as inbox items merged into the tail rather than as live infos.
Three gaps made that copy diverge from the watching app:

- The v2 inbox DTO read a flat `timeCreated`, but `Session.Inbox.User`
  nests it as `time.created`, so every materialized prompt had time 0
  ("1:00 AM") and sorted above the first prompt.
- The iOS store rebuilt REST-seeded messages with live parts without
  their pickup state, so a waiting prompt showed as a bubble.
- The authoritative reload drops cached infos, so on delivery the store
  no longer knew the prompt had been waiting and never moved it after
  the reply that ran meanwhile; the two replies then merged.

Delivery now also checks the REST copy's pickup state on both apps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On a server restart the app asked GET /api/model while the server was
still loading (an empty answer), and the server's model.updated /
provider.updated fired before the app's SSE stream reconnected, so the
event-driven refetch never ran and Session Chat stayed on "No usable
models are available".

The composer now also refetches after server.connected /
stream.reconnected, and an empty answer is retried with a 1 s / 2 s /
4 s backoff. A refresh that comes back empty keeps a catalog the
session already has. Same on both apps.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fork dialog's Open (and Commands > New) push the new session through
Session Chat's child-session destination, which always built the pushed
SessionListItem with `parentID: session.id`. The fork therefore opened
as a child of the session it was forked from and showed "Child sessions
cannot be prompted." even though the server reports it as top-level.

ChildSessionNavigationTarget now carries its own parentID: subagent
child taps pass the current session, while fork and new-session targets
leave it nil, and both destinations build the item from the target.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko marked this pull request as ready for review October 2, 2026 07:57
@ivanfenenko

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0913be6. Configure here.

DefaultSyncCoordinator changed a key's state under the lock but yielded it to
observers after unlocking, so a fast failing load could publish .stale before
the earlier .syncing publish ran and leave observers on .syncing. This made
SyncCoordinatorTests.loaderFailureRetriesWithBackoffUntilSuccess flaky in CI
(also seen on an earlier PR). States are now yielded in the same critical
section as the change, and observe() yields its first value under the lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ivanfenenko
ivanfenenko merged commit 3f9c697 into main Oct 2, 2026
@ivanfenenko
ivanfenenko deleted the fix/sim-run-major-issues branch October 2, 2026 20:47
ivanfenenko added a commit that referenced this pull request Oct 2, 2026
#337 was squash-merged as 3f9c697, whose tree is identical to this branch's
ancestor 7a481d9. Every conflict therefore resolves to this branch's side; the
merged tree equals 1147cb6 (already verified by CI and the full test suites).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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