Repository navigation
Conversation
|
🚨 SLOP COP 🚨 · I’m reviewing this now. I’ll check the change for security problems, general code quality and architectural duplication, performance regressions, and—where the local setup permits—exercise the Markdown-image flow end to end in a real browser. I’ll post one consolidated review when those passes are complete. |
| threadId: threadId ?? null, | ||
| linkRouting: markdownLinkRouting, | ||
| resolveRelativeSrc: (path) => { | ||
| if (threadId && source.kind === "working-tree") { |
There was a problem hiding this comment.
🚨 slopcop/review — Revision previews resolve images from the live checkout.
For source.kind === "head" or "merge-base", the Markdown body is read through diffFile with the appropriate Git ref, but this branch sends relative images to the ordinary project-content route, which reads the current environment. If an image changed or was deleted between the selected revision and the working tree, the preview shows the wrong bytes or a 404. Please add a raw revision-aware file-content route that preserves EnvironmentFilePreviewSource/ref and cover both head and merge-base assets.
| const primaryHost = usePrimaryHost({ enabled: skill !== null }); | ||
| const previewHostId = | ||
| primaryHost?.status === "connected" ? primaryHost.id : null; | ||
| const skillFilePreview = useHostFilePreview( |
There was a problem hiding this comment.
🚨 slopcop/review — Server-owned skill images are leased from the primary host.
The catalog also contains bb-builtin, server data-dir bb-user, and BB plugin skills; skill-listing.ts explicitly resolves those files on the server filesystem. Sending their filePath to the primary host works only when server and host happen to share that path, so images fail with a remote primary host. This hook also rereads SKILL.md after creating the lease even though useSkillContent already fetched it. A skill-aware asset endpoint that selects server storage versus the workspace host, paired with a lease-only client query, would fix both the routing gap and duplicate read.
| buildMarkdownMessageLinkRouting({ | ||
| onOpenLink, | ||
| onOpenLocalFileLink, | ||
| threadId, |
There was a problem hiding this comment.
🚨 slopcop/review — Agent-sent images resolve against the recipient thread.
Agent-origin messages carry sourceThreadId, and the server permits that sender to live in a different project/environment, but this routes image paths through the current/recipient threadId and workspace root. Cross-host messages therefore request the sender's path from the wrong machine (or can display a same-named recipient file). Select the source thread for agent messages and use its worktree route for relative paths; keep recipient routing only for system-generated content. A cross-environment sender test would catch this.
| environmentId, | ||
| environmentProjectId, | ||
| environmentRootPath, | ||
| markdownLinkRouting, |
There was a problem hiding this comment.
🚨 slopcop/review — The fresh image resolver defeats Markdown memoization.
ThreadDetailView constructs a new markdownLinkRouting object on each render, so this dependency rebuilds resolvedMarkdownLinkRouting and its resolveSrc closure every time. MarkdownPreview's comparator requires resolveSrc identity, which means an open Markdown document is reparsed during unrelated thread/timeline renders (including streaming). Stabilize the caller routing or derive a stable resolver from primitive route inputs, and add a render-count regression test.
| }, | ||
| (result) => { | ||
| const headers = new Headers({ | ||
| "cache-control": "no-store", |
There was a problem hiding this comment.
🚨 slopcop/review — Newly routed image responses cannot use their ETags.
The browser flow confirms these image URLs return Cache-Control: no-store alongside an ETag. Now that Markdown previews reuse this lease for potentially many images, toggling/reopening the preview downloads every body again. Keep the strict HTML policy, but consider private, no-cache plus If-None-Match for non-HTML assets (or bounded versioned URLs) so correctness is preserved while unchanged image bytes can be reused.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary: this PR teaches more Markdown views to load images that live beside local files, instead of asking the web app for paths it cannot serve. It also centralizes several server handlers that read file bytes from a BB host.
The ordinary working-tree flow works end to end, and I found no security issue in the new path handling. I did find three correctness gaps and two performance regressions worth fixing before landing:
- Historical
headandmerge-baseMarkdown previews read the document from the selected Git revision but fetch its images from the live checkout, so changed/deleted assets can be wrong or missing. - Skill image leases always target the primary host even though built-in, BB-user, and BB-plugin skills can be server-owned. That breaks when the server and primary host do not share a filesystem; the same path also downloads
SKILL.mda second time solely to obtain the lease. - Agent-origin messages use the recipient thread/environment for image URLs rather than
sourceThreadId, so cross-project or cross-host agent messages can 404 or display the wrong same-named file. - File-preview routing now creates a fresh
resolveSrcclosure on unrelated parent renders, defeatingMarkdownPreview's memo comparator and reparsing an open document during timeline updates. - The newly reused image endpoints return
Cache-Control: no-store. The ETag is therefore not useful to the browser, and reopening a preview redownloads unchanged image bodies.
The server-side serveDaemonFileContent extraction itself looks good: it preserves host/root selection, timeout/retry behavior, response construction, and error remapping. I also scanned the remaining direct host.read_file call sites; they serve distinct JSON/command responsibilities, so I would not broaden this helper mechanically. The clean architectural seam is a source-aware asset route (revision, server-owned skill, or host-owned file) plus a lease-only query, while keeping contained preview paths separate from trusted message routing.
Verification performed at 8daf5ef78b1a1dd469cda14b7d2c892fcc3e545e:
- App: 7 focused files, 83 tests passed.
- Server: 5 focused files, 100 tests passed.
- App and server typechecks passed;
git diff --checkpassed. - Current GitHub CI is green (the iOS and Node compatibility matrix jobs are skipped).
- Real browser: started an isolated source dev app, created a disposable project/thread, opened a Markdown fixture through the BB file panel, toggled Raw → Preview with doobie, and verified two relative PNGs returned 200 with the expected MIME type and byte dimensions. Both remained loaded after a full page reload.
- The live instance had one local host, so the revision, remote-primary-host, and cross-host sender cases were established from the routing contracts and are not claimed as live passes.
Human comments
What was wrong
Markdown image URLs were only routed to host files when a caller supplied
linkRouting.localImage. Assistant messages supplied it, but file previews and several other Markdown surfaces did not. Consequently, absolute host paths were requested from the app origin and relative paths were resolved against the SPA URL instead of the Markdown file's directory. For example,docs/report.mdcontainingshould loaddocs/images/chart.png.What changed
No public plugin API, CLI, endpoint contract, or server/daemon wire behavior changes; no daemon protocol bump is needed.
How you verified
pnpm exec turbo run typecheck lint test --filter=@bb/app: 481 test files passed; 3,890 tests passed and 3 skipped. App lint completed with 182 warnings and 0 errors.pnpm exec turbo run typecheck lint --filter=@bb/server: typecheck passed (the server package has no lint task).pnpm exec turbo run test --filter=@bb/server -- test/hosts/daemon-file-response.test.ts test/files/host-file-routes.test.ts test/public/public-projects-local-host.test.ts test/public/public-project-workspace-routing.test.ts test/public/public-thread-data.test.ts: 5 files / 100 tests passed, including byte responses, root propagation, host selection, validators, HTML policies, and error mapping.pnpm start:worktree; confirmed HTTP 200 and daemon connectivity. The dev QA thread has workspace and thread-storage fixtures; the other preview types are covered by automated tests, not completed manual demos.No linked GitHub issue.