Skip to content

fix(desktop): open the active file from the Open in button - #59903

Closed
shahidirfan100 wants to merge 1 commit into
anomalyco:devfrom
shahidirfan100:fix/desktop-open-in-active-file
Closed

shahidirfan100 wants to merge 1 commit into
anomalyco:devfrom
shahidirfan100:fix/desktop-open-in-active-file

Conversation

@shahidirfan100

@shahidirfan100 shahidirfan100 commented Oct 28, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #55858

Type of change

  • Bug fix

What does this PR do?

The side-panel Open in button always passed screen.file.root to the launcher, so the selected file opened its workspace folder in Zed or VS Code. The review panel already knows the active file, but it did not pass it to the button.

This passes activeDiff() as activeFile, resolves it with the existing resolveOpenInAppPath helper, and falls back to the workspace root when no file is selected. The file context menu already used that helper.

How did you verify your code works?

I checked the call path from ReviewPanel to OpenInAppButton and the existing resolveOpenInAppPath cases: relative file, absolute path, Windows root and empty. Prettier passes for the three files. I did not run the Electron desktop build locally; the change is a prop pass-through plus the path helper already used by the context menu.

Visual

No OpenCode UI change. The behavior change is which file the external editor opens.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Public API: adds optional activeFile to OpenInAppProps in @opencode/plugin/gui/file (backwards compatible)

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • Not all checklist items are checked. Please confirm you have tested locally and have not included unrelated changes.

Please edit this PR description to address the above within 72 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

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

Thanks for picking this up. As written, I don't think this changes what the button opens. The review panel doesn't render OpenInAppButton directly. It renders the OpenInApp.Button contract, and the file plugin implements that in packages/gui-plugins/src/file/renderer.tsx (ctx.provide(OpenInApp, { Button: bindPlugin((props: OpenInAppProps) => …) })). That implementation still renders <OpenInAppButton session={props.session} screen={props.screen} /> and never passes activeFile on. So the button always gets undefined and opens the workspace root, as before. It needs to pass activeFile={props.activeFile} there.

I checked this by tracing the code; I couldn't run the desktop app here. src/file/path.test.ts passes and tsc -b in packages/gui-plugins is clean.

Public API: this adds an optional activeFile?: string to OpenInAppProps in @opencode/plugin/gui/file. It's backwards compatible: existing callers and implementations still compile and keep the root behaviour.

Scope: #55858 is mostly about the "Open in" button next to the side panel's file tabs, which is mounted in the session.panel.end slot in renderer.tsx with only screen and session. This PR doesn't touch that button, so file tabs will still open the root. Either wire the active file tab into that slot too, or change Closes #55858 to a partial reference. The issue's right-click context-menu gaps (file tree, file tab) are also not covered.

It would also help to try it once in the desktop app before merging, since the PR wasn't run locally.

component={openIn().Button}
screen={props.screen}
session={props.session}
activeFile={activeDiff()}

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.

openIn().Button is the OpenInApp contract implementation in file/renderer.tsx, which renders <OpenInAppButton session={props.session} screen={props.screen} /> and never passes activeFile on. So this prop never reaches OpenInAppButton and the button still opens the root. That wrapper needs activeFile={props.activeFile}.

}

export default function OpenInAppButton(props: { session: MountedSession; screen: SessionScreen }) {
export default function OpenInAppButton(props: {

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 other caller of this component, the session.panel.end slot in file/renderer.tsx (the button next to the side panel's file tabs, which #55858 is mainly about), still passes only session and screen. File tabs will keep opening the workspace root unless the active tab's path is passed there too.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 72-hour window.

Feel free to open a new pull request that follows our guidelines.

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.

desktop(v2): "Open in" button in side panel header opens workspace root directory instead of the active file tab

1 participant