Repository navigation
Add sidebar row context menus - #3
Merged
SawyerHood merged 3 commits intoMay 12, 2026
Merged
Conversation
SawyerHood
marked this pull request as ready for review
May 12, 2026 21:59
Collaborator
Author
|
Updated for the follow-up feedback:
Validation rerun:
|
Collaborator
Author
|
Updated this PR for the click-dismiss follow-up. Changes:
Validation:
|
15 tasks
ymichael
added a commit
that referenced
this pull request
Oct 30, 2026
## Human comments ## What was wrong Several cache owners wrote a server reply or the thread-detail bootstrap straight into the React Query cache with `setQueryData` while a fetch of the same key could still be in flight. React Query writes fetch results without checking whether they're older than what's cached (query-core `query.ts`), so the older fetch landed last and put stale data back. Effects included: an environment or host status that stayed stale after opening a thread, a plugin settings form resetting its draft to the old value, a cancelled plugin install flipping back to running, new plugin update jobs dropping out of the list, an `idle` app update phase switching off the progress poll, and the AI service selection flickering back. These are items #2–#10 from the direct cache write audit (@thread:thr_fjr5x8dzaz). #1 (thread tabs) is fixed separately in #6611. ## What changed Two fixes, depending on whether the data has a version field: - **Environment and Host keep the newer copy by `updatedAt`** (#2, #3, #10). The bootstrap ingest (`thread-detail-cache-owner.ts`), the rename reply (`applyEnvironmentUpdateResult`), and the `useEnvironment`/`useHosts` fetches all compare `updatedAt`. The fetch-side check is what catches a fetch that started before the write and lands after it. To make it testable, those fetches now live in `environmentQueryOptions` and `hostsQueryOptions`. Host `status` comes from live daemon sessions and a disconnect doesn't change `updatedAt`, so on a tie the cached copy wins over the bootstrap. The bootstrap only fills an empty cache or replaces strictly older data. Rename replies and fetch results still win ties. - **`setQueryDataOverInFlightFetch`** (`cache-effect-utils.ts`) for data with no version (#4–#9): it writes the value, and if a fetch of the key is in flight it cancels that fetch (the cache keeps the written value) and refetches. With nothing in flight it's a plain write. Used by `applyPluginSettingsView`, `applyPluginInstallJob`, `applyPluginUpdateJob`, `hydrateAppUpdateStatus`, `hydrateSystemVersionCache` and `writeCachedAiServices`, so every caller gets the fix. Where the audit suggested an unconditional cancel-write-invalidate (#7) or a cancel before the write (#8, #9), this helper refetches only when a fetch was actually in flight. That avoids an extra request on every write. Forced version and app-update checks update the server's cache, so the trailing unforced refetch returns the forced result. No wire, CLI or plugin API changes. Not covered here: audit items #11 (plugin safe mode) and #12 (prompt history), both low risk. Also not covered: a lint rule restricting direct `setQueryData` calls to the helper, which would stop new call sites from bringing the race back. ## How you verified - New tests use real `QueryClient`/`QueryObserver` instances: start a fetch that resolves late with older data, do the write, let the fetch land, then check that the newer value survives (and, for the helper, that the trailing refetch runs). - `thread-detail-cache-owner.test.ts` (new): late environment and host-list fetches after a bootstrap, an older bootstrap over a newer cache, and the equal-`updatedAt` host status case. - `environment-workspace-cache-owner.test.ts`: a late environment fetch after a rename, and an older rename reply over a newer cache. - `in-flight-fetch-writes.test.ts` (new): one row per cache-owner write for #4–#9, plus helper tests for the no-fetch case (no extra request) and a fetch of an unobserved query. - With each source change reverted, every race test failed on the stale data and passed once the fix was restored. - `pnpm exec turbo run typecheck lint test --filter=@bb/app`: passed (647 files, 6515 tests; 0 lint errors, no new warnings). After rebasing onto `0472409243` I re-ran the three changed test files (21 tests passed). 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 5, 2026
…ns, and keep results while searching (#7074) ## Human comments ## What was wrong Finding #3 of the Nov 4 hot-path audit. The Git plugin's `branches` RPC (`plugins/git/host.ts`) called `listBranchOptions` with `remoteRefresh: "background"`. So every call listed all of `refs/heads` and `refs/remotes`, in two `for-each-ref` processes using `%(refname:short)`. It also started a throttled `git fetch --all --prune`. Calls come on every debounced keystroke in a merge-base picker, and on every ref change while a Diff tab is visible: the Diff tab keeps the query live with `loadOptions: isLive`. A fetch that moves a ref invalidates the refs tag, which refetches `branches`, which starts the next fetch once the 30 s throttle lapses. The caller only needs about 50 names that match a query. This still held on origin/main at f3ccc8b. ## What changed - `packages/environment-provider-host/src/branch-options.ts`: the parsed ref listing is cached per git common dir, so all worktrees of a repo share one entry (LRU of 8). The cache key is a stat fingerprint: inode and mtime of `packed-refs`, plus every directory under `refs/heads` and `refs/remotes`. Git writes refs by lock-and-rename, so any ref add, update or delete changes one of those. Fingerprints with a timestamp less than 2 s old are treated as racy and skip the cache, like git's racy-index rule. Reftable repos always skip it. Searches filter the cached list in memory. Core's `host.list_branch_options` uses the same function, so the project picker gets the cache too. - Git plugin: the `branches` host read now uses `remoteRefresh: "none"`. A new `fetchRemoteBranches` RPC (UI → server → host) starts the existing throttled background fetch (`refreshRemoteBranches`). The merge-base pickers call it when they open. `bb git branches` calls it before listing (best effort), so the CLI behaves as before. Skill and README updated. - `fetchRemoteBranches` (`branch-options.ts`) now runs `git fetch --prune --quiet <remote>` for `origin`, or for the only remote when there is no `origin`. If a repo has several remotes and none is named `origin`, it fetches nothing. This is the one fetch path behind the Git plugin's pickers, core's project branch picker (`host.inspect_git_source` and `host.list_branch_options`, both the background refresh and the blocking Refresh) and thread placement, so the change applies to all of them. The 30 s throttle per git common dir is unchanged. - **Two visible behaviour changes:** 1. A visible Diff tab no longer fetches remotes by itself. Remotes are fetched when a branch picker opens, from `bb git branches`, and by core's existing paths. 2. Branches on remotes other than `origin` (or the single remote) no longer refresh from the pickers, including core's project picker and its Refresh. Run `git fetch <remote>` to update them. - No `HOST_DAEMON_PROTOCOL_VERSION` bump and no plugin SDK change. The only new wire surface is the Git plugin's own RPC method. If an older plugin host lacks it, the UI ignores the error and the CLI still lists. - `plugins/git/ui/queries.ts`: `useGitBranches` keeps the last loaded results, for the same environment and selected branch, until the next search answers. Each search is a new query keyed by the typed text, so the list used to go empty on every keystroke and show "Loading branches…". With searches now taking 50–100 ms, that showed as a flicker. The picker already filters as you type, so the old results narrow immediately and are then replaced. ## How you verified Real data: `~/Projects/bb` (4,476 local branches, 2,672 remote refs, 123 worktrees, 17 remotes). Load average was 15–45 from other agents, so main and branch runs were interleaved. The harness imports the real `listBranchOptions` from a `git archive` copy of origin/main and from this branch. A PATH shim counts git spawns and turns `git fetch` into a no-op. Scripts and raw output are outside the checkout. Search keystrokes (10 queries after the first call, per process, 4 interleaved rounds each): | | git processes per keystroke | keystroke median per round | keystroke range | first (cold) call | |---|---|---|---|---| | main | 5 (2× `for-each-ref` over 7.1k refs, `symbolic-ref`, 2× `rev-parse`) | 546, 746, 307, 237 ms | 177–2,920 ms | 337–1,573 ms | | branch | 2 (`rev-parse` ×2) | 102, 84, 50, 64 ms | 46–204 ms | 378–811 ms | Fetch cost on this repo while it still had 18 remotes (17 of them contributor forks, since removed): `git fetch --all --prune --dry-run` took 147 s wall (13.8 s user, 38 s sys). `git fetch origin --prune --dry-run` took 7.5 s. The background fetch is killed at 5 s, so on main a visible Diff tab could restart a mostly wasted 5 s `fetch --all` every 30 s whenever refs moved. On the branch, `branches` reads start no fetches (see the test below). A 10-minute `ps` sample of the live machine saw one daemon-side `fetch --all`. No Diff-tab loop was running then, so I have no live before/after for the loop; the audit's 87 slow calls and the reflog alignment are the evidence for it. `for-each-ref` format cost, same repo, 5 runs each: `%(refname:short)` 382–624 ms, `%(refname:lstrip=2)` 190–277 ms, `%(refname)` 210–252 ms. The format is unchanged here; this is context for why the listing is slow. **What `fetch --all` does when the 5 s background kill hits it.** I tested a fixture repo with local bare remotes. Remote `new` branches were added and `stale` branches deleted on each remote after the first fetch. "Slow" remotes sleep 8 s in `uploadpack`. The "blackhole" remote is `ssh://[email protected]`, which never answers. I called `refreshRemoteBranches(repo, {}, "background")`: | remotes (config order) | main: `fetch --all --prune` | this branch | |---|---|---| | alpha, beta, origin, zeta (all fast) | finished in 155 ms; all four updated and pruned | 64 ms; origin updated and pruned; others untouched | | alpha, beta (slow), origin | killed at 5,035 ms; alpha updated and pruned; beta and origin left as before (`stale` kept, `new` missing) | 71 ms; origin updated and pruned | | alpha, beta (blackhole), origin | killed at 5,037 ms; alpha updated; origin left as before | 73 ms; origin updated and pruned | | origin, zeta (slow) | killed at 5,044 ms; origin updated and pruned; zeta left as before | 59 ms; origin updated and pruned | | upstream only | n/a | 60 ms; upstream updated and pruned | | alpha, zeta (no origin) | n/a | skipped; nothing fetched | `fetch --all` fetches remotes one at a time in config order. When killed, every remote before the first slow one is fully updated and pruned. The slow one and every remote after it keep their old refs. There are no partial updates and no leftover `.lock` files, because the kill takes the whole process group. Every failed background attempt also marks the repo for a retry, so the next refresh within 30 s runs again. So with one slow or unreachable remote listed before `origin`, the 5 s kill meant `origin` never refreshed. Tests (each fails before the fix and passes after; checked by reverting): - `packages/environment-provider-host/test/branch-options-cache.test.ts` ages the ref store and then: - creates a loose branch - deletes a packed-only branch - fetches a new remote - creates a branch from another worktree of the same repo In each case the next listing must reflect the change. A spawn-count test checks that a repeat search runs no `for-each-ref`. With a constant fingerprint, the four freshness tests fail. - `plugins/git/host.test.ts`: `branches` reads never reach the remote's upload-pack, and `fetchRemoteBranches` does. This fails when `branches` goes back to `remoteRefresh: "background"`. - `packages/environment-provider-host/test/workspace-git-fetch.test.ts`, both interactive and background: - with remotes `alpha`, `origin` and `zeta`, only `origin` is fetched and pruned - a lone non-origin remote is fetched - several remotes with no `origin` are skipped On the old `fetch --all` code, the multi-remote and skip cases fail. - `plugins/git/server/cli.test.ts` updated for the CLI's fetch call. - `plugins/git/ui/queries.test.tsx`: while the next search is in flight, the previous branches stay rendered. Fails without the fix. - Real app (`pnpm start:worktree`, fixture repo with 4,400 local and 2,500 remote branches): a headless browser typed in the composer's merge-base picker while a `requestAnimationFrame` probe counted frames showing "Loading branches". On main: 133/310 and 119/310. With the skeleton fix: 0/311 and 0/311. In the same app, opening the picker fetched a branch added to the bare origin, and it showed up in search about 2 s after opening. With the Diff tab open, three local ref changes over 26 s fetched nothing. - `pnpm exec turbo run typecheck --filter=bb-plugin-bb--git --filter=bb-environment-provider-host --filter=@bb/host-daemon` - `pnpm exec turbo run typecheck lint test --filter=bb-plugin-bb--git` (35 files) and `pnpm exec turbo run test --filter=bb-environment-provider-host` (5 files) - `pnpm exec turbo run test --filter=@bb/host-daemon -- test/command/host-branches-dispatch.test.ts`, `--filter=@bb/server -- test/public/public-project-workspace-routing.test.ts` and `--filter=bb-plugin-bb-guide` - lint clean on changed files. CI runs the full suites. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Nov 24, 2026
## Human comments ## What was wrong Opening the slash-command menu, listing skills, and opening one skill each cost several serial host round trips. Before every native-root scan the server made a separate `plugin.host.call resolveNativeRoots`, cached for 10 s, and only then sent `host.list_commands` / `host.list_skills`. The skills index also sent one `host.list_skills` per visible provider plus one for shared roots. Opening a skill rebuilt that whole index twice, once for content and once for files, just to map a skill id to a path. On a Connect-tunnelled host each serial wave costs ~200 ms (audit findings #2 and #3, `thr_ejgucea7p3/report.md`). Finding #4, frontmatter-only project skill reads, is handled in a separate thread. ## What changed - **Daemon wire change, `HOST_DAEMON_PROTOCOL_VERSION` 281 → 282.** - `host.list_commands` now takes `{ cwd, provider: { providerId, declaredRoots, resolver }, resolution: { contributedEnv, timeoutMs } }`. - `host.list_skills` takes `{ cwd, providers: [...], sharedRoots, resolution }` and returns `{ workspaceSkills, sharedSkills, providers: [{ providerId, skills }] }`. - `resolver` is `{ pluginId, generation, artifact }` or null. The daemon calls the plugin's `resolveNativeRoots` in-process through its `PluginHostManager`, inside the same request as the scan. It cancels that call if the listing is cancelled. A failed, malformed, or unavailable answer falls back to the declared roots with a warning, as the server did before. - **Server policy stays on the server** (`services/providers/native-roots.ts`): which providers are scanned, which plugin resolves, the host env, and a 10 s resolver cap that leaves the scan time inside the first retry attempt. The server-side resolved-roots cache (`ProviderNativeRootsCache`) is deleted because resolving is no longer a separate round trip. - **Skills index** (`services/skills/skill-listing.ts`): - One batched `host.list_skills` replaces the per-provider calls and the separate shared-roots call. - `.bb/skills` is scanned once instead of once per provider. It is now also listed when no provider has native roots. - Server-owned skills load in parallel with the host call. - A per-(host, cwd) index memo (`@bb/async-cache`, 5 min) is refreshed by every listing. Content and file reads resolve the id from it and rebuild once only for an id the last listing didn't have. Writes and deletes always rebuild first. Plugin settings changes clear it. - **Docs:** `docs/api_to_audit.md` and the `experimental_nativeRootsHostContract` JSDoc now say the daemon resolves per listing, uncached. Plugin SDK bumped to 0.6.197 for the JSDoc change. ## How you verified Measured on two real servers, main at merge base `af25b0b5a60` vs this branch, each with a fresh data dir (no `~/.bb`). Each server had a second enrolled daemon behind a TCP latency proxy adding 100 ms each way (~200 ms RTT). The proxy strips `permessage-deflate` from the daemon's upgrade, reads server→daemon frames, and counts `host-rpc.request`s. Input was the same bb checkout (9 `.bb/skills`, real `~/.claude` etc.) and `provider=claude-code`, with 8 samples per action after warm-up. Remote host (~200 ms RTT): median wall time / host RPCs per action | action | main | branch | |---|---|---| | slash menu, cold (>10 s since last) | 437 ms / 3 (resolver → `list_commands`, ‖ `read_workspace_agent_context`) | 233 ms / 2 | | slash menu, warm | 222 ms / 2 | 233 ms / 2 | | skills list, cold (>10 s since last) | ~527 ms / 13 (6 resolvers → 7 `list_skills`) | ~310 ms / 1 | | skills list, warm (resolver cache hit on main) | 364 ms / 7 | 404 ms / 1 (steady-state resample: ~300–320 ms on both) | | open one skill (content + files in parallel) | 584 ms / 16–22 (two index rebuilds + read + list) | 219 ms / 2 (`read_file` ‖ `list_files`) | Local host (primary daemon, no proxy), median: | action | main | branch | |---|---|---| | slash menu, cold / warm | 22 / 19 ms | 21 / 19 ms | | skills list | 119 ms | 115 ms | | open one skill | 167 ms | 17 ms | The warm slash menu still makes 2 RPCs in one parallel wave: `host.list_commands` and `host.read_workspace_agent_context`. Folding the second one in overlaps finding #4's change to that command, so it is left for that thread. Every action is now a single wave. The remaining ~100 ms over RTT on the skills list is server-side index work (`listServerSkills` hashing), not host traffic. Tests: - `apps/server/test/public/public-project-skills.test.ts` adds "opens a listed skill with one host read…". It asserts that a listing is one `host.list_skills`, that content + files after it are exactly `host.read_file` + `host.list_files`, and that an unknown id re-lists once. It fails on main, where every open re-lists. - `apps/host-daemon/src/command-handlers/list-skills.test.ts` covers the batched handler with a fake plugin host: the `.bb/skills` root is listed once, shared roots and resolved roots are scanned, a throwing / malformed / missing runtime falls back to declared roots with a warning, and cancelling the listing cancels the resolver call. - `native-roots.test.ts`, the commands, workspace-routing and contract tests are updated to the new wire shape. - `pnpm exec turbo run typecheck lint --filter=@bb/server --filter=@bb/host-daemon --filter=@bb/host-daemon-contract --filter=@get-bb/plugin-sdk --filter=@bb/integration-tests` passes. So do the targeted vitest runs above, plus `tests/integration` `native-roots-golden`. CI runs the full suites. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
ymichael
pushed a commit
that referenced
this pull request
Nov 25, 2026
…lability read (#8187) ## Human comments ## What was wrong A nested bb whose Account Pooler proxies to a parent pool decides per turn whether it can route through the parent, using `ParentAvailability` in `plugins/account-pool/src/parent-pool.ts`. `load()` gives the parent's `/availability` 2 s, and on any error or non-OK status returns `UNAVAILABLE_POOL`. `get()` caches that result for the full 30 s TTL, the same as a good answer. So one slow read from a busy parent takes the child off the pool for 30 s, and every turn that starts in that window runs with no pool credentials. On a child with no Claude login of its own, Claude Code answers `Not logged in · Please run /login` and Provider Retry skips the turn as not retryable. On one child this happened three times in a day, each time the parent's host was under heavy load. ## What changed - `plugins/account-pool/src/parent-pool.ts`: `ParentAvailability` remembers the last good availability. - A failed read keeps serving it, and the next read is tried after 5 s instead of 30 s. - Once reads have failed for 60 s in a row, the parent is reported unavailable and that answer is cached for the normal TTL, as before. A parent that has never answered is reported unavailable, and the read is retried after 5 s. - The read timeout goes from 2 s to 5 s. - `plugins/account-pool/src/parent-pool.test.ts`: three cases, all of which fail on `main`: - one failed read keeps the last good value and retries after 5 s; - a parent that stays down is reported unavailable after 60 s, then cached for the TTL; - a failed first read is retried after 5 s. - No wire, CLI or doc changes. ## How you verified - New tests on `main`'s `parent-pool.ts`: the 3 new tests fail with `expected { claude: false, codex: false } to deeply equal { claude: true, codex: false }`, and the other 13 pass. With the change: 16/16. - After the final commit: `pnpm exec turbo run typecheck lint test --filter=bb-plugin-account-pool --force` passed 10/10 tasks, with 14 test files and 402 tests passing. Lint reported 3 warnings, all in `app.tsx`, which this PR does not touch. `pnpm exec turbo run lint:type-aware --filter=bb-plugin-account-pool --force` passed 7/7 tasks with 0 warnings. `pnpm exec turbo run prepare:bundled --filter=bb-plugin-account-pool` passed 7/7 tasks. `oxfmt --check` passes on both files. - Standalone reproduction with real HTTP and the real clock. `ParentAvailability` uses the real `fetch` and the shipped TTL and timeouts against a local HTTP parent, and one `get()` per second stands in for a turn start. `main` and this branch ran side by side. One slow answer (request #2 answers in 8 s, then normal), on `main`: ``` [ 0.0s] parent: request #1 -> 200 {claude:true} [ 0.1s] child: turn start -> ROUTED (claude via parent pool) [ 30.2s] parent: request #2 answering in 8s [ 32.2s] child: warn could not read parent availability: The operation was aborted due to timeout [ 32.2s] child: turn start -> NOT ROUTED (turn runs with no login) after waiting 2003ms [ 62.3s] parent: request #3 -> 200 {claude:true} [ 62.3s] child: turn start -> ROUTED (claude via parent pool) summary: 43 turn starts routed, 30 not routed, 3 parent requests ``` With the change: ``` [ 0.0s] parent: request #1 -> 200 {claude:true} [ 0.1s] child: turn start -> ROUTED (claude via parent pool) [ 30.2s] parent: request #2 answering in 8s [ 35.2s] child: warn could not read parent availability: The operation was aborted due to timeout [ 35.2s] child: turn start -> ROUTED (claude via parent pool) after waiting 5003ms [ 40.2s] parent: request #3 -> 200 {claude:true} [ 70.4s] parent: request #4 -> 200 {claude:true} summary: 70 turn starts routed, 0 not routed, 4 parent requests ``` A parent that stays down (503 from 25 s on), on `main`: ``` [ 0.0s] parent: request #1 -> 200 {claude:true} [ 0.1s] child: turn start -> ROUTED (claude via parent pool) [ 30.2s] parent: request #2 -> 503 (down) [ 30.2s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 30.2s] child: turn start -> NOT ROUTED (turn runs with no login) [ 60.4s] parent: request #3 -> 503 (down) [ 60.4s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 90.5s] parent: request #4 -> 503 (down) [ 90.5s] child: warn could not read parent availability: parent availability returned HTTP 503 [120.7s] parent: request #5 -> 503 (down) [120.7s] child: warn could not read parent availability: parent availability returned HTTP 503 summary: 30 turn starts routed, 100 not routed, 5 parent requests ``` With the change, the child keeps routing for 60 s after the first failure, then reports the parent unavailable and goes back to reading every 30 s: ``` [ 0.0s] parent: request #1 -> 200 {claude:true} [ 0.1s] child: turn start -> ROUTED (claude via parent pool) [ 30.2s] parent: request #2 -> 503 (down) [ 30.2s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 35.2s] parent: request #3 -> 503 (down) [ 35.2s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 40.2s] parent: request #4 -> 503 (down) [ 40.2s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 45.3s] parent: request #5 -> 503 (down) [ 45.3s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 50.3s] parent: request #6 -> 503 (down) [ 50.3s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 55.3s] parent: request #7 -> 503 (down) [ 55.3s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 60.3s] parent: request #8 -> 503 (down) [ 60.3s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 65.3s] parent: request #9 -> 503 (down) [ 65.3s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 70.3s] parent: request #10 -> 503 (down) [ 70.3s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 75.3s] parent: request #11 -> 503 (down) [ 75.3s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 80.3s] parent: request #12 -> 503 (down) [ 80.3s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 85.4s] parent: request #13 -> 503 (down) [ 85.4s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 90.4s] parent: request #14 -> 503 (down) [ 90.4s] child: warn could not read parent availability: parent availability returned HTTP 503 [ 90.4s] child: turn start -> NOT ROUTED (turn runs with no login) [120.5s] parent: request #15 -> 503 (down) [120.5s] child: warn could not read parent availability: parent availability returned HTTP 503 summary: 90 turn starts routed, 40 not routed, 15 parent requests ``` <details><summary>repro.mts (run from the repo root as <code>node_modules/.bin/tsx repro.mts $PWD/plugins/account-pool/src/parent-pool.ts slow-once|down</code>)</summary> ```ts import { createServer } from "node:http"; import type { AddressInfo } from "node:net"; const [modulePath, scenario] = process.argv.slice(2) as [string, "slow-once" | "down"]; const { ParentAvailability } = await import(modulePath); const TOKEN = "vqMIj4xUiI3PyvKS2SllSKHsOfxLF_sAZwzNAAvV9TQ"; const started = Date.now(); const t = () => ((Date.now() - started) / 1000).toFixed(1).padStart(5); let request = 0; const server = createServer((req, res) => { request += 1; const n = request; const elapsed = (Date.now() - started) / 1000; if (req.headers["x-bb-account-pool-token"] !== TOKEN) { res.writeHead(401).end(); return; } const answer = () => { res.writeHead(200, { "content-type": "application/json" }); res.end(JSON.stringify({ claude: true, codex: false })); }; if (scenario === "slow-once" && n === 2) { console.log(`[${t()}s] parent: request #${n} answering in 8s`); setTimeout(() => { if (!res.destroyed) answer(); }, 8_000); return; } if (scenario === "down" && elapsed > 25) { console.log(`[${t()}s] parent: request #${n} -> 503 (down)`); res.writeHead(503).end(); return; } console.log(`[${t()}s] parent: request #${n} -> 200 {claude:true}`); answer(); }); await new Promise<void>((resolve) => server.listen(0, "127.0.0.1", resolve)); const { port } = server.address() as AddressInfo; const availability = new ParentAvailability({ parent: { baseUrl: `http://127.0.0.1:${port}/api/v1/plugins/account-pool/http`, token: TOKEN }, fetch, now: Date.now, onError: (error: unknown) => console.log(`[${t()}s] child: warn could not read parent availability: ${error instanceof Error ? error.message : String(error)}`), }); const durationS = scenario === "slow-once" ? 75 : 130; let last: string | null = null; let routed = 0; let unrouted = 0; while ((Date.now() - started) / 1000 < durationS) { const before = Date.now(); const value = await availability.get(); const waited = Date.now() - before; if (value.claude) routed += 1; else unrouted += 1; const state = value.claude ? "ROUTED (claude via parent pool)" : "NOT ROUTED (turn runs with no login)"; if (state !== last || waited > 500) { console.log(`[${t()}s] child: turn start -> ${state}${waited > 500 ? ` after waiting ${waited}ms` : ""}`); last = state; } await new Promise((r) => setTimeout(r, 1_000)); } console.log(`summary: ${routed} turn starts routed, ${unrouted} not routed, ${request} parent requests`); server.close(); process.exit(0); ``` </details> - **Not checked:** an isolated nested bb against a slow parent bb end to end. The reproduction drives the same class the server constructs, with the same options except `onError`. Fixes #8188 > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Validation
pnpm exec turbo run test --filter=@bb/app --force -- src/components/sidebar/ThreadRow.test.tsx src/components/sidebar/ProjectRow.test.tsxpassed: 2 files, 21 tests.pnpm exec turbo run typecheck --filter=@bb/app --forcepassed.pnpm exec turbo run lint --filter=@bb/app --forcepassed.