Skip to content

fix(checkpointing): skip checkpoint when cwd is the home directory#1294

Open
murataslan1 wants to merge 1 commit intopingdotgg:mainfrom
murataslan1:fix/checkpoint-home-dir-guard
Open

fix(checkpointing): skip checkpoint when cwd is the home directory#1294
murataslan1 wants to merge 1 commit intopingdotgg:mainfrom
murataslan1:fix/checkpoint-home-dir-guard

Conversation

@murataslan1
Copy link

@murataslan1 murataslan1 commented Mar 22, 2026

Summary

When T3 Code is launched from the home directory (~/), the checkpoint system runs git 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 cwd matches os.homedir(). If so, skip checkpointing with a descriptive CheckpointInvariantError instead of timing out.

Test plan

  • Run npx t3 from ~/ — checkpoint should be skipped with a warning, session should continue
  • Run from a project folder — checkpoint should work normally

Fixes #1227

Note

Skip checkpoint in captureCheckpoint when cwd resolves to the home directory

Adds an early guard in captureCheckpoint in CheckpointStore.ts that compares the resolved cwd against the user's home directory via homedir(). If they match, the function short-circuits with a CheckpointInvariantError before any git operations or temp directory creation occur.

Macroscope summarized 057b369.

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
Copilot AI review requested due to automatic review settings March 22, 2026 00:17
@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9c7be90e-ba44-41be-9a5e-19f889aeb4b1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 cwd resolves 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.

Comment on lines +97 to +98
const resolvedCwd = yield* Effect.try(() => path.resolve(input.cwd));
const home = yield* Effect.try(() => homedir());
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
const resolvedCwd = yield* Effect.try(() => path.resolve(input.cwd));
const home = yield* Effect.try(() => homedir());
const resolvedCwd = path.resolve(input.cwd);
const home = homedir();

Copilot uses AI. Check for mistakes.
// 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());
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
const home = yield* Effect.try(() => homedir());
const home = yield* Effect.try(() => path.resolve(homedir()));

Copilot uses AI. Check for mistakes.
Comment on lines +95 to +106
// 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.",
});
}
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 git add timeout when running T3 from home directory

2 participants