Repository navigation
Keep stale chat navigation callbacks out of the current view - #854
Conversation
0df6d2a to
b60eb27
Compare
b60eb27 to
5d863a6
Compare
Signed-off-by: dada-yan <BinjunYann@gmail.com>
5d863a6 to
bd11c1d
Compare
WaylandYang
left a comment
There was a problem hiding this comment.
Reviewed the mechanism closely and it holds up. Three things I expected to be
problems and checked — all fine, recording them so the next reader doesn't repeat
the work:
- Removing the
prevKbRefeffect is safe, not a behaviour loss.setKb
already navigates, andsamePageInKbalready drops everything after the section
segment, so/kb/A/chat/<conv>becomes/kb/B/chat— which is what the deleted
effect was doing by hand. It was redundant since #261. if (handle) returninonSnapshotis a no-op, not a dropped update. The
server yields exactly one snapshot frame at attach (api/chat.rs:995) and then
streams deltas, so there is never a second snapshot to ignore.- The transcript does not vanish when a stream ends.
finish()only flips
streaming, it does not delete the entry, soliveHerestays truthy and
shownkeeps rendering even thoughloadedKeyis stillnullfor a
freshly-created conversation.
Two things worth a look before this lands:
1. The new-conversation path works by coincidence of ordering. When send()
creates a conversation, onConversation navigates, which fires the new
useLayoutEffect; that effect calls claimView(newId) — invalidating the owner
token send() is still holding — and sets activeIdRef.current = null. The null
then defeats the routeConvId === activeIdRef.current early return in the
route-sync effect, so loadConversation is called mid-stream. It only stays
correct because loadConversation happens to return early on
liveAnswer.entry(...). That's three separate mechanisms having to agree. A short
comment saying so, or skipping the reset when routeConvId === activeIdRef.current,
would make it robust to the next edit.
2. The 448 test lines never run. vite.config.ts has
include: ["src/**/*.test.ts"], so web/tests/*.test.mjs is outside vitest
entirely — pnpm vitest list reports 0 cases from chat-view, and pnpm test is
129 tests on this branch, exactly as on dev. Nothing in CI or in any package
script references web/tests/.
That matches the existing rss-default.test.mjs convention, so it isn't a
departure — but it does mean this fix ships with no executed regression guard, for
precisely the class of async-ownership bug that regresses silently. At minimum,
please copy the rest of that convention: rss-default.test.mjs documents its exact
npm install --prefix ... playwright-core + env-var + node --test command at the
top, and this file only says "uses the optional browser setup from
rss-default.test.mjs". Without the command, the two cases are unrunnable for
anyone who doesn't go reconstruct it.
(Also worth noting for the maintainers: web/tests/rss-default.test.mjs on dev
has the same property. If these browser probes are meant to be runnable on demand,
a pnpm test:browser script would make them discoverable; if they're meant to be
CI-gated, the include pattern needs widening. Separate issue either way.)
|
Heads-up for reviewers: these three are a stack, not three independent PRs. All #854 ⊂ #856 ⊂ #855 — commits relative to It also means the diff sizes on the PR list overstate the review work, because each
Nothing wrong with the stack itself — just worth stating so reviewers don't read |
Signed-off-by: dada-yan <BinjunYann@gmail.com>
|
Addressed both review points with comments only:
I ran the documented command using the stated playwright-core version: #854 passes 11 browser subtests (12 including its parent). Propagated the comment-only change through #856 and #855; the complete stack passes 27 browser subtests (29 including parents). Runtime code and test assertions are unchanged. A shared browser script or CI integration remains a separate scope, as suggested. Updated the three PR descriptions with their current heads; the merge order remains #854 → #856 → #855. |
WaylandYang
left a comment
There was a problem hiding this comment.
Both points addressed as asked, and the two new comments describe the mechanism
accurately: navigation on a new conversation invalidates the send owner and clears
activeIdRef, so route-sync does call loadConversation, and it is
loadConversation's own liveAnswer.entry check that reclaims the already-identified
handle rather than the early return I had first credited. The test file now carries
the same install/env/run block rss-default.test.mjs does. Re-approving; the earlier
approval was dismissed by the push, not by a change of mind.
Review follow-up (2026-09-23)
Current head:
2d7e35b6af71ebf3356e702f9ff63ab0c3b370ba. Comment-only follow-up to #854 review: document the new-conversation route/ownership/live-entry handoff, correct the old early-return comment, and provide a complete optional Playwright installation and browser-test invocation at the top ofchat-view.test.mjs. These browser probes are explicitly separate from Vitest and CI; no new CI scope is introduced. The changes are carried through the #854 → #856 → #855 stack.The documented command passed on #854 (11 subtests, 12 including the parent); the final stack passed all 27 browser subtests (29 including parents). Runtime code and assertions are unchanged. Prior validation below refers to its stated historical heads.
Post-merge synchronization (2026-09-22)
Rebased onto
dev@7cfeedfeb11c3a1c42d5091c5941a51afaaeb161after #848, #851, #849, #850 and #852 merged. Current head:bd11c1d9ea61f5015d55ed8bc0f656c1bb2e2717.The UI dependency order remains #854 → #856 → #855. Retained upstream stream-interruption strings alongside the history/pagination keys when resolving i18n conflicts. The complete UI tree is byte-for-byte identical to the previous validated integration tree. Maintainer visual review remains outstanding.
Validation on combined tree
d06f4ad0199a382635a6bbf94210b9421cbeba66(675 tracked Linux inputs hash-matched):Earlier evidence below refers to its stated historical heads.
When conversation A loads slowly and the user selects B, A's late success or failure can replace B's transcript or navigate away. A late identity response from a new chat can likewise pull the user back after they leave.
This gives each view request an identity, including separate visits in A → B → A. History, navigation and initial reattachment callbacks must still own that view before changing it. Existing generation handles continue in the background. Temporary history failures keep the selected URL and offer a retry; missing/inaccessible conversations retain their existing redirect behavior. Route changes also hide the previous transcript before paint.
Validation on
dev@ea0557b, fix0df6d2a:f7bcd0878bf490d6efb122b71d6f13d379df4709combines this with Hand off exhausted tool runs to an evidence-only final answer #845 and the other scoped Chat fixes: Rust fmt, strict workspace Clippy, 1,013 tests (one pre-existing external-HTTPS RSS test ignored), workspace build, 129 frontend module tests, 27 browser subtests and frontend build pass. This integration result is distinct from the standalone branch checks.The browser harness uses optional Playwright/Chromium, following the repository's existing browser-test pattern; it adds no package dependency. Run
node --test tests/chat-view.test.mjsfromweb, withCHAT_PLAYWRIGHT_PATHandCHAT_CHROMIUM_PATHif needed. This does not introduce server-side cancellation, retries of a generation, or changes to #845's model policy.