Repository navigation
Reload flashes: quiet plugin routes, remembered plugin chrome, last-known composer options - #1678
Conversation
|
🚨 SLOP COP 🚨 · I am the Slop Cop. I started the security, code quality, performance, architecture, and product checks. |
| readCachedModelCatalog(cacheKey) ?? | ||
| (providerCacheKey === null | ||
| ? null | ||
| : readCachedModelCatalog(providerCacheKey)); |
There was a problem hiding this comment.
🚨 slopcop/review — Do not reuse models across hosts or workspaces
This fallback ignores both environmentId and hostId. The model endpoint uses the environment path as cwd, and hosts can have different account access.
After host A warms this cache, host B gets A's models before its own probe resolves. Placeholder data makes isLoading false, so new-thread submission can use an invalid model.
Please replay only exact routing keys. When the route is unknown, wait for it or cache a pointer without copying its catalog.
| }, [resolved]); | ||
| useEffect(() => { | ||
| const timeout = window.setTimeout( | ||
| markPluginFrontendsSettled, |
There was a problem hiding this comment.
🚨 slopcop/review — Do not finish a plugin boot while it remains active
This timer marks frontends settled even when the boot has started and remains active. Content scripts can take ten seconds each and mount in sequence.
At 15 seconds, slow valid panels show as unavailable. The settled effect also writes a partial or empty list over remembered chrome.
Track the not-started, booting, and complete states separately. Use the timeout only for the no-start display, and persist chrome after boot completes.
| queryFn: ({ signal }) => fetchSidebarNavigation(signal), | ||
| queryFn: async ({ signal }) => { | ||
| const response = await fetchSidebarNavigation(signal); | ||
| writeCachedSidebarBootstrap(SIDEBAR_BOOTSTRAP_CACHE_KEY, response); |
There was a problem hiding this comment.
🚨 slopcop/review — Keep the synchronous sidebar cache bounded
This response contains every unarchived thread, without a size limit. setItem serializes the full response synchronously after the network response was parsed.
A reload also parses and validates the full copy. Large supported profiles can block the main thread and exceed storage quota after this work occurs.
Cache a bounded chrome projection and read it once per page. The live response can replace the limited placeholder.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary: This PR remembers recent interface data. Reloads show that data first, then replace it with current server data.
I found three issues:
- High: The global model fallback crosses host and environment boundaries. A new-thread composer can submit a model from another route.
- Medium: The 15-second timer can finish an active plugin boot. It can show false errors and remove valid remembered chrome.
- Medium: The app synchronously stores the full, unbounded sidebar response. Large profiles can block reloads and exceed browser storage limits.
I found no security defect. The new cache helper removes useful duplication. The small cache-specific modules do not need another refactor.
The PR also has eight conflicts with current main. Current main removed @bb/agent-providers, so the model-cache work needs an architecture update during the rebase.
Verification:
- The app type check passed.
- The seven focused test files passed all 67 tests.
- A browser smoke test loaded the root route and created the new cache entries.
- The dev compiler delayed reload startup, so I could not make a reliable visual timing claim.
- The complete app suite ended with exit 137 during shared process pressure.
I used a comment-only review. I did not approve the PR or request changes.
A small shared shape for caches that replay the last verified answer on the next mount: scoped, versioned keys; every read validated against the cache's zod schema; reads and writes that never throw (a full store or a restricted browser, including a SecurityError on localStorage itself, degrades to "no cache" instead of turning a successful fetch into a query error or a render into a failure); entries from other versions pruned on first use.
…booted On a reload or deep link, /plugins/:pluginId/:panelPath renders before plugin registrations arrive, so PluginPanelView showed "This plugin panel is not available. The plugin may still be loading, or it has been disabled or removed." for a few hundred milliseconds on every load of a plugin page. - Track whether the page's plugin frontends have settled (boot resolved or failed) in a small external store; the lazy boot marks it either way. - PluginPanelView renders an empty shell for an unknown panel until then, and only a settled boot with no matching panel shows the not-available message.
…ever resolves The quiet-until-booted panel state has no end if the boot never starts (it waits on system config), so a backend outage would leave a plugin route blank forever. Mark frontends settled after a floor so a missing panel can say so; a later boot still registers panels normally.
Plugin registrations arrive after first paint, so on a reload the header title, the sidebar's plugin rows, and split-pane titles for plugin panels drew empty and then popped in once frontends booted. Remember the host-owned chrome of the panels this profile last saw (plugin id, panel id, path, title, icon, never the component) and paint it first; live registrations replace it under the same keys, so a matching plugin reconciles in place with no remount. After frontends settle only live registrations remain, and the memory is rewritten on every change so a removed plugin does not return as a ghost. One hook feeds all three surfaces (app header, sidebar rows, split-pane header); PluginPanelHeaderCenter now takes chrome rather than a full registration.
The composer showed "Loading models…" for 3-5s on every full load because system execution options are only cached in memory, and the localStorage placeholder catalog that hides that wait was wired for Claude Code alone. - Generalize the catalog cache: keyed by environment, host, and provider; written for any provider's verified response; served as placeholderData for every provider. Claude Code keeps its curated fallback on a cold cache; other providers still wait for the probe when nothing was recorded. - Rename claude-model-catalog-cache to model-catalog-cache to match. Consumers already treat placeholder rows as provisional (recovery gated on isPlaceholderData, ceiling ignored), so nothing downstream changes.
…ve resolution In a thread, the composer's model, reasoning level, service tier, and permission mode come from the thread default-execution-options query. Until it resolves the hook falls back to neutral defaults, so a full page load showed e.g. reasoning "Medium" and then snapped to the thread's real "Extra High" once the query landed, a gap the model-catalog placeholder now makes visible. - Remember each thread's last resolved options (validated against resolvedThreadExecutionOptionsSchema on read) and replay them as placeholderData; null resolutions are not remembered. - Display uses the replay; submission and the permission controls keep waiting for the verified resolution (isPlaceholderData counts as loading in both the thread prompt area and the embedded chat).
Both caches wrote through an unguarded localStorage.setItem inside their query functions, so a QuotaExceededError (unbounded per-thread keys over time, restrictive privacy modes) would have rejected a successful fetch. Move them onto the last-known cache primitive: writes never throw, other versions are pruned, reads stay schema-validated. Also make the placeholder catalog's permission ceiling the most restrictive mode instead of "full": consumers ignore it while data is provisional, so this changes nothing today, but a replay must fail safe for any future reader that forgets that gate. Document why the thread cache is keyed by thread id alone (ULIDs are globally unique; the resolved options carry host/provider).
…est catalog A thread composer can mount before its environment is known, so its first execution-options key (no environment, no host) is superseded before that fetch completes and is never cached: every cold thread load showed "Loading models..." for that frame despite a warm cache for the routed key. Record each verified catalog under a provider-level key as well and use it as the placeholder when the routed key has no entry. It is a provisional stand-in like every replay here: consumers keep gating recovery and the ceiling on isPlaceholderData, and the live probe replaces it.
…eholder The placeholder generalized the model catalog to every provider but kept replaying only the built-in provider list, while the live list also carries the host's custom and installed ACP agents. A composer remembering one of those providers therefore selected the first built-in provider for the placeholder frame and snapped to the real one when the response landed; the provider picker also grew by those rows on every full load. The last provider list each routing (environment, host) returned is now kept in its own last-known cache and replayed with the catalog. When the remembered provider is in no list the placeholder can vouch for (a cold or cleared provider cache), the placeholder is withheld and the composer waits as it did before, rather than painting a wrong provider. Covered by a custom provider replay test and a withheld-placeholder test.
Every full load started the sidebar-bootstrap query from an empty cache, so the rail showed its two-row loading skeleton on every visit (and every surface reading project names from the shared cache started blank) until the response landed. The last bootstrap this profile received is now kept in the last-known cache (validated against the wire schema on read, one entry per origin, written only from a successful fetch) and replayed as placeholder data, so the rail paints the projects and threads this browser last saw and the live response replaces them in place. Rows are navigation, so a stale row degrades to an in-page load failure at worst; a cold profile has nothing to replay and keeps today's skeleton, and the connection-aware unavailable state still applies there.
…rsion prune A cache with no routing dimensions (the sidebar bootstrap) stores under the bare version key, "prefix.version". The version prune kept only keys under "prefix.version." with the trailing dot, so each fresh page load deleted the cache's own entry before its first read: the replay vanished on every visit and the value was rewritten after the fetch, endlessly. Scoped caches never hit this because their keys always carry a segment after the version. The prune now spares the exact zero-scope key. Covered by a fresh-instance test (a second createLastKnownCache simulates the next page load's prune), which fails against the old prune.
The sidebar bootstrap replay adds about a hundred bytes to the boot path (the cache module and its placeholder wiring; the wire schema was already there), and the raw ratchet had zero headroom left: 1667.1 KB against 1667.0 KB, while brotli stays under its budget. Raise maxBootBytes by 4 KB so the guard keeps catching barrel regressions rather than paying-down noise; per the budget's own doc, the reason rides in the pull request.
28174db to
d40eaed
Compare
The execution-options placeholder fell back to a provider-level "latest" catalog keyed by provider alone, so a composer on host B or environment B could paint (and, since placeholder data is not loading, submit) models that only host A or environment A had ever reported. Only the exact environment/host/provider key replays now; a routing that was never fetched to completion keeps the built-in identity with no rows and waits for its own probe. Co-Authored-By: Claude <[email protected]>
The 15 s floor marked plugin frontends settled unconditionally, so a slow valid boot (content scripts mount in sequence and can take seconds each) reported its panels as unavailable and the remember-chrome effect wrote a partial or empty list over valid remembered chrome. Track idle / booting / complete separately: the floor only settles a boot that never started, an in-flight boot settles itself when it finishes, and remembered chrome is persisted only after the boot has actually completed. Co-Authored-By: Claude <[email protected]>
…tical path The full bootstrap (every unarchived thread of every project) was serialized to localStorage synchronously in the query function and re-parsed and validated on every placeholder evaluation. Cap each project's stored thread list, schedule the write on idle (setTimeout fallback, quota failures swallowed by the cache primitive), and read the replay once per page load. Co-Authored-By: Claude <[email protected]>
|
Pushed three commits addressing the SlopCop review (
Verified:
|
A replayed sidebar bootstrap is a snapshot from the last page load and may not know a project created since. The composer demoted that project to the personal project and reported the bootstrap as settled, so a submit in that window created the thread in the wrong project. Treat the replay as settled only when it already knows the requested project; otherwise hold the candidate (picker loading, submit blocked) until the live response. Co-Authored-By: Claude <[email protected]>
|
Follow-up to the SlopCop fixes:
|
The bounded copy is built inside the query function. A response the bounding code cannot handle threw there and failed the whole bootstrap (seen in MachinesSettingsSection tests that stub a partial response). The cache is best-effort, so swallow bounding errors and skip the write. Co-Authored-By: Claude <[email protected]>
Fixes #1676 (items 2 to 5; item 1 is the plugin PR).
Host-side last-known state so a reload paints what this profile last saw instead of neutral defaults that the live answers then replace:
placeholderData; display uses the replay while submission and the permission controls keep waiting for the verified resolution (isPlaceholderDatacounts as loading in both composers).Client only (
apps/app); no plugin API surface, no wire changes. The raw boot budget is raised by 4 KB: the sidebar replay adds about a hundred bytes to the boot path and the ratchet had zero raw headroom left (1667.1 KB against 1667.0 KB, brotli still under budget), so this keeps the guard about barrel regressions rather than byte noise.