Skip to content

feat(coderd): add open_preview chat tool - #31284

Draft
DanielleMaywood wants to merge 1 commit into
feat/agents-open-preview-routingfrom
feat/agents-open-preview-tool
Draft

DanielleMaywood wants to merge 1 commit into
feat/agents-open-preview-routingfrom
feat/agents-open-preview-tool

Conversation

@DanielleMaywood

@DanielleMaywood DanielleMaywood commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Adds the open_preview tool for root chats outside plan mode, registered only when the deployment has a wildcard app hostname. It takes a short title and exactly one of port (an existing HTTP server, optionally at a url_path) or path (an .html file, or a directory containing index.html, published through the workspace agent). The result records the workspace, agent name and either the port or the preview ID that the workspace agent returned, which the UI uses to build the preview app URL. File previews last until the agent restarts (see the agent PR).

Decision log
  • Root-only, not in plan mode. Sub-agents and plan mode cannot open previews in the user's UI.
  • Title required, at most 80 characters, because it labels the preview in the selector.
  • The stored path is the agent's canonical path, not the model's input, so the catalog shows what is actually served.
  • Registered only with a wildcard app hostname. Without one, previews cannot be displayed. Deployments whose only wildcard hostname is on a workspace proxy do not get the tool.
  • url_path opens a port preview at a path and query, such as /?folder=/home/coder/project. IsPreviewURLPath accepts only a path that starts with a single /, with no host, backslash, fragment or control characters, at most 2048 characters, so a client can append it to the preview origin without changing the origin. / is stored as empty so the root lists as one preview.
  • Port mode does not start the app or wait for readiness. Ports are limited to 1000-65535 because preview hostnames only recognize four- or five-digit ports. The UI opens port previews on preview--<port> hostnames, so they get the same isolation as file previews (see the routing PR).
  • The tool result is the source of truth for the preview list (see the endpoint PR); chattool.OpenPreviewResult is the shared typed shape.
  • The workspace agent assigns preview IDs, so coderd stores nothing and previews do not survive agent restarts. IDs are 8 hex characters: the whole preview app name is one DNS label (at most 63 characters), and with 16-character IDs 25 of 60 dogfood agents exceeded it; with 8, one does, and that one also fails for a plain code-server app.
  • The agent validates and resolves paths, so the tool works with Windows paths. The agent keys IDs by the resolved path, so /out/, /out and symlinks to one path share its ID.
  • Agent errors reach the model without transport details. They go through workspacetools.AgentAPIErrorMessage, as in edit_files.
  • getWorkspaceConn now caches the agent with its conn. Before, a parallel call that cleared the cache during a dial (or a lazy-validation agent switch that lost the race) left the cached conn paired with an empty or different agent, so getPreviewWorkspace could return an empty agent name. This changes shared chatd code: after such a race, the cached agent follows the conn that was kept.
  • coderd/x/chatd/ARCHITECTURE.md only gets a TODO; the prose is left for the human author.

Stack (proof of concept for the embedded previews RFC, review bottom-up):

  1. feat: serve published file previews from the workspace agent over tailnet #31282 Agent file previews over tailnet
  2. feat: route preview app hostnames to agent previews #31283 Preview app hostname routing
  3. feat(coderd): add open_preview chat tool #31284 open_preview chat tool ← this PR
  4. feat: add chat previews endpoint #31285 Chat previews endpoint
  5. feat(site): add a Preview tab for open_preview #31286 Preview tab UI
  6. docs(docs/coder-agents): document embedded previews #31287 Docs
  7. feat: open coder_app tabs from open_preview #31484 Open coder_app tabs

🤖 This PR was written by Coder Agents on behalf of @DanielleMaywood.

@ibetitsmike ibetitsmike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Adversarial security review — #31284 (open_preview chat tool)

Part of the stack review; the stack-level roll-up (findings S1/S2, method, verified negatives) is on #31282. Line numbers at stack head 678b80103.

Contributes to S1 (P1, contested; validated) — port mode is the escape hatch, and there is no gesture/approval gate

  • OpenPreviewArgs.Port (coderd/x/chatd/chattool/openpreview.go:52) produces a result the UI turns into a plain <port>--agent--ws--user origin (PreviewPanel.tsx:67). That origin is not covered by #31283's preview-- CORS denial and does inherit port shares (validated through the real proxy: ACAO+ACAC: true against the owner's other workspace; public share → unauthenticated 200). The tool description recommends port mode first ("Use port for an existing HTTP web app"), so the mitigated mode is the one the model is steered away from.
  • The tool has no confirmation step; it is appended unconditionally for root chats (turn_environment.go:2427) and the UI auto-renders its result (#31286). A prompt-injected model with execute can python3 -m http.server 8080 serving its own HTML and call open_preview(port: 8080) in the same turn.

Suggested fix: either drop port mode, or give port-mode previews a preview---class slug (e.g. result carries preview_slug: "preview--p8080" and routing in #31283 maps it to the port with AppSharingLevelOwner forced), so appurl.PreviewID covers both modes. Consider gating open_preview behind the same approval mechanism as other side-effecting tools, or at least making the result not auto-render (see #31286).

Unverified (single reviewer) — P3

  • Tool is always registered, even without a wildcard access URL. Publication on the agent (daemon-lifetime, 16-slot cap) happens regardless; the UI merely hides the pane. There is also no admin switch to disable the built-in (MCP allow/deny lists don't cover built-ins; no experiment flag), which contradicts the docs' "tool configuration from the control plane" promise.
  • getPreviewWorkspace can persist WorkspaceID=B with A's AgentName/Conn (turn_environment.go:1938) when the owner PATCHes the chat workspace between getWorkspaceConn and the snapshot read (reviewer demonstrated with a gomock test; root cause is UpdateChatBuildAgentBinding having no workspace_id guard — pre-existing). Owner-only impact: the catalog attributes an agent/preview to the wrong workspace.
  • Every getWorkspaceConn error is wrapped by workspaceLoadErrorResponse (openpreview.go:95) → "workspace is probably gone; use create_workspace", including a 30 s dial timeout. Other tools return err.Error(). This steers the model into a side-effecting rebind on transient errors.
  • Title filter is unicode.IsControl only (openpreview.go:75) — RLO/ZWSP/BOM/U+2028 are accepted → label spoofing in the preview selector. No HTML injection (React escapes; verified).
  • Raw model path is persisted and displayed as "the published path" (openpreview.go:118) instead of the agent's canonical path; no abs/NUL/length check in coderd (agent bounds the body at 16 KiB). A model can make the catalog show a misleading path while the pinned tree is elsewhere after symlink resolution. Suggest returning the canonical path from the agent and storing that.

nit

  • coderd/x/chatd/ARCHITECTURE.md:1014 still carries a <!-- TODO: document … --> and repeats "owner-only"; #31287 doesn't resolve it.
  • TestTurnWorkspaceContextGetWorkspaceConnLazyValidationSwitchesWorkspaceAgent was replaced rather than kept alongside the new getPreviewWorkspace test.

Verified negatives (no action)

  • Tool policy: root-only; excluded in child/plan/explore (existing TestBuildTurnEnvironmentToolPolicy passes).
  • No MCP/inline/workspace/dynamic tool can be named literally open_preview with NULL mcp_server_config_id (all contain __; built-in wins over dynamic; child chats have no dynamic tools; SubmitToolResults keyed by pending call IDs).
  • appurl.IsPreviewID regex is anchored (^…$, tested), so preview_id is safe to splice into a hostname; ports 1–999 are excluded consistently with PortRegex.
  • Lock ordering in getPreviewWorkspace has no inversion; dial identity (AsChatd → ServerTailnet.AgentConn) is pre-existing for all workspace tools.

@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-tool branch from ff3deae to 885deea Compare October 28, 2026 10:39
@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-tool branch 2 times, most recently from d929b3d to 85e2217 Compare October 28, 2026 13:06
@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-tool branch from 85e2217 to 4def999 Compare October 28, 2026 13:20

@DanielleMaywood DanielleMaywood left a comment

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.

This review was performed by ai-review, an automated review bot.

1 inline finding.

Coverage
Coverage: 7 of 8 files reviewed, 1 unsupported; 22 rules.
Candidates: 384 found, 379 outside changed lines, 0 already discussed, 5 evaluated.
Findings: 1 (1 sites, 0 pre-existing sites), 0 over budget, 0 failed.
Model: deepseek/deepseek-v4.1-flash; 5 questions, 5 answered, 0 abstained, 0 cached; 0 uncalibrated findings held back; 5262 input and 1400 output tokens.

Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-tool branch from 4def999 to b21d1ad Compare October 28, 2026 16:42
@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-tool branch 3 times, most recently from d766e67 to f5c9b86 Compare October 29, 2026 14:07
@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

@codex review

🤖 Posted by Coder Agents on behalf of @DanielleMaywood.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T14:27:52.677212Z bf63a82 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f5c9b86478

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-tool branch from f5c9b86 to 95cad1c Compare October 30, 2026 12:42
@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-tool branch from 5daa3e1 to 4774502 Compare November 3, 2026 12:21

@DanielleMaywood DanielleMaywood left a comment

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.

This review was performed by ai-review, an automated review bot.

1 inline finding.

Coverage
Coverage: 8 of 9 files reviewed, 1 unsupported; 53 rules.
Candidates: 1110 found, 1077 outside changed lines, 1 already discussed, 32 evaluated.
Findings: 1 (1 sites, 0 pre-existing sites), 0 over budget, 0 failed.
Model: deepseek/deepseek-v4.1-flash; 32 questions, 30 answered, 2 abstained (unsure 1, truncated 1), 8 cached; 0 uncalibrated findings held back; 32724 input and 39077 output tokens.

Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-tool branch from 4774502 to 970ff4f Compare November 3, 2026 14:07
@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-tool branch from 970ff4f to 45a8a8f Compare November 3, 2026 15:22
@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

/coder-agents-review

@coder-agents-review

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

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-11-06 13:39 UTC by @DanielleMaywood
Spend: $72.49 / $100.00

Review history
  • R1 (2026-11-04): 13 reviewers, 3 Nit, 5 P2, 6 P3, 9 P4, COMMENT. Review
  • R2 (2026-11-05): 10 reviewers, 4 Nit, 5 P2, 6 P3, 11 P4, COMMENT. Review
  • R3 (2026-11-05): 8 reviewers, 5 Nit, 5 P2, 7 P3, 12 P4, COMMENT. Review
  • R4 (2026-11-06): 6 reviewers, 5 Nit, 5 P2, 7 P3, 13 P4, COMMENT. Review
  • R5 (2026-11-06): 4 reviewers, 6 Nit, 5 P2, 7 P3, 15 P4, COMMENT. Review
  • R6 (2026-11-06): 4 reviewers, 8 Nit, 5 P2, 7 P3, 15 P4, COMMENT. Review
  • R7 (2026-11-06): 4 reviewers, 8 Nit, 5 P2, 7 P3, 15 P4, APPROVE. Review
  • R8 (2026-11-06): 4 reviewers, 8 Nit, 5 P2, 7 P3, 15 P4, APPROVE. Review

deep-review v0.13.0 | Round 8 | caf373e..1a15f58

Last posted: Round 8, 35 findings (5 P2, 7 P3, 15 P4, 8 Nit), APPROVE. Review

Finding inventory

Finding inventory: PR #31284

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P2 Author fixed (c2b194d) openpreview.go:66 Four of five IsPreviewURLPath rejection conditions untested (mutation-verified) R1 Netero Yes
CRF-2 P3 Author fixed (c2b194d); GetPreviewWorkspace error row declined, Netero accepted R2 openpreview.go:148 GetWorkspace and Conn.OpenPreview error paths untested R1 Netero Yes
CRF-3 P4 Author contested; panel closed R2 (1/1 accept) openpreview.go:82 Tool description hardcodes agent's 64-path limit R1 Netero Yes
CRF-4 P4 Author contested; panel closed R3 (2/2 accept) turn_environment.go:1982 getPreviewWorkspace re-check branch untested R1 Netero, Bisky Yes
CRF-5 Note Note (body) CI Flake Check was cancelled by a newer run, not a test failure R1 Netero No
CRF-6 P2 Author fixed (c2b194d) openpreview.go:98 path.IsAbs rejects Windows paths; path.Clean and its comment are redundant with agent canonicalization R1 Ryosuke P2, Luffy P2, Pariston P2, Gon P2, Leorio P2, Hisoka P2, Melody P3, Mafuuu P3, Zoro P4 Yes
CRF-7 P2 Author fixed (c2b194d) openpreview.go:31 Stored preview_id is reused for a different path after agent restart R1 Pariston P2, Melody P3, Mafuuu P3 Yes
CRF-8 P2 Author fixed (c2b194d) turn_environment.go:1989 getPreviewWorkspace pairs c.conn with c.agent, which can be empty or another agent (reproduced empty) R1 Takumi P2, Hisoka P3, Kurapika P4, Bisky P4 Yes
CRF-9 P2 Author contested; panel closed R2 (1/1 accept) coderd.go:948 open_preview has no experiment or operator switch R1 Luffy Yes
CRF-10 P3 Author fixed (c2b194d) openpreview.go:22 No shared validation for OpenPreviewResult; port range duplicates appurl; agent preview ID not checked R1 Ryosuke P3, Gon P3 Yes
CRF-11 P4 Author fixed (31acf45) openpreview.go:82 Model-facing text uses "workspace daemon" and several names for file previews R1 Gon P3, Leorio P4, Zoro Nit Yes
CRF-12 P3 Author fixed (c2b194d) openpreview.go:149 Agent error reaches model with tailnet URL and status; use AgentAPIErrorMessage R1 Leorio Yes
CRF-13 P3 Author fixed (c2b194d) ARCHITECTURE.md:1177 Added TODO needs the human author; covers other PRs and has a garbled clause R1 Gon P2, Leorio P4, Melody Nit, Luffy Nit, Mafuuu Nit, Zoro Nit Yes
CRF-14 P3 Author fixed (31acf45) turn_environment.go:2581 enablePreviews gate untested (mutation-verified) R1 Bisky Yes
CRF-15 P4 Author contested; panel closed R2 (1/1 accept) openpreview.go:108 Port upper bound untested R1 Bisky Yes
CRF-16 P4 Author contested; panel closed R2 (1/1 accept) openpreview.go:94 Neither-port-nor-path case untested R1 Bisky Yes
CRF-17 P4 Author fixed (c2b194d) openpreview.go:124 url_path error omits 2048-character limit R1 Gon, Leorio, Zoro Yes
CRF-18 P4 Author contested; panel closed R2 (1/1 accept) openpreview.go:109 Port error does not explain the range R1 Leorio Yes
CRF-19 P4 Author fixed (c2b194d) openpreview.go:57 path description omits .html/.htm requirement R1 Leorio Yes
CRF-20 P4 Author contested; panel closed R2 (2/2 accept) turn_environment.go:2581 open_preview name not reserved from dynamic tools when previews are disabled R1 Ryosuke P4, Kurapika Note Yes
CRF-21 P4 Author contested; panel closed R2 (1/1 accept) openpreview.go:62 IsPreviewURLPath is a URL rule living in chattool R1 Ryosuke Yes
CRF-22 P4 Author contested; panel closed R2 (1/1 accept) chatd_internal_test.go:1340 getWorkspaceConn agent-switch test replaced by a getPreviewWorkspace test R1 Zoro Yes
CRF-23 Nit Author fixed (c2b194d) openpreview.go:22 OpenPreviewResult doc cites endpoint from another PR instead of stored history R1 Gon Yes
CRF-24 Nit Author fixed (c2b194d) openpreview.go:41 PreviewWorkspace doc says it binds a preview R1 Gon Yes
CRF-25 Nit Author fixed (c2b194d) openpreview.go:50 GetWorkspace name differs from sibling GetWorkspaceConn R1 Gon Yes
CRF-26 Nit Dropped by orchestrator (comment states the exclusivity and which field is the identity) openpreview.go:30 Port/PreviewID comment restates names R1 Gon No
CRF-27 Nit Dropped by orchestrator (Go readers do not read the tag; example aids the doc) openpreview.go:36 URLPath example repeats tag example R1 Gon No
CRF-28 Nit Dropped by orchestrator (same cause as CRF-23; true once stack lands) openpreview_test.go:72 Test comment cites previews endpoint R1 Gon No
CRF-29 Nit Dropped by orchestrator (prior review removed a comment on this constant; limit is stated in the Title tag) openpreview.go:18 Constants lack rationale comments R1 Gon No
CRF-30 Nit Dropped by orchestrator (test-only field name, low value) openpreview_test.go:28 Rename test field path R1 Gon No
CRF-31 Nit Author fixed (31acf45) turn_environment.go:1974 getPreviewWorkspace lacks comment on re-read R1 Leorio Yes
CRF-32 Nit Dropped by orchestrator (two-line rewording aligns the term this PR uses) appurl.go:151 IsPreviewID comment change belongs in #31283 R1 Zoro No
CRF-33 OOS Author fixed (57dfcfb, #31282 random IDs) agent/agentpreview/preview.go:110 Preview IDs restart at 00000001 per agent process R1 Melody, Pariston, Mafuuu No
CRF-34 OOS Author fixed (57dfcfb, #31282 filepath.IsAbs) agent/agentpreview/api.go:70 handleOpen has no filepath.IsAbs check R1 Ryosuke, Pariston, Hisoka No
CRF-35 OOS Author fixed (c2b194d) turn_environment.go:1933 getWorkspaceConn caches conn with zeroed agent, skipping disconnect check R1 Takumi, Hisoka No
CRF-36 OOS Out of scope (body) exp_chats_previews.go (#31285) Third copy of 1000-65535 port range R1 Zoro No
CRF-37 OOS Out of scope (body) agent/agentpreview/preview.go:31, api.go:73 Agent preview error texts do not tell the model what to do R1 Leorio No
CRF-38 P4 Dropped by orchestrator (re-raise of CRF-2 part that its raiser accepted as declined) openpreview.go:123 GetPreviewWorkspace error path untested R2 Bisky No
CRF-39 Note Note (body) turn_environment.go:1960 After a lost lazy-validation race, c.agent is the winner's agent while chat AgentID is the switched agent; self-recovers R2 Takumi No
CRF-40 P4 Author fixed (b6ea144) turn_environment.go:1928 ensureWorkspaceAgent rebinds agent and cachedWorkspaceID while c.conn stays on the old workspace; getPreviewWorkspace mislabels it R2 Razor P3, Razor P4, Takumi P4 Yes
CRF-41 OOS Out of scope (body); author fix partial, window remains (R3 Takumi) turn_environment.go:1464 Same state makes every tool run on the previous workspace for the rest of the turn R2 Razor No
CRF-42 OOS Out of scope (body) agent/agentpreview/preview.go:46 "file previews" means single-file previews in the agent but all path previews in appurl and proxy R2 Gon No
CRF-43 P3 Author contested; panel closed R4 (1/1 accept) turn_environment.go:1920 After a lazy-validation switch, the conn is checked and cached under the workspace ID that UpdateChatBuildAgentBinding returned, not the one dialed R3 Ryosuke Yes
CRF-44 P3 Author fixed (9554451) openpreview.go:139 Agent older than #31282 returns text/plain 404; model gets "404 page not found" with no restart hint R3 Chopper Yes
CRF-45 Nit Author fixed (9554451) turn_environment_internal_test.go:837 noPreviews comment names a wildcard hostname neither server has; the rows differ only in enablePreviews R3 Gon P2 Yes
CRF-46 Nit Dropped by orchestrator (wording was this panel's R2 suggestion; Leorio verified it) turn_environment.go:1973 getPreviewWorkspace doc restates the lock R3 Gon P2 No
CRF-47 Note Note (body) turn_environment.go:1919 CRF-40 lock move has no regression test; reverting it passes chatd tests R3 Netero No
CRF-48 OOS Out of scope (body) coderd/database/queries/chats.sql:1488 UpdateChatBuildAgentBinding has no workspace_id guard R3 Ryosuke No
CRF-49 OOS Out of scope (body) turn_environment.go:1572 loadWorkspaceAgentLocked re-checks against the persistBuildAgentBinding result, same race R3 Ryosuke No
CRF-50 P4 Author fixed (b6ea144) openpreview.go:142 404-means-outdated-agent mapping has no comment saying the handler never returns 404 R4 Gon Yes
CRF-51 P4 Author fixed (79a4c67) turn_environment.go:1474 CRF-40 fix untested though an existing test builds the mismatch state (mutation-verified) R5 Netero Yes
CRF-52 P4 Author fixed (79a4c67) turn_environment.go:1472 Third copy of the cache reset; the copies clear different field sets, the cause of CRF-40 R5 Zoro Yes
CRF-53 Nit Author fixed (79a4c67) turn_environment.go:1470 CRF-40 comment says "relabels the cache" instead of naming cachedWorkspaceID R5 Gon P2 Yes
CRF-54 Nit Author fixed (baa3150) turn_environment.go:1981 getPreviewWorkspace doc says it returns an agent ID, which only #31484 adds R6 Netero Yes
CRF-55 Nit Author fixed (baa3150) turn_environment.go:1347 resetCacheLocked should follow the Locked-variant naming: clearCachedWorkspaceStateLocked R6 Gon Yes
CRF-56 Note Note (body) openpreview.go:75 Tool name open_preview remains while description says it offers a preview; rename would break #31285 row selection R8 Luffy No
CRF-57 OOS Out of scope (body) #31286 commit 6c17e4e Commit message says a fresh result selects its preview; code now shows a toast and opens only on click R8 Kite No

Contested and acknowledged

CRF-3 (P4, openpreview.go:82) - Tool description hardcodes agent's 64-path limit

  • Finding: The description says "at most 64 paths", copying maxPreviews = 64 from agent/agentpreview/preview.go; proposed "a limited number of paths" and let the agent error state the limit.
  • Author defense: The agent ships in the same release as coderd, the number helps the model choose a directory over many files, and the agent's own error states the real limit if it ever differs.
  • Panel closure (R2, 1/1): Netero, the agent that raised it, accepted: a stale number costs one failed tool call, after which the agent error states the real limit.

CRF-9 (P2, coderd.go:948) - open_preview has no experiment or operator switch

  • Finding: Every deployment with a wildcard app hostname gets the tool on upgrade, and the only off switch is removing the hostname, which breaks subdomain apps; proposed a previews experiment like ACP subagents and virtual desktop.
  • Author defense: An experiment on the tool would not gate the agent endpoint or the routing, the tool gives no access the model lacks through execute and port forwarding, and many built-in tools have no switch.
  • Panel closure (R2, 1/1): Luffy, the agent that raised it, accepted: the model could already serve the same files with execute and the user could open the port through port forwarding, so the tool adds no capability; the cited experiments gate new capabilities.

CRF-14 (P3, turn_environment.go:2581) - enablePreviews gate untested

  • Finding: TestBuildTurnEnvironmentToolPolicy sets enablePreviews = true for every row; replacing the gate with if true passes; proposed a root case without previews asserting the tool is absent.
  • Author defense: A broken gate is visible right away, and covering it needs a second full test server in that table.
  • Panel re-raised (R2): Bisky, the agent that raised it, re-raised: CI and dogfood both set a wildcard app hostname, so a broken gate is not visible there, and the ACP gate has a cheap Off row (acp_internal_test.go:142).

CRF-15 (P4, openpreview.go:108) - Port upper bound untested

  • Finding: Deleting > 65535 passes TestOpenPreview, and port 70000 returns ok; proposed a 65536 row.
  • Author defense: If the bound broke, routing still refuses the port because it parses it as 16 bits.
  • Panel closure (R2, 1/1): Bisky, the agent that raised it, accepted: a broken bound yields one preview that fails at routing.

CRF-16 (P4, openpreview.go:94) - Neither-port-nor-path case untested

  • Finding: Changing hasPort == hasPath to hasPort && hasPath passes tests and sends an empty path to the agent; proposed a {"title":"App"} row.
  • Author defense: If the check broke, the agent rejects the empty path with its own error.
  • Panel closure (R2, 1/1): Bisky, the agent that raised it, accepted: the agent rejects an empty path with "preview path must be absolute" (agent/agentpreview/preview.go:56).

CRF-18 (P4, openpreview.go:109) - Port error does not explain the range

  • Finding: The error does not say why ports below 1000 fail or what to do for a server on 80, 443 or 999.
  • Author defense: The error and the argument description already give the valid range, which is what the model needs.
  • Panel closure (R2, 1/1): Leorio, the agent that raised it, accepted: the range is in the error and the argument description, costing at most one extra call.

CRF-20 (P4, turn_environment.go:2581) - open_preview name not reserved from dynamic tools when previews are disabled

  • Finding: Without a wildcard hostname a client-defined dynamic tool named open_preview is accepted, and feat: add chat previews endpoint #31285 selects rows by that tool name, so they appear once a hostname is configured; proposed reserving the name always.
  • Author defense: Only the chat owner defines dynamic tools, and the catalog accepts only results for the chat's own workspace, so a clash could only add the owner's own previews to their own chat. No other conditionally registered built-in reserves its name.
  • Panel closure (R2, 2/2): Ryosuke and Kurapika, the agents that raised it, accepted: feat: add chat previews endpoint #31285 drops results for other workspaces and preview hostnames require owner sharing level, so a forged entry grants no access the owner lacks.

CRF-21 (P4, openpreview.go:62) - IsPreviewURLPath is a URL rule living in chattool

  • Finding: Other preview URL rules live in appurl; proposed moving it there.
  • Author defense: The endpoint imports chattool anyway for OpenPreviewResult, and this rule validates that stored result, so it belongs next to it.
  • Panel closure (R2, 1/1): Ryosuke, the agent that raised it, accepted: no caller outside chat builds preview URLs from a user path, and the rule validates a field of the type chattool defines.

CRF-22 (P4, chatd_internal_test.go:1340) - getWorkspaceConn agent-switch test replaced by a getPreviewWorkspace test

  • Finding: The only test of getWorkspaceConn switching agents now goes through getPreviewWorkspace; proposed keeping the original test.
  • Author defense: getPreviewWorkspace calls getWorkspaceConn first, and the test still checks the dial order, the conn, the rebound chat and the agent, so no coverage is lost.
  • Panel closure (R2, 1/1): Zoro, the agent that raised it, accepted: the renamed test now checks the conn/agent pairing invariant this PR adds to getWorkspaceConn, plus the original assertions.

CRF-4 (P4, turn_environment.go:1982) - getPreviewWorkspace re-check branch untested

  • Finding: The "chat workspace changed while connecting" re-check in getPreviewWorkspace has coverage 0; proposed a test where the GetWorkspaceAgentByID mock clears the cache on its second call, or returning agent name and workspace ID from getWorkspaceConn so the branch disappears.
  • Author defense: Per the human author's decision, unchanged. The branch is a two-line guard whose only behavior is returning an error instead of a nil conn when a concurrent call clears the cache; a test would need a mock keyed to a specific GetWorkspaceAgentByID call count, tying it to getWorkspaceConn internals; changing getWorkspaceConn's return would touch every caller to remove one guard.

CRF-40 (P4, turn_environment.go:1928) - conn/workspace pairing still breakable in the selectWorkspace window

  • Finding: R2 (Razor P3): ensureWorkspaceAgent can set c.agent/cachedWorkspaceID to B while c.conn is A's. R3 re-raise (Razor, Takumi P4): after the lock move, selectWorkspace still sets the chat and clears the cache in two steps; a tool call between them reaches the ensureWorkspaceAgent mismatch branch and pairs A's conn with B. Proposed holding c.mu across both steps or dropping c.conn in the mismatch branch.
  • Author defense: Tools reach ensureWorkspaceAgent only through getWorkspaceConn, whose every attempt first runs getWorkspaceConnLocked under c.mu, dropping a conn whose cached ID does not match. Loading the described state and calling the real entry points returned B's conn, workspace and agent. The scratch test called ensureWorkspaceAgent directly, which no tool does. The only remaining path is the UpdateChatBuildAgentBinding race (CRF-43).
  • Panel re-raised (R4): Razor, the agent that raised it, re-raised with new evidence: c.mu is released at :1802 before ensureWorkspaceAgent takes it at :1834, so a parallel call can cache A's conn and setCurrentChat(B) can run in that gap; a scratch test calling only getPreviewWorkspace got conn is A's: true, WorkspaceID==B: true, AgentName: b-agent. Takumi, the other raiser, accepted on consequence (short window, converges once the clear runs) but confirmed the defense's ordering claim does not match the code. Stays open because one raiser re-raised.

CRF-43 (P3, turn_environment.go:1920) - lazy-validation switch caches the conn under the returned row's workspace ID

  • Finding: UpdateChatBuildAgentBinding updates by chat ID only, so after a concurrent create_workspace the returned row carries B and A's conn is cached as B; proposed keeping and caching the dialed workspace ID.
  • Author defense: The race is in UpdateChatBuildAgentBinding, unchanged from main, and reproduces on origin/main for every tool. Recording the dialed workspace ID does not fix it because the chat row is already bound to A's agent, so the retry dials A again. The fix is a guarded update in that query, outside this stack.
  • Panel closure (R4, 1/1): Ryosuke, the agent that raised it, accepted: the mislabel predates this PR (the base switch branch already cached the persistBuildAgentBinding row's workspace ID), and the proposed fix would redial A because the chat row already holds A's agent ID; the only fix is the guarded query (CRF-48).

Round log

Round 1

Full panel (round 1). Netero first pass: 1 P2, 1 P3, 1 P4, 2 Notes, no P0, panel proceeded. Law not run (effective additions 358). Panel: ging-go, kurapika, melody, ryosuke, takumi, luffy (specialists); pariston, mafuuu (core); bisky, gon, leorio, hisoka (pool); zoro (wildcard). Multi-domain target 9-12; 13 including wildcard. Result: 5 P2, 6 P3, 8 P4, 3 Nit posted; 8 dropped; 5 out of scope. CRF-13 severity settled at P3: Gon's P2 asked the agent to write prose, which repo AGENTS.md:75 forbids, but AGENTS.md:76 requires reviewers to flag added TODOs. Reviewed against 2209295..2ce038a.

Round 2

Fix round (no files added or moved; GetWorkspace to GetPreviewWorkspace rename and getWorkspaceConn patch were fixes for CRF-25 and CRF-8). Churn guard PROCEED: 14 addressed, 9 contested. CRF-4 and CRF-31 reopened because the CRF-8 fix kept the getPreviewWorkspace re-check that their drop reason assumed would go. Netero (reused) no new findings, CI failures are cancellations. Panel: luffy, bisky, leorio, ryosuke, kurapika, zoro (dispute check-in, previous agents reused); ging-go, takumi (specialists for changed Go and locking code); gon (comments changed); razor (wildcard). Disputes: 8 closed, CRF-14 re-raised. New: CRF-40 P3; CRF-11 re-raised at P4; CRF-4 posted at P4; CRF-31 posted at Nit. CRF-33, CRF-34, CRF-35 resolved by the stack. Reviewed against 886faee..c2b194d.

  • Panel closure (R3, 2/2): Netero and Bisky, the agents that raised it, accepted: the guard fails safe, the race is rare, and the only deterministic test keys on the second GetWorkspaceAgentByID call, so an unrelated query reorder would break it.

Round 3

Fix round (no files added or moved; changes fix CRF-11, CRF-14, CRF-31, CRF-40). Churn guard PROCEED: 4 addressed, 1 contested (CRF-4). Netero (reused) no new findings; accepted CRF-4. Panel: bisky (reused for CRF-4 dispute); razor (CRF-40 raiser); gon, leorio (comment changes, CRF-11 and CRF-31); takumi (locking change); ging-go, ryosuke (Go specialists); chopper (wildcard). CRF-4 closed 2/2. CRF-11, CRF-14, CRF-31 verified fixed. CRF-40 re-raised at P4 (Razor, Takumi converge on the selectWorkspace window). New: CRF-43 P3, CRF-44 P3, CRF-45 Nit. Gon's doc-comment bloat dropped. Reviewed against 96a0777..31acf45.

Round 4

Fix round (changes fix CRF-44, CRF-45; turn_environment.go unchanged). Churn guard PROCEED: 2 addressed, 2 contested. Netero (reused) no new findings, verified CRF-44 by mutation. Panel: razor, takumi (CRF-40 raisers, reused), ryosuke (CRF-43 raiser, reused), chopper (CRF-44 raiser, reused), gon (CRF-45 raiser, reused), zoro (wildcard, new). CRF-43 closed 1/1. CRF-40 re-raised by Razor with a real-entry-point repro; Takumi accepted. New: CRF-50 P4. Reviewed against be60b96..9554451.

Round 5

Fix round (changes fix CRF-40, CRF-50). Churn guard PROCEED: 2 addressed, 0 contested. Netero (reused) raised CRF-51 P4 (CRF-40 fix untested, mutation-verified). Panel: razor, takumi (CRF-40 raisers, new agents, no dispute), gon (CRF-50 comment), zoro (wildcard). CRF-40 and CRF-50 verified fixed; Takumi confirmed by scratch test that the CRF-51 test is writable. New: CRF-52 P4, CRF-53 Nit (Gon P2 posted as Nit, consistent with prior comment-wording findings: the comment is accurate and the code below it shows the drop). Reviewed against caf373e..b6ea144.

Round 6

Fix round (changes fix CRF-51, CRF-52, CRF-53). Churn guard PROCEED: 3 addressed. Netero (reused) verified CRF-51 by mutation and raised CRF-54 Nit. Panel: zoro (CRF-52 raiser), gon (CRF-53 raiser, comments), takumi (locking refactor), knov (wildcard); all new agents. All three fixes verified; Takumi and Knov confirmed the conn/agent/workspace invariant holds at every writer. New: CRF-54 Nit, CRF-55 Nit. Reviewed against caf373e..79a4c67.

Round 7

Fix round (rename and comment rewording only; fixes CRF-54, CRF-55). Churn guard PROCEED: 2 addressed. Netero (reused) no findings. Panel: gon (CRF-55 raiser), leorio (comments), takumi (locking code), chopper (wildcard); all new agents, all no findings. All in-scope findings resolved. Reviewed against caf373e..baa3150.

Round 8

Fix round (two-line wording change in openpreview.go; no prior finding targets it). Churn guard PROCEED: 0 open findings. Netero (reused) no findings. Panel: leorio, gon (model-facing text), luffy (product behavior wording), kite (wildcard); all new, all no findings. Kite verified the wording against #31286's toast flow. No open findings. Reviewed against caf373e..1a15f58.

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 open_preview root-chat tool, registered when a wildcard app hostname is set, and records port or agent-published file previews as tool results. Findings: 5 P2, 6 P3, 8 P4, 3 Nit.

The failing Flake Check run was cancelled by a newer run; it did not fail a test.

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

  • agent/agentpreview/preview.go:110: preview IDs come from a counter that restarts at 00000001 in each agent process, so an ID issued before a restart names a different path afterward and stored results open the wrong content.
  • agent/agentpreview/api.go:70: handleOpen passes req.Path to open without filepath.IsAbs, so a relative path resolves against the agent's working directory; the coderd check in this PR is the only absolute-path guard.
  • coderd/x/chatd/turn_environment.go:1933: getWorkspaceConn can cache a conn while c.agent is zeroed by a concurrent clearCachedWorkspaceState, so the cache-hit disconnect check at :1801 is skipped for the rest of the turn.
  • coderd/exp_chats_previews.go (#31285): the 1000-65535 port range is written a third time, so a routing change leaves the tool and the endpoint on the old range with no compile error.
  • agent/agentpreview/preview.go:31 and agent/agentpreview/api.go:73: the agent errors "previews are closed" and "Could not open preview." do not tell the model that the agent is stopping or what to change.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
Comment thread coderd/x/chatd/turn_environment.go Resolved
Comment thread coderd/coderd.go Resolved
Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
Comment thread coderd/x/chatd/chatd_internal_test.go Resolved
Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
@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.

Round 2 on c2b194d. Open findings: 2 P3, 2 P4, 1 Nit. One P3 and one Nit are new. One P3 and one P4 were raised again because they were not fully fixed. The P4 re-check gap was dropped in round 1 and is posted now.

The fixes were checked against the code, several by mutation tests: Windows paths reach the agent, preview IDs are random, getWorkspaceConn caches the agent with its conn, agent errors have no transport details, the url_path rules are tested, and the doc and naming changes are in. That fix also resolves the round 1 out-of-scope item about the cache-hit disconnect check. The reviewers who raised them accepted your replies on the 64-path limit, the experiment gate, the port bound and empty-target tests, the port error text, the dynamic tool name, where IsPreviewURLPath lives, and the renamed test. The enablePreviews gate test is still requested (reply on that thread).

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

  • coderd/x/chatd/turn_environment.go:1464: in the state described on turn_environment.go:1928, getWorkspaceConnLocked returns the previous workspace's conn to every tool, so execute, read_file and write_file run on the previous workspace for the rest of the turn while the chat is bound to the new one.
  • agent/agentpreview/preview.go:46: the agent uses "file previews" for single-file previews only, while appurl.go:151 and workspaceapps/proxy.go:773 use it for every preview opened with path.

Notes:

  • CI failures on this head are cancellations by a newer run (changes, lint, Flake Check), not test failures.
  • After a lazy-validation switch loses the race to cache its conn, c.agent is the winning conn's agent while currentChat.AgentID is the switched agent (turn_environment.go:1960). The PR description states this, and the next cache hit re-checks the winning agent.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/turn_environment.go Resolved
Comment thread coderd/x/chatd/turn_environment.go Resolved
Comment thread coderd/x/chatd/turn_environment.go Resolved
@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

Out-of-scope items from the round 2 body:

  • coderd/x/chatd/turn_environment.go:1464: fixed in 31acf45 by the CRF-40 change. The workspace check and the cache write in getWorkspaceConn now happen under one c.mu section, so cachedWorkspaceID always describes the cached conn. When the chat moves to another workspace, getWorkspaceConnLocked therefore drops the old conn instead of returning it to execute, read_file and write_file.
  • agent/agentpreview/preview.go:46 (now :47-48 at 2d9f1f6): not changing. This is correct as stated. The comment is on the unexported preview.file field, and it uses "file previews" and "directory previews" for the two cases that field encodes. Outside agentpreview, "file preview" covers every preview opened with path. The comment is in feat: serve published file previews from the workspace agent over tailnet #31282 and describes only that field, so it does not conflict with the names that the model and coderd use.

🤖 Posted by Coder Agents on behalf of @DanielleMaywood.

@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.

Round 3 on 31acf45. Open findings: 2 P3 (new), 1 P4 (the conn/workspace pairing fix is partial), 1 Nit.

Fixes checked against the code: the RootWithoutPreviews row fails when the gate is forced on, the file preview naming is consistent, and getPreviewWorkspace has its doc comment. The reviewers who raised the untested re-check guard in getPreviewWorkspace accepted your reply. The lock move in getWorkspaceConn closes the dial race from round 2, but two other writers can still put a wrong workspace ID next to the cached conn (reply on the conn/workspace thread, and the inline comment at turn_environment.go:1920). The pairing fix is the same for both: record the workspace ID the conn was dialed for and return it from getWorkspaceConn.

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

  • coderd/database/queries/chats.sql:1488: UpdateChatBuildAgentBinding updates by chat ID with no workspace_id guard, so a lazy-validation switch that races create_workspace writes workspace A's build and agent IDs onto a chat already bound to workspace B, and later turns run every workspace tool on A.
  • coderd/x/chatd/turn_environment.go:1572: loadWorkspaceAgentLocked checks the workspace against the persistBuildAgentBinding result in the same way, so the same race caches A's agent under workspace B.
  • coderd/x/chatd/turn_environment.go:1464: the round 2 item about other tools using the previous workspace's conn is only partly fixed. In the selectWorkspace window described on the conn/workspace thread, execute still gets A's conn.

Notes:

  • Reverting the lock move in getWorkspaceConn (turn_environment.go:1919) leaves the chatd tests passing; a deterministic test would need a hook between two adjacent statements.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/turn_environment.go Resolved
Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

On the out-of-scope items in the review body: UpdateChatBuildAgentBinding (chats.sql), loadWorkspaceAgentLocked, and turn_environment.go:1464 all come from the same race in UpdateChatBuildAgentBinding. It exists on main in code this stack does not touch, so it is not being changed here. On the note about the lock move: agreed, a deterministic test would need a hook between two adjacent statements, so it stays untested.

🤖 Posted by Coder Agents on behalf of @DanielleMaywood.

@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.

Round 4 on 9554451. Open findings: 2 P4 (one new, one contested and raised again).

The outdated-agent 404 message and the noPreviews comment are fixed; a mutation test confirmed the OutdatedAgent row catches the 404 branch. The reviewer who raised the UpdateChatBuildAgentBinding caching issue accepted your reply: the mislabel predates this PR and needs the guarded query, which stays listed as out of scope. The conn/workspace pairing in the selectWorkspace window is still open. The reply on that thread shows it through getPreviewWorkspace, without calling ensureWorkspaceAgent directly. It needs either the small fix there or a human decision to accept the gap.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/chattool/openpreview.go Resolved
@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.

Round 5 on b6ea144. Open findings: 2 P4, 1 Nit, all on the conn/workspace pairing fix.

The pairing fix in the ensureWorkspaceAgent mismatch branch is verified: every write that sets c.conn also sets its agent and workspace ID under c.mu, and every write that clears agentLoaded now clears c.conn. The old conn is released once, after unlocking. The comment on the 404 mapping is accurate; the publish handler writes only 400 or 200. The remaining items are a test for the fix, one shared reset helper, and a comment wording change.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/turn_environment.go Resolved
Comment thread coderd/x/chatd/turn_environment.go Resolved
Comment thread coderd/x/chatd/turn_environment.go Resolved
@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.

Round 6 on 79a4c67. Open findings: 2 Nits.

The round 5 findings are fixed and verified. A mutation of the ensureWorkspaceAgent mismatch branch now fails TestTurnWorkspaceContext_EnsureWorkspaceAgentIgnoresCachedAgentForDifferentWorkspace. All three full cache clears go through resetCacheLocked, and every write to c.conn keeps its agent and workspace ID with it. The mismatch-branch comment names cachedWorkspaceID. Clearing cachedWorkspaceID in the mismatch branch is safe: if loadWorkspaceAgentLocked fails, the cache is fully empty and the next call reloads from the chat row.

🤖 This review was automatically generated with Coder Agents.

Comment thread coderd/x/chatd/turn_environment.go Resolved
Comment thread coderd/x/chatd/turn_environment.go Resolved
@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.

Round 7 on baa3150. No open findings.

The last two Nits are fixed: the getPreviewWorkspace doc comment lists the three fields it returns, and the cache reset helper is now clearCachedWorkspaceStateLocked at its definition and all three callers. The change since round 6 is the rename and comment wording only; lock order, field writes and release order are unchanged, and the chatd and chattool tests pass with -race.

The out-of-scope items from earlier rounds are unchanged and still need a ticket or explicit acceptance by a human, chiefly the missing workspace_id guard in UpdateChatBuildAgentBinding (coderd/database/queries/chats.sql:1488).

🤖 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.

Round 8 on 1a15f58. No open findings.

The change since round 7 rewords the OpenPreview doc comment and the first sentence of the tool description to say the tool offers a preview that the user opens from the chat. That matches the handler, which only validates, publishes and returns a result, and the #31286 UI, which shows a toast with an "Open preview" action. No other text in the stack still says the tool opens or selects the preview.

The out-of-scope items from earlier rounds still need a ticket or explicit acceptance by a human, chiefly the missing workspace_id guard in UpdateChatBuildAgentBinding (coderd/database/queries/chats.sql:1488).

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

  • #31286 commit 6c17e4e6b3: the commit message says a fresh open_preview result selects its preview and shows the tab, but the code now shows a toast and opens the preview only on click, so the squash commit would describe behavior the code no longer has.

Notes:

  • The tool is still named open_preview while the description says it offers a preview. The description's first sentence states the behavior, and renaming would change the tool name #31285 selects rows by.

🤖 This review was automatically generated with Coder Agents.

Root chats outside plan mode get open_preview. It takes a short title and
exactly one of port (an existing HTTP server) or path (an HTML file or a
directory with index.html, published through the workspace agent). The
result records the workspace, agent name and either the port or the
preview ID the agent returned, which the UI uses to build the preview app
URL.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants