Skip to content

feat: open coder_app tabs from open_preview - #31484

Draft
DanielleMaywood wants to merge 2 commits into
feat/agents-open-preview-docsfrom
feat/agents-open-preview-apps
Draft

DanielleMaywood wants to merge 2 commits into
feat/agents-open-preview-docsfrom
feat/agents-open-preview-apps

Conversation

@DanielleMaywood

@DanielleMaywood DanielleMaywood commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

open_preview accepts an app slug and opens that coder_app in its existing right panel tab instead of the Preview tab, so the agent can show an IDE or another workspace app the template already defines.

  • The tool looks up the bound agent's apps as the chat owner and accepts only subdomain apps that are not hidden, external, or command apps. Path-based apps are rejected because they run on the dashboard's origin. An unknown slug returns the slugs that qualify.
  • The chat resolves the slug on its agent and opens the app through the same handler as the add-tab menu. agent-browser opens the built-in Browser tab. The tool card shows Open app. App results get no new-preview toast, because an app can serve code the agent controls without the restrictions on preview pages.
  • App results stay out of the /previews catalog, because they name neither a port nor a preview ID.

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
  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. This PR: open coder_app tabs
Decision log
  • Option A: open the app's own tab. The right panel already has a workspace_app tab with its own URL building and auth, so open_preview reuses it rather than listing apps in the Preview tab.
  • Subdomain filter on both sides. The tool rejects hidden, external, command, and path-based apps so the model gets a clear error. Clicking Open app checks again that the app is a subdomain app and passes isWorkspaceAppEmbeddable, because the agent's apps can change after the tool ran, such as on a rebuild. Path-based apps are excluded because they run on the dashboard's origin.
  • Authorization. The agent ID comes from the chat's bound workspace connection, not from model arguments, and the app lookup runs as the chat owner through asOwner.
  • Catalog excludes apps. The Preview tab lists only port and path previews, so no catalog or SDK change was needed.
  • agent-browser. It has the built-in Browser tab, which opens only when that app is available; otherwise nothing opens.

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

@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:29:03.278315Z 7997c4f 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: d4d6eaecca

ℹ️ 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".

@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-apps branch from d4d6eae to 30b20c0 Compare October 30, 2026 12:42
@DanielleMaywood

DanielleMaywood commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

@codex review

🤖 Posted by Coder Agents on behalf of @DanielleMaywood.

@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: 30b20c0673

ℹ️ 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".

@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-apps branch from 30b20c0 to f542fad Compare October 30, 2026 13:12
@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

@codex review

🤖 Posted by Coder Agents on behalf of @DanielleMaywood.

@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: f542fad9f5

ℹ️ 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".

@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-apps branch from f542fad to 413c649 Compare October 30, 2026 13:30
@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

@codex review

🤖 Posted by Coder Agents on behalf of @DanielleMaywood.

@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: 413c6494ca

ℹ️ 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".

@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-apps branch from 413c649 to a7ea204 Compare October 30, 2026 14:16
@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-apps branch from a7ea204 to d6d5330 Compare October 30, 2026 14:47
@DanielleMaywood
DanielleMaywood force-pushed the feat/agents-open-preview-apps branch 2 times, most recently from 67fa63d to f379c34 Compare November 1, 2026 15:20

@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 reviews the squashed commit b600922. Findings: 4 P3 (one re-raised), 7 P4, 3 Nit. Two of the P4 findings, the archived-chat gate comment and the commit body, are at the end of this body instead of in threads because their locations are outside the diff; reply to them in a PR comment.

The fixes for the round 1 findings are in the code. Three are incomplete, and the inline comments cover what remains: the tool description's first sentence, the click-time subdomain check, which skips agent-browser, and the agent-browser branch, which has no test. Of the seven contested findings, the reviewers that raised them accepted the defense for six: the external and command test rows, the unauthorized-owner test, the vitest test for the Open app card, the no-qualifying-apps branch, the app+port test, and the app-versus-port question. They re-raised the dead Open app button; see that thread.

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

  • site/src/modules/apps/apps.ts:315: getAgentBrowserApp accepts a path-based agent-browser app, so the Browser tab, which the add-tab menu also opens, embeds it on the dashboard origin without a sandbox. This is the same problem as the isWorkspaceAppEmbeddable item from round 1.

site/src/pages/AgentsPage/components/ChatElements/tools/PreviewPanelContext.tsx:212

P4 [CRF-36] The comment gives a preview-only reason, but the gate below it also removes Open app in archived chats. (Leorio)

The app branch never calls savePersistedSelectedPreview, so "the preview selection, which opening relies on" does not apply to apps. If hiding apps in archived chats is intended (your reply on the archived-chat thread says it is), say so in the comment; otherwise gate only the preview branch.

🤖

In reply to PRR_kwDOGkVX1s8AAAABWOW2GQ:

P4 [CRF-38] The commit body of b600922 says the tool checks "that the right panel can embed" the app, and the PR description's first bullet says the same, though the code and docs now state the rule as subdomain-only for a security reason. (Leorio)

The add-tab menu embeds path-based apps, so a maintainer reading git log learns the wrong rule. Write, for example: "The tool checks that the chat owner can read the agent's app and that it is a subdomain app that is not hidden, external, or a command app. Path-based apps are rejected because they run on the dashboard's origin."

🤖

🤖 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 docs/coder-agents/index.md 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

Responses to the round 3 review body:

  • [CRF-36] (PreviewPanelContext.tsx:212): fixed in 2baf11e. Hiding Open app in archived chats is intended, and the comment now says why: "Archived chats are read-only and do not save the preview selection that opening a preview relies on."
  • [CRF-38] (commit body and PR description): fixed. The commit body of 2baf11e and the description's first bullet now state the rule as subdomain apps that are not hidden, external, or command apps, with path-based apps rejected because they run on the dashboard's origin.
  • Out of scope (site/src/modules/apps/apps.ts:315, getAgentBrowserApp accepts a path-based agent-browser): this behavior comes from feat: add built-in Browser tab for agent-browser #27910 on main, and this PR doesn't change it. Opening agent-browser from an open_preview result now also requires a subdomain app. Whether to change the add-tab menu is left to @DanielleMaywood.

🤖 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 is blocked on one re-raised finding with no response. The other round 3 findings have a fix or a reply.

Unaddressed:

  • P3 [CRF-11] site/src/pages/AgentsPage/components/ChatElements/tools/PreviewPanelContext.tsx:185: in a stopped workspace, every app card says "<title> is ready to open" and Open app does nothing, because a stop build stores no agents and workspaceAgent is undefined. The round 3 re-raise is a reply on the thread for this finding, which still shows as Resolved because this account cannot unresolve threads. It explains why the comparison to previews from another workspace does not hold (Tool.tsx:1209 hides the button for those) and proposes a canOpen(target) from useChatPreviewPanel. Fix it, or reply on that thread with why the button should stay enabled.

The next round reviews the current head, including the three contested round 3 findings, after a fix or a reply to this finding.

CI shows fmt and lint-docs failing. gofmt, biome format, markdownlint-cli2, and markdown-table-formatter pass locally on this PR's files, so the failures may come from elsewhere in the rebased stack (not verified).

🤖 This review was automatically generated with Coder Agents.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

On the CI note: fmt and lint-docs passed on run 42053725389 for the previous head 2baf11e, so the failures you saw came from an earlier run. That run's test-js failure was OrganizationSkillSharingDialog.test.tsx > saves only the changed entries, which this PR does not touch.

🤖 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 5 reviews c5b0dd1, which replaces onOpenPreview with getOpenAction so the card shows Open app only when it can open. Findings: 5 P4, 3 Nit. One P4, the /previews test, is at the end of this body instead of in a thread because its file is outside the diff; reply to it in a PR comment.

The dead Open app button in stopped workspaces is fixed, and the round 3 fixes hold. The reviewers that raised the two contested round 3 findings accepted your defenses: the doc comment that restates the filter, and the typo-slug error message.

Notes:

  • PreviewPanelContext.tsx:130: apps never auto-open only because the scan loop filters out "app" in target; typing useOpenNewPreviews' onOpenPreview as the preview member of the union would make the compiler enforce that rule.

coderd/exp_chats_previews_test.go:96

P4 [CRF-47] No test proves that app results stay out of /previews, which the PR description states as a property of the change. (Melody, Ryosuke)

chatPreviewsFromResults (coderd/exp_chats_previews.go:75) skips app results only because hasPort == hasPreviewID is true when both are unset, a check written to reject malformed results. If a later change relaxes it, app results appear in the Preview tab catalog with no URL and TestChatPreviews still passes. Add insertResult(map[string]any{"title": "Editor", "app_slug": "code-server"}) to the "None of these may appear" block.

🤖

🤖 This review was automatically generated with Coder Agents.

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

Copy link
Copy Markdown
Collaborator Author

On the review body:

  • CRF-47 (app results stay out of /previews): not adding an app row. chatPreviewsFromResults never reads app_slug, so an app result is a result with neither a port nor a preview ID. The "Neither" row added to TestChatPreviews in feat: add chat previews endpoint #31285 fails if the exactly-one check is relaxed, which covers the same path.
  • Typing onOpenPreview as the preview member of the union: not changing. The "does not open apps" test already enforces that rule, and the type would add an alias and annotations that restate it.

🤖 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 6 reviews 56b1985. No new findings, and no findings remain open.

The round 5 fixes are in the code: the new useChatPreviewPanel table fails when the workspace ID check, the archived gate, or the subdomain agent-browser branch is removed, and the three renames and the comment change are in place. The reviewers that raised the two contested round 5 findings accepted your defenses: the existing "Neither" row in TestChatPreviews covers app results staying out of /previews, and the docs now say Open app works while the workspace is running.

Still open from round 1 and round 3 (needs a ticket or explicit acceptance by a human): isWorkspaceAppEmbeddable (site/src/modules/apps/apps.ts:302) and getAgentBrowserApp (apps.ts:315) accept path-based apps, so the add-tab menu and the Browser tab embed them on the dashboard origin without a sandbox. This PR's open_preview path rejects them.

🤖 This review was automatically generated with Coder Agents.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

@DanielleMaywood's decision on isWorkspaceAppEmbeddable and getAgentBrowserApp accepting path-based apps in the add-tab menu and Browser tab:

Pre-existing and out-of-scope

@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 reviews f442ee5, which matches the round 6 change apart from base-branch context in openpreview.go. One Nit; nothing else is open. The out-of-scope path-based app embedding in the add-tab menu and Browser tab is recorded as accepted per your PR comment.

🤖 This review was automatically generated with Coder Agents.

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 8 reviews 1feaa85. No new findings, and no findings remain open. This PR's patch is identical to round 7, and the getPreviewWorkspace doc comment now lists the agent ID.

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

  • coderd/x/chatd/turn_environment.go:1981: the doc comment fix landed in #31284's commit 79a4c67, where PreviewWorkspace has no AgentID until this PR adds it, so #31284 through #31287 describe a field that does not exist if they merge without this PR.

🤖 This review was automatically generated with Coder Agents.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

On the out-of-scope getPreviewWorkspace comment: fixed. The wording was squashed into #31284 by mistake; #31284 (baa3150) now has the original comment, and only this PR (d676de5) says "agent ID".

🤖 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 9 reviews d676de5. No new findings, and no findings remain open. The only change to this PR's patch is the getPreviewWorkspace doc comment, which now gains "agent ID" in the same commit that adds AgentID, while #31284 keeps the original wording. That resolves the stack-ordering item from round 8.

🤖 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 10 reviews 98f3a43, rebased onto the stack's new-preview toast. Findings: 1 P3, 2 P4. The P4 about the useChatPreviewPanel doc comment is at the end of this body instead of in a thread because its line is outside the diff; reply to it in a PR comment.

