Skip to content

Cover the create-agent form hook: payload shaping, files, prefs - #861

Merged
selfcontained merged 1 commit into
mainfrom
agt_28d4e345caee/job-test-enforcer-bcf2bebf
Aug 1, 2026
Merged

Cover the create-agent form hook: payload shaping, files, prefs#861
selfcontained merged 1 commit into
mainfrom
agt_28d4e345caee/job-test-enforcer-bcf2bebf

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Summary

Recurring test-enforcer run. Local suite was green on first pass (13th consecutive run) — check ok; server 2366 pass / 8 skip, web 516, extension 60, scripts 4; inert E2E 175 pass / 12 skip; live terminal lane (pnpm run test:e2e:live, first post-#858 validation) 11 passed in 20.7s with zero leaked tmux sessions. CI scan clean — all recent failures are the two known branch-local issues (philosophy-site prettier, whiteboard migration-prefix guard).

With no failures or flakes to fix, this run adds the highest-value missing unit coverage: use-create-agent-form.ts, the create-agent dialog's entire state machine, had zero direct or indirect coverage while feeding the POST that creates real agents (worktree flags, branch fields, FormData switching).

New coverage — use-create-agent-form.test.tsx (25 tests)

  • Agent type seeding: initialAgentType when enabled, first-enabled fallback, stored last-used type, and the re-snap effect when the current type drops out of the enabled list.
  • Cwd seeding: trimmed resolveDefaultCwd, stored last-used fallback, ~/ default.
  • Startup files/links: dedupe by name:size:lastModified, object-URL previews created only for images and only once per key, revocation on remove and on unmount, link dedupe.
  • Paste routing: off-target ignore, files-win-over-text, URL text captured as a link (normalized + deduped), plain text left to the textarea.
  • Submit payload shaping (the core value): exact JSON body on the config step; worktree suppression when the cwd is not a git repo; createNewBranch/worktreeBranch/baseBranch gating (trim, omitted-on-main); context-step prompt trimming and omission when blank; the JSON-vs-FormData switch including empty-field skipping (name dropped, fullAccess: false stringified); last-used localStorage writes + cwd history most-recent-first; toast error message vs. generic fallback; creating reset in finally.

Verification

  • 8-mutant battery: 7/8 killed. The survivor (dropping the enabled-list guard in the createType initializer) is behaviorally equivalent at hook level — the re-snap effect corrects it within the same mount; the review agent confirmed the judgement.
  • 25/25 pass deterministically, including with --sequence.shuffle.tests=true.
  • Isolation hardening per repo rules: fresh jotai store per test plus an afterEach purge of the per-cwd createNewBranchPrefAtom family (atomWithLocalStorage bakes its initial localStorage read in at atom creation), explicit RTL cleanup(), explicit module-factory mock resets.
  • Review agent: 0 must-fix, 1 should-fix (atom-family purge — applied), 4 nits (3 applied; skipped the importOriginal spread to stay consistent with the repo's existing minimal api mock factories).
  • pnpm run check, full web suite (541), and pnpm run finalize:web all green.

Also filed DIS-167 for two unreachable branches in agent-card-header/status that need a product call (carried from the backlog).

🤖 Generated with Claude Code

use-create-agent-form.ts had no direct or indirect coverage despite owning
the entire create-agent dialog state machine. Add 25 unit tests pinning:

- agent type seeding (initialAgentType, last-used fallback, enabled-list
  guard, re-snap when the type drops out of the enabled list)
- cwd seeding (resolveDefaultCwd trim, last-used fallback, ~/ default)
- startup file dedupe by name:size:lastModified, image-only object-URL
  previews, revocation on remove and unmount
- paste routing (off-target ignore, files-over-text, URL capture with
  dedupe, plain-text passthrough)
- submit payload shaping: exact JSON body on the config step, worktree
  suppression for non-git cwds, branch-field gating (createNewBranch,
  worktreeBranch trim, baseBranch omitted on main), context-step prompt
  trimming, the JSON-vs-FormData switch with empty-field skipping, and
  last-used persistence plus toast error paths

An 8-mutant battery kills 7; the survivor (dropping the enabled-list guard
in the createType initializer) is behaviorally equivalent at hook level —
the re-snap effect corrects it in the same mount before consumers observe
the value.

Isolation notes: fresh jotai store per test plus an afterEach purge of the
per-cwd createNewBranch atom family (atomWithLocalStorage bakes its initial
localStorage read in at atom creation), explicit RTL cleanup() and
module-factory mock resets per the repo's no-globals vitest config.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@selfcontained
selfcontained merged commit b3e4055 into main Aug 1, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_28d4e345caee/job-test-enforcer-bcf2bebf branch August 1, 2026 02:28
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