Repository navigation
Open a sidebar HTML preview full-page in the external browser - #1638
Conversation
The inline-vis external icon in a thread opens the visualization in the sidebar. This adds the second step: the sidebar preview header gains an Open in external browser action that opens the rendered page full-page in the user's default browser. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
🚨 SLOP COP 🚨 · I am the Slop Cop. I am reviewing this pull request for security, code quality, performance, architecture, and user behavior. |
| "shrink-0 text-muted-foreground hover:bg-state-hover hover:text-foreground", | ||
| )} | ||
| onClick={() => { | ||
| openUrlInExternalBrowser( |
There was a problem hiding this comment.
🚨 slopcop/review — The new action opens workspace HTML as a top-level page on the trusted bb host.
The CSP gives the page an opaque origin, but it still permits scripts and outbound requests. A malicious file can show a false bb login page and send entered secrets elsewhere. The address bar still shows the trusted bb host. Please use a separate untrusted host. A trusted wrapper with a fixed warning and sandboxed iframe is another safe option. Add a test that proves preview content cannot replace or hide the warning.
| "shrink-0 text-muted-foreground hover:bg-state-hover hover:text-foreground", | ||
| )} | ||
| onClick={() => { | ||
| openUrlInExternalBrowser( |
There was a problem hiding this comment.
🚨 slopcop/review — Electron sends this URL to the system browser, which does not share the Electron Connect cookie.
Connect returns a sign-in page when the system browser has no owner cookie. The action then fails to open the preview immediately. Please add a secure browser handoff or another authentication flow that ends at the preview. Add a test for a paired desktop user with no system-browser cookie.
There was a problem hiding this comment.
🚨 SLOP COP 🚨 · review
Plain-English summary
This change adds a globe button to rendered HTML previews in the sidebar. The button opens the HTML as a full page in the system browser.
Findings
- Medium — A preview can show a false bb page on the trusted bb host. The server CSP blocks cookie and storage access. However, scripts can still run and send entered data elsewhere. A malicious file can copy a bb login page while the address bar shows the trusted host. Use an untrusted preview host or a trusted wrapper with a fixed warning.
- Medium — The Electron Connect path can show a sign-in page instead of the preview. Electron stores its Connect cookie in its own session. The system browser does not share that cookie. Add a secure handoff or an authentication flow that returns to the preview.
Review details
- The change uses the shared external-browser helper. I found no new code duplication that needs a required refactor.
- The code creates no blob URL, timer, subscription, or global event handler. I found no performance or cleanup issue.
- The full app suite passed 347 test files and 2,768 tests. The app type check and
git diff --checkalso passed. - The dev app loaded in a real browser. Its isolated data had no projects or threads, so the full sidebar click path was unavailable.
- The browser and dev server stopped after the test.
The final GPT-5.6 review gate marked both medium issues as required fixes. I posted this as a comment-only review, as required by this rule.
## Human comments ## What was wrong Opening an inline visualization as its own page took two clicks. The card's open icon was a `<button>` that only opened the right panel, and "Open in external browser" (#1638) lives only in the panel's toolbar. The card had no way to reach the rendered page directly. Requested in Discord #feature-requests ("Would you be open to adding a link to open artifacts on new page from inline viz?"). ## What changed - `plugins/inline-vis/app.tsx`: on HTML previews the existing open icon is now a real link (`<a href={rawFileUrl} target="_blank">`) to the same raw-file URL the iframe and the panel's globe action already use. - A plain click (or Enter) is prevented and still opens the right panel, unchanged. - Cmd/Ctrl/Shift-click and middle-click fall through to the platform: a new tab on the web; in desktop bb the existing `setWindowOpenHandler` sends them to `shell.openExternal`, i.e. the default browser. - The tooltip names the gesture: "Open in sidebar / ⌘-click to open in the browser" ("Ctrl-click" off macOS). - Markdown previews keep the sidebar-only button, matching the panel, which has no external action for Markdown. - No new chrome on the card, no SDK, server, or wire changes. Raw file responses already carry `Content-Security-Policy: sandbox allow-scripts`, so the opened page has an opaque origin. - README and PLUGIN_OVERVIEW describe the gesture. Out of scope, same gap: file links in messages (Cmd-click still opens the panel; the href is `file://`), `ExperimentalFileLink` (its href is `./<path>`, so Cmd-click opens a meaningless page), and file mention pills and attachment chips (buttons, no href). See #2288 for the web-link variant. ## How you verified - `pnpm exec turbo run typecheck test lint --filter=bb-plugin-inline-vis --filter=@bb/bundled-plugins`: pass. The one lint warning was already there. - New test: Cmd/Ctrl/Shift clicks are not prevented and do not open the panel; a plain click is prevented and calls `experimental_openFilePreview`. - `pnpm start:worktree` on a fresh store, with a real agent turn emitting `::inline-vis{file="report.html"}` and a Markdown directive, driven by real mouse and touch input in Chromium: - Plain click opened the right panel; no tab, and the app URL was unchanged. - Cmd-click and middle-click each opened `/api/v1/environments/<id>/files/report.html` as a rendered page in a new tab, without opening the panel. - Keyboard focus and Enter open the panel. - At 390px with touch, a tap opens the full-screen panel. - Desktop, using a minimal harness on the repo's Electron 44.3.0 with the same window-open handler as `desktop-window-factory.ts` (not the packaged app): - Plain click stays in-page. - Cmd-click and middle-click reach the handler with the absolute URL (`disposition: background-tab`), which the real app passes to `shell.openExternal`. - Ctrl-click on macOS is a secondary click, as expected. - Not run: native iOS long-press, Windows/Linux Ctrl-click. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
An inline visualization in a thread (
::inline-vis{file="…"}) has an external icon whose click opens the file in the sidebar. This adds the second step: once it is open there, the sidebar preview header gains an Open in external browser action that opens the visualization full-page in the user's default browser.The first click is unchanged —
plugins/inline-vis/app.tsxis untouched, so the in-thread icon still only ever opens the sidebar.Decisions worth reviewing
Globe, notExternalLink.OpenInEditorButtonalready rendersExternalLinkin this same toolbar; reusing it produced two identical adjacent icons.Globeis the codebase's browser signifier (BrowserTabContent,NewTabFileSearch,ThreadDetailView). The existing "Open in editor" affordance is untouched and still works.apps/desktop/src/main.tsparses withnew URL(payload)and no base — a relative path throws into a barereturn, i.e. a dead button with no error.toAbsolutePreviewUrlis what makes the desktop path work; a test pins it.openUrlInExternalBrowser, deliberately notuseOpenUrlByPreference. The latter honours the in-app-browser preference and would route the visualization to bb's in-app browser panel, which is not "the user's default external browser".htmlandiframestates) and is absent for text/markdown/csv. A negative test pins that.Verification
Gates on this branch, rebased onto current
main(includes #1630 and #1635):tsc --noEmitclean ·FilePreview.test.tsx19/19 ·plugins/inline-vis16/16 unchanged · ESLint 0 errors (4 pre-existingset-state-in-effectwarnings on lines this diff does not touch).Driven through the real UI in an isolated dev instance, three assertions:
The served route returns
200 text/htmlwith nocontent-disposition, so it renders rather than downloads. It carriescontent-security-policy: sandbox allow-scripts, which also applies to the top-level document: scripts run and relative assets load, butlocalStorage/cookies/same-origin fetches are unavailable — identical to what the sidebar iframe already imposes. The CSP is the security boundary for arbitrary worktree HTML and is deliberately left alone.Known gap
The live click-through exercised the browser dispatch (
window.open). The desktop dispatch (shell.openExternal→ OS default browser) is covered by a unit test assertingopenExternalUrlreceives the absolute URL, and the main-process consumer was confirmed by readingmain.ts, but the IPC hop itself was not exercised by clicking inside a packaged Electron build.Fixes #1842
BB-Thread-ID: thr_zhe3sbcbgx