fix(checkpointing): skip checkpoint when cwd is the home directory#1294
fix(checkpointing): skip checkpoint when cwd is the home directory#1294murataslan1 wants to merge 1 commit intopingdotgg:mainfrom
Conversation
Running from ~/ causes git add -A to scan the entire home directory (Applications, .npm, .cache, etc.), exceeding the 30s timeout and crashing the checkpoint system. Skip checkpointing with a descriptive error when the resolved cwd matches the user's home directory. Fixes pingdotgg#1227
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR prevents the checkpointing layer from running expensive git add -A -- . operations when T3 Code is started from the user’s home directory, avoiding timeouts and session crashes.
Changes:
- Detect when
cwdresolves to the user’s home directory before checkpoint capture. - Skip checkpoint capture in that case by failing with a descriptive
CheckpointInvariantError.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const resolvedCwd = yield* Effect.try(() => path.resolve(input.cwd)); | ||
| const home = yield* Effect.try(() => homedir()); |
There was a problem hiding this comment.
path.resolve(input.cwd) and homedir() are synchronous/non-throwing; wrapping them in Effect.try(() => …) unnecessarily introduces an UnknownException failure path (and can widen the effect error type beyond CheckpointStoreError). Prefer computing these values directly (or use Effect.sync / Effect.succeed), and if you want to guard against unexpected exceptions, map them into a CheckpointInvariantError so the service’s typed error channel stays consistent.
| const resolvedCwd = yield* Effect.try(() => path.resolve(input.cwd)); | |
| const home = yield* Effect.try(() => homedir()); | |
| const resolvedCwd = path.resolve(input.cwd); | |
| const home = homedir(); |
| // Skip checkpointing for the home directory — git add -A on ~/ scans | ||
| // thousands of unrelated files and will time out. | ||
| const resolvedCwd = yield* Effect.try(() => path.resolve(input.cwd)); | ||
| const home = yield* Effect.try(() => homedir()); |
There was a problem hiding this comment.
The home-directory check compares resolvedCwd (normalized via path.resolve) against the raw homedir() string. To avoid false negatives due to trailing separators, normalization differences, or platform-specific casing, resolve/normalize the home path via the same Path service before comparing (and consider realpath if symlinks are common).
| const home = yield* Effect.try(() => homedir()); | |
| const home = yield* Effect.try(() => path.resolve(homedir())); |
| // Skip checkpointing for the home directory — git add -A on ~/ scans | ||
| // thousands of unrelated files and will time out. | ||
| const resolvedCwd = yield* Effect.try(() => path.resolve(input.cwd)); | ||
| const home = yield* Effect.try(() => homedir()); | ||
| if (resolvedCwd === home) { | ||
| return yield* new CheckpointInvariantError({ | ||
| operation, | ||
| detail: | ||
| "Skipping checkpoint: working directory is the home directory. " + | ||
| "Please open a specific project folder instead.", | ||
| }); | ||
| } |
There was a problem hiding this comment.
This introduces a new behavioral branch (skipping checkpoint capture when cwd is the home directory) but there’s no direct regression test covering it. Consider adding a test that sets cwd to os.homedir() and asserts captureCheckpoint fails with CheckpointInvariantError (and that no git commands are executed), so this guard doesn’t regress.
Summary
When T3 Code is launched from the home directory (
~/), the checkpoint system runsgit add -A -- .which scans the entire home directory (Applications, .npm, .cache, .cargo, etc.), exceeding the 30-second timeout and crashing the session.Fix
Before capturing a checkpoint, check if the resolved
cwdmatchesos.homedir(). If so, skip checkpointing with a descriptiveCheckpointInvariantErrorinstead of timing out.Test plan
npx t3from~/— checkpoint should be skipped with a warning, session should continueFixes #1227
Note
Skip checkpoint in
captureCheckpointwhencwdresolves to the home directoryAdds an early guard in
captureCheckpointin CheckpointStore.ts that compares the resolvedcwdagainst the user's home directory viahomedir(). If they match, the function short-circuits with aCheckpointInvariantErrorbefore any git operations or temp directory creation occur.Macroscope summarized 057b369.