Skip to content

feat(site/src): open open_preview results in the right panel - #32441

Draft
DanielleMaywood wants to merge 1 commit into
open-preview/toolfrom
open-preview/ui
Draft

DanielleMaywood wants to merge 1 commit into
open-preview/toolfrom
open-preview/ui

Conversation

@DanielleMaywood

@DanielleMaywood DanielleMaywood commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Renders open_preview results in the Agents chat. For the workspace owner, the result has an Open preview button. Anyone else sees why they can't open it: only the workspace owner can, or the preview belongs to a different workspace. Nothing opens until the owner clicks.

The preview tab asks coderd for the preview's address and loads it inside a srcdoc wrapper frame whose CSP allows only that preview's origin, with the sandbox the server returns. The UI never builds a preview hostname. If the preview host has no session, it tells the dashboard, which signs in once and reloads the frame, so reopening or reloading a preview does not create a new API key. Opening a newer result for the same preview renames its tab and reloads it. Previews open only in the chat's right panel; opening a preview address directly shows an error page (#32439).

Results are parsed by shape, the title rule is checked again because the user decides by title, and the server enforces the slug and url_path rules. With the experiment disabled, the button is hidden and saved preview tabs are hidden until it is enabled again.

A manual pass in Safari 27.2 on macOS against an HTTPS deployment passed on an earlier version of this PR, before sign-in moved to on demand: file and port previews signed in and loaded inside the wrapper, every preview response carried the CSP, and the test page's fetch to the dashboard, top navigation and popup were all blocked. The on-demand sign-in was checked in Chromium and Firefox.

Stack (review bottom-up). Replaces the closed #31282 stack. Security review: coder/security-assessments#437.

  1. feat: serve published HTML previews from the workspace agent #32438 Agent file previews
  2. feat: serve agent previews on strict preview hosts #32439 Strict preview hosting and experiment
  3. feat: sign previews in from the dashboard with a host-bound token #32522 Preview sign-in
  4. feat(coderd): add the open_preview chat tool #32440 open_preview chat tool
  5. feat(site/src): open open_preview results in the right panel #32441 Agents UI, this PR
  6. docs: document open_preview previews #32442 Docs

🤖 Generated with Claude Code

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-11-26 13:57 UTC by @DanielleMaywood
Spend: $93.55 / $100.00

Review history
  • R1 (2026-11-25): 12 reviewers, 5 Nit, 8 P3, 7 P4, COMMENT. Review
  • R2 (2026-11-25), 5 Nit, 8 P3, 7 P4, COMMENT. Review
  • R3 (2026-11-25), 5 Nit, 8 P3, 7 P4, COMMENT. Review
  • R4 (2026-11-25): 13 reviewers, 9 Nit, 12 P3, 13 P4, COMMENT. Review
  • R5 (2026-11-26): 12 reviewers, 9 Nit, 12 P3, 14 P4, COMMENT. Review
  • R6 (2026-11-26): 4 reviewers, 9 Nit, 12 P3, 15 P4, COMMENT. Review
  • R7 (2026-11-26): 4 reviewers, 9 Nit, 12 P3, 15 P4, COMMENT. Review
  • R8 (2026-11-26): 4 reviewers, 9 Nit, 12 P3, 15 P4, APPROVE. Review
  • R9 (2026-11-26): 4 reviewers, 9 Nit, 12 P3, 15 P4, COMMENT. Review
  • R10 (2026-11-26): 4 reviewers, 9 Nit, 12 P3, 15 P4, COMMENT. Review

deep-review v0.13.1 | Round 10 | 0be9a55..b1c1ead

Last posted: Round 10, 36 findings (12 P3, 15 P4, 9 Nit), COMMENT. Review

Finding inventory

