Repository navigation
Remove unreachable ask-agent git failure flow - #2080
Conversation
|
🚨 SLOP COP 🚨 · I am the SlopCop. I am reviewing this pull request for security, code quality, performance, architecture, and end-to-end behavior. |
## What was wrong The app bundle ratchets were set only 3% above a measured production build, leaving too little room for normal feature work and build variation. The intended policy is 10% headroom for both the boot payload and the first-paint thread-route closure. ## What changed - Recalculate the boot raw/Brotli ceilings at exactly 10% above the current production measurements: 1,566,924 / 435,515 bytes measured and 1,723,617 / 479,067 bytes budgeted. - Recalculate the SplitWorkspaceRoute raw/Brotli ceilings the same way: 2,303,167 / 610,510 bytes measured and 2,533,484 / 671,561 bytes budgeted. - Update the in-file policy explanation from 3% to 10%. - Rebase onto current main. #2080 removed the unreachable git-failure prompt flow and its Handlebars dependency entirely, so this PR drops the now-redundant lazy-loading change and calibrates the budgets after that cleanup. - No wire-protocol, CLI, guide, or host-daemon behavior changed. ## How you verified - `pnpm exec turbo run build typecheck --filter=@bb/app --cache-dir=.turbo/cache --output-logs=new-only` - `pnpm exec turbo run test --filter=@bb/app --cache-dir=.turbo/cache --output-logs=new-only` — 404 files and 3,122 tests passed; 3 skipped. - `node apps/app/scripts/check-bundle-budget.mjs` — both measured closures pass their exact 10% ratchets. - `git diff --check` Fixes: N/A — performance maintenance requested directly. > AGENT GENERATED: by GPT-5
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary: This PR removes an “Ask agent to fix” path that users could never reach. The server never sent the special failure data that the path required. The PR also removes its unused prompts, contract variants, mobile branches, and toast examples.
I found no security, correctness, performance, or architecture issues.
I traced the Git action routes, workspace resolution, error contracts, desktop and mobile consumers, and deleted templates. The three removed failure variants had no server producer. The live workspace_unavailable contract remains intact. Project-wide searches found no stale references or duplicate replacement logic.
Focused validation passed 54 tests across the server contract, templates, mobile action model, and server action route. Type checks passed for the app, mobile app, templates, and server contract. GitHub CI is green, and git diff --check passed.
The local QA server did not reach readiness before the browser check ended, so doobie did not test the failure toasts. This limit does not block this deletion-only change because the focused route tests and CI cover the affected behavior.
I left no inline comments.
## What was wrong Issue #1072 (report: https://get-bb.github.io/reports/issues/1072.html) tracks heavy packages that sit in the static import closure of the lazy thread route (`SplitWorkspaceRoute`), so every thread open downloads and parses them before the timeline paints. Since the report was written, main already cut three of the five edges it names: `FilePreview -> @pierre/diffs` and the secondary-panel surfaces (#1894), `markdown-preview -> rehype-katex` (#1891), and Handlebars (#2080). The budget check in CI now ratchets that closure. One edge was still open: `useThreadStorageBrowser.ts` imported `@pierre/trees/react` statically, and `ThreadDetailView` calls that hook on every thread page (it has to, so the tree model survives the Info-tab/file-tab toggle). That put the tree model, its renderer and preact (~250 KB raw / ~62 KB brotli emitted) in the route closure, although only the "Thread storage" browser in the Info tab renders a tree, and the storage file list itself is only fetched once the panel opens. `node scripts/why-eager.mjs --from=views/SplitWorkspaceRoute.tsx node_modules/@pierre/trees` on main: ``` 0. apps/app/src/views/SplitWorkspaceRoute.tsx 1. apps/app/src/views/thread-detail/SplitThreadArea.tsx 2. apps/app/src/views/thread-detail/ThreadDetailView.tsx 3. apps/app/src/components/secondary-panel/useThreadStorageBrowser.ts 4. node_modules/@pierre/trees/dist/react/index.js ``` ## What changed All in `apps/app`. - `src/components/secondary-panel/ThreadStorageFileTree.tsx` (new): the only runtime importer of `@pierre/trees`. Exports `createThreadStorageTreeModel(onSelectionChange)` (the `new FileTree(...)` that `useFileTree` wrapped) and the `ThreadStorageFileTree` render component with the host style that used to live in `ThreadStorageBrowser.tsx`. - `useThreadStorageBrowser.ts`: no static tree import. When a thread has storage files, an effect imports the gate module (through `createRetryingModuleLoader`, the same helper the pierre worker pool uses) and builds the model; `model` is `null` until then, the `resetPaths`/selection sync effects wait for it, and cleanup calls `model.cleanUp()` and ignores a load that resolves after unmount. A failed chunk fetch logs a warning and the next mount retries. - `ThreadStorageBrowser.tsx`: renders the tree through `LazyThreadStorageFileTree` (new wrapper in `lazySecondaryPanelComponents.tsx`) and shows the existing "Loading files..." state while `model` is `null`. - `bundle-budget.json`: `@pierre/trees` added to the `SplitWorkspaceRoute` forbidden list and to `onDemandPackages` (gate: `ThreadStorageFileTree.tsx`, so no chunk outside that gate may reach it); route budget ratcheted to 10% above the new measurement (2,268,430 raw / 605,332 brotli, from 2,533,484 / 671,561). Route closure, `node scripts/check-bundle-budget.mjs`: before 2260.4 KB raw / 599.1 KB brotli, after 2013.9 KB raw / 537.4 KB brotli (-11% raw, -10% brotli). The tree now ships as `ThreadStorageFileTree-*.js` (253,881 B raw / 64,341 B brotli) fetched when the storage browser first has files. Not in this PR: the composer (`PromptBoxInternal -> tiptap/prosemirror`, ~600 KB raw in the shared `workspace-checkout-display` chunk). It is visible on every thread page, `PromptBoxInternal.tsx` owns the `useEditor` instance across 3,600 lines, and a first-focus handoff has to keep draft restore, autofocus, the mention menu and iOS keyboard-on-tap working. #1894 deliberately left it allowed in the route budget for that reason; it needs its own design. A previous agent's WIP on this branch (a null-rendering "tree model host" component returned from the hook as a ReactNode) was discarded in favour of the imperative model factory above. ## How you verified - New `useThreadStorageBrowser.test.tsx` (real `@pierre/trees` in jsdom, `vi.mock` factories only record when the library is first evaluated): - "loads the tree library only once there are files to show" fails on main's source files with `AssertionError: expected "vi.fn()" to not be called at all, but actually been called 1 times ... "@pierre/trees/react"` and passes on this branch. - "syncs files and selection into the model once it arrives, then destroys it on unmount": the files and `selectedPath` that arrived before the chunk are applied to the model; reconciling selection does not echo through `onSelectPath`; unmount calls `cleanUp()` once. - `node scripts/check-bundle-budget.mjs` with the new `bundle-budget.json` against main's build: `@pierre/trees is in the SplitWorkspaceRoute closure (assets/SplitWorkspaceRoute-9lmZmaba.js). It must load on demand`, exit 1. After rebuilding on this branch: `Bundle budget OK` (including the new on-demand gate check). - `pnpm exec turbo run typecheck --filter=@bb/app --force`, `pnpm exec turbo run lint --filter=@bb/app --force`, `pnpm exec turbo run build --filter=@bb/app`: pass. (The first push of this PR had two TS2322 errors in the new test file: `renderHook(..., { initialProps: { files: undefined } })` inferred the props type as `{ files: undefined }`, so the later `rerender({ files: [] })` calls did not compile and the CI bundle-budget step never ran. The test now declares `initialProps` with an explicit `{ files: readonly WorkspaceFile[] | undefined }` type; the forced typecheck is clean and the fail-before/pass-after result above was re-run with the typed test.) - `pnpm exec turbo run test --filter=@bb/app --force`: all files pass. - Manual, own dev instance + headless Chrome: opened a codex thread with two seeded storage files (`docs/notes.md`, `main.ts`); thread painted; opened the right panel, the "Thread storage" tree rendered `docs` and `main.ts`; clicking `main.ts` opened the file preview tab; switching back to Info showed the same tree (model survived the tab toggle). Fixes #1072 > AGENT GENERATED: by Claude Opus 5 ## Independent verification Round 2, by an independent verifier on a fresh worktree checked out at `3cf9d8d10` (rebased on `origin/main` `2c0b747a5`; `git merge-base --is-ancestor origin/main HEAD` true, `mergeable: MERGEABLE`). Commands run: - `pnpm install --frozen-lockfile --prefer-offline && pnpm exec turbo run build` (18/18 tasks). - `cd apps/app && node scripts/check-bundle-budget.mjs` → `SplitWorkspaceRoute closure: 2013.9 KB raw / 537.4 KB brotli` (budget 2215.3 / 591.1), `Bundle budget OK.` `node scripts/why-eager.mjs --from=views/SplitWorkspaceRoute.tsx node_modules/@pierre/trees` → `0 eagerly reachable module(s) ... only reachable behind a dynamic import (56 modules)`. The tree is emitted as `ThreadStorageFileTree-BVIqkJpc.js` (253,881 B). - `pnpm exec turbo run typecheck --filter=@bb/app --force` → `Tasks: 3 successful, 3 total`, no `error TS` (the round-1 TS2322 errors in the test file are gone). - `pnpm exec turbo run lint --filter=@bb/app --force` → `Tasks: 1 successful, 1 total`. - `pnpm exec turbo run test --filter=@bb/app --force` → `Test Files 415 passed (415)`, `Tests 3191 passed | 3 skipped`. Fail-before / pass-after (`apps/app`, `pnpm exec vitest run src/components/secondary-panel/useThreadStorageBrowser.test.tsx`): - With `bundle-budget.json`, `ThreadStorageBrowser.tsx`, `lazySecondaryPanelComponents.tsx`, `useThreadStorageBrowser.ts` checked out from `origin/main` and `ThreadStorageFileTree.tsx` removed: `1 failed | 1 passed` — `AssertionError: expected "vi.fn()" to not be called at all, but actually been called 1 times` with `1st vi.fn() call: ["@pierre/trees/react"]` at `useThreadStorageBrowser.test.tsx:45:38`. - Restored to the PR tree: `Tests 2 passed (2)`. Repro on the fixed branch (own dev instance, production `apps/app/dist` served on a private port with `/api` proxied, headless Chrome, `performance.getEntriesByType("resource")` with an enlarged buffer; codex thread `thr_52anzhhcu7` seeded with `docs/notes.md` and `main.ts` in its thread-storage dir): - Right panel closed: thread painted; `SplitWorkspaceRoute-BX4iePCW.js` (267,669 B) and `workspace-checkout-display-BuOjOA0-.js` (1,074,222 B) fetched at ~290 ms; no `/thread-storage/files` request and no `ThreadStorageFileTree` chunk at all. - Right panel open on the Info tab: `/thread-storage/files` at 1087 ms, then `ThreadStorageFileTree-BVIqkJpc.js` at 1207 ms; the "Thread storage" tree rendered `docs` and `main.ts`. CI on `3cf9d8d10`: all checks pass (Checks incl. `check-bundle-budget.mjs`, Tests app-1/2/3, integration, packages, server, Package Smoke ubuntu/macos). Residual risks / notes for the maintainer: - The composer edge (`PromptBoxInternal -> @tiptap/*` / `prosemirror-*`, ~600 KB raw inside `workspace-checkout-display`) is still a static import of the thread route; it is named in the issue title and is the largest remaining item behind "no editor parsing on first paint". `bundle-budget.json` allows it by design (#1894). If you want #1072 to keep tracking that edge, change `Fixes #1072` to `Refs #1072` or open a follow-up issue before merging; otherwise this PR closes it. - Behavior change is limited to the storage browser: one extra chunk fetch (and the existing "Loading files..." state) the first time a thread shows storage files; a failed chunk fetch leaves that state, logs a `console.warn`, and retries on the next mount. The model is now created per "files non-empty" span instead of once per `ThreadDetailView` mount, so it is rebuilt after the file list empties and refills; `resetPaths` re-applies expansion from the current search state in both designs, so no visible difference. > AGENT GENERATED: by Claude Opus 5 Co-authored-by: Claude <[email protected]>
What was wrong
The thread git-action toast only offered “Ask agent to fix” when an environment-action HTTP error contained one of three structured failure-detail variants. The current server and host-daemon path never emitted those variants, so the button, follow-up sender, prompt templates, and matching desktop/mobile contract branches were unreachable.
What changed
How you verified
Fixes: N/A — investigation-driven cleanup requested directly.