Skip to content

Paint git-diff and host chrome from cached environment - #11

Merged
Guitaraholic merged 1 commit into
mainfrom
fix/environment-chrome-from-cache
Sep 2, 2026
Merged

Paint git-diff and host chrome from cached environment#11
Guitaraholic merged 1 commit into
mainfrom
fix/environment-chrome-from-cache

Conversation

@Guitaraholic

Copy link
Copy Markdown

Human comments

What was wrong

#6 / #10 paint thread chrome from threadQueryKey while bootstrap is in flight. useEnvironment and useHosts still waited for GET /threads/:id?include=environment,host to settle.

Create already returns environmentId. Opening a second thread in the same workspace often already has that environment (and the hosts list) in React Query from the previous bootstrap ingest. The git-diff tab stayed loading and the host label stayed empty until this thread’s include GET returned.

Related: get-bb/bb#1303.

What changed

  • resolveEnvironmentQueryMount / resolveHostsQueryMount: enable from cache while bootstrap is pending; refetchOnMount: false so we do not add GET /environments/:id or GET /hosts next to the include fetch.
  • Cold open with an empty cache still waits for bootstrap. Ingest still writes environment and hosts; a later enable sees that cache.
  • Git-diff eligibility uses environment.isGitRepo from cache, so the tab can appear before bootstrap settles.

Stacked on #10. No protocol bump.

Why this way

Same rule as #6: do not refuse cache we already wrote. Starting useEnvironment whenever environmentId is set would duplicate the include GET. Cache-or-settled is the policy that avoids that.

We did not start git work-status or pull-request reads early (they still need a known environment and are the heavier follow-up). We did not merge compose+thread.

Benefit to bb

Web and desktop. Switching threads in the same project, or returning to a thread whose environment is still cached, shows git-diff eligibility and host label without waiting on this open’s include GET. New workspaces with an empty cache behave as today.

Harvest

Submit after #10 (this branch is stacked on the cache-paint stack). Independent of #7/#8. Copy this body.

Decision record: Datahazed/bb#9.

How you verified

  • resolveEnvironmentQueryMount: cached env + pending bootstrap → enabled, no refetch; empty cache waits; settled enables a cold fetch. Cached isGitRepo makes git-diff eligible.
  • resolveHostsQueryMount: cached host list + pending bootstrap → enabled, no refetch; empty cache waits.
  • environment-queries.test.tsx 10 passed, host-queries.test.ts 6 passed.

AGENT GENERATED

ThreadDetailView waited on bootstrap before useEnvironment and
useHosts, so a thread that already had environmentId (create cache
or a sibling thread in the same workspace) still hid the git-diff
tab and host label. Enable those queries from cache and skip the
duplicate GET until bootstrap settles; ingest still fills the cache.
@Guitaraholic
Guitaraholic changed the base branch from fix/layout-thread-title-from-cache to main September 2, 2026 19:15
@Guitaraholic
Guitaraholic merged commit 1fe7043 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