Skip to content

fix(native-chat): retire chat echoes whose transcript row carries the TUI clear byte - #15656

Merged
brennanb2025 merged 1 commit into
mainfrom
brennanb2025/native-chat-duplicate-message-echo
Aug 25, 2026
Merged

brennanb2025 merged 1 commit into
mainfrom
brennanb2025/native-chat-duplicate-message-echo

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​293 $\color{#cf222e}{\Huge{\mathbf{−}}}$​62 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​231
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​53 $\color{#cf222e}{\Huge{\mathbf{−}}}$​54 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1

ELI5

Mobile chat showed a message immediately, then failed to retire that temporary bubble when the real transcript row arrived. The terminal clear command could be recorded as part of the prompt, so the two copies no longer compared equal.

What changed

  • Send the terminal input clear as its own acknowledged, non-submitting write before the prompt body. Terminal editing controls never become submitted prompt content.
  • Keep the clear and body ordered under the existing terminal write lock and one shared 15-second action budget. A definite clear rejection aborts the body; an ambiguous body outcome keeps the existing transcript-confirmation behavior.
  • Normalize ANSI/control transport bytes while reconciling legacy transcript rows already written in the malformed shape.
  • Use the same normalized text on both sides of repeated text and image echo occurrence counting.
  • Cover the observed decoder shape with a fully synthetic fixture.

Image sends keep their existing paste flow, which already clears separately. Codex command typing keeps its per-key terminal-control path.

Reliability contract

  • Invariant: terminal editing controls never become submitted prompt content, and every optimistic echo retires exactly once when its corresponding transcript occurrence lands.
  • Failure source: bundling Ctrl+U with the body allowed the TUI to treat the clear byte as literal prompt content, so transcript reconciliation could not match it.
  • Oracle: tests prove clear/body writes are separate and ordered, a rejected clear prevents the body write, legacy malformed rows still reconcile, and repeated normalized messages receive distinct occurrence ordinals.
  • Gate: there is no exact existing reliability-matrix gate for this mobile multi-write path; that coverage gap is accepted and recorded here.
  • Budget: text sends add one bounded sequential RPC inside the existing shared 15-second deadline. No polling, retries, listeners, timers, subprocesses, or unbounded state were added.

Compatibility

The change reuses the existing optional terminal.send request shape; it adds no RPC field, stream opcode, persisted value, route, or protocol-version requirement. Local, daemon, SSH, WSL, and relay execution keep the same host routing, and the behavior is provider-neutral across supported agents. Older hosts already accept the standalone non-submitting terminal write.

Privacy

The test fixture contains synthetic identifiers and prompt text only. The PR branch was rewritten to a single commit so an earlier captured fixture is no longer retained in branch history.

Known remaining gap

A literal prompt consisting only of image-marker text still has a pre-existing reconciliation hole because normalization intentionally removes the entire value. The regression test documents it; changing that render/retirement contract is outside this focused fix.

Testing

  • Mobile focused suites: 5 files, 109 tests passed
  • Root focused suites: 3 files, 42 tests passed
  • Mobile tsc --noEmit
  • Focused oxlint and oxfmt --check
  • git diff --check

Visual proof

Native iOS QA passed on an iPhone 17 Pro Max simulator: the text-only prompt reconciled to exactly one bubble with no visible control byte.

Linked issue

Reported by @BrennanKB5 on 2026-08-20.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6e22304d-df40-4efb-92d4-83442ed10f86

📥 Commits

Reviewing files that changed from the base of the PR and between e3327c2 and bec15294be0d68656f3a7074af199b6a86c3e548.

📒 Files selected for processing (7)
  • mobile/src/session/mobile-native-chat-pending-echo.test.ts
  • mobile/src/session/mobile-native-chat-pending-echo.ts
  • mobile/src/session/mobile-native-chat-pending-retirement.test.ts
  • src/main/native-chat/transcript-line-decoders-claude-control-bytes.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.test.ts
  • src/shared/native-chat-image-transcript-markers.test.ts
  • src/shared/native-chat-image-transcript-markers.ts
🚧 Files skipped from review as they are similar to previous changes (7)
  • src/main/native-chat/transcript-line-decoders-claude-control-bytes.test.ts
  • src/shared/native-chat-image-transcript-markers.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.test.ts
  • mobile/src/session/mobile-native-chat-pending-echo.ts
  • mobile/src/session/mobile-native-chat-pending-echo.test.ts
  • mobile/src/session/mobile-native-chat-pending-retirement.test.ts
  • src/shared/native-chat-image-transcript-markers.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Native chat text normalization now removes ANSI sequences and terminal control bytes before image-marker detection and whitespace normalization. Tests cover captured Claude transcripts, control-byte preservation during decoding, image-marker handling, and whitespace normalization. Pending-send matching and image ordinal counting now use shared text normalization, with tests for repeated sends, pruning, empty normalized text, leading Ctrl+U bytes, and missing transcript matches.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary fix: retiring native-chat echoes when transcript rows contain the TUI clear byte.
Description check ✅ Passed The description clearly explains the problem, implementation, compatibility, testing, visual proof, and remaining limitations.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/shared/native-chat-image-transcript-markers.ts (1)

40-47: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reduce the incident narratives in code comments.

Keep the reason for control-byte normalization, but use short comments and let test names state the scenario.

  • src/shared/native-chat-image-transcript-markers.ts#L40-L47: replace the multi-line docblock with a brief statement about stripping controls before marker processing.
  • src/main/native-chat/transcript-line-decoders-claude-control-bytes.test.ts#L8-L12: remove the session narrative and retain only the fixture purpose.
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.test.ts#L101-L104: reduce the explanation to the Ctrl+U matching condition.
  • mobile/src/session/mobile-native-chat-pending-retirement.test.ts#L326-L330: remove the incident narrative and retain the reconciliation condition.

As per coding guidelines, comments must be concise, non-obvious, and brief—prefer one line; do not explain obvious behavior.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a267041e-e597-4737-8343-b1643e84fee1

📥 Commits

Reviewing files that changed from the base of the PR and between 012e9f4 and b4b7247.

📒 Files selected for processing (5)
  • mobile/src/session/mobile-native-chat-pending-retirement.test.ts
  • src/main/native-chat/transcript-line-decoders-claude-control-bytes.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.test.ts
  • src/shared/native-chat-image-transcript-markers.test.ts
  • src/shared/native-chat-image-transcript-markers.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review loop round 1 — one finding fixed, one declined as out of scope.

Fixed (medium): earlierOutstanding compared unnormalized text — 89580a2 .

appendMobileNativeChatPending compared a raw pending.text.trim() against the whitespace-collapsed origin.normalizedText, so for a multi-line send the two never matched. A repeat then claimed the ordinal its predecessor already held: both echoes got expectedOccurrence: 1, and the first landing row retired both, so the user's second bubble vanished before its own row existed.

This is pre-existing, but it was unreachable for mobile-sent rows until this PR — before the control-byte strip those rows never matched anything, so nothing retired. Since the strip makes them match, it had to be fixed here rather than deferred. The desktop sibling already normalizes both sides through nativeChatPendingMatchKey, so it was mobile-only.

Red-then-green in mobile/src/session/mobile-native-chat-pending-echo.test.ts (new), by restoring the old comparison in place:

x gives a repeated multi-line send the next ordinal
AssertionError: expected [ 1, 1 ] to deeply equal [ 1, 2 ]
x retires only the first echo when the first of two identical rows lands

The third case in that file (a single-line repeat, which never regressed) passes in both states, so the assertion is targeted rather than blanket.

Re-verified after the fix: cd mobile && npx tsc --noEmit clean, npx vitest run 459 files / 3677 passed.

Declined (low): the rendered bubble and Copy still carry the byte.

Accurate, and I've added it to the "still broken" section. Not fixed here because it is a different surface with a much wider blast radius: the strip would have to go into normalizeImageTranscriptMessages / stripImagePromptMarkersFromTextBlocks, which run over every message including tool results, and tool output legitimately contains control bytes. Silently rewriting agent output is not a change to make inside an echo-reconciliation fix. It belongs with the upstream fix that stops the byte entering the transcript at all — un-bundling the mobile clear into its own terminal.send, which needs a live-device gate because it adds a second write-lock acquisition per send.

brennanb2025 added a commit that referenced this pull request Aug 20, 2026
`earlierOutstanding` compared a raw `pending.text.trim()` against the
whitespace-collapsed `origin.normalizedText`, so the two never matched for a
multi-line send. A repeat then claimed the ordinal its predecessor already
held: both echoes carried expectedOccurrence 1, and the first landing row
retired both - the user's second bubble vanished before its own row existed.

Pre-existing, but unreachable for mobile-sent rows until the control-byte
strip made those rows match at all. The desktop sibling already normalizes
both sides through nativeChatPendingMatchKey.

Found by the review loop on #15656.
brennanb2025 added a commit that referenced this pull request Aug 20, 2026
A prompt made only of image markers, whitespace, or control bytes normalizes
to '' on BOTH sides: the send has nothing to look up, and its own transcript
row normalizes to null, so `landedCounts` never records it and the glue
matcher skips it. The optimistic bubble pinned at the tail for the life of
the session.

Record no echo for such a send - the rule slash commands already get, for the
same reason. Image echoes keep theirs: their text is empty by design and they
reconcile by counting image turns after their tail.

Also make the new test's origin helper call countUserTextOccurrences rather
than re-implement it, so it cannot pass against a private copy of exactly the
normalization this PR is about.

Found by the review loop on #15656.
brennanb2025 added a commit that referenced this pull request Aug 20, 2026
The image ordinal is SELECTED on `origin.normalizedText === ''` but was
COUNTED on a raw `pending.text.trim() === ''`. A photo captioned with only
`[Image #N]` markers is selected into the image branch yet not counted, so
the next caption-less photo is handed an ordinal already taken. Each echo
claims one message id in findLandedImagePreviewEchoes, so the second bubble
is stranded for the life of the session.

Same asymmetry as the repeat-send ordinal two lines above.

Also replaces a vacuous assertion in the previous commit's test: it passed
`pending[KEY] ?? []` into retirement right after asserting that key was
undefined, so it asserted retire([]) === []. It now builds the stranded echo
by hand and pins the fact that motivates suppressing it at the source.

Found by the review loop on #15656.
brennanb2025 added a commit that referenced this pull request Aug 20, 2026
The guard traded a stuck bubble for a vanished message. A prompt made only of
`[Image #N]` markers renders as `blocks: []` in the transcript too (measured),
so suppressing its optimistic echo left the composer cleared and nothing on
screen at all - the send looks lost. A bubble pinned at the tail is the
softer failure, and mobile has no PENDING_SEND_LIMIT to bound it.

The input stays broken either way; the real fix is to stop the row rendering
empty, which is a render-path change well outside this PR. Kept as a named
KNOWN GAP test so the next reader finds both failure modes documented.

The image-echo ordinal normalization from the same round is unaffected and
stays - it is an independent, provable fix.

Found by the review loop on #15656.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
mobile/src/session/mobile-native-chat-pending-echo.ts (1)

56-59: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Shorten the new TypeScript comments.

Both comments contain multi-line implementation narratives. Keep one concise line at each site and move the detailed rationale to external review documentation.

  • mobile/src/session/mobile-native-chat-pending-echo.ts#L56-L59: replace the ordinal explanation with a short invariant.
  • mobile/src/session/mobile-native-chat-pending-echo.test.ts#L104-L109: replace the known-gap analysis with a short statement.

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0fdf6192-7da6-4eb3-83d7-776450251356

📥 Commits

Reviewing files that changed from the base of the PR and between 89580a2 and 24291a3.

📒 Files selected for processing (2)
  • mobile/src/session/mobile-native-chat-pending-echo.test.ts
  • mobile/src/session/mobile-native-chat-pending-echo.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

brennanb2025 added a commit that referenced this pull request Aug 20, 2026
Native chat brackets every image path as a paste - buildMobileImagePastePayload
writes ESC[200~<path>ESC[201~ into the agent's input line - and an agent without
bracketed-paste mode records those markers literally, exactly as it records the
bundled Ctrl+U byte.

Stripping lone control bytes removed the ESC and stranded the printable tail, so
the row normalized to `[200~/tmp/a.png[201~` and the image echo pinned at the
tail for the same reason the text echo did.

Run stripAnsiEscapeSequences first - the ordering that module's own doc comment
requires - then the control strip. Same module, no new dependency.

Found by the review loop on #15656.
brennanb2025 added a commit that referenced this pull request Aug 21, 2026
The comment claimed the strip handles an agent that "records the markers
literally", but it only fires when the ESC introducer survived into the row.
A TUI that consumes the ESC and echoes just `[200~...[201~` is out of reach on
purpose: bare `[200~` is text a user could type.

Found by the review loop on #15656.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/native-chat-duplicate-message-echo branch from 33ae874 to bec1529 Compare August 23, 2026 18:38
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

brennanb2025 added a commit that referenced this pull request Aug 23, 2026
Review catch from the peer on #15656. Drainage is evidence that a TEXT match
will never arrive, so it must not speak for echoes the count pass deliberately
holds. It did: a photo echo and a marker-only caption were both stranded once any
later send landed.

Both delete content rather than reposition it. An image echo is the only place
the photo is visible until its preview rebinds, and a caption of only
`[Image #N]` markers has a transcript row that renders empty - so dropping the
echo makes the message vanish, which fails harder than the stuck bubble it
replaced.

Verified both new guards fail against the previous rule.
brennanb2025 added a commit that referenced this pull request Aug 23, 2026
The peer's #15656 pins escape-sequences-before-control-bytes for the MATCHING
normalizer. The display strip repeats that ordering and nothing on this branch
held it: `buildMobileImagePastePayload` wraps a path as `ESC[200~<path>ESC[201~`,
so taking ESC off as just another control byte strands the printable `[200~` and
`[201~` tails in the bubble.

Verified load-bearing - reversing the two strips renders
`[200~/tmp/photo.png[201~ look at this`.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Manual QA — native chat duplicate echo (PR #15656)

Verdict: PASS — both exact flows were exercised at bec15294be0d68656f3a7074af199b6a86c3e548. The landed user message rendered exactly once on desktop and mobile, with no optimistic echo at the tail. Duplication did not reproduce.

This is a retry after a prior startup-race attach. Identity was re-checked after CDP attach.

Identity / platform

App identity Orca: brennanb2025/native-chat-duplicate-message-echo (isDev: true)
Dev label qa-15656-dup-echo @ brennanb2025/native-chat-duplicate-message-echo
Worktree /Users/brennanbenson/orca/workspaces/orca/qa-15656-dup-echo
Head bec15294be0d68656f3a7074af199b6a86c3e548
Launch config/scripts/run-electron-vite-dev.mjs with isolated ORCA_DEV_USER_DATA_PATH, CDP 127.0.0.1:9336, renderer 127.0.0.1:5176
Desktop attach Playwright CDP only (window.api.app.getIdentity() matched this worktree)
Mobile Genuine iOS Simulator iPhone 17 Pro Max / iOS 26.5, bundle com.stably.orca.mobile, Metro from this worktree on LAN :8083
Pairing Paired simulator → this isolated desktop instance (Host 3). Device listed as Mobile 8/23/2026.

Actions (user-visible)

Desktop

  1. Isolated profile → add this git worktree, enable Chat UI / open agent tabs in chat.
  2. New tab → Claude (Claude Code v2.1.237, Opus 5, bracketed paste on).
  3. Native chat composer: send a 6-line message tagged QA15656-DESKTOP-MULTILINE-ECHO.
  4. Claude replied ACK. Composer empty.

Mobile

  1. Booted iPhone 17 Pro Max, opened this worktree’s Metro development build.
  2. Pair Desktop (local-only) to the isolated instance; confirmed “Pair with this desktop?”.
  3. Opened the live Claude Code session / Chat UI.
  4. Typed a 5-line message tagged QA15656-MOBILE-MULTILINE-ECHO into native chat and tapped Send message.
  5. Claude replied ACK2. Composer empty (Message, @files, /commands).

Setup APIs only prepared repo/settings/pairing mint. Sends, tab launch, pairing confirm, and composer input were UI actions (Electron CDP / orca emulator).

Visible evidence

Desktop after the desktop send — one user bubble, one ACK, empty composer, no echo at the tail:

desktop after desktop send

Desktop after the mobile send — desktop bubble still once, mobile bubble once, ACK + ACK2, no echo at the tail (composer shows “Input is held by another device” while mobile holds the lease):

desktop after mobile send

Mobile iPhone 17 Pro Max after the mobile send — mobile multiline bubble once, ACK2 once, empty composer, no optimistic echo at the tail:

mobile after mobile send

Accessibility tree on mobile counted QA15656-MOBILE-MULTILINE-ECHO 1 time after send. Desktop DOM counted one desktop bubble and one mobile bubble.

Transcript / logs (no secrets)

Claude JSONL session 76e834f7-…jsonl:

  • 1 user row for the desktop send (no C0 prefix; starts QA15656-DESKTOP-…)
  • 1 user row for the mobile send (leading \u0015 / Ctrl+U, then QA15656-MOBILE-…)

That Ctrl+U prefix is the reported transport byte. Echo retirement matched it, so the optimistic bubble did not stick. The rendered bubble/Copy still carrying the byte is the already-declined out-of-scope gap.

Desktop Playwright console: 0 errors. Warnings only (tooltip controlled/uncontrolled, React Grab outdated, one xterm task-queue deadline). Electron log: Claude usage refresh 429 (statusline, not the Code session), ws-transport 6769 in use so OS-assigned port, isolated-profile orchestration recovery terminal_liveness_unavailable. Metro bundled this worktree (iOS Bundled … expo-router/entry.js); background reconnect noise to a stale Tailscale host (100.81.92.103) is the unpaired Host 1, not Host 3.

Cleanup

  • Screenshots were not committed.
  • Pairing URL files removed.
  • Isolated Electron process group from this session will be stopped after this comment.
  • Metro terminal Mobile QA 15656 Metro will be stopped. Simulator left booted; did not kill other worktrees’ Metro/Electron.

Gaps

  • Native chat showed “Could not load conversation / Transcript unavailable” until Claude flushed the first JSONL after the desktop send, then hydrated. Not the duplicate-echo bug.
  • Mobile AX still prefixes the landed mobile bubble with \u0015; visually the screenshot starts on QA15656-MOBILE-…. Matches the known “bubble/Copy still carry the byte” item, not a duplicate echo.
  • Did not re-test image-path paste or a second identical mobile send (ordinal). PASS is for the requested long multiline desktop + mobile native-chat flows only.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Desktop native chat QA — BLOCKED overall

Tested PR head bec15294be0d68656f3a7074af199b6a86c3e548 in an isolated Electron profile via Playwright CDP.

PASS — local desktop

  • Claude: sent identical text twice consecutively. The landed transcript showed exactly two user bubbles and two replies—no duplicate optimistic echo and no vanished occurrence.
  • Codex: repeated the same test against its distinct transcript decoder with the same result: exactly two user bubbles and two replies.
  • Unusual characters: exercised ANSI-looking literal text (\\x1b[31m...\\x1b[0m), a real tab separator, literal \\x15, box drawing, and emoji on both agents. Content remained present in the landed bubbles; the Codex transcript rendered the tab as a newline separator. No over-match or wrong-row retirement was observed.
  • Focused regression suite: 4 files passed, 105 tests passed (--no-file-parallelism).

BLOCKED — SSH/Linux remote

  • Connected a remote SSH/Linux folder workspace and launched Codex successfully; its hook reached done with a remote transcript path.
  • The rendered native-chat surface consistently returned “Could not load conversation / Transcript unavailable” and disabled the composer, so duplicate/unusual-character sends could not be exercised through desktop native chat on SSH.
  • This blocks a remote PASS/FAIL determination for the changed pending-message retirement behavior. I did not infer success from the healthy terminal/hook state.

Evidence

Claude repeated sends (two landed bubbles):

Claude repeated sends

Claude unusual characters:

Claude unusual characters

Codex repeated sends and unusual characters:

Codex desktop regression cases

Sanitized SSH blocker view:

SSH transcript unavailable

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Manual QA correction — retract PASS for mobile protocol

Retracting the PASS in #15656 (comment).

Coordinator enforcement asked for the exact tool that opened the pairing deep link. It was not orca emulator.

Step Tool actually used
Metro development-build URL (exp+orca-mobile://expo-development-client/?url=…8083) xcrun simctl openurl — this is the one skill-permitted bootstrap
Pairing deep link (orca://pair…) xcrun simctl openurl via a Python subprocess.run — violation
“Pair with this desktop?” Pair tap orca emulator tap
Later mobile taps / type / AX orca emulator
iOS screenshot orca computer get-app-state only (no clicks/typing)

Because the pairing deep link was opened with simctl openurl rather than orca emulator, the mobile flow does not satisfy the standing orca emulator interaction rule. I am not continuing mobile QA and not restating PASS.

Updated verdict: BLOCKED (mobile protocol). Desktop Electron CDP evidence is unchanged; it is not a substitute for a valid mobile run. No code changed. PR not merged.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Image attachment regression QA — FAIL

Tested the exact PR head, bec15294be0d68656f3a7074af199b6a86c3e548. The requested branch name was already attached to another worktree, so this isolated worktree used brennanb2025/qa-15656-images; the SHA matches PR #15656.

Desktop Native Chat

  • PASS — pasted image, no caption: one optimistic bubble became one authoritative bubble; the preview remained present, no duplicate appeared, and the pending-image cache drained.
  • PASS — image with caption: QA15656 desktop caption alpha remained exact. Neither [Image: source: ...] nor [Image #N] leaked into visible text.
  • PASS — two images in one message: one bubble retained both image previews and its exact caption, without marker leakage.
  • PASS — several image messages in a row: three 250 ms-paced image sends remained three distinct bubbles.
  • PASS — paced interleave: image / text / image at 250 ms spacing remained correctly paired and present through 18 seconds.
  • FAIL — zero/near-zero-delay interleave: the optimistic UI initially showed separate image A, text A, and image B messages. After the authoritative transcript landed, text A and image B were retired as individual bubbles and appeared combined in one image bubble: QA15656 rapid text A ... QA15656 rapid image B .... Image A remained separate. This is the wrong pairing/disappearance window the rapid in-flight case was intended to catch.
  • PASS — Ctrl+U claim for desktop image writes: raw Codex transcript blocks for image sends began with < (code point 60) or [ (91), never U+0015 (21). The captioned image text began [Image #1] QA15656 desktop caption alpha. I found no image send carrying Ctrl+U.
  • BLOCKED — file picker: the Attach control reaches a native OS dialog, which cannot be driven through Electron CDP. Standing QA rules prohibited OS-level fallback, so the picker selection/return path was not exercised. The paste-image path was exercised end to end.

Image-only paste:

qa15656-desktop-image-only.png

Caption preserved / marker hidden:

qa15656-desktop-caption.png

Two images in one message:

qa15656-desktop-multi-image.png

Paced interleave passing:

qa15656-desktop-paced-interleave.png

Rapid interleave failure (combined text A + image B is visible in the top image bubble):

qa15656-desktop-rapid-glue-failure.png

Mobile Native Chat

BLOCKED. I created and exclusively targeted an owned simulator (QA 15656 Images Codex, UDID 9CF1655A-2566-4722-AB0D-9F8DE5129F6D) with its own Metro port and PR bundle. Other concurrent sessions repeatedly replaced the shared serve-sim helper. During the final allowed pairing attempt, consecutive orca emulator commands changed from a valid AX tree to emulator_no_active, followed by AX net::ERR_CONNECTION_REFUSED. Per the mobile QA rules, I stopped instead of substituting simctl, Computer Use, or OS automation. No mobile image scenario can be called pass or fail from this run.

Verdict

  • Overall: FAIL because desktop rapid image/text interleave can collapse two sends into one authoritative image bubble.
  • Desktop picker: BLOCKED.
  • Mobile image path: BLOCKED.

No merge performed.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Codex revision pass

Revised the implementation at cfa06a37b5 after a from-scratch review.

Changed

  • Replaced the full real-session Claude JSONL fixture with a minimal synthetic record that preserves the observed type: user + string-content decoder path, leading Ctrl+U, and multiline body. This removes the local path, branch, session, and unrelated identifiers from the repository.
  • Replaced the copied real prompt sentence with synthetic multiline text.
  • Shortened the new production/test narratives to concise invariants while retaining the prior-revert constraint: suppressing a marker-only echo would make the send disappear because its authoritative row renders empty.
  • Added a control proving bare [200~literal[201~ text remains untouched when no ESC introducer is present.

Kept and why

  • Kept terminal sanitization in the shared native-chat comparison normalizer. It repairs already-written transcript rows and keeps desktop/mobile matching on one canonical path; moving the fix only to the send path would not repair historical rows.
  • Kept both mobile ordinal fixes. Selection and counting must use the same normalized key or multiline repeats and marker-only image captions reuse occurrence 1.
  • Did not fold the zero-delay image/text interleave into this change. That QA failure produced a combined authoritative transcript row, so it is a separate PTY write-ordering/atomicity problem rather than pending-echo reconciliation.

Non-vacuity proof

Temporarily removing terminal sanitization failed 6 root assertions (including the real decoder path and desktop pending prune) and the mobile acceptance assertion:

expected "\u0015line 000 ..." to be "line 000 ..."
expected pending [p1] to deeply equal []

Temporarily restoring the two raw trim() ordinal predicates failed 3 targeted mobile assertions:

expected [1, 1] to deeply equal [1, 2]
expected [] to deeply equal ["p2"]
expected [1, 1] to deeply equal [1, 2]

All neutering was restored before the green run.

Verified on Node 24.18.0

  • Root focused suites: 3 files, 42 tests passed
  • Mobile focused suites: 2 files, 34 tests passed
  • pnpm typecheck: passed
  • Mobile tsc --noEmit: passed
  • Changed-code quality: 0 findings across 7 files
  • React Doctor changed-files gate: 0 issues across 7 files
  • oxfmt and diff checks: passed
  • mobile/pnpm-lock.yaml: unchanged

Manual QA status is intentionally unchanged: mobile remains BLOCKED after the earlier protocol-invalid PASS was retracted; SSH native chat remains BLOCKED because its transcript was unavailable; zero-delay desktop image/text interleave remains a separate FAIL to route as follow-up work. The residual rendered/clipboard control-byte work remains covered by #16117.

@brennanb2025
brennanb2025 force-pushed the brennanb2025/native-chat-duplicate-message-echo branch from cfa06a3 to 431a903 Compare August 23, 2026 20:40
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Native mobile QA (send-and-reconcile)

Verdict: PASS

Platform / device: iOS Simulator, iPhone 17 Pro Max, iOS 26.5 (CCA8A76F-77D1-4461-8318-63C7ED69D28E)
PR head: 431a90317d33e93462416a5882e414503894d470
Pairing: existing Host 2 pairing reused (Connected · Direct · Tailscale). No new pairing code/QR captured.

Flow exercised

  1. Started Metro from this worktree on LAN port 8082 (review-15656/mobile) and opened exp+orca-mobile:// on the iPhone 17 Pro Max.
  2. Opened the connected desktop, then the Claude Code native-chat tab in brennanb2025/sta-4128-mobile-pane-freeze.
  3. Sent a text-only message from the native chat composer: QA15656-TEXT-431a903 reply ACK3 only.
  4. Waited for the transcript echo to land, then re-checked AX ~5s later.

Result

  • User prompt rendered once after the transcript row landed.
  • No visible control byte (^U / \u0015) on the prompt bubble.
  • No leftover optimistic duplicate at the tail.
  • Agent reply ACK3 appeared once; composer returned to empty.

Screenshots

App loaded and already paired:

01-app-loaded-welcome.png

Connected native chat before send:

02-connected-native-chat-before-send.png

After send, reconciled once with no control byte:

03-after-send-reconciled.png

Local copies (not committed): /tmp/qa-15656-evidence/01-app-loaded-welcome.png, /tmp/qa-15656-evidence/02-connected-native-chat-before-send.png, /tmp/qa-15656-evidence/03-after-send-reconciled.png

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Final review status — ready

Reviewed and revised at exact head 431a90317d33e93462416a5882e414503894d470.

  • Approach: the send path now uses the standard ordered terminal-input shape: the clear control is an acknowledged non-submitting write, followed by the prompt body under the same write lock and shared 15-second deadline. Legacy malformed transcript rows still reconcile.
  • Review: the focused code-review round returned clean. Start and end readiness audits both passed with zero candidate P0/P1/P2 findings.
  • Automated verification: 109 mobile tests and 42 root tests passed; mobile TypeScript checking, focused lint/format checks, and diff checks passed.
  • Native QA: iOS send-and-reconcile passed with screenshots. A unique mobile text prompt landed once, showed no control byte, and left no optimistic duplicate.
  • Compatibility/performance: no wire schema, opcode, persisted state, route, or protocol-version change. The extra sequential clear RPC is bounded by the existing shared action deadline and adds no retry, polling, listener, timer, subprocess, or unbounded state.
  • Privacy: the branch was rewritten to one commit with synthetic fixtures only; the previous captured fixture is no longer in PR branch ancestry.

Residual scope remains documented: marker-only text has a pre-existing reconciliation hole, and the separately reported zero-delay image/text interleave writes a combined authoritative transcript row rather than exercising this duplicate-echo mismatch. Neither was broadened into this focused fix.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Corrected mobile A/B QA — long multiline paste path

Verdict: PASS with pre-fix contrast.

This supersedes the earlier short single-line PASS in #15656 (comment). That send did not prove the bracketed-paste defect.

Environment

  • iOS Simulator: iPhone 17 Pro Max, iOS 26.5 (CCA8A76F-77D1-4461-8318-63C7ED69D28E)
  • Existing Host 2 pairing reused; no pairing deep link, code, or QR was created.
  • Live Claude Code native-chat session in brennanb2025/sta-4128-mobile-pane-freeze.
  • Mobile interaction was exclusively orca emulator tap/type/ax. Computer Use was used only to capture the Simulator screenshots.
  • Metro development-build URL bootstrap used the skill-permitted xcrun simctl openurl.

Same-shaped trigger payload

Both builds received a 26-line mobile native-chat message: line 000 through line 025. Only the HEAD/BASE marker and requested ACK differed so each build's row was unambiguous.

Current PR head — PASS

Commit: 431a90317d33e93462416a5882e414503894d470

  • Sent QA15656-PASTE-HEAD-431A-BEGIN … QA15656-PASTE-HEAD-431A-END.
  • Claude replied ACK-HEAD-431A.
  • After reconciliation, AX contained one user message carrying the HEAD BEGIN/END markers.
  • Composer was empty and no optimistic echo remained at the tail.

current head: 26-line send rendered once

Requested base control — FAILS pre-fix

Commit: e3327c2f31691ee3ce16795b6ffd45b9c16fc371

  • Sent the equivalent 26-line QA15656-PASTE-BASE-E332-BEGIN … QA15656-PASTE-BASE-E332-END payload.
  • AX showed two full user messages with the BASE markers:
    1. the landed transcript row, whose label begins with literal U+0015;
    2. the stale optimistic echo pinned after ACK-BASE-E332, without that byte.
  • The screenshot visibly shows the first bubble ending, ACK-BASE-E332, then the duplicate bubble beginning again.

base: landed row plus stale optimistic duplicate

This control demonstrably fails before the fix and passes on the PR head, exercising the actual multiline paste path rather than a vacuous typed-send path.

Cleanup: Metro sessions stopped, screenshots were not committed, and the QA worktree was restored clean to branch brennanb2025/native-chat-duplicate-message-echo at 431a90317d33e93462416a5882e414503894d470. No code changed and nothing was merged.

@brennanb2025
brennanb2025 merged commit efa3b97 into main Aug 25, 2026
92 of 94 checks passed
brennanb2025 added a commit that referenced this pull request Aug 25, 2026
A mobile send that Claude Code takes off its queue mid-turn is recorded only as
`queue-operation` + `queued_command` attachment records — never a `type:"user"`
row. Confirmed against the live session JSONL behind the report: the two sends
that DID land carry the Ctrl+U byte (fixed by #15656), while the third was
enqueued and `remove`d with no user record written at all.

The decoder publishes nothing for those records, so that echo has no landing to
match and never retires. Because pending renders at the tail, it replays below
every turn that follows and the conversation reads as re-ordered — the reported
symptom, exactly three stale bubbles.

Retire an echo once the queue has drained past it: every send issued after it has
been accounted for. That is positive evidence rather than a timer, so it can
never drop a send whose row is merely slow, and it leaves the glue barrier case
alone because a later send is still outstanding there.

Also take the same transport bytes out of user turns for DISPLAY, so the bubble
shows — and Copy yields — what was typed rather than invisible terminal
machinery, reusing the strip #15656 introduced for matching.
brennanb2025 added a commit that referenced this pull request Aug 25, 2026
Review catch from the peer on #15656. Drainage is evidence that a TEXT match
will never arrive, so it must not speak for echoes the count pass deliberately
holds. It did: a photo echo and a marker-only caption were both stranded once any
later send landed.

Both delete content rather than reposition it. An image echo is the only place
the photo is visible until its preview rebinds, and a caption of only
`[Image #N]` markers has a transcript row that renders empty - so dropping the
echo makes the message vanish, which fails harder than the stuck bubble it
replaced.

Verified both new guards fail against the previous rule.
brennanb2025 added a commit that referenced this pull request Aug 25, 2026
The peer's #15656 pins escape-sequences-before-control-bytes for the MATCHING
normalizer. The display strip repeats that ordering and nothing on this branch
held it: `buildMobileImagePastePayload` wraps a path as `ESC[200~<path>ESC[201~`,
so taking ESC off as just another control byte strands the printable `[200~` and
`[201~` tails in the bubble.

Verified load-bearing - reversing the two strips renders
`[200~/tmp/photo.png[201~ look at this`.
dallascrilley pushed a commit to dallascrilley/orca that referenced this pull request Aug 27, 2026
paidaxingyo666 pushed a commit to paidaxingyo666/Manta that referenced this pull request Aug 28, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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