Finding inventory, PR #32441

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P3 Author fixed (16f0f81) OpenPreviewTool.tsx:40 parseOpenPreviewResult never checks kind despite PR claim R1 Netero Yes
CRF-2 P3 Author fixed (16f0f81) OpenPreviewTool.tsx:20 Comment cites nonexistent CheckURLPath in previewhost.go R1 Netero Yes
CRF-3 P3 Author fixed (16f0f81) AgentChatPageView.tsx:696 No test covers the experiment gate on the Open preview button R1 Netero Yes
CRF-4 P4 Author fixed (16f0f81) OpenPreviewTool.tsx:31 Slug regex accepts ports 65536-99999 that the server rejects R1 Netero Yes
CRF-5 P4 Author contested; panel closed R4 (1/1 accept) rightPanelTabs.ts:169 getMatchingAgentOrFirst fallback never applies for preview tabs R1 Netero Yes
CRF-6 P3 Author fixed (16f0f81) AgentChatPageView.tsx:579 Re-opening an existing preview only activates the stale tab, no reload, old label R1 Nami P3, Hisoka P4 Yes
CRF-7 P3 Author fixed (16f0f81) OpenPreviewTool.tsx:75 Button shown to non-workspace-owners; sign-in always 404s for them R1 Melody Yes
CRF-8 P3 Author accepted R6 (operator decision for the experimental release, no ticket; panel 2/2 accept R5) OpenPreviewTool.tsx:90 Row with hidden button shows bare title and no reason R1 Leorio P3, Nami P4 Yes
CRF-9 P3 Author fixed (16f0f81) OpenPreviewTool.tsx:41 Client copies of slug/url_path rules enforce nothing server does not; drift hides button R1 Pariston, Bisky Yes
CRF-10 P3 Author fixed (d156c13, in #32438) rightPanelTabs.ts:165 Restored file preview tabs and old buttons 404 after agent restart with no hint R1 Hisoka Yes
CRF-11 P4 Author fixed (16f0f81) Tool.tsx:1170 MCP branch of OpenPreviewRenderer is unreachable; comment premise false R1 Mafuuu, Melody, Knov Yes
CRF-12 P4 Author fixed (16f0f81) PreviewFrame.tsx:52 Each reload/remount mints a new long-lived application_connect key R1 Pariston Yes
CRF-13 P4 Author fixed (16f0f81) OpenPreviewTool.tsx:78 workspaceId guard on the button is untested R1 Bisky Yes
CRF-14 P4 Author fixed (16f0f81, PR description) rightPanelTabs.ts:167 Experiment off hides saved preview tabs; description says dropped R1 Mafuuu Note, Hisoka Note Yes
CRF-15 P4 Author contested; panel closed R4 (1/1 accept) PreviewPanel.tsx:13 PreviewPanel vs PortPreviewPanel naming hides that both show ports R1 Gon P3 Yes
CRF-16 Nit Author contested; panel closed R6 (1/1 accept) OpenPreviewTool.tsx:16 Bare 80/2048 literals copy Go constants R1 Gon P3 Yes
CRF-17 Nit Author contested; panel closed R5 (1/1 accept) api.ts:4428 Doc comments restate symbol names or JSX (6 locations) R1 Gon P2 Yes
CRF-18 Nit Author contested; panel closed R4 (1/1 accept) rightPanelTabs.ts:74 Tab field slug should be previewSlug R1 Gon Yes
CRF-19 Nit Author fixed (16f0f81) PreviewFrame.tsx:37 signIn holds a response; name signInResponse R1 Gon Yes
CRF-20 Nit Author contested; panel closed R4 (1/1 accept) AgentChatPage.test.tsx:769 Test name omits that it clicks twice R1 Leorio Yes
CRF-21 Nit Dropped by orchestrator (site FE1 mandates Vitest/RTL for behavior and forbids play assertions) PreviewFrame.test.tsx:1 New standalone RTL test file for a component R1 Pariston, Bisky, Knov No
CRF-22 Nit Dropped by orchestrator (site FE1 forbids assertions in play functions) Tool.stories.tsx:3063 OpenPreviewCompleted story has no play function checking spy R1 Bisky No
CRF-23 Nit Dropped by orchestrator (each reload frames a new document; previews.ts doc defines frameId per frame) PreviewFrame.tsx:33 Rename frameId to signInAttemptId R1 Gon No
CRF-24 Note Note (body) PR description "the routing PR" is not in the stack list R1 Leorio P4 No
CRF-25 P2 Dropped by orchestrator (comment states the limit is the server's; CRF-2 rewrites this comment) OpenPreviewTool.tsx:21 "limits the path to 2048 bytes" restates line 26 R1 Gon No
CRF-26 P2 Dropped by orchestrator (exported component contract; caller needs button conditions without reading body) OpenPreviewTool.tsx:62 OpenPreviewTool doc lists conditions in the expression R1 Gon No
CRF-27 P2 Dropped by orchestrator ("in the right panel" names the destination, not in name or type) ChatWorkspaceContext.tsx:11 openPreview doc restates field name R1 Gon No
CRF-28 Note Dropped by orchestrator (cleared; no change requested) PreviewFrame.tsx:62 srcdoc wrapper runs as dashboard origin; escaping and CSP hold R1 Kurapika No
CRF-29 Note Dropped by orchestrator (cleared; no change requested) OpenPreviewTool.tsx:76 Button scoping and sign-in authorization verified R1 Kurapika No
CRF-30 Note Dropped by orchestrator (cleared; no change requested) OpenPreviewTool.tsx:37 Go/TS pairings walked and in agreement R1 Melody No
CRF-31 Note Dropped by orchestrator (cleared; no change requested) PreviewPanel.tsx:18 Preview tab states all handled with stories R1 Nami No
CRF-32 Note Dropped by orchestrator (cleared; no change requested) AgentChatPage.test.tsx:769 Page-level preview tests catch regressions (mutation verified) R1 Bisky No
CRF-33 Note Dropped by orchestrator (cleared; no change requested) Tool.tsx:1170 Comments state condition and consequence R1 Leorio No
CRF-34 Note Dropped by orchestrator (cleared; no change requested) PreviewFrame.tsx:84 Wrapper enforces origin invariant R1 Knov No
CRF-35 OOS Fixed in base 004cc93 (verified R9) coderd/x/chatd/chattool/openpreview.go:166 Tool returns success for workspace chat owner does not own R1 Melody No
CRF-36 OOS Out of scope (body) coderd/workspaceapps/preview.go:108 New app_connect key per sign-in, never revoked; expired token rejected despite session cookie R1 Pariston, Knov No
CRF-37 OOS Out of scope (body) agent/agentpreview/preview.go:69 File preview IDs only in agent memory R1 Hisoka No
CRF-38 OOS Out of scope (body) coderd/previews.go:69 Sign-in does not check the file preview is published R1 Hisoka No
CRF-39 OOS Out of scope (body) coderd/x/chatd/chattool/openpreview.go:138 checkURLPath limits bytes but error says characters R1 Gon No
CRF-40 P4 Author contested; panel closed R5 (1/1 accept) OpenPreviewTool.tsx:70 Agent mismatch shows "belongs to a different workspace" R4 Netero Yes
CRF-41 P3 Author accepted R7 (operator decision for the experimental release, no ticket; Melody accept R5, Pariston deferred to a human R6) AgentChatPageView.tsx:608 Embedded chat (VS Code) offers Open preview that cannot load or sign in R4 Melody, Pariston Yes
CRF-42 P3 Author fixed (4ac23c2) PreviewFrame.tsx:53 Reload preview does nothing after the address request fails R4 Nami, Mafuuu Yes
CRF-43 P3 Author fixed (5421940, in #32522) PreviewFrame.tsx:98 Second sign-in-needed message dropped; panel shows bare 401 page with no cause R4 Leorio Yes
CRF-44 P3 Author contested; panel closed R5 (1/1 accept) AgentChatPage.test.tsx:860 Experiment-off test waits for getWorkspace call, not render; passes vacuously under delay R4 Komugi Yes
CRF-45 P4 Author accepted R6 (operator decision for the experimental release, no ticket; panel 1/1 accept R5) PreviewFrame.tsx:60 Frame keyed only on reloadCount; cached region switch keeps old region's sign-in URL R4 Knov Yes
CRF-46 P4 Author fixed (4ac23c2) AgentChatPageView.tsx:306 Comment says a page load loads every preview; PreviewPanel loads lazily R4 Mafuuu P4, Leorio Nit Yes
CRF-47 P4 Author fixed (4ac23c2) PreviewFrame.tsx:111 Sign-in failure branch and Reload recovery untested R4 Bisky Yes
CRF-48 P4 Author fixed (4ac23c2) AgentChatPage.test.tsx:989 Page test's Reload part duplicates PreviewFrame.test.tsx R4 Bisky Yes
CRF-49 P4 Author fixed (4ac23c2) OpenPreviewTool.tsx:33 Comment names only sign-in as the validator; address request validates on every mount R4 Gon P3 Yes
CRF-50 Nit Author fixed (4ac23c2) AgentChatPage.test.tsx:849 toBeInTheDocument presence assertions (FE1) on getByTitle results R4 Bisky Yes
CRF-51 Nit Author contested; panel closed R5 (1/1 accept) AgentChatPage.test.tsx:846 Test comment restates the next two lines R4 Gon P2 Yes
CRF-52 Nit Author contested; panel closed R5 (1/1 accept) PreviewPanel.tsx:11 reloadCount names two different counters R4 Gon Yes
CRF-53 Nit Author contested; panel closed R5 (1/1 accept) PreviewFrame.tsx:121 frame holds a sign-in response next to frameRef (the iframe) R4 Gon Yes
CRF-54 Nit Dropped by orchestrator ("on request" reads as on demand; doc comment states when it signs in) PreviewFrame.tsx:82 Rename SignInOnRequestFrame R4 Gon No
CRF-55 Note Note (body) commit 16f0f81 message Commit body still says saved preview tabs are dropped R4 Leorio P4 No
CRF-56 Note Note (body) AgentChatPage.test.tsx:782 Two page tests took 5.5-5.7s on a cold cache (5s default timeout) R4 Bisky No
CRF-57 Note Note (body) PreviewFrame.tsx:35 Proxy auto-switch reloads an open preview and discards a pending sign-in R4 Komugi No
CRF-58 Note Dropped by orchestrator (cleared; no change requested) PreviewFrame.tsx:97 Wire pairings (message string, origin, source, types, routes) agree R4 Melody No
CRF-59 Note Dropped by orchestrator (cleared; fix verifications) PreviewFrame.tsx:93 CRF-12 and CRF-9 fixes verified R4 Pariston No
CRF-60 Note Dropped by orchestrator (cleared; mutation-verified) PreviewFrame.test.tsx:129 New sign-in and gate tests catch regressions R4 Bisky No
CRF-61 Note Dropped by orchestrator (cleared; no change requested) ChatWorkspaceContext.tsx:15 previewAccess union and region-free props rule out bad states R4 Knov No
CRF-62 OOS Out of scope (body) coderd/previews.go:44 Address endpoint reuses PreviewSignInRequest/Response types R4 Netero, Gon, Leorio No
CRF-63 OOS Out of scope (body) coderd/workspaceapps/preview.go:163 Signed-out page says "Reopen from Coder" and offers Back to site, blocked by frame-src R4 Leorio, Knov No
CRF-64 OOS Out of scope (body) coderd/workspaceapps/preview.go:172 Signed-out page posts to window.top with AccessURL origin R4 Melody, Pariston No
CRF-65 OOS Out of scope (body) coderd/workspaceapps/preview.go (session cookie) Preview session cookie not kept when preview host is cross-site with dashboard R4 Leorio No
CRF-66 P4 Author contested; panel closed R6 (1/1 accept) PreviewFrame.tsx:103 Sign-in-needed after a successful sign-in is dropped silently; test at :160-163 locks it in R5 Chopper P3 Yes
CRF-67 P4 Author accepted R8 (operator decision for the experimental release, no ticket; panel 1/1 accept R7) AgentChatPageView.tsx:608 previewAccess.open accepts any workspace/agent; only OpenPreviewTool repeats the match check R6 Meruem Yes
CRF-68 Note Note (body) AgentChatPageView.tsx:577 "Same preview" identity predicate is inline in the view; only page tests cover it R6 Meruem No

Contested and acknowledged

CRF-5 (P4, rightPanelTabs.ts:169) - getMatchingAgentOrFirst fallback never applies for preview tabs

  • Finding: Netero: preview tabs use getMatchingAgentOrFirst, whose first-agent fallback cannot trigger because isUserRightPanelTab rejects empty agentName; proposed a plain find by name at both call sites for readability.
  • Author defense (R3, PRRC_kwDOGkVX1s8AAAABGD80DQ): "Declined: behavior is the same because preview tabs always carry an agent name; cheap to revisit."
  • Status: contested, awaiting panel (Netero) check-in.
  • Panel closure (R4, 1/1): Netero, the agent that raised it (reused R1 agent), traced both tab creation paths (isUserRightPanelTab rejects ""; new tabs only via previewAccess.open, which requires workspaceAgent, and OpenPreviewTool requires preview.agentName === agentName) and accepted: readability cost only, no failure mode.

CRF-16 (Nit, OpenPreviewTool.tsx:16) - Bare 80/2048 literals copy Go constants

  • Finding: Gon: 80 and 2048 copy Go constants as bare literals; proposed named constants citing the Go names.
  • Author defense (R3, PRRC_kwDOGkVX1s8AAAABGD83rg): the 2048 copy was removed in 16f0f81 because sign-in now checks url_path; the title limit 80 stays inline in its only check.
  • Status: contested, awaiting panel (Gon) check-in.
  • Panel re-raise (R4): Gon (reused R1 agent) verified 2048 is gone and held for 80: if maxPreviewTitleLength is raised, results with longer titles render as a bare title with no button and no reason, and nothing on the TS line points to the Go constant.

CRF-15 (P4, PreviewPanel.tsx:13) - PreviewPanel vs PortPreviewPanel naming hides that both show ports

  • Finding: Gon: PreviewPanel (kind: "preview") also shows port previews next to the existing PortPreviewPanel (kind: "port"); proposed naming the new panel and kind after the tool (AgentPreviewPanel, kind: "agent_preview").
  • Author defense (R4, PRRC_kwDOGkVX1s8AAAABGEFFNw): kind: "port" and PortPreviewPanel exist on main for the port forwarding panel, so preview names what this tab shows (an open_preview result) without colliding, and the PreviewPanel doc says it shows a port or file preview that the agent opened with open_preview.
  • Status: contested, awaiting Gon check-in.
  • Panel closure (R4, 1/1): Gon, the agent that raised it (reused R1 agent), accepted: cost is navigation time only; the UserTabPanel switch maps kind: "preview" to PreviewPanel in one place and the doc says it shows port and file previews.

CRF-18 (Nit, rightPanelTabs.ts:74) - Tab field slug should be previewSlug

  • Finding: Gon: the tab field slug renames the API's preview_slug and reads as an app slug in a module that also stores workspace app tabs.
  • Author defense (R4, PRRC_kwDOGkVX1s8AAAABGEFGOw): slug sits on the preview tab variant only, next to kind: "preview", so TypeScript narrows it before any read and it cannot be confused with an app tab's fields; renaming touches every preview tab test for no behavior change.
  • Status: contested, awaiting Gon check-in.
  • Panel closure (R4, 1/1): Gon (reused R1 agent) accepted: every read narrows to kind: "preview" first and workspace app tabs have no slug field (they store appId).

CRF-20 (Nit, AgentChatPage.test.tsx:769) - Test name omits that it clicks twice

  • Finding: Leorio: the name "opens a result's tab from its row once" does not say the test clicks twice.
  • Author defense (R4, PRRC_kwDOGkVX1s8AAAABGEFHKA): the name says the result opens its tab once, which is the asserted behavior; the two clicks are setup; the suggested name describes the same assertion in more words.
  • Status: contested, awaiting Leorio check-in.
  • Panel closure (R4, 1/1): Leorio (reused R1 agent) accepted: the name states the asserted behavior and is not false; the body is 20 lines.

CRF-8 (P3, OpenPreviewTool.tsx:90) - Row with hidden button shows bare title and no reason

  • Finding: Nami, Leorio: when previewAccess is unset (experiment off, or a stopped workspace with no agent in the latest build) the row shows only the title, no button and no reason; asked for an unavailableReason for those cases.
  • Author response: Acknowledged (R5, PRRC_kwDOGkVX1s8AAAABGH7hbA): hiding previews completely while the experiment is off is the chosen behavior; agrees a stopped owner workspace shows no button and no reason, and leaves it because the button appears once the workspace has an agent again.
  • Status: awaiting R5 check-in by the raising persona.
  • Panel (R5): Gon (reused R1 agent) re-raises: the reply explains why the copy exists, not how someone raising maxPreviewTitleLength finds it; one clause on the line 8 comment fixes it.
  • Panel (R5): Nami (reused R4 agent) and Leorio (reused R1 agent) accept: the experiment-off case matches the chosen design, and a stopped owner workspace regains the button when the agent connects. Recorded as Author accepted.

CRF-41 (P3, AgentChatPageView.tsx:608) - Embedded chat (VS Code) offers Open preview that cannot load or sign in

  • Finding: Melody, Pariston: previewAccess ignores isEmbedded; preview CSP frame-ancestors and the signed-out page's window.top.postMessage both assume the dashboard is top-level; asked for an unavailableReason when embedded.
  • Author response: Acknowledged (R5, PRRC_kwDOGkVX1s8AAAABGH7WUg): agrees an embedded preview is unlikely to load; previews in this experiment target the dashboard and the embedded case was not reproduced, so the embedded chat is left unchanged.
  • Status: awaiting R5 check-in by the raising persona.
  • Panel (R5): Melody (reused R4 agent) accepts. Pariston (reused R4 agent) re-raises with new evidence: a Playwright Chromium reproduction (/tmp/pariston-embed/repro.mjs, three origins, PR wrapper markup, server sandbox and CSP) shows the preview frame refused and no sign-in message when the dashboard is framed. The author's stated reason (not reproduced) no longer holds. Stays open.

CRF-45 (P4, PreviewFrame.tsx:60) - Frame keyed only on reloadCount; cached region switch keeps old region's sign-in URL

  • Finding: Knov: SignInOnRequestFrame keeps signInMutation.data across an address change when the new region's address is cached; asked to key on the address too.
  • Author response: Acknowledged (R5, PRRC_kwDOGkVX1s8AAAABGH7Ztw): reproduces at component level, but the Agents page has no region control and latency auto-select runs once, so a switch back to a cached region within a mount needs a proxy health change.
  • Status: awaiting R5 check-in by the raising persona.
  • Panel (R5): Knov (reused R4 agent) accepts: /agents renders outside DashboardLayout, so no ProxyMenu/setProxy caller; regions query has infinite staleTime. Recorded as Author accepted.

CRF-16 (Nit, OpenPreviewTool.tsx:16) - Bare 80 literal copies a Go constant

  • Finding: Gon re-raised R4: if maxPreviewTitleLength is raised, longer titles lose the button with no reason; asked for a comment naming the Go constant.
  • Author response: Contested (R5, PRRC_kwDOGkVX1s8AAAABGH7izA): the title check is deliberately a client copy since the user decides by title, and the limit only changes together with the tool, so drift needs a Go change first.
  • Status: awaiting R5 check-in by the raising persona.

CRF-17 (Nit, api.ts:4428) - Doc comments restate symbol names (3 of 6 locations unchanged)

  • Finding: Gon re-raised R4: UserTabPanel.tsx:21, rightPanelTabs.ts:78, chatEntities.ts:240 unchanged.
  • Author response: Contested (R5, PRRC_kwDOGkVX1s8AAAABGH7kLw): these are one-line docs on exported symbols, which the repository requires, and each one is accurate.
  • Status: awaiting R5 check-in by the raising persona.
  • Panel (R5, 1/1): Gon accepts: AGENTS.md requires docs on exported symbols, and all three are exported.

CRF-40 (P4, OpenPreviewTool.tsx:70) - Agent mismatch shows 'belongs to a different workspace'

  • Finding: Netero: one message for workspace and agent mismatch; asked for an agent-specific reason.
  • Author response: Contested (R5, PRRC_kwDOGkVX1s8AAAABGH7X_Q): the tool takes the agent name from the chat's own workspace agent, so a same-workspace mismatch needs a rebuild that renames the agent; one reason keeps the row short.
  • Status: awaiting R5 check-in by the raising persona.
  • Panel (R5, 1/1): Netero (reused R1 agent) accepts: the tool sets AgentName from the chat's own agent, so the mismatch needs a rename rebuild; the user can ask the agent to open it again.

CRF-44 (P3, AgentChatPage.test.tsx:860) - Experiment-off test waits for getWorkspace call, not render

  • Finding: Komugi: test passes with the gate removed when getWorkspace resolves 150 ms late; asked to wait on rendered workspace state.
  • Author response: Contested (R5, PRRC_kwDOGkVX1s8AAAABGH7gDA): removing the gate fails the test with the suite's mocks; agrees it waits for the request, but the workspace mock resolves immediately in every case.
  • Status: awaiting R5 check-in by the raising persona.
  • Panel (R5, 1/1): Komugi (reused R4 agent) accepts: with the gate removed, 42 of 42 runs (incl. single-core taskset -c 0) found the button and failed; mockResolvedValue fixes the order. The test would go vacuous only if the mock later adds a delay.

CRF-51 (Nit, AgentChatPage.test.tsx:846) - Test comment restates the next two lines

  • Finding: Gon: delete // Opening the same result again reloads it too.
  • Author response: Contested (R5, PRRC_kwDOGkVX1s8AAAABGH7bMA): the comment marks where the test moves from the newer result to reopening the same one, which the click alone does not say.
  • Status: awaiting R5 check-in by the raising persona.
  • Panel (R5, 1/1): Gon accepts: the comment marks the switch to reopening the same result.

CRF-52 (Nit, PreviewPanel.tsx:11) - reloadCount names two counters

  • Finding: Gon: chat-level counter counts reopenings, PreviewFrame's counts Reload clicks; asked to rename the chat-level chain reopenCount.
  • Author response: Contested (R5, PRRC_kwDOGkVX1s8AAAABGH7cvQ): both are React keys that reload the preview when they change, so one name fits both; the prop doc states what changing it does.
  • Status: awaiting R5 check-in by the raising persona.
  • Panel (R5, 1/1): Gon accepts: no code reads either count as a number; both are keys.

CRF-53 (Nit, PreviewFrame.tsx:121) - frame holds a sign-in response next to frameRef

  • Finding: Gon: one name for two things; asked for target.
  • Author response: Contested (R5, PRRC_kwDOGkVX1s8AAAABGH7eaw): frame is the target the iframe loads (URL, origin, sandbox) and is used only in the next three lines.
  • Status: awaiting R5 check-in by the raising persona.
  • Panel (R5, 1/1): Gon accepts: used only in three attributes of one element; type visible at the declaration.

CRF-41 R6 response

  • Author response (R6, PRRC_kwDOGkVX1s8AAAABGJBK_w): the reproduction runs a copy of the markup and CSP on static pages rather than Coder itself, and the embedded chat was already decided out of scope for this PR.
  • Status: awaiting Pariston R6 check-in (Melody accepted R5).
  • Panel (R6): Pariston (reused R4 agent) does not re-raise for lack of new evidence; the R6 defense does not answer the reproduction (it used the server CSP and sandbox strings and the PR wrapper markup) or the scope point (the diff adds the button the embedded route shows). Stays acknowledged with no fix and no ticket; a human decides.

CRF-16 R6 response

  • Author response (R6, PRRC_kwDOGkVX1s8AAAABGJBMpw): the title check is deliberately a client copy because the user decides by title, and the limit only changes together with the tool, so no cross-reference is added.
  • Status: awaiting Gon R6 check-in.
  • Panel closure (R6, 1/1): Gon (reused R1 agent) accepts with no new evidence; notes both sides still lack a cross-reference after three declines.

CRF-66 (P4, PreviewFrame.tsx:103) - Sign-in-needed after a successful sign-in is dropped silently

  • Finding: Chopper: after this mount's sign-in succeeds, a second coder-preview-sign-in-needed is dropped and the panel stays on the host's 401 page; asked for an in-panel error when the message arrives after signInMutation.isSuccess, and for the test at PreviewFrame.test.tsx:160-163 to expect it.
  • Author response (R6, PRRC_kwDOGkVX1s8AAAABGJBJVw): one sign-in per mount is deliberate because script in the preview can post the same message; the only known way a host loses the new session (a cross-site region) is now refused before the frame loads; for an expired session the host page's advice to reopen is right, because Reload remounts the frame and signs in again.
  • Status: awaiting Chopper R6 check-in.
  • Panel closure (R6, 1/1): Chopper (reused R5 agent) accepts: the R5 example (Secure cookie over HTTP) also breaks the dashboard session cookie (HTTPCookieConfig.Apply), cross-site regions are refused before the frame loads, and an expired session recovers through Reload.

CRF-8, CRF-45 R6

  • Author accepted (R6, PRRC_kwDOGkVX1s8AAAABGJBOOA and PRRC_kwDOGkVX1s8AAAABGJBP3g): "Confirmed for the experimental release (operator decision, no ticket)". This is the human acceptance the R5 review asked for.

CRF-41 R7

  • Author accepted (R7, PRRC_kwDOGkVX1s8AAAABGKBAeg): "Confirmed for the experimental release (operator decision, no ticket): previews target the dashboard, and we accept that the embedded chat shows a button whose preview does not load there." This is the human decision the R6 review asked for.

CRF-67 (P4, AgentChatPageView.tsx:608) - previewAccess.open accepts any workspace/agent; only OpenPreviewTool repeats the match check

  • Finding: Meruem: openPreviewTab does not check workspaceId/agentName, while validateUserRightPanelTabs drops tabs that fail them; a second caller that skips the check persists hidden tabs and selects an ID the tab list omits. Proposed making previewAccess a function of the preview that checks ownership, workspace and agent in one place, and removing agentName from the context.
  • Author response (R7, PRRC_kwDOGkVX1s8AAAABGKA6Ag): agrees a future caller could skip the check; today the tool row is the only caller and checks workspace and agent before opening, so the check stays where the reason text is shown.
  • Status: acknowledged, no fix, no ticket; awaiting Meruem R7 check-in.
  • Panel (R7, 1/1): Meruem (reused R6 agent) accepts: OpenPreviewTool.tsx:66-71 is the only non-test reader of previewAccess and replaces open with the reason before any click; the hazard needs a second caller. No ticket, so the review asks for the operator decision wording used for CRF-8, CRF-41 and CRF-45.

CRF-67 R8

  • Author accepted (R8, PRRC_kwDOGkVX1s8AAAABGKKAkg): "Confirmed for the experimental release (operator decision, no ticket): the workspace and agent match check stays in OpenPreviewTool, the only reader of previewAccess."

Law analysis

R1: not run. Effective additions 979 (threshold 1000). Head de09426.
R4: ran. Effective +1371 -8 (516 production). Head 16f0f81. Verdict: Don't split. Enforcement: Advisory. Asks reviewers to give PreviewFrame.tsx (postMessage origin/source check, srcdoc CSP, single sign-in per mount) dedicated attention.

Round log

Round 1

Full panel (round 1). Netero first pass: 3 P3, 2 P4, no P0, panel proceeded. Law not run (979 effective additions). Panel: ging-ts, ging-react, nami, kurapika, melody (domain specialists), pariston, mafuuu (core), bisky, hisoka, gon, leorio (pool), knov (wildcard). 12 reviewers, multi-domain security-sensitive target 9-12.
Cross-check: CRF-6 merges Nami P3 and Hisoka P4 label mismatch (same code path, same fix). CRF-8 merges Leorio P3 and Nami P4 at the higher severity. CRF-9 contradicts CRF-1/CRF-4 (remove copy vs tighten copy); comment states both options. CRF-7 adds a case to CRF-8.
Downgrades and drops (keep-argument first):

  • CRF-15 P3 to P4. Keep: two panels show ports, only one named for ports. Reason: reader-navigation cost only; the doc comment distinguishes them.
  • CRF-16 P3 to Nit. Keep: drift silently hides the button. Reason: the drift consequence is CRF-9's; naming the literal does not prevent drift; this is a magic-number convention.
  • CRF-17 P2 to Nit, combined. Keep: AGENTS.md requires substantive comments and 9 of 21 restate. Reason: no behavior or comprehension harm; convention violation. CRF-25/26/27 dropped, each comment carries information the code does not.
  • CRF-21/22. Keep: root AGENTS.md says no standalone RTL component tests. Reason: site/AGENTS.md and FRONTEND_PATTERNS.md FE1, scoped to site/, require Vitest/RTL for behavior and forbid play assertions.
  • CRF-23. Keep: value changes per reload. Reason: each reload frames a new document; name matches the documented per-frame meaning.
  • CRF-24 P4 to Note (body). Keep: reviewers cannot locate the routing behavior. Reason: PR text, no file line; posted as a body process note.
  • CRF-14 Note raised to P4 because it asks for a change.
    Verified: mcpclient prefixing (mcpclient.go:1229), postPreviewSignIn owner check (previews.go:64), createAppConnectKey per request, agent in-memory preview map, NewPreviewID per path, ParsePreviewSlug uint16, getMatchingAgentOrFirst fallback, persistence of unfiltered tabs (AgentChatPageView.tsx:319). Leorio's CRF-20 line 131 was a blank line; used Bisky's :769 for the same test.
    8 P3, 7 P4, 5 Nit posted. Reviewed against e37889b..de09426.
    Post-post correction: CRF-3's posted fix asks for a Vitest assertion that no Open preview button renders. FE1 forbids presence assertions in Vitest (shown/hidden goes to a story screenshot). Next round: when verifying CRF-3, accept an FE1-compliant fix (a story with openPreviewEnabled: false showing the row, or a non-visual assertion such as no signInToPreview call and no persisted tab) and say so in the reply. Base AGENTS.md (e37889b:AGENTS.md:82) no longer has the "no standalone RTL test files" line, which confirms the CRF-21/22 drops.

Round 2 update

BLOCKED. 6 of 20 findings silent (CRF-5, CRF-10, CRF-15, CRF-16, CRF-18, CRF-20): no code change, no reply. 14 claimed fixed in 16f0f81, unverified by the panel. No review. Reviewed against 18fa1d5..16f0f81 (rebased; prior head de09426).

Round 3 update

BLOCKED. Head unchanged (16f0f81). Author replied on all six R2-silent threads. CRF-10 claimed fixed in d156c13 (#32438, in base; agent 404 page now says the agent restarted); CRF-5 and CRF-16 contested with reasons. CRF-15, CRF-18, CRF-20 each got the identical reply "Declined: naming preference.", which the churn-guard rules classify as silent (copy-pasted reply, no finding-specific reasoning). No PR description or top-level comment gives naming rationale (checked). Orchestrator has no override; advisor concurred. The R2 sign-in rewrite (postMessage-driven on-demand sign-in) is still unreviewed by any panel. Reviewed against 18fa1d5..16f0f81.

Round 4 update

PROCEED (churn guard). CRF-15, CRF-18, CRF-20 now contested with finding-specific reasons (R4 replies). CRF-5, CRF-16 contested since R3. Head unchanged since R2 (16f0f81); this is the first panel round on it. Restructure round: PreviewFrame rewritten for on-demand sign-in (postMessage coder-preview-sign-in-needed), new getPreviewAddress API, PR description states the new sign-in design. Inventory validation: dropped/OOS rows re-checked against 16f0f81; none reopened (CRF-36 key-per-sign-in is reduced by on-demand sign-in, stays OOS).
Panel (restructure round, full panel): domain ging-ts, ging-react, nami, kurapika, melody; core pariston, mafuuu; pool bisky, hisoka, komugi; wildcard knov (random draw). Dispute check-ins on reused R1 agents: netero (CRF-5), gon (CRF-15/16/18), leorio (CRF-20); they do not count toward the size target. Law ran (Don't split, Advisory).
Fix verification: CRF-1, 2, 4 (Netero), CRF-3 gate mutation-verified (Netero, Bisky) but its test is timing-dependent (CRF-44, posted on the CRF-3 thread), CRF-6 (Nami, Hisoka), CRF-7 (Melody), CRF-9 (Pariston, Bisky), CRF-10 (Hisoka, in d156c13), CRF-11 (Mafuuu, Knov), CRF-12 (Pariston), CRF-13 (Bisky), CRF-14 (Mafuuu, Hisoka), CRF-19 (Gon). CRF-8 re-raised (Nami, Leorio: stopped workspace and experiment off still show a bare title). CRF-17 re-raised (Gon: 3 of 6 locations unchanged; R2 status was set from the churn guard alone).
Downgrades (keep-argument first): CRF-49 P3 to P4. Keep: the comment is the stated reason the client checks were removed. Reason: the comment is incomplete, not false (sign-in does check in full); no behavior depends on it. CRF-51 P2 to Nit. Keep: AGENTS.md comment rule. Reason: convention only, as with CRF-17 in R1. CRF-46 merges Mafuuu P4 and Leorio Nit at P4. CRF-54 dropped. Keep: the request prop makes the name ambiguous. Reason: the doc comment states when it signs in.
Verified by orchestrator: previewhost.go:120 frame-ancestors 'self' <dashboardOrigin>; preview.go:172 window.top.postMessage; AgentChatPageView.tsx:608 previewAccess ignores isEmbedded; ChatTopBar hides the panel toggle when embedded; experiment-off test waits on API.getWorkspace being called (AgentChatPage.test.tsx:861).
10 new posted (4 P3, 6 P4) plus 4 Nit; 3 re-raises (CRF-8 P3, CRF-16 Nit, CRF-17 Nit). 4 contested closed (CRF-5, 15, 18, 20). Reviewed against 18fa1d5..16f0f81.

Round 5 update

PROCEED (churn guard: 7 addressed, 3 acknowledged, 7 contested, 0 silent). Head 4ac23c2 (rebased onto 631c66e). Fix round: 5 files changed since R4 (PreviewFrame.tsx, PreviewFrame.test.tsx, OpenPreviewTool.tsx, AgentChatPageView.tsx, AgentChatPage.test.tsx), no files added, no exported signature change, +49 effective additions. Law not re-run (+49 since R4 Law). Inventory validation: dropped/OOS rows unchanged by the new diff; CRF-65 (cross-site cookie) is now refused server-side per 5421940, still OOS.
Panel (fix round): personas with contested or acknowledged findings or open findings in changed code (gon, komugi, nami, mafuuu, knov, bisky, leorio, melody, pariston), domain specialists for changed .ts/.tsx (ging-ts, ging-react), wildcard chopper (random). All except chopper were their previous agents (dispute check-in). Netero ran first (no findings; CRF-40 closed).
Fix verification: CRF-42 (Nami, Mafuuu, Bisky mutation), CRF-43 (Leorio: cross-site cause refused server-side in 5421940), CRF-46 (Mafuuu, Leorio), CRF-47, CRF-48, CRF-50 (Bisky mutation), CRF-49 (Gon, Leorio, Netero).
CRF-66 (Chopper P3 to P4). Keep: a silent drop leaves the user on a 401 page whose instruction repeats the failure, and each retry mints a key. Reason: the known trigger (cross-site cookie) is now refused before any frame loads (CRF-43), and Chopper's example (Secure cookie over plain HTTP) would also reject the dashboard's own session cookie, so no reachable trigger is identified; the in-PR change is defensive messaging. Not merged into CRF-43 because Leorio, its raiser, verified that fix.
Posted: 1 new (CRF-66 P4), re-raises CRF-41 (P3) and CRF-16 (Nit). Human decision needed: CRF-8 and CRF-45 accepted by the author without a ticket. Reviewed against 631c66e..4ac23c2.

Round 6 update

PROCEED (churn guard: 0 addressed, 1 acknowledged, 2 contested, 0 silent). Head 79c6491 is a rebase of 4ac23c2 onto 9ec965f; git range-diff reports the PR commit identical. CRF-8 and CRF-45 accepted as an operator decision. Fix round with no code change: dispute check-ins only (Gon CRF-16, Chopper CRF-66, Pariston CRF-41) plus a wildcard; Netero re-run because the head SHA changed.
Panel: gon, chopper, pariston (reused agents, dispute check-ins), wildcard meruem (random). Netero: no findings (rebase only; base change is Go-only and keeps response shapes and the message string).
Posted: CRF-67 (P4). Closed: CRF-16, CRF-66. CRF-41 needs a human decision. Reviewed against 9ec965f..79c6491.

Round 7 update

PROCEED (churn guard: 2 acknowledged, 0 silent). Head 9db4ea5 is a rebase of 79c6491 onto a1249bd; git range-diff reports the PR commit identical; the base change is 7 lines in coderd/previews.go. CRF-41 accepted as an operator decision. Fix round: Meruem check-in on CRF-67, plus core (pariston, mafuuu) to reach 3, plus a wildcard; Netero re-run because the head SHA changed.
Panel: meruem (dispute check-in, reused), pariston, mafuuu (core, reused), wildcard chopper (random, reused). All no findings. Netero: no findings; base change is comment-only in coderd/previews.go.
No new findings. All in-scope findings are fixed, closed by the panel, or accepted; CRF-67 awaits the operator's confirmation. Reviewed against a1249bd..9db4ea5.

Round 8 update

PROCEED (churn guard: no open findings). Head c626616 is a rebase of 9db4ea5 onto 9a116a6; git range-diff reports the PR commit identical; the base change is comment-only (coderd/previews.go, previewhost.go). CRF-67 accepted as an operator decision. Fix round with no disputes: 3-reviewer minimum filled with mafuuu (core) and kurapika, hisoka (pool; last saw the code at R4, before the R5 reload changes), plus a wildcard. Netero re-run because the head SHA changed.

Panel: mafuuu (core), kurapika, hisoka (pool), wildcard chopper (random); all reused agents; all no findings. Netero: no findings. No open in-scope findings remain. Event APPROVE. The out-of-scope rows (CRF-35 to CRF-39, CRF-62 to CRF-65) still need tickets or human acceptance. Reviewed against 9a116a6..c626616.

Round 9 update

PROCEED (churn guard: no open findings). Head 71bab52 is a rebase of c626616 onto 004cc93; git range-diff reports the PR commit identical; the base change is tests (coderd/previews_test.go, agent/agentpreview/preview_test.go) and coderd/x/chatd/ARCHITECTURE.md only. Fix round with no disputes: 3-reviewer minimum filled with bisky, melody, nami (pool and domain; last saw the code at R5), plus a wildcard. Netero re-run because the head SHA changed.

Panel: bisky, melody, nami (pool and domain), wildcard meruem (random); all reused agents; all no findings. Netero: no findings. Melody showed the base now returns an error result for a workspace the chat owner does not own (coderd/x/chatd/chattool/openpreview.go, owner check before the port branch), so CRF-35 is fixed in base. CRF-64 still applies. Event COMMENT, so that R8's APPROVE stays the only bot approval. Reviewed against 004cc93..71bab52.

Round 10 update

PROCEED (churn guard: no open findings). Head b1c1ead is a rebase of 71bab52 onto 0be9a55; git range-diff reports the PR commit identical. The base change since R9 is tests, coderd/x/chatd/ARCHITECTURE.md, and one runtime change: previewHostingFor in coderd/previews.go now reads the workspace proxy with the caller's context instead of dbauthz.AsSystemRestricted, and treats a missing row or an authorization error (httpapi.Is404Error) as an unknown region. The UI calls the endpoints that use it. Fix round with no disputes: 3-reviewer minimum filled with pariston, hisoka, ging-ts (pool; security and server-contract angle for the base change), plus a wildcard. Netero re-run because the head SHA changed.

Panel: pariston, hisoka, ging-ts (pool), wildcard zoro (random, new agent); all no findings. Netero: no findings. Netero, Pariston, Hisoka and Zoro each showed that the previewHostingFor change leaves the dashboard's responses unchanged: the member role grants site-wide workspace_proxy read (coderd/rbac/roles.go), so only a scoped token without that permission now gets the existing 400, which PreviewFrame renders with Reload. Event COMMENT, so that R8's APPROVE stays the only bot approval. Reviewed against 0be9a55..b1c1ead.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds the Agents UI for open_preview results: a tool row with an Open preview button, and a right-panel tab that signs in and frames the preview in a CSP wrapper. 8 P3, 7 P4, 5 Nit.

The PR description says "see the routing PR", and no PR in the stack list is the routing PR. Name its number.

Out of scope (needs a ticket or explicit acceptance by a human):

  • coderd/x/chatd/chattool/openpreview.go:166: the tool returns success for a workspace the chat owner does not own. Sign-in rejects that workspace, so the model tells the user a preview is ready that cannot open.
  • coderd/workspaceapps/preview.go:108, coderd/workspaceapps.go:146: each sign-in creates an application_connect API key with session lifetime that is never revoked, and an expired sign-in token is rejected even when the request has a valid preview session cookie. Every frame reload adds a key.
  • agent/agentpreview/preview.go:69: file preview IDs exist only in agent memory, so preview links and tabs return 404 after an agent restart until open_preview runs again.
  • coderd/previews.go:69: sign-in issues a token for a file preview slug without checking that the agent has published that ID, so the failure appears inside the frame instead of as a sign-in error.
  • coderd/x/chatd/chattool/openpreview.go:138: checkURLPath limits the path in bytes but its error says "characters", so a model with a long non-ASCII path cannot tell why it failed.

🤖 This review was automatically generated with Coder Agents.

export const parseOpenPreviewResult = (
result: unknown,
): NewPreviewTab | undefined => {
const rec = asRecord(result);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-1] parseOpenPreviewResult never reads kind, so the PR description's "parsed strictly by kind" does not hold. (Netero)

A result with no kind, or with kind: "port" and a file slug such as preview--0123abcd, gets an Open preview button. Check that kind is "port" or "file" and matches the slug form, or remove the claim from the description.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified in 16f0f81d16: the description now says results are parsed by shape, which matches the parser.

🤖

);
};

// Mirrors CheckURLPath in coderd/workspaceapps/previewhost/previewhost.go,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-2] CheckURLPath in coderd/workspaceapps/previewhost/previewhost.go does not exist. The rule this code mirrors is checkURLPath in coderd/x/chatd/chattool/openpreview.go:129. (Netero)

A reader who follows this reference to keep the two checks in sync finds nothing to compare. Point the comment at checkURLPath.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 16f0f81d16: the comment and the client url_path check are gone.

🤖

buildId: chat.build_id,
agentId: chat.agent_id,
agentName: workspaceAgent?.name,
openPreview: openPreviewEnabled ? openPreviewTab : undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-3] No test fails if the Open preview button shows with the open-preview experiment off. (Netero)

Changing this line to openPreview: openPreviewTab, left Tool.test.tsx, AgentChatPage.test.tsx and rightPanelTabs.test.ts passing (60 of 60), because every page test returns ["open-preview"] from /api/v2/experiments. Add a case to the open_preview results block that returns [] and asserts that no Open preview button renders.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-44] "offers no preview while the experiment is off" waits for API.getWorkspace to be called, not for its response to render, so it checks the gate only when the workspace render finishes first. (Komugi)

The button can only appear after the workspace renders, because previewAccess is undefined while workspace is unset. With !openPreviewEnabled || removed, the test fails with the current mock but passes when getWorkspace resolves 150 ms after the call. Before looking for buttons, wait for something rendered from the loaded workspace, or resolve a deferred getWorkspace and wait until the query succeeds.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: removing the experiment check from previewAccess fails this test with the mocks the suite uses, so it guards the gate today; you are right that it waits for the workspace request rather than its render, but the workspace mock resolves immediately in every case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defense holds: with the gate removed, 42 of 42 runs (including on a single core) found the button and failed. Closed.

🤖


const isPreviewSlug = (value: unknown): value is string =>
typeof value === "string" &&
/^preview--([0-9a-f]{8}|[1-9][0-9]{0,4})$/.test(value);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4 [CRF-4] The port branch [1-9][0-9]{0,4} accepts preview--65536 through preview--99999, which appurl.ParsePreviewSlug rejects with strconv.ParseUint(target, 10, 16). (Netero)

Such a result shows a button whose sign-in returns 400. Match the server's range, or remove this copy (see the comment on the duplicated server rules).

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 16f0f81d16: the parser checks only the preview-- prefix.

🤖

return (
openPreviewEnabled &&
tab.workspaceId === workspace.id &&
getMatchingAgentOrFirst(workspace, tab.agentName) !== undefined

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4 [CRF-5] getMatchingAgentOrFirst falls back to the first agent only for an empty name, and isUserRightPanelTab already rejects preview tabs with an empty agentName, so here and in UserTabPanel.tsx:77 the call only finds an agent by name. (Netero)

A reader has to trace back to isUserRightPanelTab to confirm that a preview tab cannot fall back to an unrelated agent. Use getWorkspaceAgents(workspace).find((agent) => agent.name === tab.agentName) at both call sites.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: behavior is the same because preview tabs always carry an agent name; cheap to revisit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defense holds: both ways a preview tab gets an agent name keep it non-empty. Closed.

🤖

}
const runes = [...value].length;
return (
runes >= 1 && runes <= 80 && !/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u.test(value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-16] 80 here and 2048 on line 26 are bare copies of maxPreviewTitleLength and maxURLPathLength in coderd/x/chatd/chattool/openpreview.go. (Gon)

Declare them as named constants, each with a comment that names the Go constant it mirrors.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: the 2048 copy is gone in 16f0f81 because sign-in now checks url_path, and the title limit 80 stays inline in its only check.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 2048 copy is gone. The 80 remains: if maxPreviewTitleLength in coderd/x/chatd/chattool/openpreview.go is raised, results with longer titles render as a bare title with no button and no reason, and nothing on this line points to the Go constant. Adding "The limit of 80 mirrors maxPreviewTitleLength in coderd/x/chatd/chattool/openpreview.go." to the comment above isPreviewTitle is enough. (Gon)

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: the title check is deliberately a client copy, since the user decides by title, and the limit only changes together with the tool, so a drift would need a Go change first.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still open as a Nit. The reply explains why the client keeps a copy, but not how someone who raises maxPreviewTitleLength in coderd/x/chatd/chattool/openpreview.go finds it: neither side names the other, and results with longer titles would then lose the button with no reason. One clause on the existing comment above isPreviewTitle fixes it: "The limit of 80 mirrors maxPreviewTitleLength in coderd/x/chatd/chattool/openpreview.go." (Gon)

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: the title check is deliberately a client copy because the user decides by title, and the limit only changes together with the tool, so we are not adding the cross-reference here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted. Neither side names the other, so whether that is acceptable is now the author's call. Closed. (Gon)

🤖

Comment thread site/src/api/api.ts Outdated
};

/**
* Signs the caller in to a preview. The returned URL carries a short-lived

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-17] Several new doc comments open with a sentence that restates the symbol name or the JSX, and AGENTS.md requires comments to be "substantive and concise". (Gon)

Here, keep only "The returned URL carries a short-lived sign-in token." The same applies to previews.ts:5 ("Signs in to a preview for one frame"), PreviewFrame.tsx:24 ("under a header with the preview's host and a reload button"), UserTabPanel.tsx:21 (the list of kinds repeats the exhaustive switch), rightPanelTabs.ts:78, and chatEntities.ts:240.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three of the six locations are unchanged: UserTabPanel.tsx:21 (the list of kinds), rightPanelTabs.ts:78 ("A preview tab before it has an ID."), and chatEntities.ts:240. (Gon)

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: these are one-line docs on exported symbols, which the repository requires, and each one is accurate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defense holds: AGENTS.md requires docs on exported symbols, and all three are exported. Closed.

🤖

label: string;
workspaceId: string;
agentName: string;
slug: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-18] The tab field slug renames the API's preview_slug, and in a module that also stores workspace app tabs, a bare slug reads as an app slug. (Gon)

Name it previewSlug.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: naming preference.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: slug sits on the preview tab variant only, next to kind: "preview", so TypeScript narrows it before any read and it cannot be confused with an app tab's fields; renaming it touches every preview tab test for no behavior change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defense holds: every read narrows to kind: "preview" first, and workspace app tabs store appId, not slug. Closed.

🤖

const signInQuery = useQuery(
previewSignIn({ ...preview, region_id: proxy.proxy?.id }, frameId),
);
const signIn = signInQuery.data;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-19] signIn holds a PreviewSignInResponse, but it reads as a function at signIn && ... and wrapperHTML(signIn, title). (Gon)

Name it signInResponse.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 16f0f81d16.

🤖

return { user: userEvent.setup(), signIn };
};

it("opens a result's tab from its row once", async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-20] The test name "opens a result's tab from its row once" does not say that the test clicks twice. (Leorio)

For example: "clicking Open preview twice opens one tab and focuses it".

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: naming preference.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: the test name says the result opens its tab once, which is the asserted behavior, and the body's two clicks are the setup; the suggested name describes the same assertion in more words.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defense holds: the name states the asserted behavior. Closed.

🤖

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new push changes code for 14 of the 20 round 1 findings. The panel will check those changes in the next round. Six findings have no code change and no reply, so the review is paused until each one gets a response: a fix in this PR, a linked GitHub issue, or a reply on its thread explaining why it should not change.

  • site/src/pages/AgentsPage/utils/rightPanelTabs.ts:165 (P3): after an agent restart, restored file preview tabs and earlier file preview buttons open a 404 inside the frame, with nothing telling the user to open the preview again.
  • site/src/pages/AgentsPage/utils/rightPanelTabs.ts:169 (P4): getMatchingAgentOrFirst is used where only a lookup by name can happen, here and in UserTabPanel.tsx.
  • site/src/pages/AgentsPage/components/RightPanel/PreviewPanel.tsx:13 (P4): PreviewPanel also shows port previews next to PortPreviewPanel, and only the doc comment tells the two apart.
  • site/src/pages/AgentsPage/components/ChatElements/tools/OpenPreviewTool.tsx:16 (Nit): the title limit 80 is a bare copy of maxPreviewTitleLength.
  • site/src/pages/AgentsPage/utils/rightPanelTabs.ts:74 (Nit): the tab field slug renames the API's preview_slug.
  • site/src/pages/AgentsPage/AgentChatPage/AgentChatPage.test.tsx (Nit): the test name "opens a result's tab from its row once" does not say that it clicks twice.

🤖 This review was automatically generated with Coder Agents.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three of the six findings paused in the last review now have a response the panel can evaluate: the agent-restart 404 (fixed in d156c13, #32438), the getMatchingAgentOrFirst lookup, and the bare title limit. Three still block the review, because each got the same reply, "Declined: naming preference.", which gives no reason specific to that finding:

  • site/src/pages/AgentsPage/components/RightPanel/PreviewPanel.tsx:13 (P4): PreviewPanel also shows port previews next to PortPreviewPanel, so a reader looking for how port previews render finds the wrong panel.
  • site/src/pages/AgentsPage/utils/rightPanelTabs.ts:74 (Nit): the tab field slug renames the API's preview_slug, and the module also stores workspace app tabs.
  • site/src/pages/AgentsPage/AgentChatPage/AgentChatPage.test.tsx (Nit): the test name "opens a result's tab from its row once" does not say that it clicks twice.

To unblock, reply on each thread with one sentence on why the current name is better for that case, rename it, or link an issue.

The sign-in rewrite pushed in 16f0f81 (sign-in on request from the preview frame) has not been reviewed by the panel yet. The lack of findings on it is not an approval.

🤖 This review was automatically generated with Coder Agents.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This round reviews 16f0f81, which moves preview sign-in to run only when the preview host reports no session. New findings: 4 P3, 6 P4, 4 Nit.

Twelve earlier findings are verified fixed, and the disputes on the agent lookup, the panel name, the slug field and the test name are closed; each thread has a reply. Three are re-raised on their threads: rows that give no reason when previews are unavailable, the title limit literal, and three unchanged doc comments.

The commit message of 16f0f81 still says saved preview tabs are dropped; the PR description was corrected.

Out of scope (needs a ticket or explicit acceptance by a human):

  • coderd/previews.go:44: the address endpoint takes and returns PreviewSignInRequest and PreviewSignInResponse although it does not sign in, so getPreviewAddress reads as a sign-in call.
  • coderd/workspaceapps/preview.go:163: inside the Agents panel, the signed-out page tells the user to reopen the preview from Coder, and its Back to site action is blocked by the wrapper's frame-src, so the page offers no action that works.
  • coderd/workspaceapps/preview.go:172: the signed-out page posts to window.top with the AccessURL origin, so sign-in never starts when the dashboard is framed or reached through another hostname.
  • coderd/workspaceapps/preview.go: the preview session cookie uses the default SameSite, so when the preview host is cross-site with the dashboard the browser does not send it inside the frame and the preview never stays signed in (the #32522 review reproduced this in Chromium).

Notes:

  • "opens a result's tab from its row once" and "renames an open preview's tab and reloads it for a newer result" took 5.5 to 5.7 s on a cold Vitest cache against the 5 s default timeout; warm runs took about 1 s.
  • When the selected proxy changes, including the automatic latency-based switch on a first page load, an open preview reloads from the new region and loses its page state.

🤖 This review was automatically generated with Coder Agents.

activateRightPanelTab(tab.id);
};

const previewAccess =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-41] previewAccess offers Open preview in the embedded chat (/agents/:agentId/embed, used by the VS Code extension), where the preview frame can neither load nor sign in. (Melody, Pariston)

The preview CSP is frame-ancestors 'self' <dashboardOrigin> (previewhost.go:120), which every ancestor must match, and the signed-out page posts to window.top (preview.go:172), which is the webview host when the dashboard is framed; so the browser blocks the frame and drops the sign-in message. This follows from the CSP and postMessage rules and was not run in a VS Code webview. isEmbedded (line 249) is not part of previewAccess: when it is true, set an unavailableReason such as "Previews open only in the Coder dashboard."

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: you are right that the preview CSP lists only the dashboard as a frame ancestor, so a preview opened from the VS Code embed is unlikely to load there, but previews in this experiment target the dashboard and we did not reproduce the embedded case, so the embedded chat is left unchanged in this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-raised with a reproduction. A Playwright Chromium page with three origins (embedder, dashboard, preview host), this PR's wrapper markup, the server's sandbox and the preview CSP from previewhost.go:118-120 rendered the preview and received the sign-in message with the dashboard at the top level, but with the dashboard framed the browser refused the preview response (frame-ancestors) and no message reached the dashboard. In the VS Code extension, Open preview therefore opens the right panel on a blocked frame with no reason, and Reload and reopening repeat it. When useEmbedContext().isEmbedded is true, set previewAccess to { unavailableReason: "Previews open only in the Coder dashboard." }. (Pariston)

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: thanks for the reproduction. It runs a copy of the markup and CSP on static pages rather than Coder itself, and we already decided not to change the embedded chat in this PR, so we are leaving it as is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not re-raised: there is no new evidence. The R6 reply does not answer the reproduction, which used the server's CSP and sandbox strings and this PR's wrapper markup, and the button this diff adds is shown in the embedded route. With no fix and no ticket, this needs a human decision: file a ticket or accept it explicitly. (Pariston)

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed for the experimental release (operator decision, no ticket): previews target the dashboard, and we accept that the embedded chat shows a button whose preview does not load there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recorded as an operator decision for the experimental release.

🤖

variant="subtle"
className="ml-auto"
aria-label="Reload preview"
onClick={() => setReloadCount((count) => count + 1)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-42] After the address request fails, Reload preview does nothing. (Nami, Mafuuu)

The button only bumps reloadCount, the key of SignInOnRequestFrame, which is not rendered in the addressQuery.error branch, and the app QueryClient sets retry: false (App.tsx:19). A scratch test where getPreviewAddress rejects once and then resolves left one address call and no frame after clicking Reload. Call addressQuery.refetch() from the button when the address query has failed, and add that case to PreviewFrame.test.tsx.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4ac23c2: Reload now refetches a failed address request, with a PreviewFrame test that fails without the refetch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 4ac23c2859; the new test fails without the refetch.

🤖

event.data !== previewSignInNeeded ||
event.origin !== address.origin ||
event.source !== frameRef.current?.contentWindow?.frames[0] ||
signInRequested.current

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 [CRF-43] When the preview host still reports no session after the one sign-in a mount allows, the second coder-preview-sign-in-needed message is dropped and the panel shows the host's 401 page, which says "Reopen this preview from Coder to sign in again." (Leorio)

That happens when the browser does not keep the preview host's cookie after the sign-in redirect, for example when the preview host is cross-site with the dashboard; Reload then signs in again, mints another key, and lands on the same page. The once-per-mount guard is right, but the user is not told what failed. On a sign-in-needed message after this mount already signed in, show an error in the panel that says the preview host did not keep the sign-in and the browser may be blocking its cookies.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 5421940 (#32522): the root cause is fixed in sign-in: a primary region whose wildcard is on another site is now refused, so the address request fails with "Previews need a wildcard access URL on the same site as the dashboard." instead of the user looping through the 401 page.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified in 5421940: a cross-site wildcard is refused on the address request with a message that names the fix.

🤖

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defense holds: an HTTP deployment with Secure cookies cannot sign in to the dashboard either, cross-site regions are refused before the frame loads, and an expired session recovers through Reload. Closed. (Chopper)

🤖

preview &&
previewAccess &&
(preview.workspaceId !== workspaceId || preview.agentName !== agentName)
? { unavailableReason: "This preview belongs to a different workspace." }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4 [CRF-40] A result whose agent_name differs from the chat's agent shows "This preview belongs to a different workspace." even when workspace_id matches. (Netero)

Both conditions share one message, and "offers no preview of another workspace or agent to the owner" asserts that text for the agent_name: "other-agent" row. Give the agent mismatch its own reason, for example "This preview belongs to a different agent in this workspace."

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: the tool takes the agent name from the chat's own workspace agent, so a mismatch inside the same workspace needs a rebuild that renames the agent, and one reason for both cases keeps the row short.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defense holds: the tool takes the agent name from the chat's own agent, so this needs a rebuild that renames it. Closed.

🤖

</div>
{address ? (
<SignInOnRequestFrame
key={reloadCount}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4 [CRF-45] SignInOnRequestFrame is keyed only on reloadCount, so after a region switch to an address that is still cached, it keeps framing the previous region's sign-in URL. (Knov)

frame = signInMutation.data ?? address prefers the sign-in response for the address it mounted with, while handleMessage compares against the current address.origin. A scratch test with the app's query client settings (region A, switch to B, sign in, switch back to A) left the inner frame on B's URL. Key the component on the address too, for example key={`${reloadCount}:${address.url}`}.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: this reproduces at the component level, but the Agents page has no region control and the latency auto-select runs once, so the region can only switch back to a cached one within a mount through a proxy health change, and we are leaving the key as is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The panel accepts this: the Agents page renders no ProxyMenu, and the regions query does not refetch during a mount, so the switch back needs no user action to avoid. A human should confirm the acceptance or file a ticket.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed for the experimental release (operator decision, no ticket): the Agents page has no region menu and the regions query does not refetch during a mount, so we are not keying the frame on the address.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recorded as an operator decision for the experimental release.

🤖

!isPreviewTitle(rec.title) ||
typeof rec.workspace_id !== "string" ||
typeof rec.agent_name !== "string" ||
// Sign-in checks the slug and URL path in full, so the parser checks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4 [CRF-49] The comment names sign-in as the check on the slug and URL path, but the request that runs on every mount is the address request, and sign-in may never run. (Gon)

Both handlers validate through resolvePreview (coderd/previews.go), so the removal is safe, but a reader of this comment could conclude that a browser with a live preview session skips the check. For example: "coderd checks the slug and URL path in full on every address and sign-in request, so the parser checks only their shape."

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4ac23c2: the comment now names every check the slug and path go through.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 4ac23c2859: both endpoints go through resolvePreview.

🤖

// Opening the same result again reloads it too.
await page.user.click(newerButton);
await waitFor(() => expect(newerFrame).not.toBeInTheDocument());
expect(previewFrame("Docs v2")).toBeInTheDocument();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-50] expect(previewFrame("Docs v2")).toBeInTheDocument() is a presence assertion, which FE1 (.claude/docs/FRONTEND_PATTERNS.md) rules out in Vitest, and getByTitle already throws when the frame is missing. (Bisky)

Call previewFrame(...) without expect here and at line 994.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 4ac23c2: the presence assertion now compares frames instead of only checking one exists.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified fixed in 4ac23c2859.

🤖

expect(newerFrame).not.toBe(firstFrame);
expect(firstFrame).not.toBeInTheDocument();

// Opening the same result again reloads it too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-51] // Opening the same result again reloads it too. repeats the next two lines. (Gon)

Delete it.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: the comment marks where the test moves from the newer result to reopening the same one, which the click alone does not say.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defense holds: the comment marks the switch to reopening the same result. Closed.

🤖

agent: WorkspaceAgent;
tab: Extract<UserRightPanelTab, { kind: "preview" }>;
/** Changing it loads the preview again. */
reloadCount: number;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-52] reloadCount here counts how often the chat reopened the tab, while reloadCount in PreviewFrame.tsx counts Reload clicks, and both are used as a React key one component apart. (Gon)

Rename the chat-level chain to reopenCount (previewReopenCounts, previewReopenCount).

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: both counters are React keys that reload the preview when they change, so one name fits both, and the prop doc states what changing it does.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defense holds: both counters are only React keys, and no code reads either as a number. Closed.

🤖

if (signInMutation.isPending) {
return <PreviewLoading />;
}
const frame = signInMutation.data ?? address;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit [CRF-53] frame holds a PreviewSignInResponse, while frameRef holds the iframe element. (Gon)

Give the response another name, for example target.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: frame is the target the iframe loads (its URL, origin and sandbox) and is used only in the next three lines, so the name describes how it is used.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defense holds: frame is used only in three attributes of one element. Closed.

🤖

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This round reviews 4ac23c2, which makes Reload retry a failed address request, adds tests for both failure paths, and rewords two comments. New findings: 1 P4.

Seven round 4 findings are verified fixed, and seven disputes are closed (replies on each thread). Two findings are re-raised on their threads: the embedded VS Code chat still offers a preview that cannot load, which now reproduces in Chromium, and the title limit copy still does not name the Go constant.

Two gaps are accepted in replies without a ticket: rows of a stopped workspace show no reason, and a region switch back to a cached region keeps the old region's frame. The panel agrees with both. A human should confirm that acceptance or file a ticket.

