Skip to content

refactor(clients): share thread list v2 sort in client-runtime - #5144

Open
t3dotgg wants to merge 1 commit into
t3code/prioritize-woke-input-threadsfrom
t3code/shared-thread-list-sort
Open

refactor(clients): share thread list v2 sort in client-runtime#5144
t3dotgg wants to merge 1 commit into
t3code/prioritize-woke-input-threadsfrom
t3code/shared-thread-list-sort

Conversation

@t3dotgg

@t3dotgg t3dotgg commented Jul 31, 2026

Copy link
Copy Markdown
Member

Stacked on #4745.

Web and mobile each carried their own copy of the thread list v2 ordering rules: the active-list priority callback was duplicated at both call sites, and the settled tails used different comparators — mobile sorted by latestUserMessageAt ?? updatedAt and ignored settledAt entirely, so an explicitly settled thread could land in a different position on each client.

This moves the ordering rules into @t3tools/client-runtime/state/thread-sort, next to the already-shared sortThreadsForListV2:

  • threadListV2Priority — the woke / un-settled / default ranking, derived only from server-backed state (wokeAt, settledOverride), so every client and device computes the same order by construction.
  • resolveSettledTimestamp + sortSettledThreadsForListV2 — moved from web's Sidebar.logic.ts; settled rows order by when the work ended (settledAt, else last activity). Mobile's settled tail now uses it too, and its slim-row time label reads from the same resolver so label and order can't disagree.

Both clients delete their local copies; web's settled-sort tests moved to the shared package with the code.

Verification:

  • vp test run packages/client-runtime apps/mobile apps/web/src/components (1764 tests)
  • vp run --filter @t3tools/{client-runtime,web,mobile} typecheck
  • targeted lint and format checks

Made with Claude Fable 5 using Claude Code.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com


Open in Devin Review

Note

Low Risk
Refactor of list ordering and display timestamps with parity tests; no auth or persistence changes. Mobile settled order may shift for threads where explicit settle time differed from last activity.

Overview
Unifies thread list v2 ordering in @t3tools/client-runtime/state/thread-sort so web and mobile no longer maintain separate comparators.

Adds threadListV2Priority (woke → keep-active → default, from server-backed wokeAt and settledOverride), resolveSettledTimestamp, and sortSettledThreadsForListV2 (most recently “finished” first). Web and mobile partition/sort through these helpers instead of inline callbacks and web-only Sidebar.logic settled sort.

Mobile behavior change: the settled tail previously ordered by latestUserMessageAt / updatedAt and ignored settledAt; it now matches web. Slim settled rows show resolveSettledTimestamp so the time label matches sort order.

Removes duplicated settled-sort code and tests from Sidebar.logic; coverage lives in threadSort.test.ts.

Reviewed by Cursor Bugbot for commit 816ff2d. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Share thread list v2 sort logic in client-runtime across web and mobile

  • Moves resolveSettledTimestamp, sortSettledThreadsForListV2, and threadListV2Priority into packages/client-runtime/src/state/threadSort.ts, removing duplicated implementations from apps/web/src/components/Sidebar.logic.ts.
  • Settled threads are now sorted by resolved settled timestamp (explicit settledAt, else last activity including turn completion timestamps), with stable id tiebreaking, in both the web sidebar and mobile thread list.
  • Active thread prioritization uses the shared threadListV2Priority function, with wake threads ranked above manual keep-active pins; wake tracking changes from a Set to a Map of key->wokeAt in both consumers.
  • The timestamp label on each mobile thread row now uses resolveSettledTimestamp to match the sort key.
  • Behavioral Change: settled thread ordering now considers turn completion timestamps (latestTurn.requestedAt/startedAt/completedAt), which may reorder threads that previously sorted by latestUserMessageAt or updatedAt.

Macroscope summarized 816ff2d.

Web and mobile each carried their own copy of the v2 active-list priority
derivation and settled-tail ordering, and mobile's settled tail ignored
settledAt entirely, so the two clients could disagree on order.

The priority rule (threadListV2Priority) and the settled sort
(sortSettledThreadsForListV2 + resolveSettledTimestamp) now live in
@t3tools/client-runtime/state/thread-sort next to sortThreadsForListV2.
Priority derives only from server-backed state (wokeAt, settledOverride),
so every client and device renders the same order by construction. Mobile's
settled rows also adopt the shared timestamp resolver for their time label
so label and order can't disagree.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d2f6438a-58df-4823-9c2a-4c5916ff39c8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Jul 31, 2026
@macroscopeapp

macroscopeapp Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 816ff2d

This PR consolidates duplicate thread sorting logic from web and mobile apps into the shared client-runtime package. The sorting behavior is preserved, with one intentional improvement: mobile's settled thread timestamps now align with their sort order. Tests are comprehensive and moved to the shared package.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant