anomalyco / anomalyco/opencode

Bootstrap queries are refetched immediately: no staleTime, and Windows directories produce two cache entries

Open
#47,681 0 comments 0 reactions 1 assignee View on GitHub

@Brendonovich is already working on this.

Since Sep 6, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Two independent causes in packages/app/src/context/global-sync/bootstrap.ts make the app refetch
data the bootstrap has just loaded.

No staleTime. None of loadGlobalConfigQuery, loadProjectsQuery, loadProvidersQuery,
loadAgentsQuery, loadPathQuery or loadReferencesQuery sets a staleTime, so every entry
counts as stale the moment it is written. Several consumers request these during startup — the
global bootstrap, the per-project bootstrap, the child store, the composer controls — and each one
that mounts after the write issues its own request for what is already in the cache.

Unnormalised directory in the query key. The directory-scoped keys are built from the raw
directory the bootstrap was handed:

queryKey: [scope, directory, "agents"]

Consumers reach the same queries through the PathKey facade in
packages/app/src/context/server-sync.tsx, which normalises backslashes to slashes:

agents: (directory: PathKey) => loadAgentsQuery(scope, directory, ...)

bootstrapInstance computes directoryKey(directory) for its own bookkeeping but passes the raw
directory into bootstrapDirectory. On Windows, C:\repo\app and C:/repo/app are therefore two
separate cache entries for one directory, and the consumer side never hits what the bootstrap
loaded.

Plugins

None

OpenCode version

dev (ea2d59d7ca)

Steps to reproduce
  1. On Windows, open a project whose path the app hands through with backslashes.
  2. Watch the requests the app makes during startup.
  3. The directory-scoped bootstrap queries are issued twice — once by the bootstrap under the raw
    path, once by the consumers under the normalised one — and the un-stale-timed queries are
    issued again by each consumer that mounts.
Screenshot and/or share link

N/A

Operating System

Windows 11 (26200)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.