2.7 KiB
2.7 KiB
id, title, status, wave, depends_on, plan, spec
| id | title | status | wave | depends_on | plan | spec |
|---|---|---|---|---|---|---|
| 01-collapse-persistence-hook | Collapse persistence hook | done | 1 | plan.md | ../../specs/agents/requirements/collapsible-agent-blocks.md |
Task 01: Collapse persistence hook
Per-agent collapsed/expanded preference, stored as one JSON record in
localStorage, exposed through a domain hook with the same
storage-event + custom-event broadcast shape as
useLocalStorageBoolean (see apps/web/hooks/use-local-storage-boolean.ts
and apps/web/hooks/domains/settings/use-hide-disabled-agent-profiles-in-nav.ts).
- Acceptance:
useCollapsedAgentBlocks()returnscollapsed(agentName): booleanandsetCollapsed(agentName, collapsed): void; unknown/missing entries and invalid JSON default tofalse(expanded).setCollapsedmerges one entry into the stored record underkandev:agents:collapsedBlocks:v1, persists it, and dispatches the sync event so other tabs/components re-render; settingfalsewritesfalsefor that agent (explicit expanded, independent of others).- Read failures degrade to the default without throwing; write failures
throw (same contract as
useLocalStorageBoolean).
- Verification (TDD: write the test first, watch it fail, then implement):
cd apps && pnpm --filter @kandev/web test -- hooks/domains/settings/use-collapsed-agent-blocks.test.ts cd apps/web && pnpm run typecheck cd apps && pnpm --filter @kandev/web lint -- hooks/domains/settings/use-collapsed-agent-blocks.ts hooks/domains/settings/use-collapsed-agent-blocks.test.ts - Files likely touched:
apps/web/hooks/domains/settings/use-collapsed-agent-blocks.ts(new)apps/web/hooks/domains/settings/use-collapsed-agent-blocks.test.ts(new)
- Dependencies: None.
- Parallelism: sequential.
- Inputs: Spec "What" + "Data model" + "Scenarios"; existing
use-local-storage-boolean.tsand its test as the mechanism template; test helperapps/web/hooks/local-storage-mock.test-helpers.ts. - Output contract: summary, files changed, exact test/lint/typecheck results, and task/plan status update in the same conversation.
Results
pnpm --filter @kandev/web test -- hooks/domains/settings/use-collapsed-agent-blocks.test.ts→ 13/13 passed (TDD: red on missing module, then green).cd apps/web && pnpm run typecheck→ clean.pnpm exec eslint --max-warnings 0 hooks/domains/settings/use-collapsed-agent-blocks.ts hooks/domains/settings/use-collapsed-agent-blocks.test.ts→ clean.- Files:
apps/web/hooks/domains/settings/use-collapsed-agent-blocks.ts(new),apps/web/hooks/domains/settings/use-collapsed-agent-blocks.test.ts(new). Test suite split into four describes to stay under the 100-line function limit.