Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

Closedmurataslan1(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/1294/headopened View on GitHub

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.
    1. 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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

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

      @@ -91,3 +92,7 @@
      9192 Effect.gen(function* () {
      9293 const operation = "CheckpointStore.captureCheckpoint";
      9394
      95+ // Skip checkpointing for the home directory — git add -A on ~/ scans
      96+ // thousands of unrelated files and will time out.
      97+ const resolvedCwd = yield* Effect.try(() => path.resolve(input.cwd));
      98+ const home = yield* Effect.try(() => homedir());

      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
      97- const resolvedCwd = yield* Effect.try(() => path.resolve(input.cwd));
      98- const home = yield* Effect.try(() => homedir());
      97+ const resolvedCwd = path.resolve(input.cwd);
      98+ const home = homedir();
      @@ -91,3 +92,7 @@
      9192 Effect.gen(function* () {
      9293 const operation = "CheckpointStore.captureCheckpoint";
      9394
      95+ // Skip checkpointing for the home directory — git add -A on ~/ scans
      96+ // thousands of unrelated files and will time out.
      97+ const resolvedCwd = yield* Effect.try(() => path.resolve(input.cwd));
      98+ const home = yield* Effect.try(() => homedir());

      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
      98- const home = yield* Effect.try(() => homedir());
      98+ const home = yield* Effect.try(() => path.resolve(homedir()));
      @@ -91,3 +92,15 @@
      9192 Effect.gen(function* () {
      9293 const operation = "CheckpointStore.captureCheckpoint";
      9394
      95+ // Skip checkpointing for the home directory — git add -A on ~/ scans
      96+ // thousands of unrelated files and will time out.
      97+ const resolvedCwd = yield* Effect.try(() => path.resolve(input.cwd));
      98+ const home = yield* Effect.try(() => homedir());
      99+ if (resolvedCwd === home) {
      100+ return yield* new CheckpointInvariantError({
      101+ operation,
      102+ detail:
      103+ "Skipping checkpoint: working directory is the home directory. " +
      104+ "Please open a specific project folder instead.",
      105+ });
      106+ }

      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.

    4. Closing because the linked issue is closed and checkpointing was refactored beyond this one-line guard.

      This was closed as part of a large repo-wide maintenance sweep. If you think it's still relevant, please reopen.

    5. juliusmarminge closed this

Sign in to join this conversation.