Cover the create-agent form hook: payload shaping, files, prefs - #861
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Recurring test-enforcer run. Local suite was green on first pass (13th consecutive run) —
checkok; 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)initialAgentTypewhen enabled, first-enabled fallback, stored last-used type, and the re-snap effect when the current type drops out of the enabled list.resolveDefaultCwd, stored last-used fallback,~/default.name:size:lastModified, object-URL previews created only for images and only once per key, revocation on remove and on unmount, link dedupe.createNewBranch/worktreeBranch/baseBranchgating (trim, omitted-on-main); context-step prompt trimming and omission when blank; the JSON-vs-FormData switch including empty-field skipping (namedropped,fullAccess: falsestringified); last-used localStorage writes + cwd history most-recent-first; toast error message vs. generic fallback;creatingreset infinally.Verification
createTypeinitializer) is behaviorally equivalent at hook level — the re-snap effect corrects it within the same mount; the review agent confirmed the judgement.--sequence.shuffle.tests=true.createNewBranchPrefAtomfamily (atomWithLocalStorage bakes its initial localStorage read in at atom creation), explicit RTLcleanup(), explicit module-factory mock resets.importOriginalspread to stay consistent with the repo's existing minimalapimock factories).pnpm run check, full web suite (541), andpnpm run finalize:weball green.Also filed DIS-167 for two unreachable branches in
agent-card-header/statusthat need a product call (carried from the backlog).🤖 Generated with Claude Code