Skip to content

fix: apply dashboard app link rules to coder open app - #31261

Closed
EhabY wants to merge 1 commit into
mainfrom
fix/cli-open-app-session-token
Closed

EhabY wants to merge 1 commit into
mainfrom
fix/cli-open-app-session-token

Conversation

@EhabY

@EhabY EhabY commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

coder open app now fills in $SESSION_TOKEN using the same link rules as the dashboard (#31208): a known Coder handler, a url that is the deployment the CLI is logged in to, and token=$SESSION_TOKEN as the only placeholder. Previously it filled in the token for any template app URL.

External app URLs that still contain the placeholder are printed with a warning instead of opened. Sub-agent apps still never get the token. Apps without the placeholder open as before.

The allowed handlers now live in one place in codersdk, as VS Code-family schemes (VSCodeSessionTokenScheme), VSCodeCoderExtensionID, VSCodeSessionTokenPath and JetBrainsSessionTokenHandler. The dashboard gets them through typesGenerated.ts, and hard-coded coder.coder-remote link builders now use VSCodeCoderExtensionID.

Breaking changes

For template apps that use $SESSION_TOKEN, coder open app now prints the URL with the placeholder and exits 0 instead of opening it when:

  • The URL isn't a known Coder handler, for example https://..., http://... or another custom scheme.
  • url isn't the deployment the CLI is logged in to. This includes templates that override provider "coder" { url = ... }, CLIs logged in through a different hostname than the one in the link, and url values with a path, userinfo or an explicit default port.
  • The link has a non-standard shape: the placeholder outside the raw token= entry, duplicate or percent-encoded param names, or a JetBrains Gateway link that doesn't start with #type=coder&.

Inside a workspace (CODER=true), these URLs are printed with the placeholder instead of the token.

Decision log
  • Port the dashboard's handler and destination check rather than only a scheme list: a scheme list would still fill in the token for IDE links pointing at another deployment.
  • Trust only client.URL: the CLI has no browser origin. Scheme and host are compared exactly, so the CLI may be slightly stricter than the dashboard.
  • Keep refusing sub-agent apps instead of opening them with an empty token, as the dashboard does.
  • One handler list: codersdk enums used by the CLI and generated for the dashboard, instead of two hand-kept copies. VS Code-family links are rebuilt from scheme, extension ID and path; the 3 JetBrains prefixes don't share that shape, so they stay whole. Both callers split every prefix with the same rule: scheme and authority end at the first /, ? or # after ://. The tracked app sessions registry wasn't reused: it lists apps for usage tracking, not links trusted with a token.
  • Keep an explicit handler list rather than accepting any <scheme>://coder.coder-remote link: the scheme decides which program opens the link, and only VS Code forks treat coder.coder-remote as the Coder extension.
  • Same parameter rules as the dashboard: no extra rejection of & or = in decoded values, since registry modules put folders and download links in unencoded.

Generated with Coder Agents.

@EhabY EhabY self-assigned this Oct 26, 2026
@coder coder deleted a comment from linear-code Bot Oct 26, 2026
@linear-code

linear-code Bot commented Oct 26, 2026

Copy link
Copy Markdown

CLI-57

@dylanhuff-at-coder

Copy link
Copy Markdown
Collaborator

Closing in favor of #31721, which lands the same coder open app fix (Ehab's ok with it). Thanks @EhabY! Your codersdk handler list is carried over in #31767.

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants