Files
t3code/packages/client-runtime
Theo BrowneandClaude Fable 5 bc23ec5073 perf: fix sustained-CPU hot paths from the July 2026 web performance audit
Addresses the audit's findings with minimal, desktop-first changes (no
payload deferral, no streaming-path work since streaming is off by default):

- Sidebar: replace the 10-thread bulk detail prewarm with a single
  hover-based prewarm; at idle one shell stream + at most one detail stream
- Server replay: thread catch-up reads only the thread's aggregate stream
  via the (aggregate_kind, stream_id, sequence) index instead of scanning
  the global log; shell catch-up is bounded (500 events) with a shell
  snapshot fallback for stale cursors
- Shell summaries: thread.message-sent updates latestUserMessageAt
  incrementally; activity-appended triggers the history-wide summary
  rebuild only for approval/user-input activity kinds; streaming assistant
  chunks no longer fan out per-chunk shell upserts
- Client runtime: O(1) activity appends when order is preserved; skip
  IndexedDB full-snapshot encodes while a turn is running (settle event and
  scope finalizer persist the final state)
- Timeline derivation: share one ordered activities view across the four
  derivations (identity-cached, O(n) sorted check); k-way merge for the
  combined timeline instead of concat+sort
- Composer drafts: debounce JSON serialization itself, and cache per-draft
  partialization by object identity so typing doesn't re-clone every
  retained draft
- Shiki: negative-cache languages without grammars (sh, yaml) so those
  fences stop retrying and throwing on every render
- Bootstrap polling: one shared change-detecting poller instead of one
  2s interval per consumer; minimap only writes data-in-view on change

Co-Authored-By: Claude Fable 5 <[email protected]>
2026-07-09 04:09:08 -07:00
..

Client Runtime

Shared client behavior for web and mobile. Public APIs are organized by package subpath. The package intentionally has no root export.

Public subpaths

Subpath Responsibility
authorization Bearer and DPoP authorization plus token persistence contracts
connection Targets, catalog, supervision, retries, registry, and onboarding
environment Environment identity, descriptors, endpoints, and scoped keys
errors Shared client error inspection
operations Multi-step application workflows
operations/projects Multi-step project creation workflows
platform Platform capability and persistence service contracts
relay Managed relay API and environment discovery
rpc HTTP/RPC clients, protocol, sessions, and subscriptions
state/<domain> Focused shared state, retention, reducers, and Atom constructors

Dependency direction

Platform applications provide platform services. connection composes those capabilities with authorization, relay, and rpc to supervise environment sessions. Independent state modules consume the connection registry and expose focused state or Atom constructors to application-owned runtimes.

Applications should import the narrowest relevant subpath. There is no broad state export: use domain paths such as state/shell, state/threads, state/terminal, or state/vcs. Subpath indices and explicitly exported domain files are public API boundaries; all other files remain implementation details.