Repository navigation
Migrate app API usage to @bb/sdk - #739
Merged
Merged
Conversation
SawyerHood
force-pushed
the
bb/bb-workflow-skill-check-thr_e4mkfam5y5
branch
from
July 16, 2026 13:45
8b4cab8 to
8cb891e
Compare
…check-thr_e4mkfam5y5 # Conflicts: # packages/plugin-sdk/bundled-types/bb-plugin-sdk.d.ts # packages/sdk/src/areas/projects.ts # packages/templates/src/generated/plugin-sdk-dts.generated.ts
…gnal on thread mutations Parse tabs.get bodies with threadTabsResponseSchema like tabs.update already does, and split ThreadActionArgs/ThreadInteractionTargetArgs from the signal-bearing read args (mirroring EnvironmentActionArgs) so mutation methods no longer accept a signal they never forward. Co-Authored-By: Claude Fable 5 <[email protected]>
ymichael
added a commit
that referenced
this pull request
Sep 19, 2026
…3944) ## Human comments ## What was wrong Reported on Discord: an agent mentions a filename in inline code, bb auto-links it, and clicking a file that is not in the workspace opens a preview panel that says `Failed to load file` and nothing else — no reason, for any kind of failure. Two independent defects landed on the same blank message. **Server.** `GET /environments/:id/diff/file` called `host.read_file` directly and never translated the daemon's error, so a missing file surfaced as `502 ENOENT` rather than the 404 every `/files/*` route already returns. The remap lives inside `serveDaemonFileContent`, which every route returning a `Response` uses and therefore gets for free; this route returns JSON, builds its own call, and so silently opted out. It has never had the remap since the route was added in f7d3397 (2026-05-11). **App.** `resolveSecondaryPanelFilePreviewState` classified not-found with `error instanceof HttpError && error.status === 404`. That was correct when written, but #739 (3d6a61a) moved these queries onto the typed SDK, which throws `BbHttpError` — structurally identical, different class, so `instanceof` silently answers `false` and never type-errors. The not-found branch became unreachable and every failure fell through to a branch that discarded the message. That second defect is a real regression the report did not mention. For the workspace preview the symptom was unchanged, because the server was already returning 502 — but **project file previews** hit a route that does return a genuine 404, so they showed `File not found.` before 2026-07-16 and `Failed to load file` after. Host file previews regressed the same way in #2005 (9768d55, 2026-08-20). Thread-storage previews still fetch through `api.*`, which is why this stayed invisible. ## What changed - `apps/server/src/routes/environments.ts` — `.catch(remapDaemonFileRouteError)` on the `diff/file` read. Missing file → 404, oversized → 413, bad path → 400. No wire change; the daemon protocol is untouched. - `apps/app/src/lib/http-error.ts` (new) — `asHttpError` / `getHttpErrorMessage`, covering both `HttpError` and `BbHttpError`. `mutation-errors.ts` had a private copy of the message logic and now imports this one instead (net −20 lines there). - `apps/app/src/components/secondary-panel/ThreadStorageFilePreview.tsx` — the 404 check and the message extraction both go through the shared helpers, so the preview reports the server's reason when there is one and keeps `Failed to load file` only as a true fallback. - `apps/app/src/components/secondary-panel/FilePreview.tsx` — `"Preview not available for <mime>."` moves to a new `unsupported` state. It had been riding on `kind: "error"`, and the old code inferred `role="alert"` from *whether a message existed*; once real errors carry messages, every genuine failure would have silently stopped being announced to screen readers. On surfacing daemon text: with the server fix a missing file is a plain 404 and renders `File not found.`, so the daemon's path string no longer reaches the UI at all. What remains surfaceable are server-authored bodies (`file_too_large`, `invalid_path`, `host_unavailable`) describing host-local state the user already owns. Path traversal was checked — `path=/etc/passwd` resolves under the workspace root and 404s. ## How you verified Reproduced first, on a built instance from this worktree with a project checkout containing only `exists.md`. Before the change: `502 {"code":"ENOENT", ...}` and a bare `Failed to load file`. After, in the running app: | Click | Result | | --- | --- | | `does-not-exist.md` | `File not found.`, path shown in the header, no `HTTP 404:` prefix | | `too-big.md` (30 MB) | `File size 31457280 bytes exceeds the 25 MB limit` | | `exists.md` | renders normally | Tests (fail before, pass after — confirmed by reverting `asHttpError` to `HttpError`-only, which reproduces `expected 'HTTP 404: Path does not exist: /works…' to be 'File not found.'`, the exact string the browser showed): - `apps/server/test/public/public-environments.test.ts` — 2 tests: ENOENT → 404 with the daemon command asserted, oversized → 413. - `apps/app/src/components/secondary-panel/FilePreview.test.tsx` — 6 tests across both error classes, the generic fallback, and the `unsupported` state not being an alert. - `FilePreview.stories.tsx` — rows for a failure with a reason and for an unsupported type. Commands: `turbo run typecheck lint test --filter='...[origin/main]'`. Typecheck and lint clean (0 errors; the 191 app lint warnings are pre-existing and none are in the touched lines). Nine `@bb/integration-tests` and eight `@bb/server` files failed as 60s timeouts under parallel load, across plugins, install scripts, event pruning and shared ports — all unrelated to previews, and all pass when re-run in isolation. ## Not addressed bb auto-links any inline-code token ending in `.md` without checking it exists. Confirmed, but deliberately left alone: checking would mean a host round trip per filename mention during markdown render, and a file the agent just deleted or is about to create is legitimately mentionable. With the 404 remap in place a dead link now lands on a clear `File not found.` Worth its own issue if we want resolved-vs-unresolved link styling, ideally off a cached workspace listing rather than a probe per token. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5 <[email protected]>
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
@bb/sdkclients across queries, mutations, dialogs, and workspace flowsAbortSignalthrough SDK read methodsValidation
bb-applauncher timeout passed on isolated rerunNotes
The remaining raw HTTP usage is intentional for binary previews, sidebar bootstrap, voice transcription, provider-CLI NDJSON streaming, and websocket flows without equivalent SDK behavior.
Review follow-up
b013d4e29:tabs.getnow parses responses withthreadTabsResponseSchema, and mutation arg types no longer advertise an ignoredAbortSignal(splitThreadActionArgs/ThreadInteractionTargetArgs, regenerated plugin-sdk dts)