Skip to content

feat: status item right-click context menu support #16

Description

@JokerRun

Problem

When using statusItem(), there is no way to attach a native context menu to the status bar icon. Right-clicking (or ctrl-clicking) does nothing.

For agent-driven UIs (e.g. companion panels, monitoring tools), a right-click menu is essential for actions like Quit, Toggle visibility, Open inspector, etc. Without it, users must build these controls inside the popover HTML, which is cumbersome and non-native.

Proposed Solution

Add native NSMenu support for status items:

Swift side:

  • Handle rightMouseUp and ctrl+leftMouseUp on the status item button
  • Parse a new status-menu JSON command to build NSMenu items dynamically
  • Emit {"type":"menu","id":"..."} on stdout when a menu item is selected

Node wrapper:

  • Add setMenu(items) method on the GlimpseWindow instance
  • Emit 'menu' event with the selected item id

Usage

const menu = statusItem(html, { title: 'My Agent' });

menu.setMenu([
  { id: 'inspect', title: 'Open Inspector' },
  { id: 'quit', title: 'Quit' },
]);

menu.on('menu', (id) => {
  if (id === 'quit') process.exit(0);
});

I have a working implementation and will open a PR shortly.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions