From f330a79ce27e2a86363895f7104effe792a8c483 Mon Sep 17 00:00:00 2001 From: Tyler Gray Date: Thu, 14 May 2026 14:23:46 -0400 Subject: [PATCH] =?UTF-8?q?fix(types):=20close=203=20svelte-check=20errors?= =?UTF-8?q?=20=E2=80=94=20sessions=20prop=20+=20invoke=20mock=20(#214=20PR?= =?UTF-8?q?4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part of the #214 cleanup. Brings `npm run check` from 50 -> 47 errors (closes 3). Scoped to the two genuinely mechanical fixes from #214's proposed PR4 — groups E and M turned out to need real investigation, see below. ## Changes - **Group H** — `routes/sessions/+page.svelte` passed `sessionSummary={sessionStore.selectedSessionSummary}` to `SessionDetailPanel`. Neither side exists anymore: `SessionStoreState` has no `selectedSessionSummary`, and `SessionDetailPanel`'s `Props` is `{ detail, onClose }`. The prop was already dead — removed the line. - **Group K** — `tests/helpers/invokeMock.ts` typed the `invoke` mock implementation's `args` as `Record`. Tauri's `invoke` signature is `(cmd, args?: InvokeArgs, ...)` and `InvokeArgs` is wider (e.g. `number[]`), so the narrower callback param made the mock unassignable. Widened to `InvokeArgs` and cast at the boundary where it's handed to the ergonomic `handler` callback. ## Deferred from #214's PR4 grouping - **Group E** (keybindings `"Input"` context, 6 errors) — not a fixture cleanup. The tests pass at runtime (31/31) but reference `'Input'`, which is in neither `KEYBINDING_CONTEXTS` nor `KEYBINDING_ACTIONS`; they only pass via cross-test override state. Adding `'Input'` to the `KeybindingContext` union would be a phantom-value behavior change; rewriting the tests needs care around their state dependencies. - **Group M** (`AgentMemoryPanel` `selectedProject`, 1 error) — a latent runtime bug, not drift. `projectsStore` has no project-selection concept at all, so `projectsStore.selectedProject?.path ?? null` is always `null` — the panel's project-scope memory silently never gets a path. Needs a data-flow decision (prop vs. route param). ## Test plan - [x] `npm run check` — 50 errors (down from 53 on `main`) - [x] `npx vitest run` (sessionStore + helpers consumers) — pass - [x] Zero new errors Co-Authored-By: Claude Opus 4.7 (1M context) --- src/routes/sessions/+page.svelte | 1 - src/tests/helpers/invokeMock.ts | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/sessions/+page.svelte b/src/routes/sessions/+page.svelte index 7f892aff..a525ac74 100644 --- a/src/routes/sessions/+page.svelte +++ b/src/routes/sessions/+page.svelte @@ -139,7 +139,6 @@ {:else if sessionStore.sessionDetail} sessionStore.clearSession()} /> {/if} diff --git a/src/tests/helpers/invokeMock.ts b/src/tests/helpers/invokeMock.ts index 7fc5fc7d..725b56bb 100644 --- a/src/tests/helpers/invokeMock.ts +++ b/src/tests/helpers/invokeMock.ts @@ -1,5 +1,6 @@ import { vi } from 'vitest'; import { invoke } from '@tauri-apps/api/core'; +import type { InvokeArgs } from '@tauri-apps/api/core'; /** * Set up command-routing mock for Tauri invoke. @@ -33,7 +34,7 @@ export function mockInvokeResponses(responses: Record): void { export function mockInvokeHandler( handler: (cmd: string, args?: Record) => unknown ): void { - vi.mocked(invoke).mockImplementation(async (cmd: string, args?: Record) => { - return handler(cmd, args); + vi.mocked(invoke).mockImplementation(async (cmd: string, args?: InvokeArgs) => { + return handler(cmd, args as Record | undefined); }); }