Skip to content

fix: defer getWorkingTreeState call and clean up process exit handling#415

Open
fix2015 wants to merge 1 commit into
openai:mainfrom
fix2015:fix/perf-and-process-cleanup
Open

fix: defer getWorkingTreeState call and clean up process exit handling#415
fix2015 wants to merge 1 commit into
openai:mainfrom
fix2015:fix/perf-and-process-cleanup

Conversation

@fix2015

@fix2015 fix2015 commented Jul 1, 2026

Copy link
Copy Markdown

A few things I noticed while reading through the code:

  • resolveReviewTarget() was calling getWorkingTreeState(cwd) right at the top, which runs 3 git commands — but if --base is provided, it returns immediately without ever using the result. moved the call down to just before it's actually needed, so those git commands don't run for nothing
  • the session lifecycle hook was using process.exit(1) in its catch handler, which kills the process before stderr has time to flush. the main companion script already uses process.exitCode = 1 correctly, so matched the hook to the same pattern
  • nowIso() was defined identically in both state.mjs and tracked-jobs.mjs — consolidated to a single import from tracked-jobs

- moved getWorkingTreeState() below the early return checks in
  resolveReviewTarget() — it was running 3 git commands that got thrown
  away whenever --base or --scope was specified
- replaced process.exit(1) with process.exitCode = 1 in the session
  lifecycle hook so stderr output actually has time to flush
- deduplicated nowIso() — was defined identically in both state.mjs
  and tracked-jobs.mjs, now state.mjs imports it from tracked-jobs
@fix2015 fix2015 requested a review from a team July 1, 2026 17:16
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