DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
feat(shell): 新窗口按钮常驻所有机器行
Menghuan1918224393080f5e
diff --git a/src/layout/components/remote-switcher.test.tsx b/src/layout/components/remote-switcher.test.tsxindex 2418e0b1..0f225c03 100644--- a/src/layout/components/remote-switcher.test.tsx+++ b/src/layout/components/remote-switcher.test.tsx@@ -234,16 +234,16 @@ describe('remoteSwitcher 增强(4.4)', () => {})describe('remoteSwitcher 行内双动作(当前窗口 vs 新窗口)', () => {- it('已连接机器行尾出现新窗口按钮:点击只发 remote_open_window,不触发切换', async () => {+ it('新窗口按钮常驻所有机器行:点击只发 remote_open_window,不触发切换', async () => {seedMachines([machineOf({ id: 'm1', name: 'alpha', state: 'connected', tunnelBaseUrl: 'http://127.0.0.1:4001' }),machineOf({ id: 'm2', name: 'beta', state: 'disconnected' }),])render(<RemoteSwitcher onManage={manageSpy} />)const menu = await openMenu()- // 仅已连接行有按钮(title/aria 语义键)+ // 已连接与未连接行都有按钮(未连接开窗后由新窗口内壳层发起连接)const buttons = within(menu).getAllByRole('button', { name: 'remote.open_new_window' })- expect(buttons.length).toBe(1)+ expect(buttons.length).toBe(2)fireEvent.click(buttons[0]!)await waitFor(() => {expect(invokeSpy).toHaveBeenCalledWith('remote_open_window', { machineId: 'm1', url: 'http://127.0.0.1:4001' })@@ -253,6 +253,18 @@ describe('remoteSwitcher 行内双动作(当前窗口 vs 新窗口)', () =>expect(remote.pendingId).toBeNull()})+ it('未连接机器的新窗口按钮:url 置空(窗口内启动连接流程)', async () => {+ seedMachines([machineOf({ id: 'm2', name: 'beta', state: 'disconnected' })])+ render(<RemoteSwitcher onManage={manageSpy} />)+ const menu = await openMenu()+ const button = within(menu).getByRole('button', { name: 'remote.open_new_window' })+ fireEvent.click(button)+ await waitFor(() => {+ expect(invokeSpy).toHaveBeenCalledWith('remote_open_window', { machineId: 'm2', url: '' })+ })+ expect(remote.activeId).toBeNull()+ })+it('机器行显示 user@host:port 副标题', async () => {seedMachines([machineOf({ id: 'm1', name: 'alpha', host: '10.1.1.1', port: 22, user: 'root', state: 'disconnected' })])render(<RemoteSwitcher onManage={manageSpy} />)diff --git a/src/layout/components/remote-switcher.tsx b/src/layout/components/remote-switcher.tsxindex f8f0250c..c0cc95f9 100644--- a/src/layout/components/remote-switcher.tsx+++ b/src/layout/components/remote-switcher.tsx@@ -37,11 +37,12 @@ function subtitleOf(machine: SshMachineRow): string | undefined {return target}-/** 新窗口打开远端(复用壳层 remote_open_window 命令;聚焦已有窗口)。 */+/**+ * 新窗口打开远端(复用壳层 remote_open_window 命令;聚焦已有窗口)。+ * 未连接机器也可开窗(url 置空):新窗口内壳层启动即发起标准连接流程。+ */function openInNewWindow(machine: SshMachineRow, onError: (err: unknown) => void): void {- if (machine.tunnelBaseUrl === undefined)- return- invoke('remote_open_window', { machineId: machine.id, url: machine.tunnelBaseUrl })+ invoke('remote_open_window', { machineId: machine.id, url: machine.tunnelBaseUrl ?? '' }).catch(onError)}@@ -154,26 +155,25 @@ export function RemoteSwitcher({ onManage }: { onManage: () => void }) {<Description className={cn('ml-auto shrink-0', pending && 'text-warning')}>{stateTextOf(machine, pending, t)}</Description>- {/* 行尾双动作:行本体=当前窗口切换;图标=新窗口打开。- RAC 菜单项的 press 由原生事件冒泡驱动(其 PressEvent- 无 stopPropagation),故图标用原生 span + 事件阻断:+ {/* 行尾双动作:行本体=当前窗口切换;图标=新窗口打开(常驻——+ 未连接机器开窗后由新窗口内壳层发起连接)。RAC 菜单项的+ press 由原生事件冒泡驱动(其 PressEvent 无+ stopPropagation),故图标用原生 span + 事件阻断:点击只发 remote_open_window,本窗口不跟着切换 */}- <If cond={connected}>- <span- role="button"- tabIndex={-1}- aria-label={t('remote.open_new_window')}- className="inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted hover:bg-panel2 hover:text-ink"- onPointerDown={e => e.stopPropagation()}- onPointerUp={e => e.stopPropagation()}- onClick={(e) => {- e.stopPropagation()- openInNewWindow(machine, handleOpenWindowError)- }}- >- <ArrowUpRightFromSquare className="size-3.5" />- </span>- </If>+ <span+ role="button"+ tabIndex={-1}+ aria-label={t('remote.open_new_window')}+ className="inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-muted hover:bg-panel2 hover:text-ink"+ onPointerDown={e => e.stopPropagation()}+ onPointerUp={e => e.stopPropagation()}+ onClick={(e) => {+ e.stopPropagation()+ openInNewWindow(machine, handleOpenWindowError)+ }}+ >+ <ArrowUpRightFromSquare className="size-3.5" />+ </span></span></Dropdown.Item>)