Skip to content

The agent that grows with you

fix(desktop): right-click on the terminal rail + opens the gateway menu

Teknium2325df0f1885
diff --git a/apps/desktop/src/app/right-sidebar/terminal/rail-new-terminal.tsx b/apps/desktop/src/app/right-sidebar/terminal/rail-new-terminal.tsx
index 3dbe36c7149..73b06d8dbb4 100644
--- a/apps/desktop/src/app/right-sidebar/terminal/rail-new-terminal.tsx
+++ b/apps/desktop/src/app/right-sidebar/terminal/rail-new-terminal.tsx
@@ -53,17 +53,20 @@ export function NewTerminalButton({ className }: { className: string }) {
</button>
)
- const tipped = (
+ // The context-menu trigger (when there is one) sits inside the Tip, right on
+ // the button: Tip hands its extra props to the tooltip content, so a trigger
+ // wrapped around it never reaches the button.
+ const tipped = (trigger: ReactNode) => (
<Tip
label={<TipHintLabel hint={newHint && formatCombo(newHint)} text={t.rightSidebar.terminalNew} />}
placement="right-rail"
>
- {button}
+ {trigger}
</Tip>
)
if (!choices.length) {
- return <li className="flex w-full justify-center">{tipped}</li>
+ return <li className="flex w-full justify-center">{tipped(button)}</li>
}
const items = (Item: typeof ContextMenuItem | typeof DropdownMenuItem): ReactNode =>
@@ -77,7 +80,7 @@ export function NewTerminalButton({ className }: { className: string }) {
return (
<li className="flex w-full flex-col items-center">
<ContextMenu>
- <ContextMenuTrigger asChild>{tipped}</ContextMenuTrigger>
+ {tipped(<ContextMenuTrigger asChild>{button}</ContextMenuTrigger>)}
<ContextMenuContent>
<ContextMenuLabel>{t.rightSidebar.terminalNewOn}</ContextMenuLabel>
{items(ContextMenuItem)}
diff --git a/apps/desktop/src/app/right-sidebar/terminal/rail.test.tsx b/apps/desktop/src/app/right-sidebar/terminal/rail.test.tsx
index b3629c77594..e0712b10dfc 100644
--- a/apps/desktop/src/app/right-sidebar/terminal/rail.test.tsx
+++ b/apps/desktop/src/app/right-sidebar/terminal/rail.test.tsx
@@ -1,6 +1,8 @@
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
+import type { DesktopConnectionsRegistry } from '@/global'
+import { $connectionsRegistry } from '@/store/connections'
import { $bindings } from '@/store/keybinds'
import { TerminalRail } from './rail'
@@ -31,4 +33,29 @@ describe('TerminalRail', () => {
expect($activeTerminalId.get()).toBe('term-1')
expect($terminals.get()).toHaveLength(1)
})
+
+ it('right-click on + opens the gateway menu and opens a tab on the picked gateway', async () => {
+ $connectionsRegistry.set({
+ connections: [
+ { id: 'local', kind: 'local', label: 'This device' },
+ { id: 'nas', kind: 'ssh', label: 'NAS' }
+ ],
+ primary: 'local',
+ version: 2
+ } as unknown as DesktopConnectionsRegistry)
+
+ try {
+ render(<TerminalRail />)
+ const plus = screen.getByRole('button', { name: 'New terminal' })
+
+ // The app-wide menu leaves a marked trigger alone; an unmarked one gets the generic menu.
+ expect(plus.hasAttribute('data-hermes-context-menu-trigger')).toBe(true)
+ fireEvent.contextMenu(plus)
+
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'NAS' }))
+ expect($terminals.get().at(-1)).toMatchObject({ connectionId: 'nas', kind: 'user' })
+ } finally {
+ $connectionsRegistry.set(null)
+ }
+ })
})