The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): 'New terminal on…' tabs record the active profile
Teknium0079924fcd58
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.tsxindex 73b06d8dbb4..7efa51c5840 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@@ -22,14 +22,25 @@ import type { DesktopRegistryConnection } from '@/global'import { useI18n } from '@/i18n'import { formatCombo } from '@/lib/keybinds/combo'import { cn } from '@/lib/utils'+import { $connectionsRegistry } from '@/store/connections'import { $bindings } from '@/store/keybinds'+import { $activeGatewayProfile } from '@/store/profile'-import { $localGateway, $terminalShellGateways } from './terminal-gateway'+import { $localGateway, $terminalShellGateways, defaultTerminalGateway, shellGatewayFor } from './terminal-gateway'import { createTerminal } from './terminals'type GatewayChoice = Pick<DesktopRegistryConnection, 'id' | 'kind' | 'label'>-const openOn = (choice: GatewayChoice) => createTerminal(undefined, { connectionId: choice.id })+// Same {connectionId, profile} record as +, so the SSH tunnel is the active+// profile's. The session's cwd is a path on its own host: a tab on another+// gateway starts in its home instead.+function openOn(choice: GatewayChoice) {+ const gateway = shellGatewayFor(choice.id, $activeGatewayProfile.get(), $connectionsRegistry.get())+ const session = defaultTerminalGateway()+ const sameHost = !session || gateway?.connectionId === session.connectionId++ createTerminal(sameHost ? undefined : '', gateway)+}/** The rail's new-terminal control. Click opens on the gateway picked in* Sessions; with an SSH gateway registered, the chevron (or a right-click ondiff --git a/apps/desktop/src/app/right-sidebar/terminal/rail.test.tsx b/apps/desktop/src/app/right-sidebar/terminal/rail.test.tsxindex e0712b10dfc..61ee2c8eeee 100644--- a/apps/desktop/src/app/right-sidebar/terminal/rail.test.tsx+++ b/apps/desktop/src/app/right-sidebar/terminal/rail.test.tsx@@ -4,6 +4,8 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest'import type { DesktopConnectionsRegistry } from '@/global'import { $connectionsRegistry } from '@/store/connections'import { $bindings } from '@/store/keybinds'+import { $activeGatewayProfile } from '@/store/profile'+import { $connection } from '@/store/session'import { TerminalRail } from './rail'import { $activeTerminalId, $terminals } from './terminals'@@ -58,4 +60,31 @@ describe('TerminalRail', () => {$connectionsRegistry.set(null)}})++ it('a menu-opened SSH tab records the active profile and no path from another host', 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)+ $connection.set({ connectionId: 'local' } as never)+ const profile = $activeGatewayProfile.get()+ $activeGatewayProfile.set('work')++ try {+ render(<TerminalRail />)+ fireEvent.contextMenu(screen.getByRole('button', { name: 'New terminal' }))+ fireEvent.click(await screen.findByRole('menuitem', { name: 'NAS' }))++ // The tunnel is keyed by (gateway, profile); This device's cwd means nothing on the NAS.+ expect($terminals.get().at(-1)).toMatchObject({ connectionId: 'nas', cwd: '', profile: 'work' })+ } finally {+ $activeGatewayProfile.set(profile)+ $connection.set(null)+ $connectionsRegistry.set(null)+ }+ })})