The adaptation holds: app results never reach the toast, and the toast and the Open app button both go through getOpenAction behind canOpenResults. Removing isOtherUserReadOnly and the narrow-viewport check affected only auto-open, which app results never had. The three findings are text that still describes the old auto-open behavior.


site/src/pages/AgentsPage/components/ChatElements/tools/PreviewPanelContext.tsx:153

P4 [CRF-56] The useChatPreviewPanel doc comment says it "offers new results in a toast", which this PR makes false for app results. (Gon, Leorio)

The PR adds app results to the hook and filters them out of the toast, so a reader of the hook's contract expects a toast for every new open_preview result. Change it to "offers new port and file previews in a toast".

🤖

🤖 This review was automatically generated with Coder Agents.

Comment thread docs/coder-agents/index.md Resolved
@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

CRF-56: fixed in a2b6f3e. The useChatPreviewPanel doc comment now says it "offers new port and file previews in a toast".

🤖 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 11 reviews a2b6f3e. No new findings, and no findings remain open. The three round 10 fixes are in place: the app filter comment says app results get no toast, and the hook doc and the docs limit the toast to port and file previews. The tool description's new first sentence is accurate for both target kinds.

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

  • site/src/pages/AgentsPage/components/ChatElements/tools/Tool.tsx:1178: port and file result cards still say "Opened <title>", but since the stack's toast change a preview opens only when the user selects Open preview, so the card states an action that did not happen. The label comes from the base stack, not this PR.

🤖 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 12 reviews 2cde57d. No new findings, and no findings remain open. The only change since round 11 is the docs sentence at docs/coder-agents/index.md:324, which now matches the base toast: Opened a preview, shown only for port, file, and directory previews.

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

  • site/src/pages/AgentsPage/components/ChatElements/tools/PreviewPanelContext.tsx:233: the base toast now says "Opened a preview", but the preview opens only when the user selects the toast's Open preview button, so the toast states an action that has not happened. This is the same issue as the Tool.tsx:1178 card label from round 11. Both strings come from the base stack, not this PR.

🤖 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 13 reviews 9b55b2a. No new findings, and no findings remain open. After the rebase, the base owns the canOpenResults gate and the archived-chat toast dismissal; this PR only rewords the archived-chat comment and adds workspaceAgent and openWorkspaceApp to the base's toast test. The reworded comment is accurate for both Open preview and Open app.

The out-of-scope items from rounds 11 and 12 ("Opened <title>" on port and file cards at Tool.tsx:1178, and the "Opened a preview" toast text) are unchanged base text.

🤖 This review was automatically generated with Coder Agents.

@DanielleMaywood

Copy link
Copy Markdown
Collaborator Author

🤖 Posted by Coder Agents on behalf of @DanielleMaywood.

Adds url_path support for app targets, per review feedback. The tool now accepts url_path with app as well as port, and the app tab the result opens carries it into the app's URL: {"title": "VS Code", "app": "code-server", "url_path": "/?folder=/home/coder/project"}. App tabs dedupe on app and path.

Also rebased on main (base moved to 693a6c6); all stack branches were force-pushed with the new SHAs.

open_preview accepts an app slug. The tool checks that the chat owner can
read the agent's app and that it is a subdomain app that is not hidden,
external, or a command app. Path-based apps are rejected because they run
on the dashboard's origin. The user opens the app's existing workspace app
tab from the tool result. App results stay out of the preview catalog.

Generated by Coder Agents on behalf of @DanielleMaywood.
open_preview now accepts url_path with an app as well as a port. The tool
validates it as before and stores it in the result, and the app tab the
result opens carries it into the app's URL, so an app can open at a path
and query other than its root, such as /?folder=/home/coder/project. App
tabs dedupe on the app and path, and the docs describe the argument.

Generated by Coder Agents on behalf of @DanielleMaywood.

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.

1 participant