Skip to content

Keep chat thinking before its answer across history loads - #33628

Merged
brennanb2025 merged 8 commits into
mainfrom
brennanb2025/sta-11667-transcript-order
Oct 27, 2026
Merged

brennanb2025 merged 8 commits into
mainfrom
brennanb2025/sta-11667-transcript-order

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A chat answer could appear above its own thinking when several transcript records had the same timestamp. The conversation now follows the transcript's actual order, including when older history loads while new replies arrive.

What Changed

File-backed chat rows use their existing position in the transcript as their display order. Their timestamps keep their original meaning. Thinking stays before its answer, pasted images remain attached to the right prompt, and command feedback and optimistic messages keep their normal placement.

Desktop, web and phone reads and subscriptions agree on the representation. Older clients and servers retain their existing path; this adds no saved ordering field, minimum server version or RPC operation.

Why

A row needs the same position whether it came from a full read, a recent window, an older page or a live append. Adjusting timestamps depended on how much history had been read and could also make old content look newer to status logic. Source positions supply that stable order without reading the missing prefix or changing the transcript file.

Plan: one change covering the reader, shared projection, image folding, incremental assembly and compatible transport selection. Ordering and the mixed-version read contract take the full review path.

Linked Issue

Tracked in STA-11667. Supersedes #31794, which remains open for maintainer disposition.

Visual Proof

Branch-only hidden Electron screenshots use deterministic transcript fixtures, with no agent execution. Thinking stays above the final answer, and an appended pasted image remains one prompt with an attachment chip.

Collapsed thinking before answer

Expanded thinking before answer

One pasted image prompt with answer below

Testing

CI is green on reviewed head 916dbf83f0a25d011e0ccf3ac6df7050d2380c83: all five root shards, static analysis/typechecking, mobile verification, macOS/Linux/Windows transcript readers, persistence, relay integration, packaging and three WSL distro checks passed. PR Checks and Mobile verify.

Targeted contracts exercise the actual file reader and watcher, 300→500 older-history expansion followed by row501 from the original watcher, final reasoning/answer rendering, image boundaries, mixed sources, old/new transport representations, and bounded N/10N incremental work. The real reader-to-phone stream/fold contract runs in the root suite without requiring the mobile app's dependency tree. The two affected root suites passed 14/14; the five affected mobile suites passed 810 distinct cases, including strict bridge accounting for 795 recordings with 0 unclassified. The normal pre-commit hooks passed. Four existing mobile recordings now expect the negotiated capability; their replies, checkpoints and visible outcomes are unchanged. Most JSON churn comes from moving blocks in the existing sorted content-addressed pool.

The hidden branch screenshot check verified thinking above its answer and one appended image prompt/attachment chip. It used deterministic transcript fixtures, without live agent execution or an image-preview-pixels claim.

  • Screenshot check of the actual transcript screen completed
  • Automated regression contracts completed

Review

The full review completed two adversarial rounds, an independent architecture challenge, compatibility and performance passes, and a final comparison with the common pattern. Later CI repairs changed only tests, recordings and their runner; all 20 production files remain identical to the independently reviewed implementation. The earlier screenshot evidence carries across those non-shipped commits.

Agent skill upstream boundary

  • Not applicable; this change contains no upstream skill-installer material.

Notes

Intended adaptations of the common pattern: external transcript files use byte positions instead of saved sequence fields; terminal supplements keep their existing placement; historical image rows fold into one prompt; mixed-version clients retain the original representation when the capability is absent.

No provider login, process lifecycle, saved transcript or journal migration changes. The native chat UI QA row applies: renderer/contract tests and a quick branch screenshot, without a real-agent QA round.

Checklist

  • Focused on one ordering mechanism
  • User-facing behavior and approach explained
  • Screenshot attached
  • Independent correctness, compatibility, reference and performance review complete
  • Cross-platform and mixed-version contracts verified
  • CI green on the reviewed head

@brennanb2025
brennanb2025 marked this pull request as ready for review October 25, 2026 20:29
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3fe24a50-bfc9-428e-89a6-17ae07652178
Commits

Reviewing files that changed from the base of the PR and between 7fa1011 and 916dbf8.

Files selected for processing: 9
  • config/vitest.config.ts
  • mobile/rpc-foundation/goldens/matrix-session.native-chat-page-nativechat.readsession-1.json
  • mobile/rpc-foundation/goldens/matrix-session.native-chat-page-nativechat.subscribe-1-1.json
  • mobile/rpc-foundation/goldens/matrix-session.native-chat-page-nativechat.subscribe-2-1.json
  • mobile/rpc-foundation/goldens/native-chat-page-earlier.json
  • mobile/rpc-foundation/pilot-scenarios.json
  • mobile/src/session/mobile-native-chat-page-rejection.test.ts
  • mobile/src/session/use-mobile-native-chat-session-tool-result-paging.test.tsx
  • tests/e2e/native-chat-live-history.unit.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Walkthrough

The change adds the transcriptSourceOrder capability to mobile and web session requests. When enabled, transcript readers attach record byte offsets to messages and retain their timestamps. Legacy requests continue to use timestamp-based ordering. Renderer projection and session assembly use canonical transcript positions where available and account for supplemental messages and image grouping. Tests cover transcript reads, pagination, subscriptions, capability negotiation, message assembly, and rendered reasoning order.

Priority: Normal

Merge Risk: Minimal · up to 916db

No actionable merge-blocking issue is established; the previously reported CI concern no longer applies.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 40 files. (5 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title "Keep chat thinking before its answer across history loads" matches the main change: file-backed chat rows now use transcript source positions for display order, so reasoning stays before it…
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.
Description check Passed The pull request description is complete and focused. It includes the required explanation, change summary, rationale, linked issue, visual proof, testing details, review notes, compatibility consider…
Full details: Title check

Explanation

The title "Keep chat thinking before its answer across history loads" matches the main change: file-backed chat rows now use transcript source positions for display order, so reasoning stays before its answer when older history loads or live appends arrive. It is specific and scoped to the primary user-visible problem.

Full details: Description check

Explanation

The pull request description is complete and focused. It includes the required explanation, change summary, rationale, linked issue, visual proof, testing details, review notes, compatibility considerations, and checklist. The linked issue is provided as an explicit Linear issue rather than under the exact Fixes # label, but the required tracking information is present.

Full details: Docstring Coverage

Explanation

Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 45 functions across 40 files. (5 skipped: 5 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 91c1169b-e6a0-48d1-9318-1b599fdacde4
Commits

Reviewing files that changed from the base of the PR and between 843e502 and 87bcd2a.

Files selected for processing: 32
  • mobile/src/session/mobile-native-chat-stream-frame.test.ts
  • mobile/src/session/use-mobile-native-chat-session.test.ts
  • mobile/src/session/use-mobile-native-chat-session.ts
  • src/main/ipc/native-chat-subscribe-lifecycle.test.ts
  • src/main/ipc/native-chat.test.ts
  • src/main/ipc/native-chat.ts
  • src/main/native-chat/transcript-file-order.test.ts
  • src/main/native-chat/transcript-file-order.ts
  • src/main/native-chat/transcript-incremental-reader.ts
  • src/main/native-chat/transcript-reader.ts
  • src/main/native-chat/transcript-stream-lines.ts
  • src/main/native-chat/transcript-tail-reader.ts
  • src/main/native-chat/transcript-watch-contract.ts
  • src/main/native-chat/transcript-watch-engine.ts
  • src/main/runtime/rpc/methods/native-chat-ssh-transcript.test.ts
  • src/main/runtime/rpc/methods/native-chat.ts
  • src/renderer/src/components/native-chat/NativeChatMessageList.queued-turn-order.test.tsx
  • src/renderer/src/components/native-chat/native-chat-incremental-assembler.test.ts
  • src/renderer/src/components/native-chat/native-chat-incremental-assembler.ts
  • src/renderer/src/components/native-chat/native-chat-message-grouping.ts
  • src/renderer/src/components/native-chat/native-chat-message-list-projection.ts
  • src/renderer/src/components/native-chat/native-chat-sent-prompt-history.ts
  • src/renderer/src/components/native-chat/native-chat-session-assembler.ts
  • src/renderer/src/components/native-chat/native-chat-session-transport.test.ts
  • src/renderer/src/components/native-chat/native-chat-session-transport.ts
  • src/renderer/src/components/native-chat/use-native-chat-live-session.test.ts
  • src/renderer/src/web/preload-api/web-native-chat-api.ts
  • src/renderer/src/web/web-preload-api-runtime-calls.test.ts
  • src/shared/native-chat-transcript-projection.test.ts
  • src/shared/native-chat-transcript-projection.ts
  • src/shared/native-chat-types.ts
  • src/shared/rpc-contract/native-chat-params.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@brennanb2025

brennanb2025 commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor Author

An answer could appear above its own thinking when transcript rows shared a timestamp. Timestamp adjustment also made row order depend on how much history had loaded. The chat now follows stable transcript positions, keeping thinking before its answer as older history loads and new messages arrive. Pasted images remain attached to their prompt, and command feedback and pending messages retain their placement. Older clients and servers keep their existing representation.

The full review completed two adversarial rounds, an independent architecture challenge, compatibility and performance checks, and a final comparison with the common pattern. It resolved pagination/append ordering, fabricated-clock status effects and equal-time image pairing. CI follow-ups repaired test-project admission, stale capability expectations and synchronization with the real watcher; shipped code stayed unchanged. No open P0/P1 or newly accepted worse behavior remains. Intended adaptations of the common pattern use byte positions for externally owned files, preserve terminal supplements and historical image pairing, and retain the old representation for clients without the capability. Existing phone prompt-first image normalization and unmatched-image lookahead limitations are outside this change.

Verified: actual reader/watcher → 300-to-500 older history → original watcher row501, renderer thinking-before-answer, image page/append pairing, actual RPC old/new read and stream representations, real phone frame/fold consumption and bounded N/10N append-decision work. Focused root and mobile contracts passed; strict bridge accounting covered 795 recordings with 0 unclassified. CI is green on reviewed head 916dbf83f0a25d011e0ccf3ac6df7050d2380c83: all five root shards, static analysis/typechecking, mobile verification, macOS/Linux/Windows transcript readers, persistence, relay integration, packaging and three WSL distro checks passed. PR Checks and Mobile verify.

A hidden branch-only Electron screenshot check used deterministic transcript fixtures, without agent execution. It verified the actual transcript screen with expanded thinking above the answer and one appended image prompt/attachment chip. Image preview pixels, live provider replies, lifecycle/login and remote performance were not exercised; the changed flows are in the UI tests row. Screenshot evidence is from 3db8c40. Later commits d6f97ac, bdd54fd, 7fa1011, cff603b and 916dbf8 touch only non-shipped tests/recordings/test-runner configuration; the screen and runtime code remain identical. Final reviewed head: 916dbf8.

For Brennan’s review:

Thinking before the answer

Expanded thinking above the answer

One pasted-image prompt and attachment chip

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