🤖 This review was automatically generated with Coder Agents.

event.data !== previewSignInNeeded ||
event.origin !== address.origin ||
event.source !== frameRef.current?.contentWindow?.frames[0] ||
signInRequested.current

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4 [CRF-66] A coder-preview-sign-in-needed message that arrives after this mount's sign-in succeeded is dropped without telling the user, so the panel stays on the host's 401 page, whose "Reopen this preview from Coder" text sends the user into the same failure. (Chopper)

The cross-site cause is now refused before any frame loads, but any other case where the preview host does not keep the session ends the same way, and each Reload mints another key. PreviewFrame.test.tsx:160-163 ("the signed-in frame asking again changes nothing") checks only that no second call is made. Keep the one sign-in per mount, and when the message arrives after signInMutation.isSuccess, show an error in the panel that says the preview host did not keep the sign-in, with that test expecting the error.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: signing in once per mount is deliberate, since script in the preview can post the same message, and the only known way a host loses the new session, a cross-site region, is now refused before the frame loads. For an expired session the host page's advice to reopen is right, because Reload remounts the frame and signs in again.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This head is a rebase of 4ac23c2 with the same PR diff. New findings: 1 P4.

The title limit and second sign-in message disputes are closed. The operator decisions on stopped-workspace rows and the region-switch frame are recorded.

