Skip to content

Add unit coverage for useAgentHotkeys - #874

Merged
selfcontained merged 1 commit into
mainfrom
agt_65025ea8519c/job-test-enforcer-def7ab19
Aug 4, 2026
Merged

Add unit coverage for useAgentHotkeys#874
selfcontained merged 1 commit into
mainfrom
agt_65025ea8519c/job-test-enforcer-def7ab19

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Summary

Recurring test-enforcer run. Local suite was green on first pass (16th consecutive run): check ok; unit server 2394 / web 590 / extension 60 / scripts 4; inert E2E 175 passed / 12 skipped (1.1m); live tmux lane 11 passed (20.6s) with zero leaked sessions. CI scan clean. With the suite stable, this run closes the next_focus coverage gap: the agent-view hotkey hub had no direct tests.

What's covered

New apps/web/src/hooks/use-agent-hotkeys.test.tsx (24 tests):

  • Agent cycling — nested review agents are filtered before indexing (including the case where a review agent precedes the selection, which shifts the raw-list index), empty-list no-navigate, no-selection → first/last by direction, modulo wraparound, and top-level review-role agents staying cycleable. Navigation asserted through a real MemoryRouter location probe.
  • focus-terminal-input — the enabled: !isMobile && canFocusTerminal registration option (both halves) plus the handler's independent canFocusTerminal guard.
  • toggle-media-sidebar — desktop-without-sidebar no-op, desktop-with-sidebar toggle, mobile toggle; state inversion pinned by argument.
  • toggle-agent-sidebar / palette — left-panel inversion, Cmd+K palette open/close toggle, new-agent → create dialog, keyboard-shortcuts/settings/help/shortcuts.
  • Template palette groups — callable-only gating (empty/no-data/mixed), action run() closes the palette and resolves launchTemplate, ?? null fallback for cleared/unknown ids.

The useHotkey mock captures handler + options per render and refuses to fire disabled hotkeys, so tests can't certify behavior production would never reach.

Verification

  • 13-mutant battery against use-agent-hotkeys.ts — all 13 killed (one initially survived: findIndex against the unfiltered list; killed by the review-agent-precedes-selection test).
  • One general review round: 0 must-fix; 1 should-fix applied (disabled-hotkey refusal in pressHotkey), 2 nits applied (mock-lifetime comment, media toggle call counts). The as Agent/as Template fixture-cast nit was intentionally left — the factories set every field the hook reads.
  • pnpm run check, full unit suite, pnpm run finalize:web all green after the review fixes.

🤖 Generated with Claude Code

The agent-view hotkey hub (Cmd+K palette, agent cycling, terminal focus,
sidebar toggles) had no direct coverage. New use-agent-hotkeys.test.tsx
(24 tests) pins:

- cycleAgent: nested review agents filtered before indexing (a review
  agent preceding the selection must not shift the cycle order), empty
  list no-navigate, no-selection first/last by direction, modulo
  wraparound, and top-level review-role agents staying cycleable
- focus-terminal-input: enabled option (!isMobile && canFocusTerminal)
  plus the handler's own canFocusTerminal guard
- toggle-media-sidebar desktop/mobile guard halves and state inversion
- toggle-agent-sidebar inversion, palette open/close toggle
- palette actions (new-agent, keyboard-shortcuts navigation) and
  callable-template gating of paletteGroups, launch template resolution

Hotkey registration is mocked with a per-render registry that refuses to
fire disabled hotkeys (matching production reachability); navigation is
asserted through a real MemoryRouter location probe. 13-mutant battery
run, all killed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@selfcontained
selfcontained merged commit b391743 into main Aug 4, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_65025ea8519c/job-test-enforcer-def7ab19 branch August 4, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant