Skip to content

fix(app): 78x faster Home cold loading#36214

Merged
Hona merged 6 commits into
anomalyco:devfrom
Hona:desktop-session-bench
Jul 14, 2026
Merged

fix(app): 78x faster Home cold loading#36214
Hona merged 6 commits into
anomalyco:devfrom
Hona:desktop-session-bench

Conversation

@Hona

@Hona Hona commented Jul 10, 2026

Copy link
Copy Markdown
Member

TLDR;

  • Load Home sessions from the instance-free V2 API instead of one V1 request and full instance bootstrap per directory.
  • Keep passive project metadata stores dormant until a user opens a session/location.
  • Treat the V2 session index as authoritative and paginate complete 5,000-row pages.
  • Preserve the existing Home DOM, styling, and interactions.

Changelog

Improved

  • Home session history appears without initializing every open project and worktree.
  • LSP, provider, path, and reference services now start only when a location is actually opened.
  • Restored/open tabs continue to initialize their own locations.

Implementation

  • Reads the typed upstream/dev V2 global session API, following cursors until the session index is complete.
  • Stores the index and live event overlay in TanStack Query, reconciles events received during fetches, and refetches after SSE reconnect/disposal/session moves.
  • Filters child and archived sessions, converts the narrow V2 summary for Home only, and preserves per-directory retention/search behavior.
  • Passes query cancellation through every V2 page.
  • Includes explicit TODO(v2) markers for replacing the temporary adapter with released client.v2.project.list plus root-only, updated-time client.v2.session.list.

Benchmark

Real Beta desktop data: 123 projects, 4,096 session rows, three restored tabs.

  • Before: 23,790.59 ms cold Home timeline
  • After: 312.75 ms cold Home timeline
  • Improvement: approximately 76x / 98.7%
  • Home directory initializations: 12 -> 0
  • The two initialized locations after the change belong only to restored tabs.

Validation

  • 61 focused Home/session/lifecycle tests pass.
  • The previously failing session-list-path-loading E2E regression passes locally.
  • App and E2E typechecks pass.
  • Repository-wide push-hook typecheck passes across 30 packages.
  • Production app build passes.
  • Full app unit run before this follow-up: 574 pass; one unrelated existing Arabic i18n parity failure for session.header.reveal keys.

@Hona
Hona requested a review from Brendonovich as a code owner July 10, 2026 04:48
Copilot AI review requested due to automatic review settings July 10, 2026 04:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Home page cold-load path by switching session history loading to a single V2 “global” snapshot (with SSE replay) and by keeping per-directory child stores’ heavier queries dormant until a directory is actually opened, while preserving the existing V1 per-directory loader as a fallback.

Changes:

  • Load Home sessions via one guarded V2 session.list snapshot and replay session.* SSE events over it, with a V1 directory-loader fallback on error.
  • Avoid bootstrapping per-directory queries (path/providers/LSP/references) for passive directory reads until a real directory access.
  • Update related sync plumbing and add focused tests for snapshot parsing/retention and child-store passivity.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/app/src/pages/home.tsx Switch Home to V2 snapshot query + SSE replay and keep V1 directory loader as fallback.
packages/app/src/pages/home-session-snapshot.ts Add snapshot parsing/retention + SSE event application helpers for Home’s V2 adapter.
packages/app/src/pages/home-session-snapshot.test.ts Add tests for snapshot loading, validation/guarding, retention, and event replay.
packages/app/src/context/server-sync.tsx Gate directory refresh and LSP/reference prefetch behind “queries enabled” checks.
packages/app/src/context/global-sync/child-store.ts Add query enable toggles so passive child creation doesn’t start heavy queries until bootstrapped.
packages/app/src/context/global-sync/child-store.test.ts Add regression test ensuring non-bootstrapping children remain passive until real access.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/app/src/pages/home.tsx Outdated
Comment on lines +366 to +371
setSessionEvents(
produce((draft) => {
const list = (draft[key] ??= [])
list.push(event)
}),
)
Comment on lines +42 to +45
export function retainHomeSessions(sessions: Session[], limit: number, now: number) {
const grouped = Map.groupBy(sessions, (session) => pathKey(session.directory))
return [...grouped.values()].flatMap((items) => trimSessions(items, { limit, permission: {}, now }))
}
@Hona Hona changed the title fix(app): improve Home cold loading fix(app): 78x faster Home cold loading Jul 10, 2026
@Hona Hona added the beta label Jul 10, 2026
@Hona
Hona merged commit 449c649 into anomalyco:dev Jul 14, 2026
9 checks passed
jerome-benoit pushed a commit to jerome-benoit/opencode that referenced this pull request Jul 14, 2026
avion23 pushed a commit to avion23/opencode that referenced this pull request Jul 17, 2026
avion23 pushed a commit to avion23/opencode that referenced this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants