The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): the onboarding changes add no anti-slop findings
alt-glitch9008321de6a6
diff --git a/apps/desktop/electron/window-growth.test.ts b/apps/desktop/electron/window-growth.test.tsindex d1dbacdba46..eae61988ab3 100644--- a/apps/desktop/electron/window-growth.test.ts+++ b/apps/desktop/electron/window-growth.test.ts@@ -3,18 +3,27 @@* but a user who moves or resizes it afterwards has placed it, and that* placement must be saved.*/-import type { Rectangle } from 'electron'-import { describe, expect, it, vi } from 'vitest'+import type { Rectangle, WebContents } from 'electron'+import { describe, expect, it } from 'vitest'-import { isAppSized, markAppSized, registerWindowSizing } from './window-growth'+import { isAppSized, markAppSized, registerWindowSizing, type WindowSizingHost } from './window-growth'+import type { WindowSizeMode } from './window-size-types'-const ipc = vi.hoisted(() => new Map<string, (event: unknown, mode: string) => void>())const WORK_AREA: Rectangle = { height: 1080, width: 1920, x: 0, y: 0 }-vi.mock('electron', () => ({- ipcMain: { on: (channel: string, listener: (event: unknown, mode: string) => void) => ipc.set(channel, listener) },- screen: { getDisplayMatching: () => ({ workArea: WORK_AREA }) }-}))+// The size IPC as the main process delivers it, on one display.+function sizingHost() {+ const listeners: Parameters<WindowSizingHost['onSizeRequest']>[0][] = []++ const host: WindowSizingHost = {+ onSizeRequest: listener => listeners.push(listener),+ workAreaOf: () => WORK_AREA+ }++ const send = (sender: WebContents, mode: WindowSizeMode) => listeners.forEach(listener => listener({ sender }, mode))++ return { host, send }+}function placedWindow(initial: Rectangle) {let bounds = { ...initial }@@ -52,7 +61,8 @@ describe('isAppSized', () => {// The main window as the size IPC sees it: the renderer's webContents, and bounds setBounds moves.function mainWindow(initial: Rectangle) {let bounds = { ...initial }- const webContents = {}+ // SAFETY: the size IPC only compares the sender with the window's webContents by identity.+ const webContents = {} as WebContentsreturn {getBounds: () => ({ ...bounds }),@@ -71,9 +81,10 @@ describe('window sizing for the first-run intro', () => {it("puts an existing user's window back where it was when the intro ends", () => {const placed: Rectangle = { height: 900, width: 1500, x: 40, y: 60 }const win = mainWindow(placed)+ const { host, send } = sizingHost()// SAFETY: registerWindowSizing reads only the members mainWindow() fakes.- registerWindowSizing({ enabled: true, mainWindow: () => win as never })- const size = (mode: string) => ipc.get('hermes:window:size')?.({ sender: win.webContents }, mode)+ registerWindowSizing({ enabled: true, host, mainWindow: () => win as never })+ const size = (mode: WindowSizeMode) => send(win.webContents, mode)size('onboarding')expect(win.getBounds()).not.toEqual(placed)diff --git a/apps/desktop/electron/window-growth.ts b/apps/desktop/electron/window-growth.tsindex dd57a49927b..6f6c623b63c 100644--- a/apps/desktop/electron/window-growth.ts+++ b/apps/desktop/electron/window-growth.ts@@ -1,10 +1,24 @@-import { type BrowserWindow, ipcMain, type Rectangle, screen } from 'electron'+import { type BrowserWindow, ipcMain, type IpcMainEvent, type Rectangle, screen } from 'electron'import type { WindowSizeMode } from './window-size-types'import { windowSize } from './window-state'+type SizeRequestListener = (event: Pick<IpcMainEvent, 'sender'>, mode: WindowSizeMode) => void++/** The Electron surface window sizing uses: the size IPC and the display under a window. */+export interface WindowSizingHost {+ onSizeRequest: (listener: SizeRequestListener) => void+ workAreaOf: (bounds: Rectangle) => Rectangle+}++const electronHost: WindowSizingHost = {+ onSizeRequest: listener => ipcMain.on('hermes:window:size', listener),+ workAreaOf: bounds => screen.getDisplayMatching(bounds).workArea+}+interface WindowSizingOptions {enabled: boolean+ host?: WindowSizingHostmainWindow: () => BrowserWindow | null}@@ -51,8 +65,8 @@ function sizedBounds(mode: WindowSizeMode, bounds: Rectangle, workArea: Rectangl// from Settings leaves an existing user's window where it was.const beforeOnboarding = new WeakMap<BrowserWindow, Rectangle>()-export function registerWindowSizing({ enabled, mainWindow }: WindowSizingOptions): void {- ipcMain.on('hermes:window:size', (event, mode: WindowSizeMode) => {+export function registerWindowSizing({ enabled, host = electronHost, mainWindow }: WindowSizingOptions): void {+ host.onSizeRequest((event, mode) => {const win = mainWindow()if (!enabled || !win || win.isDestroyed() || event.sender !== win.webContents) {@@ -81,7 +95,7 @@ export function registerWindowSizing({ enabled, mainWindow }: WindowSizingOptionreturn}- const next = sizedBounds(mode, bounds, screen.getDisplayMatching(bounds).workArea)+ const next = sizedBounds(mode, bounds, host.workAreaOf(bounds))if (next) {markAppSized(win, next)diff --git a/apps/desktop/src/app/settings/onboarding-settings.test.tsx b/apps/desktop/src/app/settings/onboarding-settings.test.tsxindex 26f0a131206..c37482694bc 100644--- a/apps/desktop/src/app/settings/onboarding-settings.test.tsx+++ b/apps/desktop/src/app/settings/onboarding-settings.test.tsx@@ -7,6 +7,7 @@ import { $introCopy, skipIntro } from '@/components/onboarding/first-run/intro'import { group } from '@/components/pane-shell/tree/model'import { applyLayoutPreset } from '@/components/pane-shell/tree/presets'import { $activePresetId, $layoutTree } from '@/components/pane-shell/tree/store'+import { setPrimaryGateway } from '@/store/gateway'import { $chatOnboardingSolo, $introView } from '@/store/onboarding-intro'import { $onboardingPhase } from '@/store/onboarding-phase'import {@@ -20,22 +21,20 @@ import { $activeSessionId, $connection, $selectedStoredSessionId } from '@/storeimport { OnboardingSettings } from './onboarding-settings'const started = { resumed: false, run_id: 'run-2', session_id: 'rt-2', stored_session_id: 'st-2' }-const calls: [string, unknown][] = []-// SAFETY: the fake answers onboarding.start / onboarding.state with the fields the start reads.-const answerGateway: OnboardingRequest = async <T,>(method: string, params?: unknown): Promise<T> => {+type RequestParams = Parameters<OnboardingRequest>[1]++const calls: [string, RequestParams][] = []++const answerGateway: OnboardingRequest = async <T,>(method: string, params?: RequestParams): Promise<T> => {calls.push([method, params])+ // SAFETY: the fake answers onboarding.start / onboarding.state with the fields the start reads.return (method === 'onboarding.state' ? { eligible: true, run: true, run_id: 'run-2', session_id: 'st-2' } : started) as T}-// A mock drops the generic signature, so the direct call below passes the typed function.-const requestGateway = vi.fn(answerGateway)--vi.mock('@/app/gateway/hooks/use-gateway-request', () => ({ useGatewayRequest: () => ({ requestGateway }) }))-const size = vi.fn()// The shell's opener (wiring.tsx::adoptSessionRoute): the stored chat becomes the selected, routed one.@@ -53,6 +52,8 @@ beforeEach(() => {configurable: true,value: { chatOnboarding: { size }, guestOnboardingEnabled: true }})+ // SAFETY: the Settings button's gateway request calls only `request` on the primary socket.+ setPrimaryGateway({ request: answerGateway } as never)// SAFETY: factsSource reads only `mode`.$connection.set({ mode: 'local' } as never)$onboardingChatOpener.set(adopt)@@ -69,7 +70,10 @@ beforeEach(() => {size.mockClear()})-afterEach(cleanup)+afterEach(() => {+ cleanup()+ setPrimaryGateway(null)+})async function runAgain() {const mine = $layoutTree.get()diff --git a/apps/desktop/src/app/settings/plugin-install-run.ts b/apps/desktop/src/app/settings/plugin-install-run.tsindex 92fecb3b404..538592bc92a 100644--- a/apps/desktop/src/app/settings/plugin-install-run.ts+++ b/apps/desktop/src/app/settings/plugin-install-run.ts@@ -20,11 +20,11 @@ export interface InstallComponents {desktop: boolean}-const HINT_COMPONENTS: Record<'agent' | 'both' | 'desktop', (probe: ProbeResult) => InstallComponents> = {+const HINT_COMPONENTS = {agent: probe => ({ agent: probe.agent, desktop: false }),both: probe => ({ agent: probe.agent, desktop: probe.desktop }),desktop: probe => ({ agent: false, desktop: probe.desktop })-}+} satisfies Record<'agent' | 'both' | 'desktop', (probe: ProbeResult) => InstallComponents>/** What an install puts down: every half the repository has, narrowed by a legacy deep link or by* "install the agent half here" (whose desktop half is already loaded). */diff --git a/apps/desktop/src/components/onboarding/skip-setup.test.tsx b/apps/desktop/src/components/onboarding/skip-setup.test.tsxindex 230eae08c94..28a4052a5eb 100644--- a/apps/desktop/src/components/onboarding/skip-setup.test.tsx+++ b/apps/desktop/src/components/onboarding/skip-setup.test.tsx@@ -1,6 +1,6 @@import type { OnboardingEndedPayload } from '@hermes/shared'import { act, cleanup, render, screen } from '@testing-library/react'-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import { afterEach, beforeEach, describe, expect, it } from 'vitest'import { $onboardingPhase } from '@/store/onboarding-phase'import { noteOnboardingEnded, startOnboarding } from '@/store/onboarding-run'@@ -9,10 +9,6 @@ import { $connection, $selectedStoredSessionId } from '@/store/session'import { OnboardingSkip } from './skip-setup'-vi.mock('@/app/gateway/hooks/use-gateway-request', () => ({- useGatewayRequest: () => ({ requestGateway: vi.fn() })-}))-const started = { resumed: false, run_id: 'run-1', session_id: 'rt-1', stored_session_id: 'st-1' }const ended: OnboardingEndedPayload = { outcome: 'done', run_id: 'run-1', stored_session_id: 'st-1' }const ensureProfile = async (): Promise<void> => undefineddiff --git a/apps/desktop/src/lib/plugin-catalog.ts b/apps/desktop/src/lib/plugin-catalog.tsindex a57c3815193..75660b72580 100644--- a/apps/desktop/src/lib/plugin-catalog.ts+++ b/apps/desktop/src/lib/plugin-catalog.ts@@ -69,16 +69,26 @@ function asEntry(raw: unknown): null | PluginCatalogEntry {const row = raw as Record<string, unknown>- if (typeof row.name !== 'string' || typeof row.repo !== 'string' || !row.repo) {+ // A field that is not a string reads as absent.+ const text = (field: 'description' | 'name' | 'repo' | 'sha' | 'subdir'): string | undefined => {+ const value = row[field]++ return typeof value === 'string' ? value : undefined+ }++ const name = text('name')+ const repo = text('repo')++ if (name === undefined || !repo) {return null}return {- name: row.name,- repo: row.repo,- sha: typeof row.sha === 'string' && row.sha ? row.sha : undefined,- subdir: typeof row.subdir === 'string' && row.subdir ? row.subdir : undefined,- summary: typeof row.description === 'string' ? firstSentence(row.description) : undefined+ name,+ repo,+ sha: text('sha') || undefined,+ subdir: text('subdir') || undefined,+ summary: firstSentence(text('description') ?? '')}}diff --git a/apps/desktop/src/store/onboarding-run.test.ts b/apps/desktop/src/store/onboarding-run.test.tsindex 7aca6d88a0e..8c6becec3e7 100644--- a/apps/desktop/src/store/onboarding-run.test.ts+++ b/apps/desktop/src/store/onboarding-run.test.ts@@ -7,6 +7,7 @@ import {$onboardingSettleFrom,decideOnboarding,noteOnboardingEnded,+ type OnboardingRequest,reconcileOnboarding,skipOnboarding,startOnboarding@@ -24,11 +25,11 @@ const resume = vi.fn(async (storedId: string) => $selectedStoredSessionId.set(st// `runId`: the run onboarding.state reports open; null once something ended it.function backend(state: { eligible: boolean; run: boolean }, runId: null | string = 'run-1') {const calls: string[] = []- const starts: unknown[] = []+ const starts: Parameters<OnboardingRequest>[1][] = []const started = { resumed: false, run_id: 'run-1', session_id: 'rt-1', stored_session_id: 'st-1' }const read = { ...state, run_id: runId, session_id: runId && 'st-1' }- const request = async <T,>(method: string, params?: unknown): Promise<T> => {+ const request = async <T,>(method: string, params?: Parameters<OnboardingRequest>[1]): Promise<T> => {calls.push(method)if (method === 'onboarding.start') {diff --git a/apps/desktop/src/store/pane-focus.ts b/apps/desktop/src/store/pane-focus.tsindex 142938b306c..cc67da2b071 100644--- a/apps/desktop/src/store/pane-focus.ts+++ b/apps/desktop/src/store/pane-focus.ts@@ -51,10 +51,10 @@ export function revealDesktopPane(pane: string): boolean {// Elite is the terminal deck with the tools its card names open. The preset itself rests them, so the// same deck picked in Settings stays quiet; a pick from the layout card or set_theme shows the difference.-const PICK_OPENS: Readonly<Record<string, readonly string[]>> = { 'terminal-deck': ['terminal', 'files'] }+const PICK_OPENS = new Map<string, readonly string[]>([['terminal-deck', ['terminal', 'files']]])/** The panes a layout pick opens beyond its preset's resting set. */-export const layoutPickOpens = (preset: string): readonly string[] => PICK_OPENS[preset] ?? []+export const layoutPickOpens = (preset: string): readonly string[] => PICK_OPENS.get(preset) ?? []/** Open the panes `layoutPickOpens` names for `preset`. */export function openLayoutPickPanes(preset: string): void {