The embedded VS Code chat still offers Open preview on a frame the browser refuses, with no fix and no ticket. The reviewers have no new evidence and do not re-raise it, so this needs a human decision: file a ticket or accept the gap explicitly, as was done for the two items above.

Notes:

  • The rule for which tabs count as the same preview (agentName, slug, urlPath, AgentChatPageView.tsx:577) is inline in the view, so only the slow page-level tests cover it; a helper next to validateUserRightPanelTabs could be tested in rightPanelTabs.test.ts.

🤖 This review was automatically generated with Coder Agents.

activateRightPanelTab(tab.id);
};

const previewAccess =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P4 [CRF-67] previewAccess.open accepts a preview from any workspace or agent, and only OpenPreviewTool keeps foreign previews out, by repeating the match check against a context field (agentName) that exists for that one check. (Meruem)

openPreviewTab appends and selects the tab without checking workspaceId or agentName, while validateUserRightPanelTabs drops a tab that fails either, so a second caller that skips the check persists a hidden tab and selects an ID the tab list omits; each further click adds another, because the lookup searches only validated tabs (inferred from the code, not run). The Desktop action at line 435 already avoids this by offering the action only when the panel can render. Make previewAccess a function of the preview, built in the view, that checks ownership, workspace and agent in one place, and remove agentName from ChatWorkspaceContextValue.

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declined: you are right that the match check lives in the tool row rather than in previewAccess, so a future caller could skip it. Today the tool row is the only caller and it checks workspace and agent before opening, so we are keeping the check where the reason text is shown.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accepted: today OpenPreviewTool is the only reader of previewAccess outside tests and stories, and it replaces open with the reason before any click. With no ticket, please confirm this as an operator decision. (Meruem)

🤖

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed for the experimental release (operator decision, no ticket): the workspace and agent match check stays in OpenPreviewTool, the only reader of previewAccess.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This head is a rebase of 79c6491 with the same PR diff; the base change since then is comment-only in coderd/previews.go. No new findings.

The embedded VS Code chat gap is recorded as an operator decision. The reviewers accept keeping the workspace and agent match check in the tool row, because that row is the only caller today. That leaves a hazard for any future caller of previewAccess.open and has no ticket, so please confirm it as an operator decision on its thread, as was done for the other accepted gaps.

Every other in-scope finding is fixed or closed.

🤖 This review was automatically generated with Coder Agents.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This head is a rebase of 9db4ea5 with the same PR diff; the base change since then is comment-only. No new findings, and every finding from earlier rounds is fixed, closed, or accepted as an operator decision for the experimental release.

The out-of-scope server items listed in earlier reviews (sign-in types reused by the address endpoint, the signed-out page's action and window.top target, key lifetime, the tool reporting success for workspaces the owner does not hold) are not part of this PR and still need tickets or explicit acceptance.

🤖 This review was automatically generated with Coder Agents.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This head is a rebase of c626616 with the same PR diff. The base change since then is tests and coderd/x/chatd/ARCHITECTURE.md. No new findings. The approval from the previous review still applies, so this review is a comment rather than a second approval.

The base now returns an error from open_preview for a workspace the chat owner does not own, so that out-of-scope item from earlier reviews is resolved. The other out-of-scope server items (sign-in types reused by the address endpoint, the signed-out page's action and window.top target, key lifetime) are not part of this PR and still need tickets or explicit acceptance.

🤖 This review was automatically generated with Coder Agents.

Renders open_preview results in the Agents chat with an Open preview
button. The preview tab loads the preview's address in a srcdoc wrapper
frame whose CSP allows only that preview's origin. When the preview's
signed-out page posts coder-preview-sign-in-needed, the tab signs in
through the dashboard endpoint, at most once per mount, and loads the
returned URL. With the experiment off, the button is hidden and saved
preview tabs are dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review coder-agents-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This head is a rebase of 71bab52 with the same PR diff. No new findings. The earlier approval still applies, so this review is a comment rather than another approval.

The base now reads the workspace proxy in previewHostingFor with the caller's context instead of AsSystemRestricted. That does not change what this UI receives: the member role grants site-wide read on workspace proxies, and the dashboard session has no narrower scope. Only a token scoped without workspace_proxy:read now gets the 400 "This region does not serve previews.", which PreviewFrame already shows in its error alert with Reload.

The out-of-scope server items from earlier reviews (sign-in types reused by the address endpoint, the signed-out page's action and window.top target, key lifetime) are not part of this PR and still need tickets or explicit acceptance.

🤖 This review was automatically generated with Coder Agents.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

experimental Changes that might not necessarily be merged, until its approved to proceed with.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant