Repository navigation
fix(desktop): open the active file from the Open in button - #59903
shahidirfan100 wants to merge 1 commit into
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
There was a problem hiding this comment.
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()} |
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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.
|
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. |
Issue for this PR
Closes #55858
Type of change
What does this PR do?
The side-panel
Open inbutton always passedscreen.file.rootto 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()asactiveFile, resolves it with the existingresolveOpenInAppPathhelper, 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
ReviewPaneltoOpenInAppButtonand the existingresolveOpenInAppPathcases: 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
Added by the opencode bot (AI-generated).
Public API: adds optional
activeFiletoOpenInAppPropsin@opencode/plugin/gui/file(backwards compatible)