Skip to content

fix(native-chat): stop matching pending echoes across clock domains - #13613

Closed
brennanb2025 wants to merge 15 commits into
mainfrom
brennanb2025/issue-11519-cross-clock-pending-echo
Closed

brennanb2025 wants to merge 15 commits into
mainfrom
brennanb2025/issue-11519-cross-clock-pending-echo

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​917 $\color{#cf222e}{\Huge{\mathbf{−}}}$​144 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​773
Prod 18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1275 $\color{#cf222e}{\Huge{\mathbf{−}}}$​432 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​843

Summary

Fixes #11519 / STA-2989: Chat UI pending-echo matching and /clear filtering compared renderer-clock sentAt to host/provider transcript message.timestamp. On remote runtimes those are different machines, so host-behind stranded optimistic bubbles forever and blanked post-clear transcripts, while host-ahead retired echoes against older identical prompts and let pre-clear rows survive /clear.

Change

  1. Echo retirement — nativeChatPendingMatchingAfter / messageIsAfterPendingTimestamp only use host-domain bounds (matchingAfterTimestamp / afterMessageTimestamp). Never fall back to renderer sentAt. Without a host bound, identity + occurrence matching sees the full list.
  2. /clear — record the message ids visible at clear time and hide those ids. No wall-clock comparison across domains.
  3. Extract command-marker cache/boundary helpers into native-chat-command-markers.ts (+ thin hook) so files stay under max-lines.

Does not duplicate #11509 (conversation retain on session replace) or #13513 (cancelled-send occurrence release). Those PRs document this clock-domain mix as a known unfixed limit (#11519).

Screenshots

No visual change in the correct state — this removes permanent stale bubbles / blank post-clear lists that should not appear. Behavior is pinned by unit tests (host-behind and host-ahead at both echo retirement and /clear).

Testing

  • pnpm lint (via pre-commit oxlint on changed files; max-lines clean, no new bypasses)
  • pnpm typecheck:web
  • pnpm typecheck (full three-project; web-only change path exercised)
  • Focused tests: native-chat-pending.test.ts, native-chat-pending-occurrence.test.ts, NativeChatInteractiveCard.test.tsx (68 passed)
  • Broader: src/renderer/src/components/native-chat/ (69 files / 719 tests passed)
  • pnpm build — not run; renderer-only pure TS with no main/preload/packaging surface
  • Added host-behind / host-ahead regressions for echo retirement and /clear

SHA: 5bc65d45e8b838bc7edec9735ab78c8defb9c549

AI Review Report

Self-reviewed for pure logic, React effects, tests, and repo fit:

  • Pure logic: removed the only cross-domain comparisons; /clear is id-set membership (O(n) over page-sized lists). Occurrence inheritance no longer copies renderer sentAt into a field labeled host-domain.
  • React: slash markers live in a small hook; deps are commandMarkerScope + messages. No new subscription or render loop.
  • Cross-platform: renderer-only TypeScript — no paths, shell, shortcuts, or Electron main/IPC changes. Same on macOS/Linux/Windows; remote SSH/runtime is the motivating case.
  • Wire compatibility: no RPC/stream frame changes (optional in-memory marker field only).
  • Residual: send-into-empty while history is still loading with an identical completed prompt can still claim an unbound echo via occurrence matching — the old sentAt filter already failed the same way when the host clock was ahead.

Security Audit

No new attack surface.

  • Input: message ids and slash command strings already on the path; id hide-set is equality over internal transcript ids.
  • Command execution / paths / auth / secrets / IPC: none added.
  • Dependencies: none added.
  • Memory: command-marker cache still LRU-bounded; id arrays capped with the existing 8-marker limit.

Notes

@coderabbitai

coderabbitai Bot commented Aug 10, 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
📝 Walkthrough

Walkthrough

Native chat now tracks transcript generation, sequence, and high-water metadata across live-session snapshots, appends, replacements, and pagination. Command markers use dedicated scoped cache and hook modules, record /clear boundaries, and filter transcript messages by message ID or transcript order. Launch prompts use dedicated transcript-aware utilities and hooks. Pending-send pruning and rendering use transcript-aware boundaries and no longer use renderer-only timestamps for host matching. Tests cover ordering, session adoption, command markers, pagination, clock skew, launch prompts, and repeated sends.

Merge Risk: 🔵 Low · up to fcb85

The pending-send lifecycle can use the previous chat scope's generation baseline after a scope change, which may remove optimistic bubbles and allow duplicate sends. The risk is localized and mergeable with explicit owner follow-up to reset the baseline when the scope changes.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The pull request also adds broad live-session, launch-prompt, pagination, and transcript-order refactors not clearly required by issue #11519. Separate unrelated live-session, launch-prompt, pagination, and transcript-order changes, or document why each change is required for the #11519 fix.
Docstring Coverage ⚠️ Warning Docstring coverage is 38.10% 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 identifies the main clock-domain bug affecting pending-echo matching.
Description check ✅ Passed The description clearly covers the problem, implementation, linked issue, testing, behavior impact, and residual risk.
Linked Issues check ✅ Passed The changes address issue #11519 by removing cross-clock matching and using transcript identities for echo retirement and /clear filtering.
✨ 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: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 598033b0-07f5-4be6-93a3-e31052642fc5

📥 Commits

Reviewing files that changed from the base of the PR and between 56b6d84 and 5bc65d4.

📒 Files selected for processing (8)
  • src/renderer/src/components/native-chat/NativeChatInteractiveCard.test.tsx
  • src/renderer/src/components/native-chat/NativeChatView.tsx
  • src/renderer/src/components/native-chat/native-chat-command-markers.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.ts
  • src/renderer/src/components/native-chat/native-chat-pending.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending.ts
  • src/renderer/src/components/native-chat/use-native-chat-command-markers.ts

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron QA (exact SHA 4f95a39522dba2f0bdcf21ace9792afe48c61878)

Result: PASS — host-behind clear/replacement and ordinary optimistic echo behave correctly on the pushed head.

Method

  • Confirmed worktree HEAD == PR head 4f95a39522dba2f0bdcf21ace9792afe48c61878.
  • Independently verified prior CDP Electron screenshots (taken after the commit on this exact SHA) against the claimed DOM outcomes; screenshots are gitignored and not in the PR diff.
  • Control path for the source run: Electron + agent-browser over CDP only (no Computer Use / Playwright / OS UI automation).
  • Did not re-drive an identical second Electron session because exact-head CDP evidence already matched the claims.

Observed

Scenario Observation
Host-behind /clear + replacement Ran /clear present; pre-clear rows hidden; post-clear content still renders (fresh after clear host behind, fresh answer)
Ordinary optimistic echo Immediate bubble ordinary optimistic echo probe with transcript still intact

Screenshots (attached, not committed)

Host-behind clear + replacement Ordinary optimistic echo
host-behind clear/replacement ordinary optimistic echo

Gaps

  • macOS Electron evidence only; no Windows/Linux screenshot package.
  • No live multi-host SSH clock-skew session (renderer-local order/id path; fixture + unit harness cover the decision logic).
  • Known residual: unbound occurrence claim when sending into empty history that is still loading with an identical completed prompt (same class as pre-fix host-ahead).

Attachment SHA (uploads ref): 0e69e3c878aecee27ba146647ee8cea207e8b98f

@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 (3)
src/renderer/src/components/native-chat/use-native-chat-transcript-order.ts (1)

11-39: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider returning a named object instead of a 4-tuple.

append and settle have identical signatures: (messages, retainedCount) => void. The tuple position is the only distinction. A caller that swaps them compiles cleanly and produces wrong sequence semantics. A named object removes that class of mistake.

♻️ Proposed refactor
-export function useNativeChatTranscriptOrder(): readonly [
-  NativeChatTranscriptOrder,
-  () => void,
-  (messages: readonly NativeChatMessage[], retainedCount: number) => void,
-  (messages: readonly NativeChatMessage[], retainedCount: number) => void
-] {
+export type NativeChatTranscriptOrderControl = {
+  order: NativeChatTranscriptOrder
+  replace: () => void
+  append: (messages: readonly NativeChatMessage[], retainedCount: number) => void
+  settle: (messages: readonly NativeChatMessage[], retainedCount: number) => void
+}
+
+export function useNativeChatTranscriptOrder(): NativeChatTranscriptOrderControl {
-  return [current, replace, append, settle]
+  return { order: current, replace, append, settle }
 }

Update the destructuring at src/renderer/src/components/native-chat/use-native-chat-live-session.ts lines 69-70 to match.

src/renderer/src/components/native-chat/use-native-chat-live-session.test.ts (1)

483-520: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add the non-empty-clear replacement case.

This test covers /clear on an empty transcript, where treating replacement-settled rows as post-clear is correct. The inverse case is not covered: /clear on a non-empty transcript, then a replacement frame whose payload still contains pre-clear rows and no longer contains clearAfterMessageId.

In that case applyCommandMarkerBoundaries cannot resolve the id boundary and falls through to the sequence filter. The replacement settle assigns the pre-clear rows sequences above clearTranscriptHighWater, so they would become visible again. This is the same root cause flagged at src/renderer/src/components/native-chat/native-chat-transcript-order.ts lines 26-57.

Do you want me to draft this regression test?

src/renderer/src/components/native-chat/use-native-chat-load-earlier.ts (1)

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

Replace MutableRefObject with RefObject here.

package.json pins @types/react@^19.2.17 for this renderer target, where MutableRefObject is deprecated.

♻️ Proposed refactor
-import { useCallback, type MutableRefObject } from 'react'
+import { useCallback, type RefObject } from 'react'

Then update the four ref parameter types:

-  limitRef: MutableRefObject<number>
-  transcriptEpochRef: MutableRefObject<number>
-  latestSessionId: MutableRefObject<string | null>
-  latestTransport: MutableRefObject<SessionTransport>
+  limitRef: RefObject<number>
+  transcriptEpochRef: RefObject<number>
+  latestSessionId: RefObject<string | null>
+  latestTransport: RefObject<SessionTransport>

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c8a93ae6-49cb-45cb-b26f-f8f1c31bc63b

📥 Commits

Reviewing files that changed from the base of the PR and between 5bc65d4 and 4f95a39.

📒 Files selected for processing (17)
  • src/renderer/src/components/native-chat/NativeChatView.tsx
  • src/renderer/src/components/native-chat/native-chat-command-markers.ts
  • src/renderer/src/components/native-chat/native-chat-incremental-assembler.ts
  • src/renderer/src/components/native-chat/native-chat-live-session-order.ts
  • src/renderer/src/components/native-chat/native-chat-live-session-types.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.ts
  • src/renderer/src/components/native-chat/native-chat-pending.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-order.test.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-order.ts
  • src/renderer/src/components/native-chat/use-native-chat-command-markers.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-command-markers.ts
  • src/renderer/src/components/native-chat/use-native-chat-live-session.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-live-session.ts
  • src/renderer/src/components/native-chat/use-native-chat-load-earlier.ts
  • src/renderer/src/components/native-chat/use-native-chat-retained-session.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-transcript-order.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/native-chat/NativeChatView.tsx
  • src/renderer/src/components/native-chat/native-chat-pending.test.ts

Comment on lines +86 to +92
if (unsubscribe && typeof (unsubscribe as { then?: unknown }).then === 'function') {
void (unsubscribe as Promise<unknown>).then((fn) => {
if (typeof fn === 'function') {
;(fn as () => void)()
}
})
}

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Attach a rejection handler to the promise teardown path.

void (unsubscribe as Promise<unknown>).then(...) has no rejection handler. If transport.subscribe resolves to a rejected promise, the renderer raises an unhandledrejection event. Teardown runs on every source rebind and on unmount, so an IPC failure during subscribe reaches this path.

🛡️ Proposed fix
   if (unsubscribe && typeof (unsubscribe as { then?: unknown }).then === 'function') {
-    void (unsubscribe as Promise<unknown>).then((fn) => {
-      if (typeof fn === 'function') {
-        ;(fn as () => void)()
-      }
-    })
+    void (unsubscribe as Promise<unknown>)
+      .then((fn) => {
+        if (typeof fn === 'function') {
+          ;(fn as () => void)()
+        }
+      })
+      // A failed subscribe has nothing to tear down; do not raise unhandledrejection.
+      .catch(() => undefined)
   }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (unsubscribe && typeof (unsubscribe as { then?: unknown }).then === 'function') {
void (unsubscribe as Promise<unknown>).then((fn) => {
if (typeof fn === 'function') {
;(fn as () => void)()
}
})
}
if (unsubscribe && typeof (unsubscribe as { then?: unknown }).then === 'function') {
void (unsubscribe as Promise<unknown>)
.then((fn) => {
if (typeof fn === 'function') {
;(fn as () => void)()
}
})
// A failed subscribe has nothing to tear down; do not raise unhandledrejection.
.catch(() => undefined)
}

pending.sentAt is renderer time while transcript message.timestamp is
host/provider time on remote runtimes. Never use sentAt as a host-domain
bound for echo retirement, and hide /clear rows by the message ids visible
at clear time so host-behind and host-ahead no longer strand or leak turns.

Closes #11519
Keep transcriptOrder generation across null→sessionId adoption and
same-session snapshots so empty-boundary pending can retire against the
mandatory initial snapshot. Settle first-seen rows on adoption and
replacement frames only (reconnect baselines stay unsequenced), and
boundary-filter glue fallbacks so pre-watermark history cannot prune a
fresh multi-send pair.
Extract notFound retry scheduling and subscribe outside the effect body, and always return a disposer so effect-needs-cleanup accepts the live-session hook on changed-code quality.
useRef(createNativeChatTranscriptOrder()) re-ran create on every render,
allocating and discarding an order object plus Map. Seed with the standard
null-guarded lazy-ref pattern and keep updater identity stable across re-renders.
@brennanb2025
brennanb2025 force-pushed the brennanb2025/issue-11519-cross-clock-pending-echo branch from 4eb7ab2 to 6be90b2 Compare August 17, 2026 11:12
@coderabbitai

coderabbitai Bot commented Aug 17, 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.

@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: e4c18be4-56de-41aa-b710-8c04447c412e

📥 Commits

Reviewing files that changed from the base of the PR and between 7ae6aed and 6be90b2.

📒 Files selected for processing (26)
  • src/renderer/src/components/native-chat/NativeChatInteractiveCard.test.tsx
  • src/renderer/src/components/native-chat/NativeChatInteractiveCard.tsx
  • src/renderer/src/components/native-chat/NativeChatView.tsx
  • src/renderer/src/components/native-chat/native-chat-command-markers.ts
  • src/renderer/src/components/native-chat/native-chat-incremental-assembler.ts
  • src/renderer/src/components/native-chat/native-chat-launch-prompt.test.ts
  • src/renderer/src/components/native-chat/native-chat-launch-prompt.ts
  • src/renderer/src/components/native-chat/native-chat-live-session-order.ts
  • src/renderer/src/components/native-chat/native-chat-live-session-types.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.ts
  • src/renderer/src/components/native-chat/native-chat-pending.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending.ts
  • src/renderer/src/components/native-chat/native-chat-session-assembler.ts
  • src/renderer/src/components/native-chat/native-chat-session-transport.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-order.test.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-order.ts
  • src/renderer/src/components/native-chat/use-native-chat-command-markers.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-command-markers.ts
  • src/renderer/src/components/native-chat/use-native-chat-launch-prompt.ts
  • src/renderer/src/components/native-chat/use-native-chat-live-session.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-live-session.ts
  • src/renderer/src/components/native-chat/use-native-chat-load-earlier.ts
  • src/renderer/src/components/native-chat/use-native-chat-retained-session.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-transcript-order.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-transcript-order.ts
🚧 Files skipped from review as they are similar to previous changes (22)
  • src/renderer/src/components/native-chat/native-chat-session-assembler.ts
  • src/renderer/src/components/native-chat/native-chat-session-transport.ts
  • src/renderer/src/components/native-chat/use-native-chat-retained-session.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-transcript-order.test.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.test.ts
  • src/renderer/src/components/native-chat/native-chat-incremental-assembler.ts
  • src/renderer/src/components/native-chat/native-chat-live-session-types.ts
  • src/renderer/src/components/native-chat/use-native-chat-transcript-order.ts
  • src/renderer/src/components/native-chat/use-native-chat-live-session.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-launch-prompt.ts
  • src/renderer/src/components/native-chat/use-native-chat-command-markers.test.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-order.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-load-earlier.ts
  • src/renderer/src/components/native-chat/native-chat-launch-prompt.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-command-markers.ts
  • src/renderer/src/components/native-chat/native-chat-transcript-order.ts
  • src/renderer/src/components/native-chat/native-chat-pending-occurrence.ts
  • src/renderer/src/components/native-chat/native-chat-pending.test.ts
  • src/renderer/src/components/native-chat/native-chat-launch-prompt.ts
  • src/renderer/src/components/native-chat/native-chat-pending.ts
  • src/renderer/src/components/native-chat/use-native-chat-live-session.ts
  • src/renderer/src/components/native-chat/native-chat-live-session-order.ts

Included review availability: Your plan includes up to 10 reviews per rolling hour; 0 remain after this review.

@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: 0348c0b5-4e9d-4afe-9b61-a11016fcebe6

📥 Commits

Reviewing files that changed from the base of the PR and between 6be90b2 and fcb85ae.

📒 Files selected for processing (2)
  • src/renderer/src/components/native-chat/NativeChatView.tsx
  • src/renderer/src/components/native-chat/use-native-chat-pending-sends.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/native-chat/NativeChatView.tsx

Included review availability: Your plan includes up to 10 reviews per rolling hour; 0 remain after this review.

Comment on lines +29 to +38
useEffect(() => {
setPending(readPendingSendCache(scope))
}, [scope])
useEffect(() => {
if (pendingGenerationRef.current !== order.generation) {
// A source rebind invalidates pane-local optimistic sends.
setPending(writePendingSendCache(scope, []))
}
pendingGenerationRef.current = order.generation
}, [order.generation, scope])

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reset the generation baseline when scope changes.

Lines 30-31 load the new scope cache. Lines 33-36 can then erase it because pendingGenerationRef.current still contains the previous scope generation.

When the scope changes, set pendingGenerationRef.current to order.generation before generation invalidation runs. Keep invalidation for generation changes within the same scope only. Otherwise, returning to a scoped chat with pending sends can remove its optimistic bubbles and allow duplicate sends.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

"## Final review and validation\n\nFinal pushed SHA: fcb85ae.\n\nReview history (predecessor completed four rounds):\n- Round 1 found cross-generation pending matching, snapshot/reconnect retirement gaps, clear fallback blanking, live-status identity risk, launch clock fallback, and a timestamp fallback.\n- Round 2 tightened source/generation isolation and conservative snapshot handling; it identified the opposite risk of promoting an untrusted snapshot baseline.\n- Round 3 fixed source/clear isolation, pending cancellation, and recovery paths; replacement-baseline, snapshot-only, and live-status races remained.\n- Round 4 reconfirmed snapshot-only pending/launch retirement, paged-out clear tails, and live /clear status identity races.\n\nAdjudication:\n- Snapshot-only pending/launch retirement: (b) inherent architecture, known limitation. Ordinary and reconnect snapshots carry no causal host sequence, so sequencing them would incorrectly retire an empty-boundary echo against pre-send history; leaving them unsequenced can strand a first-send/launch bubble when the completed turn arrives only in a reconnect snapshot. This remains reachable for remote/SSH panes until a later append or bounded cache eviction, and is explicitly worse than the old clock-skew tradeoff in that case. Fixing it requires a host-side causal watermark/protocol change, outside this renderer-only issue.\n- Live /clear status identity: (b) inherent architecture, known limitation. Live status has no transcript/source identity, so a lingering pre-clear ask cannot be distinguished from a first post-clear ask solely from status. The conservative clear path suppresses unresolved status and keeps transcript rows visible when a boundary is unavailable; it never auto-clears user data. A source/status identity contract is a follow-up architectural change, not a safe local fix.\n\nThe final mechanical extraction of pending-send state only keeps NativeChatView.tsx under the max-lines ratchet; no behavior was changed in response to those two inherent races.\n\nValidation:\n- Native-chat directory: 77 test files, 796 tests passed.\n- Wider renderer tree: 2,831 test files; 23,751 passed, 10 failed, 4 skipped. The 10 failures are the pre-existing terminal IME xterm suites (terminal-ime-xterm-cancelled-preedit-visibility and terminal-ime-xterm-midline-preedit-tail), outside this PR.\n- npx oxlint src/renderer/src: passed.\n- Changed-code quality gate against pinned 7ae6aed: 27 changed files, 0 code-quality, 0 type-aware, 0 React Doctor findings.\n- ref-oss: not run (coordinator-run).\n\nThe branch is pushed and the worktree contains only the two protected untracked paths: .llm-counsel/ and issue-11519-lazy-ref-report.md."

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing: superseded by #24207, which orders pending prompts chronologically and tolerates cross-host clock skew.

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.

[Bug]: Chat UI matches pending echoes across two clock domains — renderer send time vs remote transcript timestamps

1 participant