Skip to content

fix(client): refresh only loaded catalogs on location events - #47443

Open
Hona wants to merge 1 commit into
v2from
catalog-echo
Open

fix(client): refresh only loaded catalogs on location events#47443
Hona wants to merge 1 commit into
v2from
catalog-echo

Conversation

@Hona

@Hona Hona commented Sep 5, 2026

Copy link
Copy Markdown
Member

createData re-fetches a location's catalog on every catalog / agent / command / skill / reference / integration / websearch / mcp.* event for any Location the server emits about — including Locations this client never opened. On a shared server that is every Location another client booted. A Desktop capture showed 1,679 request jobs in 99 s across 118 directories from this path alone; the TUI does the same work silently because Bun has no per-origin socket limit.

Change

flowchart LR
  E[location event] --> I[invalidate catalog]
  I --> G{loaded? read before or reading now}
  G -->|yes| R[re-fetch]
  G -->|no| N[nothing: next explicit sync fetches fresh]
Loading
  • locationResource gains loaded(ref): store.location[key][field] !== undefined || sync.has(key). This is the test config.updated was already doing inline (data.ts:1219-1222 on v2), now named and applied to every per-location refresh, including the credential.* loop over stored location keys.
const resync = (...resources) =>
  resources.forEach((resource) => {
    resource.invalidate(location)
    if (resource.loaded(location)) refresh(() => resource.sync(location))
  })
  • Websearch providers have no explicit reader anywhere; the TUI's integration dialog (dialog-integration.tsx:102) relies on events to fill them. That refresh is gated on the location having been opened (info present after syncInfo) instead of on a prior read, so first population still happens.

TUI

No behaviour change for what the TUI displays:

Path Why unchanged
Own directory (context/location.tsxlocation.sync) reads all 12 catalogs on open, so every one is loaded()
Session tabs in other dirs syncInfo + vcs.sync only; vcs.branch.updated is a store write, never a fetch
Skill / integration dialogs explicit sync() on open
Web-search providers populated on first event for opened locations (covered by a new test)
mini/catalog.shared.ts raw SDK, not the store

What it stops doing: re-fetching agents/models/MCP for Locations other clients booted on the same server. It never displayed that data.

Companion to #47441 (app-side).

Every Location booted on the server emits catalog, agent, command, skill,
reference, integration, websearch and MCP events, including Locations this
client never opened. Each event eagerly re-fetched that location's catalog,
producing request waves across hundreds of directories.

Events still invalidate so the next explicit read is fresh, but only catalogs
a consumer already read are re-fetched, mirroring the existing config.updated
guard. credential.* events apply the same rule per stored location key.

Websearch providers have no explicit reader; the TUI's integration dialog
relies on events to fill them, so that refresh is gated on the location having
been opened (syncInfo) instead of on a prior read.
Copilot AI lite review requested due to automatic review settings September 5, 2026 05:03

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants