Repository navigation
feat(gui-extensions): add terminal to session panel menu - #57942
SlasshyOverhere wants to merge 1 commit into
Conversation
The session panel + menu only offered Open file and Open browser, leaving the terminal reachable only through View > Toggle Terminal. Register a third menu item that opens the terminal dock and focuses its active pty.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
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. |
|
Thanks for this, @SlasshyOverhere. The description and screenshots make the gap easy to follow. I think this duplicates #56892, which also adds Terminal to the session side panel's If you see something missing there, such as focus handling or the shortcut hint in the menu, reviewing, testing or commenting on #56892 would be the best way to help. |
Why
The session side panel's
+menu only offered Open file and Open browser. The terminal existed and worked, but the only way to reach it was theView → Toggle Terminalcommand or its `ctrl+`` shortcut. If you were already working in the side panel, opening a terminal meant leaving that menu, hunting through the command palette or the View menu, and then finding the panel that appeared.That gap is inconsistent: the other two things the side panel can host are discoverable from the menu it owns, and the terminal was not.
What
Registers a third item, Terminal, in the same
session.panelmenu, next to Open file (order: 10) and Open browser (order: 20):Selecting it opens the terminal in the right sidebar panel and puts the cursor in the active terminal.
Behavior details:
Toggle Terminalcommand closes the panel when it is already open. A menu item named "Terminal" that closes the terminal when you pick it a second time is surprising, so this item only opens and focuses. Closing stays with the command, the panel's own close control, andView → Toggle Terminal.layout.open(DOCK, session)against the sameterminal:maindock the toggle command uses, so the item never creates a second terminal panel, a second pty, or a second set of restore buffers. Whatever was already running in the session's terminal is what you land in.terminal.requestFocus(terminal.active()), so you can type immediately instead of clicking into the pane.ctx.sessions.current()and returns early when there is none, matching how the toggle command guards itself.keybind: "terminal.toggle"publishes the existingToggle Terminalbinding, so the menu item renders with the same `ctrl+`` hint the other entries show for their commands.tab.titlekey ("Terminal" / "ターミナル" / …) instead of adding a near-duplicate string.Implementation is entirely inside the
terminalgui-extension. No app, server, protocol, or generated client changes, so nothing needed regenerating (bun run generateis unnecessary: no publicProtocolorHttpApichange).Files
packages/gui-extensions/src/terminal/renderer.tsx— one import (MenuItemfrom../sdk) and onectx.add(MenuItem, …)registration next to the existingtoggleandnewcommands.The explicit
MenuItemreturn annotation is required: a bare object literal widensmenutostringand stops satisfying the discriminated union of session-panel, add-server, and server-row items.Verification
bun run typecheck— 34/34 turbo tasks successful, no errors.bun run lint— exit 0, no errors (only the repo's pre-existing warnings).View → Toggle Terminal,ctrl+\``, theterminal` slash command) still behave as before, since the panel and dock were not touched.Notes for review
MenuItem. The terminal has no "unavailable" state to hide it in, and the extension is only loaded for sessions anyway.