[Bug]: Checkpoint restore succeeds but leaves later edits in skip-worktree files
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- git, node.js, typescript
调研方向
Start with the reproduction script in the issue and the restore command in apps/server/src/vcs/GitVcsDriver.ts (lines 1396–1411); compare its behavior for a skip-worktree path with the ordinary-file control. Read the checkpoint success handling in apps/server/src/orchestration-v2/CheckpointService.ts (lines 526–550) and the cited Git restore documentation. Done means restore returns success and both files match the checkpoint without clearing the flag, while sparse-checkout exclusions retain their intended behavior.
由索引模型根据 Issue 内容生成。
描述
Summary
Reverting workspace files can report success while a tracked file marked skip-worktree keeps its later edits. A normal tracked file beside it restores correctly, but the flagged file does not when its checkpoint content matches HEAD. This was reproduced through the production checkpoint driver in a disposable Git worktree.
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Create a Git repository with two committed text files and add a detached worktree.
- Mark one file skip-worktree in that worktree, then capture a checkpoint through the production Git driver.
- Change both files and restore the checkpoint. Check the returned success value and both file contents.
- Clear the skip-worktree flag and restore again to verify the workaround.
Save the script below as repro-skip.mjs and run node repro-skip.mjs /path/to/t3code from any directory. It requires a checkout of the stated commit with its normal dependencies installed, Node with TypeScript source support and Git. It creates all fixture files, Git metadata, HOME, TMPDIR, and T3 state under one temporary directory and removes it on exit; it leaves the checkout unchanged. Exit 1 means the defect reproduced, 0 means expected behavior, and 2 means a setup or control failed. The final script reproduced deterministically in one recorded run; earlier focused probes established the same behavior.
Reproduction script: repro-skip.mjs
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';
import { pathToFileURL } from 'node:url';
import { execFileSync } from 'node:child_process';
const checkout = path.resolve(process.argv[2] ?? '.');
const scratch = fs.mkdtempSync('/tmp/t3-diff-repro-');
for (const name of ['home', 'tmp', 'state']) fs.mkdirSync(path.join(scratch, name));
process.env.HOME = path.join(scratch, 'home');
process.env.TMPDIR = path.join(scratch, 'tmp');
process.env.T3CODE_HOME = path.join(scratch, 'state');
process.env.GIT_CONFIG_NOSYSTEM = '1';
process.env.GIT_CONFIG_GLOBAL = path.join(scratch, 'gitconfig');
fs.writeFileSync(process.env.GIT_CONFIG_GLOBAL, '');
const git = (cwd, ...args) => execFileSync('git', args, { cwd, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trimEnd();
const local = name => import(pathToFileURL(path.join(checkout, name)).href);
let result = 'inconclusive';
try {
console.log(`Node ${process.version}; ${process.platform} ${process.arch}`);
if (typeof Bun !== 'undefined') console.log(`Bun ${Bun.version}`);
console.log(execFileSync('git', ['--version'], { encoding: 'utf8' }).trim());
console.log(`T3 Code ${git(checkout, 'rev-parse', 'HEAD')}`);
const repo = path.join(scratch, 'repository');
fs.mkdirSync(repo);
git(repo, 'init', '-q');
git(repo, 'config', 'user.name', 'Fixture');
git(repo, 'config', 'user.email', '[email protected]');
const require = createRequire(path.join(checkout, 'apps/server/package.json'));
const dep = name => import(require.resolve(name));
const Effect = await dep('effect/Effect');
const Layer = await dep('effect/Layer');
const NodeServices = await dep('@effect/platform-node/NodeServices');
const NodeCrypto = await dep('@effect/platform-node/NodeCrypto');
const GitDriver = await local('apps/server/src/vcs/GitVcsDriver.ts');
const VcsProcess = await local('apps/server/src/vcs/VcsProcess.ts');
const Config = await local('apps/server/src/config.ts');
const layer = Layer.mergeAll(GitDriver.layerVcs, GitDriver.layer).pipe(
Layer.provide(Config.layerTest(repo, path.join(scratch, 'state'))),
Layer.provideMerge(VcsProcess.layer),
Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
);
fs.writeFileSync(path.join(repo, 'flagged.txt'), 'baseline\n');
fs.writeFileSync(path.join(repo, 'control.txt'), 'baseline\n');
git(repo, 'add', '.');
git(repo, 'commit', '-qm', 'baseline');
const worktree = path.join(scratch, 'worktree');
git(repo, 'worktree', 'add', '-q', '--detach', worktree, 'HEAD');
git(worktree, 'update-index', '--skip-worktree', 'flagged.txt');
await Effect.runPromise(Effect.gen(function* () {
const driver = yield* GitDriver.makeVcsDriverShape();
const checkpointRef = 'refs/t3/checkpoints/repro';
yield* driver.checkpoints.captureCheckpoint({ cwd: worktree, checkpointRef });
if (git(worktree, 'show', `${checkpointRef}:flagged.txt`) !== 'baseline') throw Error('capture');
fs.writeFileSync(path.join(worktree, 'flagged.txt'), 'later\n');
fs.writeFileSync(path.join(worktree, 'control.txt'), 'later\n');
const restored = yield* driver.checkpoints.restoreCheckpoint({ cwd: worktree, checkpointRef });
const control = fs.readFileSync(path.join(worktree, 'control.txt'), 'utf8') === 'baseline\n';
const flagged = fs.readFileSync(path.join(worktree, 'flagged.txt'), 'utf8') === 'baseline\n';
console.log(`restore returned: ${restored}; normal control restored: ${control}`);
console.log(`skip-worktree file restored: ${flagged}`);
if (!restored || !control) throw Error('control');
git(worktree, 'update-index', '--no-skip-worktree', 'flagged.txt');
yield* driver.checkpoints.restoreCheckpoint({ cwd: worktree, checkpointRef });
const workaround = fs.readFileSync(path.join(worktree, 'flagged.txt'), 'utf8') === 'baseline\n';
console.log(`restored after clearing flag: ${workaround}`);
if (!workaround) throw Error('workaround');
result = flagged ? 'expected behavior' : 'defect reproduced';
}).pipe(Effect.scoped, Effect.provide(layer)));
} catch (error) {
console.log(`Setup/control failure: ${error?._tag ?? error?.name ?? 'unknown'}`);
} finally {
fs.rmSync(scratch, { recursive: true, force: true });
}
console.log({ 'expected behavior': 'RESULT: expected behavior', 'defect reproduced': 'RESULT: defect reproduced', inconclusive: 'RESULT: inconclusive' }[result]);
process.exitCode = result === 'expected behavior' ? 0 : result === 'defect reproduced' ? 1 : 2;
Expected behavior
A successful file restore should return the workspace to the captured file contents, including tracked files whose index flags hide changes from ordinary Git commands. T3 Code documents that Revert files too puts the workspace back to its checkpoint and also undoes user edits: docs/user/composer.md#L172-L180. Git documents the skip-worktree interaction and its explicit override in the git-restore manual.
Actual behavior
Calling driver.checkpoints.restoreCheckpoint returns true and restores the normal control file to the checkpoint. The tracked flagged.txt, marked with git update-index --skip-worktree before capture and edited afterward, keeps later instead of the captured baseline. This reproduction uses a checkpoint whose flagged blob matches HEAD; a separate probe with different checkpoint and HEAD blobs did restore that file, so this report does not claim all flagged-file restores fail.
Impact
Minor bug or occasional failure
Impact: P2 - The file rollback silently leaves a subset of later edits in place. The observed case is a non-sparse worktree with a manually flagged tracked path whose captured blob matches HEAD; no data-loss incident was observed. A verified workaround is to clear that path’s skip-worktree bit with git update-index --no-skip-worktree -- flagged.txt before repeating restore.
Version or commit
main @ 0bb6eaa546c91915efbd3f092088c694f3949709. This report establishes the source-checkout behavior at that commit, not a separately installed release build.
Environment
Node v26.12.1; Git 2.56.0; macOS / darwin arm64. The script uses the checkout’s installed dependencies. Windows and Linux were not run.
Logs or stack traces
The capture and restore calls are real Git-driver operations, not copied shell implementations. Capture stores the expected baseline blob; the ordinary file restores; the flagged file does not; clearing the flag restores it. The restore command does not override skip-worktree bits in apps/server/src/vcs/GitVcsDriver.ts#L1396-L1411. The checkpoint service treats the returned true as success in apps/server/src/orchestration-v2/CheckpointService.ts#L526-L550.
Evidence provenance: observed. Local verification: reproduced. Reproduction completeness: complete at the production module boundary. The corresponding UI action was traced in source but was not exercised in a running client. Missing fact: NOT_ENOUGH_INFO — real-client behavior and other platforms require a separate UI run; no broader claim is made here.
restore returned: true; normal control restored: true
skip-worktree file restored: false
restored after clearing flag: true
RESULT: defect reproduced
Workaround
Verified: clear the affected file’s skip-worktree bit with git update-index --no-skip-worktree -- flagged.txt before repeating restore. This changes that index flag; the script confirms the contents then restore.
Restoration check
Repeat the script and require both files to match the captured contents when restore succeeds, without manually clearing flags. Preserve the ordinary-file control and verify that real sparse-checkout exclusions retain their intended behavior.
Expected source: the contract citations under Expected behavior. Failure source: the executed reproduction script and production source locations above. Evidence provenance: observed. Local verification: reproduced. Reproduction completeness: complete at the production module boundary. The running UI was not exercised.
References
- https://github.com/pingdotgg/t3code/issues/13741 — concerns checkpoint capture performance and handling flagged entries in the private capture index; this report concerns successful restore leaving later working-tree edits behind.
- 主要语言
- TypeScript
- 星标
- 24.8k
- 派生
- 6.4k
- 平均合并
- 59 分钟
- 30 天内合并 PR
- 418
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
pingdotgg/t3code 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
via-triage
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 68/100
维护者通常 1 天内回复
-
Question card options show LaTeX as raw source, though the question text renders it可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
[Bug]: Settings inheritance popover shows raw slugs for branch naming, default permissions and response streaming可能已有人在做 @juliusmarminge 于 1 天前认领。 未关闭vouch:denounced
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
nikoheikkila/nikoheikkila.fi#1131 ·
维护者通常 1 天内回复
-
Resources: Update work of urumqi可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 65/100
railmapgen/rmp-gallery#4176 ·
维护者通常 2 天内回复
-
GraphQL custom headers duplicate differently cased default headers可能已有人在做 @yxr-2025 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
github/forgoodfirstissue#574 ·