Repository navigation
fix(ios): keep streamed transcripts stable across tool boundaries - #136702
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Live proof recordings (iOS 27 simulator, isolated dev gateway, paced mock model with a real Before ( After (this PR, same turn with a 12 s model delay after the tool result): the working indicator persists through the tool phase and the delay, the pre-tool commentary stays as its own message, and the reply streams once as per-item text. After, #135250 scenario: scrolling through earlier messages while reasoning and the reply stream, including left-edge diagonal swipes that used to latch the drawer and drag the content card sideways. The transcript stays put; only the deliberately horizontal edge swipe at the end opens the drawer.
attachment-858501045.mp4attachment-2315117102.mp4attachment-3940969079.mp4 |
|
Codex review: blocked before merge. Reviewed September 2, 2026, 7:15 PM ET / 23:15 UTC. ClawSweeper reviewWhat this changesThe PR repairs iOS chat streaming across tool boundaries by separating live-text ownership, retaining in-flight runs across stale history refreshes, retiring replaced view models, stabilizing streamed tables, and tightening sidebar gesture commitment. Regression provenancePossible regression — probable (reviewed change; known regression link). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 4 items remain Keep open. The exact head resolves the prior close-anywhere drawer finding and implements the still-missing iOS transcript/run-state repair; no introduced blocking defect was found. It remains a maintainer-owned, protected PR pending exact-head iOS validation and maintainer review. Priority: P1 Review scores
Verification
How this fits togetherThe native iOS chat tab owns an OpenClawChatViewModel that combines gateway history with live agent events into a transcript and tool activity. The same iOS surface handles sidebar gestures while a run is active. flowchart LR
A[Gateway history] --> C[Chat view model]
B[Live agent events] --> C
C --> D[Run ownership and stream text]
D --> E[Markdown transcript blocks]
E --> F[iOS chat tab]
G[Touch drag] --> H[Sidebar gesture decision]
H --> F
Decision needed
Why: The protected maintainer label and live session-state behavior require an explicit maintainer decision even though the prior concrete finding is resolved. Before merge
Agent review detailsSecurityNone. PR surfaceOther +256. Total +256 across 12 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain this owner-boundary repair, then land only after exact-head iOS validation and maintainer review confirm the live-run lifecycle remains stable. Do we have a high-confidence way to reproduce the issue? Yes—at source level, the focused tests encode the stale-history/live-event ordering and the agent-versus-cumulative-text sequence that exercise the reported failure. This read-only review did not rerun the simulator scenario. Is this the best way to solve the issue? Yes. The patch repairs the producers and lifecycle owner rather than masking visual symptoms: it records agent-text ownership, preserves pending runs across superseded snapshots, and retires replaced event loops. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e49922bbab6f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Re the ClawSweeper P1 "Preserve close swipes outside the opening edge": the reported behavior does not occur. The edge/top eligibility check is a Swift condition list whose first clause is The shape did invite the misread, so the follow-up commit restructures it into an explicit Rank-up moves: the two "resolve merge risk" items are the same finding and are covered by the above; the production delta stays at the owner boundaries listed in the description. |
The iOS chat transcript flickered, jumped, and went blank during agentic runs. Four owner defects reproduced on a dev gateway with a paced mock model: - The streaming bubble had two producers after a tool boundary: the chat delta carries the gateway's run-cumulative buffer while the agent stream carries the current item. Agent text now owns the bubble once observed for a run. - Every streaming event bumped the run ownership generation, so an in-flight history refresh came back superseded and refreshIfPending fell through to message-shape inference, retiring the app's own run as soon as the tool-call assistant message was persisted. A superseded snapshot never retires a run, and inFlightRun guards the heuristic paths. - ChatProTab closures captured the view value, so rebuilt view models leaked (three live) and each processed every gateway event. Closures capture the app model and presentation strings; replaced models detach their transport loop. - The block segmenter skipped a trailing table while streaming, appending rows to the previous paragraph and restarting the word reveal on every row. Trailing tables now render as they stream; pipe-only fragments wait for a delimiter. Also make the sidebar drawer commit only on clearly horizontal drags so a thumb scroll near the left edge no longer shifts the content card sideways, and repair the stale session-button assertion in RootTabsSidebarRegressionTests. Fixes #135250 Refs #135214, #124759
Scope the edge and top-exclusion eligibility to closed-drawer opening gestures in an explicit block (no behavior change) and cover a content-card start on a presented drawer closing.
21d91e0 to
d54a53c
Compare
|
Merged via squash.
|
…enclaw#136702) ## What Problem This Solves iPhone users report that the chat transcript "jumps up and down constantly", flickers, and shows blank areas while an agent is working (openclaw#135250, openclaw#135214; a public report on 2026-09-02 that also mentions crashes). Reproduced on an isolated dev gateway with a paced mock model (reasoning → preamble → `read` tool → final reply), recorded on the simulator and analyzed frame by frame. Four independent owner defects in the shared chat UI and the iOS chat tab produce the symptoms: 1. **Two producers wrote the streaming bubble.** After a tool boundary the gateway's `chat` `delta` buffer is run-cumulative (`"Let me look at the workspace first.Here is…"`) while the `agent` `assistant` stream carries the current item's text. The view model applied both, so the bubble alternated between the two texts several times per second and its height oscillated by a line. 2. **The app retired its own run mid-run.** `invalidateRunSnapshots()` bumps the ownership generation on every streaming event, so any `chat.history` refresh in flight during streaming came back superseded; `refreshIfPending` then skipped the gateway's `inFlightRun` fact and fell through to the message-shape heuristic, which cleared the pending run as soon as history contained the assistant message that carries the tool call. From then on every assistant delta was dropped as a foreign run: no working indicator, blank transcript, until the final arrived. App log: `pending refresh delayMs=1500` → `pending cleared` two seconds after send, `agent.wait … CancellationError`. 3. **Rebuilt chat view models leaked and kept processing every event.** `heap` showed three live `OpenClawChatViewModel` instances; each processed every gateway event (`ours=false pending=0` twins in the log), ran its own history polling and haptics. The retain chain went through the model's closures capturing the `ChatProTab` view value and its `@State` saved values. 4. **A streaming table flipped between prose and table.** The block segmenter skipped a trailing table while streaming, so rows were appended to the previous paragraph as prose, the paragraph text was rewritten on every row (restarting the word reveal, text going invisible), and the table popped in only when text followed it: measured as repeated ±25–80 pt up/down shifts. Also fixes the iPhone edge-drawer drag latching on marginal diagonals (openclaw#135250's horizontal shift): a vertical thumb scroll near the left edge could drag the content card sideways and spring back. ## Why This Change Was Made Each fix lands at the owner that records the fact: the view model keeps one canonical producer for live text and never lets a superseded history snapshot retire a run the gateway reports in flight; the chat tab hands the model closures that do not capture the view and detaches a model's transport loop when it is rebuilt; the segmenter keeps prose prefix-stable while a table streams; the drawer commits only on clearly horizontal drags. ## User Impact Agentic replies on iPhone stream without flicker or blank gaps, the working indicator stays until the run really ends, tables render once while streaming, scrolling near the left edge no longer shifts the transcript sideways, and the app stops doing every chat event's work three times. Evidence (live simulator rig against an isolated dev gateway with a paced mock model, before/after recordings, frame-by-frame motion metrics, app diagnostics log): see the PR body and comments. Shared Swift package: 449 tests passed; iOS drawer/sidebar suites passed; SwiftFormat/SwiftLint clean; Codex autoreview scoped-clean; ClawSweeper exact-head review: no findings. Fixes openclaw#135250 Refs openclaw#135214, openclaw#124759
What Problem This Solves
iPhone users report that the chat transcript "jumps up and down constantly", flickers, and shows blank areas while an agent is working (#135250, #135214; a public report on 2026-09-02 that also mentions crashes). Reproduced on an isolated dev gateway with a paced mock model (reasoning → preamble →
readtool → final reply), recorded on the simulator and analyzed frame by frame. Four independent owner defects in the shared chat UI and the iOS chat tab produce the symptoms:chatdeltabuffer is run-cumulative ("Let me look at the workspace first.Here is…") while theagentassistantstream carries the current item's text. The view model applied both, so the bubble alternated between the two texts several times per second and its height oscillated by a line.invalidateRunSnapshots()bumps the ownership generation on every streaming event, so anychat.historyrefresh in flight during streaming came back superseded;refreshIfPendingthen skipped the gateway'sinFlightRunfact and fell through to the message-shape heuristic, which cleared the pending run as soon as history contained the assistant message that carries the tool call. From then on every assistant delta was dropped as a foreign run: no working indicator, blank transcript, until the final arrived. App log:pending refresh delayMs=1500→pending clearedtwo seconds after send,agent.wait … CancellationError.heapshowed three liveOpenClawChatViewModelinstances; each processed every gateway event (ours=false pending=0twins in the log), ran its own history polling and haptics. The retain chain went through the model's closures capturing theChatProTabview value and its@Statesaved values.Also fixes the iPhone edge-drawer drag latching on marginal diagonals (#135250's horizontal shift): a vertical thumb scroll near the left edge could drag the content card sideways and spring back.
Why This Change Was Made
Each fix lands at the owner that records the fact: the view model keeps one canonical producer for live text and never lets a superseded history snapshot retire a run the gateway reports in flight; the chat tab hands the model closures that do not capture the view and detaches a model's transport loop when it is rebuilt; the segmenter keeps prose prefix-stable while a table streams; the drawer commits only on clearly horizontal drags.
User Impact
Agentic replies on iPhone stream without flicker or blank gaps, the working indicator stays until the run really ends, tables render once while streaming, scrolling near the left edge no longer shifts the transcript sideways, and the app stops doing every chat event's work three times.
Evidence
Rig: isolated dev gateway (
OPENCLAW_STATE_DIR, token auth, port 18899) with a paced Responses-API mock model (35 ms/word, reasoning summary → preamble →readtool → 12 s model delay → final reply), iOS 27 simulator driven headlessly withidb, recordings analyzed frame by frame (vertical shift of the transcript band; "direction reversals within 1 s" is the up/down signature).OpenClawChatViewModelinstances (heap)pending clearedbeforerun observation terminal)App diagnostics after the fix (proof run):
pending refreshat +2 s, +6 s, +15 s all keep the run;run observation … completed→pending clearedonly at the real end.Tests:
swift test --filter 'ChatViewModelTests|ChatMarkdownBlockSegmenterTests|ChatReaderScrollStateTests|ChatStreamingRevealTests': 449 tests, 5 suites, passed. New:superseded pending refresh preserves an in-flight run(fails on the previous code on both assertions),agent assistant text owns the run instead of cumulative chat buffers(agent-first / delta-first / delta-only),detached transport ignores late events and in-flight history,streamed table prefixes preserve prose and only grow table rows,streaming table header waits without hiding inline pipes.xcodebuild test … -only-testing:OpenClawTests/RootSidebarDrawerGestureTests -only-testing:OpenClawTests/RootTabsSidebarRegressionTests -only-testing:OpenClawTests/RootTabsSourceGuardTests: passed (exit 0).RootTabsSidebarRegressionTestshad a stale assertion (expectedopenChat(sessionKey:)in the session button after fix(ios): open session dashboards without nested control UI #132983 switched it toselectSession); repaired here, it is not in the CI-only-testinglist.config/swiftformat) and SwiftLint 0.65.1: clean.pnpm ios:buildfor the simulator: succeeded.--mode uncommitted): scoped-clean.LOC: production +107/−99 (net +8: the recorded per-run "agent text seen" fact, the explicit transport detach lifecycle, and the trailing-table hold-back; the drawer predicate and live-state refactor are net negative); tests +176/−26 plus a 95-line new test file.
Accepted tradeoff: while streaming, a trailing paragraph whose every line starts with
|is held back until its table delimiter row arrives (or the message completes), so ASCII-art-style pipe paragraphs appear late rather than flickering.Not changed (follow-ups): the gateway replays its buffered chat deltas (100+ events in one burst) at run end, which re-adopts a just-finished run for ~150 ms; a "Select Text" sheet and code-block copy on iOS; the background-wake refresh path is dead (no
fetchbackground mode).Fixes #135250. Refs #135214, #124759; copy/selection landed separately in #135430.