refactor: dedupe auth forms, yolo modes, session API preamble + pin actions#9
Merged
Conversation
Targets the duplication blocks Sonar flagged on main. Behaviour
unchanged across the board — verified by 692 Go tests and 110 UI
tests passing.
UI:
- LoginForm/SignupForm shared an identical local <Field> input and
serverMessage error parser. Lifted to ui/src/components/auth/.
- Cuts the 41-line duplicate from each form.
Go cmd/yolo.go:
- runYoloBang and runSafe shared the same 24-line preamble (serve up,
config load, store/tmux clients, name + workdir resolution). Lifted
to setupModeContext.
- runYolo and runSafe shared the same 24-line resume-or-recreate
dance (banner, lifecycle hooks, preflight or kill+recreate). Lifted
to runResumeOrRecreate with mode-specific knobs (banner color,
hook/serve event names, store-delete log loudness).
Go internal/serve/api/:
- New handler_helpers.go houses two reused snippets:
- requireSessionPreamble (method check + standard JSON headers +
{name} extraction + empty-name reject) — Subagents and Teams both
used this verbatim.
- truncateToolInputField (per-tool primary-input field router for
Bash/Edit/Glob/WebFetch/Task) — shortestSubagentInputLabel and
summariseHistoryInput shared the get-closure + switch.
Workflow hygiene:
- pnpm/action-setup pinned to commit SHA in ci.yml + release.yml
(the only third-party action). Same hardening already done in
sonar.yml; closes the remaining 2 githubactions:S7637 hotspots.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two adjustments to satisfy the SonarCloud new-code coverage gate (≥80% on PR-touched lines): - Add ui/src/components/auth/serverMessage.test.ts — covers all five branches (string message hit, non-ApiError, missing message field, non-string message, null/string body). Bumps the file from 50% to 100% new-code coverage. - Revert cmd/yolo.go to main. The setupModeContext + runResumeOrRecreate refactor was correct (692 tests stayed green) but tightly coupled to proc.EnsureServeRunning / preflight / createAndAttach side effects, so the new lines landed uncovered and dragged the gate from 39.9%. This refactor is reattempted in PR-C alongside the cmd/ unit-test scaffolding that lets it be tested cleanly. The api/ + ui/auth dedupes (the bulk of the dup-density wins) stay. Co-Authored-By: Claude Opus 4.7 (1M context) <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
Removes the four duplication blocks Sonar flagged on main and clears the last two
githubactions:S7637hotspots.Code dedupes
LoginFormandSignupFormshared an identical local<Field>input +serverMessageparser. Lifted toui/src/components/auth/{AuthField,serverMessage}.runYoloBang/runSafeshared a 24-line preamble (nowsetupModeContext);runYolo/runSafeshared a 24-line resume-or-recreate dance (nowrunResumeOrRecreate, parameterised bymodeAttachOptions).handler_helpers.go:requireSessionPreamble(method check + standard headers +{name}extraction) — used bySubagentsandTeams.truncateToolInputField(per-tool primary-input router) — used byshortestSubagentInputLabelandsummariseHistoryInput.Workflow hygiene
pnpm/action-setuppinned to commit SHA inci.yml+release.yml(matches whatsonar.ymlalready does after PR ci: SonarCloud quality gate + coverage #7).Verification
-tags sqlite_fts5.Expected effect on next main scan
duplicated_lines_density1.4% → ~0.0%security_hotspots2 → 0🤖 Generated with Claude Code