Skip to content

Fix native chat image marker position handling - #14162

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/native-chat-image-marker-position
Aug 13, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/native-chat-image-marker-position

Conversation

@brennanb2025

Copy link
Copy Markdown
Contributor

Summary

  • Fix native chat image transcript markers so [Image #N] is detected and stripped at the start, end, or middle of a caption.
  • Preserve user-entered text spacing while folding image source turns into one rendered user bubble.
  • Add shared, mobile reconciliation/rendering, and desktop assembler/pending regression coverage.

Before this fix, an image send could render two bubbles: one delivered bubble with literal trailing [Image #1] text and no image, plus a second never-clearing optimistic bubble holding the photo. The root cause was a start-anchored shared regex even though Claude can append the marker as a suffix; because that regex is shared, desktop native chat was affected too.

The send-ordering race that lets the marker arrive late is deliberately not fixed here. Replacing the fixed settle delays or changing image send ordering remains follow-up scope.

Screenshots

No screenshot was captured. Before: two bubbles appeared for one image send—literal trailing marker/no image, then a never-clearing photo bubble; after: one bubble contains the caption and folded image.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test — targeted affected suites pass; the full root suite was stopped after unrelated existing PTY/updater/remote-runtime failures (pty-handler.test.ts, ipc/pty.test.ts, updater.test.ts, remote-runtime-pty-transport.test.ts, pty-subprocess.test.ts).
  • pnpm build
  • Tests added for trailing and mid-text image markers across shared, mobile, and desktop paths.

Targeted commands:

  • PATH="/opt/homebrew/opt/node@24/bin:$PATH" pnpm exec vitest run --config config/vitest.config.ts src/shared/native-chat-image-transcript-markers.test.ts src/renderer/src/components/native-chat/native-chat-session-assembler.test.ts src/renderer/src/components/native-chat/native-chat-preassembled-session-parity.test.ts src/renderer/src/components/native-chat/native-chat-pending.test.ts — 84 passed.
  • PATH="/opt/homebrew/opt/node@24/bin:$PATH" node ./mobile/node_modules/vitest/vitest.mjs run --config mobile/vitest.config.ts mobile/src/session/mobile-native-chat-draft-reconcile.test.ts mobile/src/session/use-mobile-native-chat-drafts.test.ts mobile/src/session/mobile-native-chat-render-data.test.ts — 45 passed.
  • New suffix-marker tests were run before the source change and failed as expected: 7 root failures and 4 mobile failures; they pass after the fix.

AI Review Report

Self-reviewed marker stripping, transcript folding, pending-send matching, preview migration, and all importers/call sites. Cross-platform macOS/Linux/Windows behavior was checked: this is pure shared string/regex logic with no platform-dependent path, shell, or shortcut behavior, and it remains compatible with local, folder-workspace, SSH, and remote sessions.

Security Audit

No new input authority, filesystem access, network behavior, or dependency changes. Image source-path parsing is unchanged; only the position of an existing transcript marker is generalized.

Notes

Scope is intentionally limited to marker-position handling and tests. Send ordering, settle delays, and queued/pending labels are unchanged.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@brennanb2025, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 8 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3bf9b110-81fd-4dfa-9374-b76f35b01b39

📥 Commits

Reviewing files that changed from the base of the PR and between 2076cd9 and 5facc5f.

📒 Files selected for processing (8)
  • mobile/src/session/mobile-native-chat-draft-reconcile.test.ts
  • mobile/src/session/mobile-native-chat-draft-reconcile.ts
  • mobile/src/session/mobile-native-chat-image-transcript-markers.ts
  • mobile/src/session/use-mobile-native-chat-drafts.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.ts
  • src/renderer/src/components/native-chat/native-chat-pending.test.ts
  • src/shared/native-chat-image-transcript-markers.test.ts
  • src/shared/native-chat-image-transcript-markers.ts
📝 Walkthrough

Walkthrough

Image prompt markers are now recognized anywhere in transcript text, including repeated runs. Marker removal preserves required spacing. Transcript assembly merges image sources with trailing-marker prompts into one cleaned user message with an image reference. Mobile draft reconciliation normalizes text, matches these prompts, migrates standalone previews, clears pending sends, and assigns previews to the authoritative message. Regression tests cover parsing, assembly, rendering, pending-send pruning, and reconciliation.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, rationale, testing, scope, and behavior, but it omits the required issue link and visual attachments. Add a valid linked issue and attach before-and-after visual proof, or use the exact N/A statement only if no visual change exists.
Docstring Coverage ⚠️ Warning Docstring coverage is 23.08% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the primary change: handling native chat image marker positions.
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.
✨ Finishing Touches 💡 1
📝 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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 905f56c0-40d2-4907-bacc-e35ebb39c6b7

📥 Commits

Reviewing files that changed from the base of the PR and between 150cc6f and 3d4658e.

📒 Files selected for processing (10)
  • mobile/src/session/mobile-native-chat-draft-reconcile.test.ts
  • mobile/src/session/mobile-native-chat-draft-reconcile.ts
  • mobile/src/session/mobile-native-chat-image-transcript-markers.ts
  • mobile/src/session/mobile-native-chat-render-data.test.ts
  • mobile/src/session/use-mobile-native-chat-drafts.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending.test.ts
  • src/renderer/src/components/native-chat/native-chat-preassembled-session-parity.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-assembler.test.ts
  • src/shared/native-chat-image-transcript-markers.test.ts
  • src/shared/native-chat-image-transcript-markers.ts

@brennanb2025

Copy link
Copy Markdown
Contributor Author

QA evidence (HEAD 66c6be1d3f)

Validated the current worktree only. Isolated desktop instance identity: Orca: brennanb2025/native-chat-image-marker-position / devRepoRoot=/Users/brennanbenson/orca/workspaces/orca/native-chat-image-marker-position / CDP 9417.

Desktop

Seeded a Claude JSONL transcript with a source turn plus a trailing [Image #1] caption (look at this trailing caption[Image #1]) and a source turn plus a mid-text marker (please review [Image #1] this middle caption), then opened native chat on a fixture repo.

Result: two user bubbles only (not four). Each bubble shows the folded image chip plus the cleaned caption. No literal [Image #1] / [Image: source:…] in the transcript body, and no leftover optimistic photo bubble. Renderer console had no feature errors (React DevTools / React Grab / one xterm deadline warning only). App log had existing Claude 429 usage noise, not a chat-render failure.

desktop-native-chat-image-markers.png

Mobile

iPhone 17 Pro simulator (iOS 26.5, already running). Metro from this worktree mobile/ on LAN :8090. Opened the genuine development build, paired live to the isolated desktop instance, then opened the same fixture worktree chat.

Result: same two user bubbles — image + look at this trailing caption, image + please review this middle caption (middle-marker spacing preserved). No literal [Image #N] in the message body and no duplicate/stuck optimistic bubble.

mobile-native-chat-image-markers.png

Remaining risk

Tab titles still show the raw [Image: source: …] prefix. That is a generated-title surface, not the chat-bubble fold this change covers. Send-ordering / settle-delay races were not re-tested (out of scope).

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

🧹 Nitpick comments (1)
mobile/src/session/use-mobile-native-chat-drafts.ts (1)

136-142: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document the canonical matching field.

captureSendOrigin now returns normalizedText after whitespace canonicalization. Add a brief comment to the exported return contract or MobileNativeChatSendOrigin.normalizedText stating that this value is for reconciliation only. Callers must keep using the original text for display and send payloads.

Based on learnings: document non-obvious members of exported hook-return contracts, but do not add boilerplate documentation for trivial local callbacks.

Source: Learnings


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 54e8926f-77b1-4542-adc7-580b8a564513

📥 Commits

Reviewing files that changed from the base of the PR and between 3d4658e and 2076cd9.

📒 Files selected for processing (5)
  • mobile/src/session/mobile-native-chat-draft-reconcile.test.ts
  • mobile/src/session/mobile-native-chat-draft-reconcile.ts
  • mobile/src/session/use-mobile-native-chat-drafts.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 (4)
  • mobile/src/session/mobile-native-chat-draft-reconcile.ts
  • src/shared/native-chat-image-transcript-markers.test.ts
  • mobile/src/session/mobile-native-chat-draft-reconcile.test.ts
  • src/shared/native-chat-image-transcript-markers.ts

@AmethystLiang

Copy link
Copy Markdown
Contributor

thanks for reporting. looking into it

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* fix(native-chat): handle image markers in any position

* fix(native-chat): preserve image caption whitespace

* test(native-chat): cover marker boundary spacing

* fix(mobile): normalize image echo reconciliation

* fix(mobile): use idiomatic tail access

* refactor(native-chat): share image echo matching

* perf(native-chat): avoid unchanged block copies
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.

2 participants