Skip to content

feat(desktop): add menu-bar tray companion - #52365

Closed
iamdavidhill wants to merge 2 commits into
devfrom
menu-bar-tray
Closed

iamdavidhill wants to merge 2 commits into
devfrom
menu-bar-tray

Conversation

@iamdavidhill

Copy link
Copy Markdown
Contributor

Adds an opt-out OpenCode menu-bar (macOS) / system-tray (Windows, Linux) companion that lists the active session tabs and offers quick actions. It works from the desktop app and from the terminal app.

Menu

Needs you
  [favicon•] Fix login
             dashboard · Context 52% · $0.12
Active sessions
  [ • ]      CSV export                       ← working
             cli · Context 18% · $0.03
  [favicon•] Refactor auth                    ← finished, not yet viewed (blue dot)
             api · No context · $0.00
────────────
New Agent…   ⌘N
Settings     ⌘,
Docs
────────────
Quit         ⌘Q
  • Lists open session tabs only, not history. Sessions with questions or permission requests appear under Needs you.
  • A working session shows a dot. A blue corner dot means the session finished and has not been viewed. An attention dot means it needs input. The menu-bar icon also gets a dot when any session needs attention.
  • Favicons use the desktop's resolved project colours and overrides. Titles and project names are truncated. Tooltips show Local or Worktree, the context percentage, and the cost.
  • ⌘⌥O opens the menu from anywhere (Ctrl+Alt+O on Linux, Win+Alt+O on Windows, because Ctrl+Alt is AltGr on many layouts). On Windows, the footer items are plain options without shortcut labels.

Two hosts, one tray

flowchart LR
  subgraph Desktop
    R[Renderer tabs] -- AppSetTrayTabs --> M[Electron main]
  end
  subgraph Terminal
    T[TUI tabs] -- state --> B[CLI bridge<br/>127.0.0.1 + bearer token]
    B <-- poll /state, POST /command --> C[Electron tray-only companion]
  end
  M --> S[(OpenCode service)]
  C --> S
  M --> Tray
  C --> Tray
Loading
  • Desktop: the renderer publishes open tabs and avatars. The main process loads session status, context, and cost from the service (native/tray-sessions.ts). Tray actions go to the window that owns the session.
  • Terminal: opencode (bun run dev locally) starts an authenticated loopback bridge (cli/services/terminal-tray.ts) and launches a tray-only Electron entrypoint (desktop/src/main/terminal-tray.ts). New Agent, Settings, and selecting a session run in the TUI. On macOS, the terminal app is also brought to the front. Quitting the companion leaves the TUI running, and the companion exits when the last terminal client exits.
  • The bridge contract is in @opencode/schema/terminal-tray:
Command = { type: "session"; sessionID } | { type: "new" | "settings" | "focus" }
State   = { enabled; focused; sessions: string[]; current? }

Opt-out

  • Desktop: Settings → General → Menu bar / system tray.
  • Terminal: Settings → Terminal → Menu bar / system tray, "tray": { "enabled": false } in cli.json, or OPENCODE_TRAY=0.
  • The companion is not launched over SSH, on headless Linux, or for non-interactive commands.

Screenshots

@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant