fmt(js): npm run fix on merge (#107101)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
hermes-seaeye[bot]
2026-09-10 04:43:55 +00:00
committed by GitHub
parent 7cdc6a7338
commit 425b00174d
8 changed files with 50 additions and 17 deletions
+21 -10
View File
@@ -47,13 +47,18 @@ it('returns native clicks and approval actions to the emitting window, not the p
const focusWindow = vi.fn()
registerNativeNotifications({ getMainWindow: () => primary as unknown as BrowserWindow, focusWindow })
const notify = host.handle.mock.calls[0][1] as (event: IpcMainInvokeEvent, payload: HermesNotification) => boolean
const payload = {
kind: 'approval',
sessionId: 'runtime-source',
focusSessionId: 'stored-source',
title: 'Approval',
actions: [{ id: 'approve', text: 'Approve' }, { id: 'reject', text: 'Reject' }]
actions: [
{ id: 'approve', text: 'Approve' },
{ id: 'reject', text: 'Reject' }
]
}
expect(notify({ sender: source.webContents } as unknown as IpcMainInvokeEvent, payload)).toBe(true)
expect(focusWindow).not.toHaveBeenCalled()
expect(primary.webContents.send).not.toHaveBeenCalled()
@@ -89,16 +94,22 @@ it('delivers plugin callbacks to their source and falls back only for navigation
actions: [{ id: 'open', text: 'Open', activate: '/plugin/detail' }]
})
host.shown[0].emit('action', { actionIndex: 0 }, undefined)
expect(source.webContents.send).toHaveBeenCalledWith('hermes:notification-activate', expect.objectContaining({
actionId: 'open',
notifyId: 'source-callback',
activate: '/plugin/detail'
}))
expect(source.webContents.send).toHaveBeenCalledWith(
'hermes:notification-activate',
expect.objectContaining({
actionId: 'open',
notifyId: 'source-callback',
activate: '/plugin/detail'
})
)
expect(primary.webContents.send).not.toHaveBeenCalled()
source.isDestroyed.mockReturnValue(true)
host.shown[0].emit('click')
expect(primary.webContents.send).toHaveBeenCalledWith('hermes:notification-activate', expect.objectContaining({
activate: '/plugin',
notifyId: undefined
}))
expect(primary.webContents.send).toHaveBeenCalledWith(
'hermes:notification-activate',
expect.objectContaining({
activate: '/plugin',
notifyId: undefined
})
)
})
@@ -9,6 +9,7 @@ afterEach(() => vi.useRealTimers())
it('retains a dismissed banner until its later click or action is consumed', () => {
vi.useFakeTimers()
const registry = createNotificationRegistry()
for (const event of ['click', 'action']) {
const notification = Object.assign(new EventEmitter(), { close: vi.fn() })
const handler = vi.fn()
@@ -20,13 +21,16 @@ it('retains a dismissed banner until its later click or action is consumed', ()
expect(handler).toHaveBeenCalledOnce()
expect(registry.has(notification)).toBe(false)
}
expect(vi.getTimerCount()).toBe(0)
})
it('dismisses an expired notification before releasing it and releases failed delivery immediately', () => {
vi.useFakeTimers()
const registry = createNotificationRegistry({ ttlMs: 1000 })
const notification = Object.assign(new EventEmitter(), { close: vi.fn(() => expect(registry.has(notification)).toBe(true)) })
const notification = Object.assign(new EventEmitter(), {
close: vi.fn(() => expect(registry.has(notification)).toBe(true))
})
registry.retain(notification)
vi.advanceTimersByTime(1000)
expect(notification.close).toHaveBeenCalledOnce()
@@ -14,6 +14,7 @@ export function createNotificationRegistry({ ttlMs = NOTIFICATION_RETENTION_TTL_
function retain(notification: RetainedNotification): void {
live.add(notification)
const release = () => {
clearTimeout(timer)
live.delete(notification)
@@ -32,6 +33,7 @@ export function createNotificationRegistry({ ttlMs = NOTIFICATION_RETENTION_TTL_
notification.close()
release()
}, ttlMs)
timer.unref()
}
@@ -16,4 +16,3 @@ export interface HermesNotification {
notifyId?: string
actions?: { id: string; text: string; activate?: string }[]
}
@@ -7,7 +7,13 @@ import { group } from '@/components/pane-shell/tree/model'
import * as tree from '@/components/pane-shell/tree/store'
import { registry } from '@/contrib/registry'
import { $selectedStoredSessionId } from '@/store/session'
import { $sessionTiles, closeSessionTile, discardSessionTile, openSessionTile, patchSessionTile } from '@/store/session-states'
import {
$sessionTiles,
closeSessionTile,
discardSessionTile,
openSessionTile,
patchSessionTile
} from '@/store/session-states'
import { useDesktopIntegrations } from './use-desktop-integrations'
@@ -21,6 +27,7 @@ beforeAll(() => {
render: () => null,
title: 'Chat'
})
tree.watchContributedPanes()
paneMirror({
source: $sessionTiles,
@@ -80,12 +87,14 @@ it('a native click reveals the existing remote Bot tab without changing its owne
sessions: []
})
)
const scope = {
ownerRoute: { connectionId: 'remote-writer', profile: 'writer', mode: 'remote' as const },
workspaceMode: 'bots' as const,
workspaceOwnerKey: 'remote-writer::writer',
workspaceTabTitle: 'Bot Chat'
}
openSessionTile('bot-chat', 'center', 'workspace', undefined, scope)
patchSessionTile('bot-chat', { runtimeId: 'bot-runtime' })
tree.revealTreePane('workspace')
@@ -216,13 +216,19 @@ export function useDesktopIntegrations({
const storedId = viaLocalMap !== sessionId ? viaLocalMap : (storedSessionIdForRuntimeId(sessionId) ?? sessionId)
// A notification reveals a tab; it must not reclassify a Bot chat.
const scope = $sessionTiles.get().find(tile => tile.storedSessionId === storedId) ?? $botChatScopes.get()[storedId]
const scope =
$sessionTiles.get().find(tile => tile.storedSessionId === storedId) ?? $botChatScopes.get()[storedId]
if (isOverlayView(appViewForPath(locationPathname))) {
navigate(sessionRoute($selectedStoredSessionId.get() ?? ''), { replace: true })
}
openSession(storedId, navigate, 'stack', scope && { ...scope, workspaceMode: scope.workspaceMode ?? 'sessions' })
openSession(
storedId,
navigate,
'stack',
scope && { ...scope, workspaceMode: scope.workspaceMode ?? 'sessions' }
)
}
})
@@ -74,7 +74,9 @@ it('captures durable navigation identity while keeping the runtime id for approv
try {
dispatchNativeNotification({ kind: 'approval', sessionId: runtimeId, title: 'Approval' })
expect(notify).toHaveBeenCalledWith(expect.objectContaining({ sessionId: runtimeId, focusSessionId: 'durable-chat' }))
expect(notify).toHaveBeenCalledWith(
expect.objectContaining({ sessionId: runtimeId, focusSessionId: 'durable-chat' })
)
} finally {
dropSessionState(runtimeId)
}
@@ -212,7 +212,7 @@ export function dispatchNativeNotification(input: NativeNotificationInput): bool
actions: input.actions,
activate: input.activate,
body: input.body,
focusSessionId: input.sessionId ? storedSessionIdForRuntimeId(input.sessionId) ?? undefined : undefined,
focusSessionId: input.sessionId ? (storedSessionIdForRuntimeId(input.sessionId) ?? undefined) : undefined,
icon: input.icon,
kind: input.kind,
notifyId: input.notifyId,