perf: hoist invariant git worktree-list out of the agents-status loop, lazy-require cockpit (plan phase 4)#617
Merged
NagyVikt merged 1 commit intoJun 3, 2026
Conversation
…, lazy-require cockpit (plan phase 4)
Phase 4 of the gitguardex improvement plan: perf hot-paths, no observable behavior change.
- B3 agents/inspect.js + agents/status.js: buildAgentsStatusPayload called changedFiles() ->
inspectAgentBranch() -> worktreePathForBranch() once PER SESSION, each running
`git worktree list --porcelain`. The list is invariant within one (synchronous) payload build,
so fetch it once via new listWorktrees() and thread it down through optional options.worktrees
(~6N -> ~5N+1 git spawns). Backward-compatible: callers that omit worktrees fetch on demand.
- B4 cli/main.js + cli/commands/misc.js: lazy-require('../cockpit') inside the two functions that
use it instead of eager top-level. Cockpit pulls 32 modules; now loaded only when it renders.
Proven: requiring main.js pulls 0 cockpit modules (was 32).
Deferred: B5 finish base-branch hoist (collides with unlanded detectDefaultBaseBranch WIP);
cockpit/index.js spread narrowing (export cleanup, no perf benefit).
Verification: node --test failing set byte-identical to base (zero new failures).
Independent review: no blocking findings.
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.
Automated by gx branch finish (PR flow).