Repository navigation
Conversation
`last_activity_ts` is forwarded verbatim from the transcript row that
produced it -- slot_projection reads `message.get("ts")` and passes the
string straight through -- and the backend states those rows do not
share one format: current builds stamp offset-aware values via
`monotonic_transcript_ts`, while transcripts from older builds still
hold naive `datetime.now().isoformat()` rows. `transcript_sort_key`
exists on the Python side for exactly this, and its docstring names the
failure: compared as STRINGS they order by their text.
Two frontend sites compared that text and so could rank a later session
first. Two aware stamps written under different offsets are enough:
`09:00:00+08:00` is 01:00Z and `02:30:00+00:00` is 02:30Z, so the more
recent session carries the smaller string.
- SessionGridView's picker listed the staler session above the live one.
- ArtifactDetailPage's `pickBoundSlot` returned the stale session as
"the most recently active", so opening an artifact's companion chat
resumed the wrong conversation -- and "New chat" depends on that same
tie-break, where picking the archived slot makes the button look inert.
Both now resolve the stamp to an instant first, which is also how the
backend reads it: an offset-bearing value is absolute, a naive one is
local, i.e. the zone of the writer that produced it. `recencyEpoch` in
the command palette's recents provider already did this by hand for the
same field; it is left as it is, since folding it in would also change
how it treats a numeric stamp, which nothing here shows is needed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
UX Review (Fable 5, fork) — ✅ PASSUX-level review of I've now reviewed everything available. The diff changes no user-visible control, label, string, or layout — it only corrects the sort order of the existing session-picker rows and which existing session the artifact companion chat resumes, plus tests and the committed sha-pinned before/after screenshots (binary-only in the patch, so not viewable here, but they show only pre-existing rows in corrected order). No new vocabulary, no new states, no lens-13 element transformation — so the no-new-control carve-out applies and no evidence gap exists. UX-Verdict: PASS Pure ordering correction: no control, string, or state added — the picker and companion chat now simply honor their own "most recently active" promise. [UX-REVIEWED] 7ed812e |
Design Review (Fable 5, fork) — ✅ PASSDesign-level review of All premises verified against the base tree: Design-Verdict: PASS Root-cause fix at the right seam: instants replace text comparison, reusing the existing [DESIGN-REVIEWED] 7ed812e |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- website/src/utils/slotRecency.ts:29 -- |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed Review detailsThe core change is correct and I can rule out defects in it:
The sole candidate (committed No findings. [OPUS-REVIEWED] 7ed812e |
First Principles Review (Fable 5, fork) — 🔴 BLOCKPremise-level review of All claims verified against base: both First-Principles-Verdict: BLOCK Four PNGs force-added under gitignored Not justified as shipped
What this change shipsInventory (5 items) — 4 justifiedIntent: opening an artifact's chat or the pane picker should resume/list the genuinely most-recent session, not the one whose timestamp text sorts highest — a FIX.
BlockersCommitted screenshots contradict a recorded repo decision. Subtractions
[FIRST-PRINCIPLES-REVIEWED] 7ed812e |
Before/after captures of the picker's row order, dark and light. The
markup in both is the real rendered list, serialized out of the
production component tree by SessionGridViewCoverage.test.tsx -- the
before side with SessionGridView.tsx reverted to origin/main -- so the
order shown is the component's, not the harness's.
`gh pr edit --attach` is unavailable to a fork contributor ("attaching
files requires write access to the repository", confirmed on gh
2.100.0), so these go under temp-screenshots/ and are linked from the PR
body by raw URL, which is the path the Screenshot Evidence check accepts
by name.
No production code changes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Closing in favour of #10950, which carries the same fix from current Why replaced rather than amended. The current-head First Principles review One correction to this PR's second commit message, which claimed GPT 5.6's non-blocking finding is real and is fixed in #10950. Rather than CI attribution, for the record — none of this PR's red is branch-caused:
This PR touches only TypeScript under |
Problem / Motivation
Opening an artifact's companion chat can resume the wrong session, and the
session picker can list a staler session above a newer one.
Both surfaces decide "most recently active" by comparing
last_activity_tsasTEXT:
That value is not a normalized timestamp.
slot_projection.pyreadsmessage.get("ts")off the transcript row and passes the string throughuntouched, and the backend states plainly that those rows do not share one
format —
history.py,transcript_sort_key:transcript_sort_keyexists on the Python side precisely to avoid this. Thefrontend never got the equivalent.
Two aware stamps written under different offsets are enough on their own — no
legacy row required, and no host-timezone dependency:
2026-09-14T09:00:00+08:002026-09-14T02:30:00+00:00so descending-by-text puts the older session first. That pairing arises
whenever two hosts write one transcript (a gateway in UTC, a desktop that is
not) or one host crosses a DST boundary.
Why it matters
pickBoundSlotis the one that actually costs the user something. Its owndocstring is the contract it was breaking:
Picking wrong drops the user into a stale conversation about the artifact they
just opened. The same tie-break is load-bearing for "New chat", where the file
already records the consequence of it resolving to the wrong slot:
SessionGridView's picker is the milder half — a list ordered wrongly — but it isthe list a user picks a pane's session from, so recency is the whole point of it.
Neither failure announces itself: there is no error, the order simply is not the
order it claims to be.
What changed (motivation → approach → change)
Symptom → the "most recently active" session is sometimes not the most
recently active one.
Root cause → a raw, multi-format transcript timestamp compared as text.
Change → resolve the stamp to an instant before comparing, which is also how
the backend reads it: an offset-bearing value is absolute, and a naive one is
local — the zone of the writer that produced it.
New
website/src/utils/slotRecency.tsexportsslotActivityMsand abyRecentActivitycomparator, built on the existingtoDatecoercion insrc/i18n/format.ts(already the repo's single seam for "the several timestampshapes this codebase carries"). Both call sites now sort through it. Absent and
unparseable stamps still sort last, matching the
|| ''fallback they replaced.A shared helper rather than the same lambda twice, because the rule that makes it
correct — which formats can appear and why a naive one is local — is a paragraph
of provenance that belongs in one place, not duplicated in two components.
Two related sites deliberately left alone, both for stated reasons rather than
convenience:
recencyEpochincommandPalette/providers/recentsProvider.ts:159reads thesame field and is already correct — it does
new Date(t).getTime(). It isnot rewritten here: folding it into the shared helper would also change how it
treats a numeric stamp (it multiplies any number by 1000;
toDatedoes thatonly below its seconds ceiling), and nothing in this defect shows that change is
needed. Changing a correct function's behaviour inside a fix is not a tidy-up.
ArtifactDetailPage.tsx:1255,artifact.updated_at > boundSlotResolved.last_activity_ts,is also a text comparison — but it is a declared best-effort one, and the
comment above it bounds the harm: "ISO timestamps compare lexicographically; a
miss just means the agent re-reads via
artifact_get." A wrong answer therecosts one redundant read, not a wrong session. It is a considered trade-off with
a benign failure mode, so overturning it is a separate judgment call and not
mine to make silently.
Tests
src/utils/slotRecency.test.ts(new, 5 cases) pins the comparator, includinga
the fixtures really do disagreeguard-the-guard case: it asserts that the twofixtures order one way as text and the other way as instants. Without that, a
later edit could quietly swap in a fixture pair that agrees, and every remaining
case would keep passing while proving nothing.
Two behavioural tests, each placed immediately after an existing test that
covers the same behaviour and cannot catch this defect — both of those use
same-shaped stamps, so text order and instant order agree and either
implementation passes them:
SessionGridViewCoverage.test.tsx— "ranks recency by INSTANT, not by timestamptext": the picker must list the later session first.
ArtifactDetailPage.companionChat.test.tsx— "picks the most recent by INSTANT,not by timestamp text": the resolver must activate the live slot, and must
resume rather than create (a wrong pick that also created would hide itself).
Every fixture uses two offset-bearing stamps, so both resolve to the same
instants on any runner. The naive-vs-aware case — the backend's own example — is
host-timezone dependent by construction, so it is asserted only as a parse rule
(
slotActivityMson a naive stamp equals local midnight-based arithmetic) andnever as an ordering, per the repo's rule that an unpinned date assertion flakes
in CI.
Run:
mainand thenew tests in place, both behavioural tests fail with the defect itself:
AssertionError: expected 'chat-stale' to be 'chat-live'AssertionError: expected 'Stale one0 msgs' to contain 'Live one'6 passed (6)/249 passed (249).npx tsc --noEmit,npx eslinton all six files: clean.src/i18n/localeFormatting.test.ts:7 passed. This removes two entries fromthat gate's bare-
localeComparetail; the ceiling is upward-only, so a decreaseneeds no ledger edit and conflicts with no parallel i18n branch.
Manual verification
N/A — unit coverage sufficient: the defect is a pure ordering decision over two
input strings, and both consumer tests drive the real component and assert the
resolved slot, not a re-derived comparison.
Screenshots / video
The session picker, with the two stamps from the table at the top:
Stale oneat09:00:00+08:00(01:00Z) andLive oneat02:30:00+00:00(02:30Z).Live oneis the more recent session and carries the smaller string.
Before — the staler session is listed first:
After — most recent first:
Light theme
No panel, component, layout or theme is touched: the rows are byte-identical and
only their order changes. The same one-line comparator also decides which session
an artifact's companion panel opens with —
chat-livewhere it previously openedchat-stale— which has no separate visual of its own beyond the session thatappears.
How these were produced. The markup in both images is the REAL rendered picker
list, serialized straight out of the production component tree by
SessionGridViewCoverage.test.tsx— the before side withSessionGridView.tsxreverted toorigin/main— and re-mounted against the realstylesheet for the capture. Nothing in the harness decides the order; the
component already did. Mounting
SessionGridViewin a browser page is notpossible here, because its test harness stubs
api/clientandhooks/useWebSocketthroughvi.mock, which has no browser equivalent, and ahalf-stubbed grid renders its error boundary instead.
The row text read back off each rendered page, in the same run:
gh pr edit --attachis the documented route and is not available to a forkcontributor — it fails with
attaching files requires write access to the repository, which I confirmed on gh 2.100.0, so the version floor was not theobstacle. The files are therefore committed under
temp-screenshots/and linkedby raw URL pinned to commit
7ed812e, the path the Screenshot Evidence checkaccepts by name and the one #10488 and #10574 used. They are the second commit on
this branch and can be dropped without touching the fix.
Related Issues
No existing issue — found by auditing frontend consumers of backend-emitted
timestamps. Searched open and closed issues and open PRs for
last_activity_tsordering first; nothing matched.
Contention on the two exact paths was checked against all 300 open PRs
(
SessionGridView.tsx: 1 — #9921, a test-fixture line only;ArtifactDetailPage.tsx:2 — #8468 and #8360, neither touching these hunks). I ran that scan once with a
known-positive control path, because my first attempt returned an empty result for
every path including one I knew had twelve open PRs — a silently broken query
reads exactly like "no contention".
Pattern harvest
Rule candidate:
semgrepPattern: a timestamp that arrives from the backend as an opaque string being
ordered with
localeCompareor a relational operator instead of being resolved toan instant.
Two things generalize past this one fix:
The producer already knew.
transcript_sort_keywas written because stringcomparison gets this wrong, and its docstring spells the failure out. The defect is
not that nobody knew — it is that the knowledge stopped at the language boundary.
Wherever one side of a wire contract builds a careful comparator, the other side
consuming the same field raw is worth checking; that is what turned this up, and
it is cheaper than a generic scan.
The existing tests pinned the behaviour with fixtures that could not fail. Both
surfaces already had a "picks the most recent" test, and both used same-shaped
stamps — full behavioural coverage of the exact rule, and blind to the bug. The
transferable habit is to pick the fixture the implementation choice decides, not
one that merely exercises the path; the
the fixtures really do disagreecase inthe new unit test is that habit written down so it cannot rot.
Checklist
feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code