Repository navigation
fix(chat): bound deep-link recovery to its restore window - #19296
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check that 30s really covers a slow gateway restart. The only support is the comment's claim that restores "settle on the same seconds scale"; nothing measured it. Not justified as shipped
What this change shipsInventory (4 items) — 3 justifiedIntent: when a denied
[FIRST-PRINCIPLES-REVIEWED] c357f54 Description read[DESCRIPTION-READ] 1f332154dfe4acaa03d6dac8e0ba81dacc9eb5d4e7775f509e536ccd8c29cd8b That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that 30s covers a slow gateway restart with a large restore; if not, a real deep link stops auto-activating and the user has to click it in the sidebar. [DESIGN-REVIEWED] c357f54 Description read[DESCRIPTION-READ] 2b761d92f1e2775440ffa39bccfd35c10238227a9615fdd3d4523af5b5ec91d7 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Check what the user sees after expiry: a deep link that resolves more than 35s after opening clears the "not found" banner and leaves them on another session, with no pointer to the one that arrived. [UX-REVIEWED] c357f54 Description read[DESCRIPTION-READ] 735d38ff5166ab61ff32469d7f512bb9d6a2b6dae2f70d4b7efee04077ef12f1 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Expire automatic recovery after thirty seconds while still clearing a disproved not-found notice. Reconnect does not renew the recovery latch. Co-authored-by: Leon <276034861+leonlaiyc@users.noreply.github.com>
1f987bd to
c357f54
Compare
|
Self-review (crew-pr-reviewer, read-only): RECOMMEND APPROVE This PR stops a denied |
buluoray
left a comment
There was a problem hiding this comment.
LGTM. I checked this at head c357f54.
What it fixes: a /chat?sid=<key> link that was denied ("session not found") stayed armed forever, so a slots or reconnect frame minutes later could pull the person away from the session they were reading or typing in.
Checked:
- The bound fails closed:
useChatPageSessionController.ts:733checksDate.now() - denied.deniedAt > SID_RECOVERY_WINDOW_MS(30s) before the "active slot unchanged" branch, clears only its own stale banner, and never callsswitchSlot. The record is cleared first (:727), so it is used at most once. - A key that arrives inside the window still lands; that path is unchanged.
- Reconnect does not renew the window:
deniedAtis written only in the 5s deadline callback, which nullsinitialSidRefand so cannot re-stamp. - No new timer; the check is a timestamp comparison. The tests fake timers, which fakes
Datein vitest. learn-cron-dashboard.mdnames the 30s bound and "reconnect does not renew".
Mutations: making the expiry check always false reddens "only clears the banner when the key arrives long after the restore window" and "does not renew recovery on reconnect and still permits an explicit switch"; a window of 0 reddens "still resolves the link when the key arrives inside the restore window"; re-stamping deniedAt on every effect re-run reddens the reconnect test. ChatPage.sid.test.tsx: 67/67. CI at this head: 0 failed.
Non-blocking: Date.now() is wall-clock, so a clock moved backwards stretches the window; performance.now() would remove that case. The spec diff adds a stray blank line before ### UI Pages.
Problem / Motivation
Goal: Bound automatic denied deep-link recovery to the intended restore window.
A denied
/chat?sid=<key>recovery record can remain armed indefinitely. A much later slots or reconnect frame can then navigate away from the session the user is reading or composing in.Replaces #12026 by @leonlaiyc, carried to a main-repo branch so CI can run with full permissions. The original commit is cherry-picked unchanged with Leon's authorship preserved, plus a
Co-authored-by:trailer. Thank you, @leonlaiyc.Why it matters
A late slots frame can interrupt the session a user is reading or composing in.
Not a goal
What changed (motivation → approach → change)
The denial is timestamped in the session controller (
deniedAt). Automatic activation is allowed only within 30 seconds of that denial (SID_RECOVERY_WINDOW_MS). An expired matching frame still clears the false not-found banner, but leaves the active session alone. The away-and-back latch and explicit navigation stay intact. Reconnect does not renew the timestamp. The owning dashboard spec records the bound.Backwards compatibility
Compatible: explicit switching and recovery inside the window still work. Automatic recovery after expiry is intentionally narrowed.
Reader: website/src/pages/chat/useChatPageSessionController.ts:deniedSidRef -- entry: chat -- expired frames clear the stale notice; explicit switchSlot is unaffected and fake-time tests cover both paths.
Tests
website/src/test/ChatPage.sid.test.tsx: fake-time tests cover recovery inside the window, notice-only clearing after expiry, reconnect without renewal, and explicit switching after expiry. The expired and reconnect regressions fail on main and pass on this head.Manual verification
N/A — fake-time component tests deterministically reproduce the delayed slots-frame behaviour.
Screenshots / video
Why no screenshot: This changes the timing of an existing navigation path without changing layout, components, styling or copy.
Related Issues
Fixes #16504
Replaces #12026
Provenance: Design review on #11870.
Pattern harvest
Rule candidate: review-prompt
Pattern: A retained recovery latch needs a bounded temporal predicate; test a matching frame after expiry and after reconnect.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.