fmt(js): npm run fix on merge (#94046)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7e500d2ead
commit
74ad422d50
@@ -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'
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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<HyprlandDispatchReply> {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@@ -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', () => {
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ export function missingRendererAssets(indexPath: string, deps: RendererBundleDep
|
||||
|
||||
if (!existsSync(file)) {
|
||||
missing.push(ref)
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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 })
|
||||
})
|
||||
|
||||
@@ -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'))
|
||||
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user