Repository navigation
fix(dashboard): order session recency by instant, not timestamp text - #10950
Conversation
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Before merging, check that opening an artifact's companion chat resumes the newer of two sessions stamped with different timezone offsets. No screenshot shows that path. [UX-REVIEWED] d89a469 Description read[DESCRIPTION-READ] 0fcb8e85c3e83577a5e0f0810898337b138101bf7c1a33ac1c47465f82f25ff8 That sha256 names everything this verdict read: the PR description, plus the 5 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 |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the rendered picker list stays stable across rerenders: the comparator now parses each timestamp, regexes it, and returns fractional values on every comparison. [DESIGN-REVIEWED] d89a469 Description read[DESCRIPTION-READ] 9c384f51ff6ab020166d4d22e38ae4aef29fa373f56f000971f7f8b8a6af9901 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 |
First Principles Review (Opus 5.5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS This adds a second Not justified as shipped
What this change shipsInventory (6 items) — 4 justifiedIntent: open the session that was truly active most recently, whatever the timestamp format or offset — a FIX.
[FIRST-PRINCIPLES-REVIEWED] d89a469 Description read[DESCRIPTION-READ] 8ec7e531d5b3cd64a8c2d6e6598cc1e0d0e7525cd23ff057b62de3350800703a That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: Every AI review lane is PASS with no blocking findings (GPT 5.6, Opus 4.8, Design Review, First Principles Review, UX Review), the branch is
I'll also post dispositions for the advisory Watch items Design Review and First Principles Review left (the If you'd prefer I don't touch this PR, add the |
8850fb3 to
17a7c33
Compare
`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.
Resolving to an instant is not by itself enough, because `Date` keeps
three fractional digits and TRUNCATES the rest. `monotonic_transcript_ts`
stamps a row as `previous + 1 microsecond` whenever the host clock has
not advanced between two writes -- on Windows, whose system clock
advances in ~15.6 ms steps, that is the ordinary case -- so a session
that wrote twice inside one tick is one MICROSECOND ahead of a session
that wrote once in it. A plain `getTime()` reads both as the same
instant, the comparator returns 0, and `Array.prototype.sort` being
stable then answers "most recently active" with whatever order the slots
happened to arrive in. `slotActivityMs` therefore adds back the fraction
of a millisecond the parse dropped; truncation is what makes that safe,
since the remainder is always the part `Date` discarded rather than a
value it rounded past.
`recencyEpoch` in the command palette's recents provider already
resolved this field to an instant by hand; 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>
|
Deterministic picker evidence: production PlaceholderPane, identical fixtures and source selected directly from main or the feature head. The visible order reverses to choose the later instant. Captured with scripted Playwright on 2026-10-03; no page errors. Source head in the record is the feature head before this evidence-only amend. [
{
"mode": "before",
"source": "origin/main",
"order": [
"Earlier: 01:00 UTC",
"Later: 02:30 UTC"
],
"errors": []
},
{
"mode": "after",
"source": "17a7c33f842d7b74f76df74a202442674abfb451",
"order": [
"Later: 02:30 UTC",
"Earlier: 01:00 UTC"
],
"errors": []
}
] |
17a7c33 to
d89a469
Compare
|
|
|
Review dispositions for current head
The two First Principles CONCERNS already have individual current-head dispositions above; these comments do not reopen or widen that repair. |
iamwhatever
left a comment
There was a problem hiding this comment.
Reviewed: session recency in SessionGridView and the artifact companion chat now sorts by parsed instant (new slotRecency util) instead of comparing timestamp text, which mis-ordered mixed offsets and precisions. The util is unit-tested for offsets, fractional seconds and unparsable values, and both call sites have render tests. Spec note added. CI green.
Problem / Motivation
Goal: Order the split-session picker and artifact companion choice by actual last-activity instants across timestamp formats and offsets.
Two dashboard surfaces decide "most recently active" by comparing
last_activity_tsas text:last_activity_tsis the raw transcriptts, forwarded verbatim —slot_projection.py:166readsmessage.get("ts")and passes the string straight through. The backend states those rows do not share one format: current builds stamp offset-aware values viahistory.monotonic_transcript_ts, while transcripts written by older builds still hold naivedatetime.now().isoformat()rows.history.transcript_sort_key:972exists on the Python side for exactly this, and its docstring names the failure — compared as strings they order by their text.Two aware stamps written under different offsets are enough to break it:
09:00:00+08:00is 01:00Z and02:30:00+00:00is 02:30Z, so the more recent session carries the smaller string.What a user sees:
SessionGridView) lists the staler session above the live one.ArtifactDetailPage.pickBoundSlot) returns the stale session as "the most recently active", so opening an artifact's chat resumes the wrong conversation. "New chat" depends on that same tie-break, so when it picks the archived slot the button looks inert.Why it matters
Both surfaces exist to answer one question — which session should I open? — and answer it with the wrong one. The picker case is a mis-sorted list the user can work around by reading titles. The companion-chat case is silent: the page resumes an older conversation and nothing says it picked the wrong one, so context gets appended to an archived session.
The two formats coexist on purpose (old transcripts are not rewritten), so this is not a migration that ages out. A single host crossing a DST boundary is enough to produce the mixed-offset pair.
Not a goal
What changed (motivation → approach → change)
Both current consumers still compare last_activity_ts text. Replay the original PR's instant comparator in their current owners, using toDate and restoring the fractional millisecond remainder that JavaScript Date truncates. The original two commits are consolidated into one logical fix; the session spec records both the precision and naive-timestamp limitation. The existing command-palette recency selector has broader fallback semantics and millisecond precision, so it cannot replace this comparator without changing these consumers' contract.
Backwards compatibility
Compatible: the same session fields, picker priorities and artifact binding rules remain. Only erroneous mixed-offset/format ordering and sub-millisecond ties change. Naive timestamps remain an approximation in the viewer's zone.
Removes nothing: no session, field, public API, supported path or capability is removed.
Tests
90 tests passed across slotRecency.test.ts, SessionGridViewCoverage.test.tsx and ArtifactDetailPage.companionChat.test.tsx. They exercise mixed offsets, timestamp precision, invalid/missing values, picker priorities and artifact companion resolution. Focused ESLint passed. npm run build passed (TypeScript and Vite); docs lint and the added-line brand gate passed.
Manual verification
Captured the production picker in Chromium using two offset-aware timestamps whose text and instant order disagree. The visible list changes from Earlier / Later to Later / Earlier. No runtime page errors occurred. Component tests cover the artifact resolver with the same kind of pair.
Screenshots / video
Scripted Playwright renders the production PlaceholderPane with the same deterministic fixtures on both heads. Both sessions are idle, unbound and have equal priority. Text sorting puts 09:00+08:00 first, although 02:30+00:00 is the later instant. This branch lists the later session first. The heading and timestamp explanation are capture context; the picker itself is the production component loaded directly from current main or this branch.
Related Issues
Closes #16516
Pattern harvest
Rule candidate: review-prompt
Pattern: compare timestamp instants rather than timestamp text, and preserve the producer's precision when Date truncation could turn distinct records into ties.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement