Skip to content

feat(gui-extensions): add terminal to session panel menu - #57942

Closed
SlasshyOverhere wants to merge 1 commit into
anomalyco:devfrom
SlasshyOverhere:sidebar-terminal
Closed

SlasshyOverhere wants to merge 1 commit into
anomalyco:devfrom
SlasshyOverhere:sidebar-terminal

Conversation

@SlasshyOverhere

@SlasshyOverhere SlasshyOverhere commented Oct 21, 2026 •

Copy link
Copy Markdown

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 the View → Toggle Terminal command 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.panel menu, next to Open file (order: 10) and Open browser (order: 20):

# Item Menu order
1 Open file 10
2 Open browser 20
3 Terminal 30

Selecting it opens the terminal in the right sidebar panel and puts the cursor in the active terminal.

Behavior details:

  • Always opens, never toggles. The existing Toggle Terminal command 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, and View → Toggle Terminal.
  • Reuses the existing terminal. It calls layout.open(DOCK, session) against the same terminal:main dock 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.
  • Focuses the active pty. After opening, it calls terminal.requestFocus(terminal.active()), so you can type immediately instead of clicking into the pane.
  • No session, no item. The callback resolves the routed session through ctx.sessions.current() and returns early when there is none, matching how the toggle command guards itself.
  • Shortcut is shown. keybind: "terminal.toggle" publishes the existing Toggle Terminal binding, so the menu item renders with the same `ctrl+`` hint the other entries show for their commands.
  • Localized. The title reuses the existing tab.title key ("Terminal" / "ターミナル" / …) instead of adding a near-duplicate string.

Implementation is entirely inside the terminal gui-extension. No app, server, protocol, or generated client changes, so nothing needed regenerating (bun run generate is unnecessary: no public Protocol or HttpApi change).

Files

packages/gui-extensions/src/terminal/renderer.tsx — one import (MenuItem from ../sdk) and one ctx.add(MenuItem, …) registration next to the existing toggle and new commands.

ctx.add(
  MenuItem,
  (): MenuItem => ({
    menu: "session.panel",
    id: "open",
    title: ctx.t("tab.title"),
    icon: "terminal",
    keybind: "terminal.toggle",
    order: 30,
    run() {
      const target = current()

      if (!target) return

      layout.open(DOCK, target.session)
      target.terminal.requestFocus(target.terminal.active())
    },
  }),
)

The explicit MenuItem return annotation is required: a bare object literal widens menu to string and 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).
  • Ran the desktop app against this branch and used the new item: it opens the terminal panel in the right sidebar and focuses the active pty; picking it again leaves the open terminal open.
  • Existing entry points (View → Toggle Terminal, ctrl+\``, the terminal` slash command) still behave as before, since the panel and dock were not touched.

Notes for review

  • The item is registered unconditionally for the routed session, mirroring the browser extension's simple case rather than the browser's availability-gated MenuItem. The terminal has no "unavailable" state to hide it in, and the extension is only loaded for sessions anyway.
  • Nothing is added to the terminal's tab strip or the widget layout: this is purely a discoverability entry point into the panel that already existed.

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.
Copilot AI balanced review requested due to automatic review settings October 21, 2026 22:25
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Oct 21, 2026

Copilot AI 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.

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.

@github-actions

Copy link
Copy Markdown
Contributor

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

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

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.

@opencode-agent opencode-agent Bot closed this Oct 21, 2026
@opencode-agent

Copy link
Copy Markdown
Contributor

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 + menu (next to Open file / Browser). It goes further and makes each terminal its own side panel tab, replacing the dock this item opens.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants