refactor: split main.go and session.go into focused files#434
Merged
tomasz-tomczyk merged 1 commit intomainfrom May 2, 2026
Merged
refactor: split main.go and session.go into focused files#434tomasz-tomczyk merged 1 commit intomainfrom
tomasz-tomczyk merged 1 commit intomainfrom
Conversation
Pure file moves, no logic changes. Splits within package main: - cli_dispatch.go: commandDispatch map, printHelp, printConfigHelp, printVersion - cli_serve.go: runServe + serverConfig + flag parsing + bindListener + runIdleTimeoutChecker + applySessionOverrides + the daemon-boot path - cli_install.go: runInstall + installIntegration + integrationMap + destFor / installOneFile / printUniqueHints / globalDestKind helpers - session_focus.go: Focus / FocusKind / DiffScope types + visibleInFocus + stampWithFocus + SetFocus + scoped-view computation (cachedAvailableScopes, GetSessionInfoScoped, GetFileDiffSnapshotScoped, loadScopedFileState, computeScopedDiffHunks) - session_write.go: WriteFiles + scheduleWrite debounce + snapshotForWrite + buildCritJSON + merge* helpers + handleExternalDeletion + clearAllCommentData + critJSONIsEmpty + mergeExternalCritJSON main.go drops from 3151 -> 2150 LOC. session.go drops from 3189 -> 1932 LOC. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #434 +/- ##
==========================================
+ Coverage 67.36% 67.39% +0.03%
==========================================
Files 30 35 +5
Lines 9820 9820
==========================================
+ Hits 6615 6618 +3
+ Misses 2689 2687 -2
+ Partials 516 515 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Pure file moves, no logic changes. Splits
main.goandsession.gointo focused files withinpackage mainto reduce per-file LOC and group related code.New files (all
package main, no API changes)cli_dispatch.go—commandDispatchmap,printHelp,printConfigHelp,printVersioncli_serve.go—runServe+serverConfig+ flag parsing +bindListener+runIdleTimeoutChecker+applySessionOverrides(the daemon-boot path)cli_install.go—runInstall+installIntegration+integrationMap+destFor/installOneFile/printUniqueHints/globalDestKindhelperssession_focus.go—Focus/FocusKind/DiffScopetypes +visibleInFocus+stampWithFocus+SetFocus+ scoped-view computation (cachedAvailableScopes,GetSessionInfoScoped,GetFileDiffSnapshotScoped,loadScopedFileState,computeScopedDiffHunks)session_write.go—WriteFiles+scheduleWritedebounce +snapshotForWrite+buildCritJSON+merge*helpers +handleExternalDeletion+clearAllCommentData+critJSONIsEmpty+mergeExternalCritJSONBefore / after LOC
main.gosession.gocli_dispatch.gocli_serve.gocli_install.gosession_focus.gosession_write.goNet +48 LOC across the seven files (five new
package main+ import headers).Review
+lines added inmain.go/session.go— pure deletions, all additions land in new filesgo build,go vet,go test -race -count=1,gofmt -l,golangci-lintall cleanTest plan
mise exec -- go build ./...mise exec -- go vet ./...mise exec -- go test -race -count=1 ./...(53s, all pass)mise exec -- gofmt -l .mise exec -- golangci-lint run ./...(0 issues)Followups (out of scope here)
main.gois still 2150 LOC — the spec only enumerated three newcli_*.gofiles; the remaining subcommands (runShare,runFetch,runPull,runPush,runComment,runPlan,runReview,runStop,runStatus,runCleanup, etc.) could be peeled off in a follow-up if a sub-1000 target is desired.session.gois still 1932 LOC. Comment CRUD methods (AddCommentthroughUnresolvedCommentCount, ~510 LOC) are a coherent block that could move tosession_comments.go.ChangeBaseBranch(~100 LOC) is a candidate too. Skipped here to honor the spec's enumeration.🤖 Generated with Claude Code