Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): paginate large thread history for remote clients #4018

Closedsercada(GitHub profile, opens in a new tab)wants to merge 7 commits intomain fromrefs/pull/4018/headopened View on GitHub

Summary

Fixes #2761.

This rebases the server and web implementation from #3510 onto current main, where that PR is now conflicting after the repository history changes. Original implementation commits retain @olafura as their author. It deliberately leaves native mobile out of scope.

  • bound initial thread-detail activity reads to the newest 500 rows
  • expose cursor-based older-activity pages over RPC
  • let web users load older history while preserving scroll position and live updates
  • reset and deduplicate paged history when the live window reshapes
  • avoid sidebar thread-detail prewarming in browser/headless clients; Electron keeps its current warm-up behavior

Why

A live remote-web reproduction showed that the server and Tailscale path returned a 12.6 MB snapshot in about 0.2 seconds, so transport was not the bottleneck. The browser was eagerly hydrating eight visible thread details totaling roughly 38 MB. The largest thread contained 1,758 activities and serialized to 16.4 MB.

With this change, a browser initially hydrates only the selected thread and only its newest 500 activities. In the same dataset that window is about 6.7 MB, while older history remains reachable on demand.

Verification

  • pnpm exec vp run typecheck
  • pnpm exec vp check — 0 errors; 9 existing nested-component warnings
  • pnpm exec vp test apps/server/src/orchestration/Layers/ProjectionSnapshotQuery.test.ts — 11 passed
  • pnpm exec vp test packages/client-runtime/src/state/threadReducer.test.ts — 26 passed
  • pnpm exec vp test apps/web/src/components/chat/MessagesTimeline.test.tsx — 15 passed
  • full workspace build — web, server, marketing, and desktop completed

Related: #3817 addresses heartbeat tolerance, but does not reduce the large history payload or browser processing cost.


Note

Medium Risk Touches projection read paths, a new RPC surface, and chat timeline state (cursors, dedup, reshape resets); behavior is heavily tested but wrong pagination could hide or duplicate activity rows on long threads.

Overview Caps thread-detail activity loads to the 500 newest rows and sets hasMoreActivities when older rows exist, with a new orchestration.getThreadActivities RPC (sequenced beforeSequence or legacy beforeCreatedAt / beforeActivityId cursors) to page older history.

Web merges lazy-loaded pages into the live window in ChatView, resets on thread/window reshape, dedupes by id, and MessagesTimeline scroll-up auto-load (edge-triggered to avoid retry loops) plus a manual “Load older history” control. Browser sidebar no longer prewarms thread details; Electron still does. snapshot HTTP and CLI offline resolution switch from getSnapshot to getCommandReadModel so project-only consumers avoid loading full per-thread tables.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit de8fd65934768173819b93adcd6b92af3e8c7fc3. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Paginate large thread history for remote web clients

  • Caps thread-detail snapshots at the 500 most recent activities and sets hasMoreActivities on threads that have older history beyond this window.
  • Adds a new orchestration.getThreadActivities WebSocket RPC with cursor-based pagination, supporting both sequenced (beforeSequence) and legacy unsequenced (beforeCreatedAt/beforeActivityId) cursors.
  • ChatView now lazy-loads and prepends older activities on demand, merging them with the live window for display and the composer context meter.
  • MessagesTimeline renders a 'Load older history' header control or a loading indicator, and auto-triggers a single load when the viewport reaches the top, rearming only when the cursor advances or the user scrolls away.
  • Sidebar thread prewarming is disabled for browser clients and kept only for Electron, and the snapshot/offline-snapshot endpoints now return the lightweight command read model instead of the full projection snapshot.
  • Behavioral Change: remote clients no longer receive full thread activity history in the initial snapshot; older history must be fetched via the new paginated RPC.
Macroscope summarized de8fd65.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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

      Run ID: 0354f988-d9a3-4df0-ac72-7c2a2bf226c0

      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
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This PR introduces a new pagination feature for thread activities with significant runtime behavior changes (windowing to 500 activities, new RPC endpoint, complex client-side lazy-loading state management). The scope and complexity warrant human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot).

      Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c9783d1ac79cfa2f93b670c1aa3259b903ec46e7. Configure [here](https://www.cursor.com/dashboard/bugbot).
    5. olafura(GitHub profile, opens in a new tab)commented

      I'm mostly using this branch which contains all the fixes and a tui https://github.com/olafura/t3code/tree/olafura/simple-tui been pretty busy I have some updates hit another limit :grin: I'm pushing some updates that you can cherry pick if you want

    6. Closing in favor of #2829 (orchestration V2).

      #2829 deletes the V1 orchestration layer this PR builds on — apps/server/src/orchestration/**, provider/Layers/*Adapter.ts and provider/Services/** are removed and replaced by apps/server/src/orchestration-v2/**, with the IPC surface renamed to ORCHESTRATION_V2_WS_METHODS. The files this PR touches either no longer exist or are rewritten, so it can't be rebased — it would need reimplementing against the V2 adapters.

      This is not a judgement on the change itself. Several of these are real gaps we still want fixed; the base just moved out from under them.

      Once #2829 merges, please rebase onto main, port the change to the V2 equivalent, and reopen (or open a fresh PR). Ping me and I'll prioritise the review.

    7. juliusmarminge closed this

Sign in to join this conversation.