From 74ad422d50e6d76e26ba5ce3b4d2a4d520e923dd Mon Sep 17 00:00:00 2001 From: "hermes-seaeye[bot]" <307254004+hermes-seaeye[bot]@users.noreply.github.com> Date: Mon, 24 Aug 2026 17:03:13 +0000 Subject: [PATCH] fmt(js): `npm run fix` on merge (#94046) Co-authored-by: github-actions[bot] --- apps/desktop/electron/hud-hyprland.test.ts | 38 ++++++++++--------- apps/desktop/electron/hud-hyprland.ts | 9 ++--- .../desktop/electron/hud-input-policy.test.ts | 5 +-- apps/desktop/electron/hud-input-policy.ts | 6 +-- apps/desktop/electron/renderer-bundle.ts | 1 + .../src/app/gateway/hooks/use-gateway-boot.ts | 4 ++ .../desktop/src/app/hud/composer-drag.test.ts | 4 +- .../desktop/src/app/hud/resize-handle.test.ts | 4 +- .../files/use-project-tree.test.ts | 21 ++++++++-- .../right-sidebar/files/use-project-tree.ts | 4 +- .../src/app/right-sidebar/index.test.tsx | 7 +--- apps/desktop/src/app/right-sidebar/index.tsx | 3 +- .../src/lib/json-rpc-gateway-recovery.test.ts | 10 ++--- ui-tui/src/__tests__/gatewayClient.test.ts | 8 +++- ui-tui/src/gatewayClient.ts | 9 ++++- 15 files changed, 74 insertions(+), 59 deletions(-) diff --git a/apps/desktop/electron/hud-hyprland.test.ts b/apps/desktop/electron/hud-hyprland.test.ts index bd5505cb5f..07feb0f615 100644 --- a/apps/desktop/electron/hud-hyprland.test.ts +++ b/apps/desktop/electron/hud-hyprland.test.ts @@ -19,8 +19,9 @@ import { const TITLE = 'Hermes HUD' const ADDRESS = '0x55d1' const SOCKET_ENV = { HYPRLAND_INSTANCE_SIGNATURE: 'abc123', XDG_RUNTIME_DIR: '/run/user/1000' } + const LUA_REJECT = - 'error: [string "return hl.dispatch(setfloating address:0x55d1)"]:1: \')\' expected near \'address\'\n\n → Note: dispatch in lua is a shorthand for hl.dispatch(...), your syntax might need to be updated.' + "error: [string \"return hl.dispatch(setfloating address:0x55d1)\"]:1: ')' expected near 'address'\n\n → Note: dispatch in lua is a shorthand for hl.dispatch(...), your syntax might need to be updated." afterEach(() => { resetHyprlandDispatchSyntax() @@ -40,10 +41,7 @@ test('classifies Hyprland dispatch replies the way 0.54 and 0.56 actually write assert.equal(classifyHyprlandDispatchReply('Invalid dispatcher'), 'wrong-syntax') assert.equal(classifyHyprlandDispatchReply(LUA_REJECT), 'wrong-syntax') assert.equal(classifyHyprlandDispatchReply('No such window found'), 'failed') - assert.equal( - classifyHyprlandDispatchReply('warning: =[C]:-1: hl.focus: window not found'), - 'failed' - ) + assert.equal(classifyHyprlandDispatchReply('warning: =[C]:-1: hl.focus: window not found'), 'failed') }) test('finds the HUD by exact title among other windows of the same pid', () => { @@ -74,20 +72,14 @@ test('legacy float is setfloating (idempotent), not togglefloating', () => { const commands = hudOverlayCommands(ADDRESS, 'float') assert.equal(commands.legacy, 'dispatch setfloating address:0x55d1') - assert.equal( - commands.lua, - 'dispatch hl.dsp.window.float({ action = "enable", window = "address:0x55d1" })' - ) + assert.equal(commands.lua, 'dispatch hl.dsp.window.float({ action = "enable", window = "address:0x55d1" })') }) test('lua pin uses enable so a second promote does not unpin', () => { const commands = hudOverlayCommands(ADDRESS, 'pin') assert.equal(commands.legacy, 'dispatch pin address:0x55d1') - assert.equal( - commands.lua, - 'dispatch hl.dsp.window.pin({ action = "enable", window = "address:0x55d1" })' - ) + assert.equal(commands.lua, 'dispatch hl.dsp.window.pin({ action = "enable", window = "address:0x55d1" })') }) test('skips compositors that are not Hyprland', async () => { @@ -99,6 +91,7 @@ test('skips compositors that are not Hyprland', async () => { uid: 1000, request: async (_socket, command) => { calls.push(command) + return 'ok' } }) @@ -118,19 +111,17 @@ test('floats then pins a tiled HUD on a classic hyprlang session', async () => { delayMs: 0, request: async (_socket, command) => { calls.push(command) + if (command === 'j/clients') { return JSON.stringify([hudClient()]) } + return 'ok' } }) assert.equal(promoted, true) - assert.deepEqual(calls, [ - 'j/clients', - 'dispatch setfloating address:0x55d1', - 'dispatch pin address:0x55d1' - ]) + assert.deepEqual(calls, ['j/clients', 'dispatch setfloating address:0x55d1', 'dispatch pin address:0x55d1']) }) test('falls back to Lua dispatch when the classic session grammar is rejected', async () => { @@ -144,12 +135,15 @@ test('falls back to Lua dispatch when the classic session grammar is rejected', delayMs: 0, request: async (_socket, command) => { calls.push(command) + if (command === 'j/clients') { return JSON.stringify([hudClient()]) } + if (command.startsWith('dispatch setfloating') || command.startsWith('dispatch pin ')) { return LUA_REJECT } + return 'ok' } }) @@ -168,9 +162,11 @@ test('caches Lua syntax so the next promote does not probe classic first', async if (command === 'j/clients') { return JSON.stringify([hudClient()]) } + if (command.startsWith('dispatch setfloating') || command.startsWith('dispatch pin ')) { return LUA_REJECT } + return 'ok' } @@ -193,6 +189,7 @@ test('caches Lua syntax so the next promote does not probe classic first', async delayMs: 0, request: async (_socket, command) => { calls.push(command) + return request(_socket, command) } }) @@ -215,9 +212,11 @@ test('does not pin a window that is already pinned, and does not float one that delayMs: 0, request: async (_socket, command) => { calls.push(command) + if (command === 'j/clients') { return JSON.stringify([hudClient({ floating: true, pinned: true })]) } + return 'ok' } }) @@ -239,11 +238,14 @@ test('retries until Hyprland lists the HUD', async () => { request: async (_socket, command) => { if (command === 'j/clients') { lookups += 1 + if (lookups < 3) { return JSON.stringify([{ address: '0x111', title: 'Hermes', floating: true }]) } + return JSON.stringify([hudClient({ floating: true, pinned: true })]) } + return 'ok' } }) diff --git a/apps/desktop/electron/hud-hyprland.ts b/apps/desktop/electron/hud-hyprland.ts index 0f0fde15fa..afd4766842 100644 --- a/apps/desktop/electron/hud-hyprland.ts +++ b/apps/desktop/electron/hud-hyprland.ts @@ -98,10 +98,7 @@ export function parseHudHyprlandClient(payload: string, title: string): HudHyprl return null } -export function hudOverlayCommands( - address: string, - action: 'float' | 'pin' -): { legacy: string; lua: string } { +export function hudOverlayCommands(address: string, action: 'float' | 'pin'): { legacy: string; lua: string } { const selector = `address:${address}` if (action === 'float') { @@ -122,8 +119,7 @@ async function dispatchWithFallback( socketPath: string, pair: { legacy: string; lua: string } ): Promise { - const order: HyprlandDispatchSyntax[] = - cachedSyntax === 'lua' ? ['lua', 'legacy'] : ['legacy', 'lua'] + const order: HyprlandDispatchSyntax[] = cachedSyntax === 'lua' ? ['lua', 'legacy'] : ['legacy', 'lua'] for (const syntax of order) { const command = syntax === 'legacy' ? pair.legacy : pair.lua @@ -140,6 +136,7 @@ async function dispatchWithFallback( } cachedSyntax = syntax + return kind } diff --git a/apps/desktop/electron/hud-input-policy.test.ts b/apps/desktop/electron/hud-input-policy.test.ts index b8521fadda..96ba97624a 100644 --- a/apps/desktop/electron/hud-input-policy.test.ts +++ b/apps/desktop/electron/hud-input-policy.test.ts @@ -49,10 +49,7 @@ test('an auto hint follows the session', () => { test('asking for X11 on a Wayland session gets the solid HUD', () => { assert.equal(hudInputPolicy('linux', WAYLAND_SESSION, ['--ozone-platform=x11']), 'solid') - assert.equal( - hudInputPolicy('linux', { ...WAYLAND_SESSION, ELECTRON_OZONE_PLATFORM_HINT: 'x11' }, []), - 'solid' - ) + assert.equal(hudInputPolicy('linux', { ...WAYLAND_SESSION, ELECTRON_OZONE_PLATFORM_HINT: 'x11' }, []), 'solid') }) test('the explicit switch beats the hint, and the last switch wins', () => { diff --git a/apps/desktop/electron/hud-input-policy.ts b/apps/desktop/electron/hud-input-policy.ts index ecc668dace..ddc2fb13a1 100644 --- a/apps/desktop/electron/hud-input-policy.ts +++ b/apps/desktop/electron/hud-input-policy.ts @@ -119,10 +119,6 @@ export function hudUsesNativeDrag(platform: string, env: NodeJS.ProcessEnv, argv * native titlebar drag. Native Wayland already delegates movement to the * compositor and must stay out of this path. */ -export function hudUsesWorkspaceTransfer( - platform: string, - env: NodeJS.ProcessEnv, - argv: readonly string[] -): boolean { +export function hudUsesWorkspaceTransfer(platform: string, env: NodeJS.ProcessEnv, argv: readonly string[]): boolean { return platform === 'linux' && hudInputPolicy(platform, env, argv) === 'solid' } diff --git a/apps/desktop/electron/renderer-bundle.ts b/apps/desktop/electron/renderer-bundle.ts index e9d3705022..03aed2ce21 100644 --- a/apps/desktop/electron/renderer-bundle.ts +++ b/apps/desktop/electron/renderer-bundle.ts @@ -117,6 +117,7 @@ export function missingRendererAssets(indexPath: string, deps: RendererBundleDep if (!existsSync(file)) { missing.push(ref) + continue } diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts index 20174af6a3..23763a39d3 100644 --- a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts +++ b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.ts @@ -405,6 +405,7 @@ export function useGatewayBoot({ if (!gatewayOpen()) { await attemptReconnect() + return } @@ -500,6 +501,7 @@ export function useGatewayBoot({ } publish(conn) + // Bounded for the same reason as attemptReconnect() (#93454): a wedged // ticket mint would otherwise hang the gateway switch forever. const wsUrl = await withTimeout( @@ -507,6 +509,7 @@ export function useGatewayBoot({ RECONNECT_ATTEMPT_TIMEOUT_MS, 'Timed out re-minting the gateway WebSocket URL' ) + await gateway.connect(wsUrl) if (cancelled) { @@ -799,6 +802,7 @@ export function useGatewayBoot({ RECONNECT_ATTEMPT_TIMEOUT_MS, 'Timed out minting the gateway WebSocket URL' ) + await gateway.connect(wsUrl) if (cancelled) { diff --git a/apps/desktop/src/app/hud/composer-drag.test.ts b/apps/desktop/src/app/hud/composer-drag.test.ts index 91f80062d3..f3f633bc95 100644 --- a/apps/desktop/src/app/hud/composer-drag.test.ts +++ b/apps/desktop/src/app/hud/composer-drag.test.ts @@ -98,9 +98,7 @@ describe('useHudComposerDrag', () => { it('spans X11 workspaces only for an armed grab, then pins to the current desktop on release', () => { const target = pressTarget() - const { result } = renderHook(() => - useHudComposerDrag(true, { controlDrag: true, workspaceTransfer: true }) - ) + const { result } = renderHook(() => useHudComposerDrag(true, { controlDrag: true, workspaceTransfer: true })) act(() => result.current.onPointerDown({ diff --git a/apps/desktop/src/app/hud/resize-handle.test.ts b/apps/desktop/src/app/hud/resize-handle.test.ts index 9ea59371e7..7d1ffd1390 100644 --- a/apps/desktop/src/app/hud/resize-handle.test.ts +++ b/apps/desktop/src/app/hud/resize-handle.test.ts @@ -89,9 +89,7 @@ describe('useHudResizeHandle', () => { 'nw' ) ) - act(() => - void window.dispatchEvent(new PointerEvent('pointermove', { pointerId: 4, screenX: 250, screenY: 275 })) - ) + act(() => void window.dispatchEvent(new PointerEvent('pointermove', { pointerId: 4, screenX: 250, screenY: 275 }))) expect(setBounds).toHaveBeenCalledWith({ x: 50, y: 175, width: 670, height: 345 }) }) diff --git a/apps/desktop/src/app/right-sidebar/files/use-project-tree.test.ts b/apps/desktop/src/app/right-sidebar/files/use-project-tree.test.ts index 8f538cfe65..21c7677860 100644 --- a/apps/desktop/src/app/right-sidebar/files/use-project-tree.test.ts +++ b/apps/desktop/src/app/right-sidebar/files/use-project-tree.test.ts @@ -294,7 +294,12 @@ describe('useProjectTree', () => { }) ) readDir.mockResolvedValueOnce(ok([{ name: 'from-b', path: '/shared/from-b', isDirectory: false }])) - $connection.set({ baseUrl: 'https://gateway.example', connectionId: 'connection-a', mode: 'local', profile: 'default' } as never) + $connection.set({ + baseUrl: 'https://gateway.example', + connectionId: 'connection-a', + mode: 'local', + profile: 'default' + } as never) const { result } = renderHook(() => useProjectTree('/shared')) @@ -332,7 +337,12 @@ describe('useProjectTree', () => { }) ) readDir.mockResolvedValueOnce(ok([{ name: 'src', path: '/shared/src', isDirectory: true }])) - $connection.set({ baseUrl: 'https://gateway.example', connectionId: 'connection-a', mode: 'local', profile: 'default' } as never) + $connection.set({ + baseUrl: 'https://gateway.example', + connectionId: 'connection-a', + mode: 'local', + profile: 'default' + } as never) const { result } = renderHook(() => useProjectTree('/shared')) @@ -369,7 +379,12 @@ describe('useProjectTree', () => { }) ) readDir.mockResolvedValueOnce(ok([{ name: 'from-b', path: '/shared/from-b', isDirectory: false }])) - $connection.set({ baseUrl: 'https://gateway.example', connectionId: 'connection-a', mode: 'local', profile: 'default' } as never) + $connection.set({ + baseUrl: 'https://gateway.example', + connectionId: 'connection-a', + mode: 'local', + profile: 'default' + } as never) const { result } = renderHook(() => useProjectTree('/shared')) diff --git a/apps/desktop/src/app/right-sidebar/files/use-project-tree.ts b/apps/desktop/src/app/right-sidebar/files/use-project-tree.ts index 22541fc51f..c36a6aa780 100644 --- a/apps/desktop/src/app/right-sidebar/files/use-project-tree.ts +++ b/apps/desktop/src/app/right-sidebar/files/use-project-tree.ts @@ -346,7 +346,9 @@ async function revalidateTree( const nextData = await reconcile(rootPath, state.data) setProjectTree(latest => - latest.cwd === cwd && latest.loaded && desktopFsCacheKey() === connectionKey ? { ...latest, data: nextData } : latest + latest.cwd === cwd && latest.loaded && desktopFsCacheKey() === connectionKey + ? { ...latest, data: nextData } + : latest ) } diff --git a/apps/desktop/src/app/right-sidebar/index.test.tsx b/apps/desktop/src/app/right-sidebar/index.test.tsx index 47f427a4be..9a0720f3e9 100644 --- a/apps/desktop/src/app/right-sidebar/index.test.tsx +++ b/apps/desktop/src/app/right-sidebar/index.test.tsx @@ -2,12 +2,7 @@ import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/re import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import type { HermesReadDirResult } from '@/global' -import { - $connection, - $selectedStoredSessionId, - $workspaceCwdOwner, - setCurrentCwd -} from '@/store/session' +import { $connection, $selectedStoredSessionId, $workspaceCwdOwner, setCurrentCwd } from '@/store/session' import { resetProjectTreeState } from './files/use-project-tree' diff --git a/apps/desktop/src/app/right-sidebar/index.tsx b/apps/desktop/src/app/right-sidebar/index.tsx index a8341690b1..b154ecf304 100644 --- a/apps/desktop/src/app/right-sidebar/index.tsx +++ b/apps/desktop/src/app/right-sidebar/index.tsx @@ -36,8 +36,7 @@ export function RightSidebarPane({ onActivateFile, onActivateFolder }: RightSide // A transition intentionally retains the old CWD until the new session // confirms its workspace. Do not issue a filesystem read against that path: // under a gateway switch it may belong to a different remote machine. - const hasWorkspace = - Boolean(currentCwd) && (workspaceCwdOwner ?? null) === (selectedStoredSessionId ?? null) + const hasWorkspace = Boolean(currentCwd) && (workspaceCwdOwner ?? null) === (selectedStoredSessionId ?? null) const { collapseAll, diff --git a/apps/desktop/src/lib/json-rpc-gateway-recovery.test.ts b/apps/desktop/src/lib/json-rpc-gateway-recovery.test.ts index f6bcc4ac4e..c7638d21ad 100644 --- a/apps/desktop/src/lib/json-rpc-gateway-recovery.test.ts +++ b/apps/desktop/src/lib/json-rpc-gateway-recovery.test.ts @@ -164,12 +164,10 @@ describe('hermes-ws-recovery-v1 silent blackhole', () => { await client.connect('ws://gateway.test/api/ws') await Promise.resolve() - const ambiguousSubmit = client - .request('prompt.submit', { session_id: 'runtime-1', text: 'one prompt' }) - .then( - () => null, - error => error as Error - ) + const ambiguousSubmit = client.request('prompt.submit', { session_id: 'runtime-1', text: 'one prompt' }).then( + () => null, + error => error as Error + ) await vi.advanceTimersByTimeAsync(61) await vi.waitFor(() => expect(backend.sockets).toHaveLength(2)) diff --git a/ui-tui/src/__tests__/gatewayClient.test.ts b/ui-tui/src/__tests__/gatewayClient.test.ts index 41c88d56f2..bce7602cc4 100644 --- a/ui-tui/src/__tests__/gatewayClient.test.ts +++ b/ui-tui/src/__tests__/gatewayClient.test.ts @@ -97,7 +97,13 @@ const { FakeWebSocket } = vi.hoisted(() => { vi.mock('undici', () => ({ WebSocket: FakeWebSocket })) -import { GatewayClient, RECONNECT_BASE_MS, RECONNECT_MAX_MS, WS_HEARTBEAT_DEAD_MS, WS_HEARTBEAT_INTERVAL_MS } from '../gatewayClient.js' +import { + GatewayClient, + RECONNECT_BASE_MS, + RECONNECT_MAX_MS, + WS_HEARTBEAT_DEAD_MS, + WS_HEARTBEAT_INTERVAL_MS +} from '../gatewayClient.js' describe('GatewayClient websocket attach mode', () => { const originalWebSocket = globalThis.WebSocket diff --git a/ui-tui/src/gatewayClient.ts b/ui-tui/src/gatewayClient.ts index 2730df10ee..8b30d0e7f9 100644 --- a/ui-tui/src/gatewayClient.ts +++ b/ui-tui/src/gatewayClient.ts @@ -270,7 +270,14 @@ export class GatewayClient extends EventEmitter { this.heartbeatSentAt = now try { - ws.send(JSON.stringify({ id, jsonrpc: '2.0', method: 'gateway.ping', params: { last_activity_ms: this.lastActivityAt } })) + ws.send( + JSON.stringify({ + id, + jsonrpc: '2.0', + method: 'gateway.ping', + params: { last_activity_ms: this.lastActivityAt } + }) + ) } catch { this.lifecycle('[lifecycle] websocket heartbeat send failed; forcing reconnect') this.stopHeartbeat()