Skip to content

Start thread bootstrap as soon as create succeeds - #7

Merged
Guitaraholic merged 2 commits into
mainfrom
fix/prefetch-bootstrap-on-create
Sep 2, 2026
Merged

Start thread bootstrap as soon as create succeeds#7
Guitaraholic merged 2 commits into
mainfrom
fix/prefetch-bootstrap-on-create

Conversation

@Guitaraholic

@Guitaraholic Guitaraholic commented Sep 2, 2026

Copy link
Copy Markdown

Human comments

What was wrong

Send waits for sdk.threads.spawn, seeds threadQueryKey, then navigates. GET /threads/:id?include=environment,host (and the timeline prefetch AppLayout opts into) started only after ThreadDetailView mounted. Even with cache paint (Datahazed/bb#6), environment, host, git-diff eligibility, and timeline still paid a round trip after the remount.

Related: get-bb/bb#1303. Complements #6 and Datahazed/bb#3 / get-bb/bb#2935.

What changed

  • Extracted loadThreadDetailBootstrap / prefetchThreadDetailBootstrap — the same queryFn the thread view uses.
  • useCreateThread onSuccess prefetches it, so navigate joins in-flight work instead of starting it after mount.
  • One call site covers compose, plugin composers, and the showcase hero.
  • Cold sidebar opens are unchanged (that is Datahazed/bb#8).

No router change. No HOST_DAEMON_PROTOCOL_VERSION bump.

Why this way

Create is the last moment we know the thread id before the remount. Starting bootstrap there is cheaper than keeping compose and thread both mounted, and it does not invent GET /threads/:id/open.

The prefetch must use the view’s queryFn. A slimmer prefetch that only does the include GET would cache-hit bootstrap and skip timeline/queue/approvals when #3 is present.

Benefit to bb

Web and desktop, every successful new-thread send that navigates. Environment/host chrome and timeline can be in flight or cached by the time the thread view commits, so first paint is less empty. Daemon protocol unchanged.

Harvest

Independent of #6 (they compose). Open on get-bb after or with #6. #8 stacks on this helper — do not submit #8 first.

Decision record: docs/perf-control-plane.md (PR #9).

How you verified

Phase-order test (apps/app/src/test/perf-phase.ts) records bootstrap-get during useCreateThread onSuccess and requires it to land before create-returned. Starting bootstrap only after ThreadDetailView mounts fails this test.

  • apps/app/src/hooks/mutations/thread-runtime-mutations.test.tsx asserts the include GET and bootstrap cache before any view mounts. Combined with thread-queries.test.tsx: 35 passed.

AGENT GENERATED

Guitaraholic added 2 commits September 2, 2026 20:19
Create already writes threadQueryKey, then navigates. Bootstrap
(GET /threads/:id?include=environment,host, and timeline when the
shell asked for it) waited until ThreadDetailView mounted. Prefetch
the same query in useCreateThread onSuccess so navigate joins work
already in flight.
Phase log records bootstrap-get during useCreateThread onSuccess and
requires it to land before mutateAsync returns.
@Guitaraholic
Guitaraholic force-pushed the fix/prefetch-bootstrap-on-create branch from ca973a2 to 725dd71 Compare September 2, 2026 19:19
@Guitaraholic
Guitaraholic merged commit cc41d2c into main Sep 2, 2026
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