Skip to content

perf: hoist invariant git worktree-list out of the agents-status loop, lazy-require cockpit (plan phase 4)#617

Merged
NagyVikt merged 1 commit into
mainfrom
agent/claude/phase4-perf-hoist-agents-status-git-prob-2026-06-03-13-26
Jun 3, 2026
Merged

perf: hoist invariant git worktree-list out of the agents-status loop, lazy-require cockpit (plan phase 4)#617
NagyVikt merged 1 commit into
mainfrom
agent/claude/phase4-perf-hoist-agents-status-git-prob-2026-06-03-13-26

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

@NagyVikt NagyVikt commented Jun 3, 2026

Automated by gx branch finish (PR flow).

…, 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.
@NagyVikt NagyVikt merged commit 2f00891 into main Jun 3, 2026
@NagyVikt NagyVikt deleted the agent/claude/phase4-perf-hoist-agents-status-git-prob-2026-06-03-13-26 branch June 3, 2026 11:43
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