Skip to content

fix(mobile): keep standalone compaction out of the reply stream - #721

Merged
huichen merged 1 commit into
mainfrom
fix/mobile-compaction-state
Sep 18, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/mobile-compaction-state

Conversation

@huichen

@huichen huichen commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Two reports from the phone: a compaction tap that seemed to do nothing, and a screenshot showing a committed compaction divider with the composer stuck on "generating" and the send button replaced by stop.

Root causes

  1. A standalone compaction was folded into a reply. The Agent stamps compaction frames with the run identity it currently holds — for a manual compaction that is the run that just finished — and the mobile projector treated any run frame other than agent_end as "the run is active". So a manual compaction re-opened the settled reply, set the session to streaming, and, because no agent_end follows, never cleared it: the phantom "generating…" bubble plus the stop button in the report.
  2. A refused tap was silent. The hook kept its own pending flag and returned without a word when it was set. A missed terminal frame (backgrounded app, dropped stream) left that flag set for the whole 30-minute timeout, during which every tap of a visible action did nothing.
  3. The draft kept the command (a feat(mobile): trigger manual context compaction from the slash menu #719 regression, found by the harness once it could fail): the picker was wired to the dispatcher, bypassing the path that removes the typed /query, so /压缩 stayed in the input to be sent as a message.

Changes

  • Compaction frames no longer mark a run active. A standalone one (its own phase, as compaction_started/committed carry) becomes its own divider item, so it never revives a finished reply; a mid-turn compaction stays inline in the run it belongs to, keeping the shared projector's "interrupted before completion" marking intact. A standalone compaction that produces no marker (nothing to compact / reused result) takes its own running placeholder away instead of leaving an empty bubble.
  • The tap gate is the authoritative compacting state, not local bookkeeping, and a refused start now says why. A waiter that never sees its terminal event is ended by the session leaving the compacting state (unobserved, no invented result) rather than by a 30-minute timeout.
  • The / action runs through the completion hook again, so the typed command is removed from the draft.
  • cdp.mjs: an eval step that throws now fails the capture run. Previously it only printed, so assertion-style eval steps (already used by several scenarios) could never fail — which is how the draft bug above shipped as "verified".

Verification

  • Mobile: tsc --noEmit, eslint, jest --runInBand (1644 passed) — new tests cover the standalone/mid-turn routing, the no-marker case, the lost-terminal settle, the refused tap, and that running an action clears the draft.
  • Real RN Web harness, with the same wire sequence the Agent sends folded through the real reducer (?compacted=1): with this fix 1/1 captured; reverting only projection.ts fails the same scenario with committed compaction left the reply generating (0/1). The three compaction scenarios (compact-context, compacting, compact-context-outcome) pass, and the committed screenshot shows the divider with the normal send button and no "generating" text.
  • Mock data and a mock Desktop host — not a native-device or live-Agent E2E.

@huichen
huichen enabled auto-merge (squash) September 18, 2026 05:28
@huichen
huichen merged commit 071bf60 into main Sep 18, 2026
12 checks passed
@huichen
huichen deleted the fix/mobile-compaction-state branch September 18, 2026 05:31
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