[Bug]: Diff counters and artifacts collide across chats working on the same repository
Before submitting
- [x] Searched existing reports for artifact and cross-thread diff collisions; no matching report found.
- [x] Included the user-observed scenario, expected behavior and investigation limits.
Area
Not sure — thread UI / diff counters / artifact attribution.
Summary
When multiple chats work on the same repository, the user reports that diff counters and artifacts collide across chats. This makes it difficult to tell which changes or outputs belong to which conversation.
This report records a user-observed problem, not an independently reproduced implementation-level diagnosis. The exact artifact surface and whether the chats shared one physical checkout or used separate worktrees have not yet been isolated. No claim of data loss or confirmed file overwriting is made.
Reported scenario / reproduction to validate
- Open two chats, A and B, for the same repository.
- Work on changes and generate artifacts in each chat.
- Switch between A and B and inspect their diff counters and artifact displays.
- Observe cross-chat collision/mixing instead of clear attribution to the relevant chat.
For a minimal diagnostic test, use distinct A-only and B-only files and distinctly labeled generated artifacts. Repeat first with a shared checkout, then with separate worktrees. This matrix is proposed for investigation; it has not been executed for this report.
Expected behavior
- Artifact attribution and artifact identity remain scoped to the correct thread/run, even for chats targeting the same repository.
- Thread-specific diff counters match their stated scope and do not inherit another chat's state accidentally.
- If a counter intentionally represents the entire shared checkout's Git diff, label that scope clearly. A shared worktree naturally has shared file changes; the UI should distinguish that from a thread's own contribution.
- Separate worktrees for the same repository should have independent diff state and artifact attribution.
Actual behavior
User reports that diff counters and artifacts collide across chats working on the same repository. Exact UI counts, screenshots and overwrite behavior are not yet captured.
Impact
Review reliability is degraded: users cannot confidently attribute changes and outputs to the chat they are reviewing.
Version or commit
Environment used for the surrounding investigation: T3 Code Nightly 0.1.1-nightly.20261020.3411, macOS 26.5 arm64 desktop. The precise version at each reported collision was not separately captured.
Investigation questions
- Are the counters checkout-wide, thread-baseline-based or turn-based, and does their label communicate that?
- Are frontend caches/event subscriptions keyed by repository when they also need thread/worktree identity?
- Are generated artifact IDs or output locations shared across threads, or is the collision limited to presentation?
These are diagnostic questions, not established root causes. No private repository names, paths, artifact contents or chat logs are included.
Workaround
Separate worktrees and distinct output locations may reduce shared-filesystem ambiguity, but have not been verified as a fix for the reported UI collision.
Concrete repro of the shared-checkout case, on T3 Code Nightly 0.1.1-nightly.20261020.3411 (macOS, Claude provider).
Setup: two threads, A and B, bound to the same checkout (root workspace, same branch). No worktrees.
- Thread B is mid-task, editing
src/app/(home)/(tabs)/_layout.tsx. - In thread A, ask a question that makes the agent edit no repository files (it only ran read-only commands; a temporary config it wrote was deleted, and
git statuswas clean after each of its commands). - While thread A's turn runs, thread B commits one change and leaves a further uncommitted edit to the same file.
- Thread A's turn ends.
Expected: thread A's turn shows no changed-files card, because the thread made no repository changes.
Actual: thread A's turn shows "1 changed file +23 −3" under src/app/(home)/(tabs), which is thread B's uncommitted edit. Thread B's commit (+280 −86) was not attributed to A, which suggests the #17161 filtering covers commits but not another thread's working-tree edits.
So in the shared-checkout case the counter is checkout-wide, not thread-scoped. #12306 already detects shared workspaces for rewind; the same signal could either scope the card to paths the thread's own tool calls touched, or label it as shared-checkout changes. Separate worktrees avoid it.
I think this is very hard to solve for T3 Code (you'd have to monitor all the changes the agent makes to attribute them), but I have a simple solution that WOULD work for me:
I have my agents always commit their work, and if I have multiple ones running in the same repo, they are pretty good at committing only their changes.
Then the problem becomes easier: Identify the 1 or more commits the agent made in the last exchange, and show those as "changes" (and preselect Diff panel).
Still happens on T3 Code 0.1.10-nightly.20261115.4736, web app, Linux x64, Codex provider, one thread on the current checkout (no worktree). I sent a prompt that used no tools and, while that turn was running, made a commit and left a two-line uncommitted edit to a tracked file from a terminal, standing in for a second thread. When the turn ended it showed "1 changed file +4 -4" for that file, and the diff held both the uncommitted edit and the commit, plus an earlier commit I had made from the terminal between the previous turn and this one. So on this nightly the turn card counts outside commits as well as outside working-tree edits, which is wider than the earlier comment that saw the commit left out. A control turn with no outside changes showed no card.
Checked and drafted by Claude Opus 5.5 in T3 Code, reviewed and posted by me.
Reproduced on main at d6061ec8ad with a server test that runs real Git through the real CheckpointStore and CheckpointDiffQuery. It needs no second thread: any write to the workspace between the turn-start and turn-end checkpoints shows up in the turn diff.
Cause. A turn diff compares the checkpoint captured before the turn with the one captured after it. The only filter is retainedFilePaths in apps/server/src/checkpointing/CheckpointDiffQuery.ts, which drops files a pull or rebase brought in (#36332). Uncommitted edits from an editor, a terminal or another thread pass through, because nothing records which files the agent changed.
Steps in the test:
- Commit
agent.tsanduser.ts. - Capture the turn-start checkpoint.
- Change
agent.ts(the agent's edit), then saveuser.ts(an edit made outside the agent). - Capture the turn-end checkpoint and request the turn diff.
Result: the test fails, because the diff contains both files:
AssertionError: expected 'diff --git a/agent.ts b/agent.ts\n…' to not include 'user.ts'
diff --git a/user.ts b/user.ts
-before
+external edit
Save it as apps/server/src/checkpointing/ExternalEditRepro.test.ts and run vp test run src/checkpointing/ExternalEditRepro.test.ts from apps/server. It can serve as the regression test for a fix.
Test
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
import * as NodeServices from "@effect/platform-node/NodeServices";
import { assert, it } from "@effect/vitest";
import { CheckpointRef, CheckpointScopeId, RunId, ThreadId } from "@t3tools/contracts";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Path from "effect/Path";
import { checkpointRefForScopeOrdinal } from "../orchestration-v2/CheckpointService.ts";
import * as ThreadManagement from "../orchestration-v2/ThreadManagementService.ts";
import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts";
import * as VcsProcess from "../vcs/VcsProcess.ts";
import * as CheckpointDiffQuery from "./CheckpointDiffQuery.ts";
import * as CheckpointStore from "./CheckpointStore.ts";
const layerVcsProcess = VcsProcess.layer.pipe(Layer.provide(NodeServices.layer));
const layerStore = CheckpointStore.layer.pipe(
Layer.provide(VcsDriverRegistry.layer.pipe(Layer.provide(layerVcsProcess))),
Layer.provide(NodeServices.layer),
);
const layerTest = Layer.merge(layerStore, layerVcsProcess).pipe(
Layer.provideMerge(NodeServices.layer),
Layer.provideMerge(NodeCrypto.layer),
);
it.effect("[repro] an external edit during a turn stays out of the turn diff", () =>
Effect.gen(function* () {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const process = yield* VcsProcess.VcsProcess;
const store = yield* CheckpointStore.CheckpointStore;
const cwd = yield* fs.makeTempDirectoryScoped({ prefix: "t3-external-edit-" });
const git = (args: ReadonlyArray<string>) =>
process.run({ operation: "repro.git", command: "git", cwd, args });
yield* git(["init"]);
yield* git(["config", "user.email", "[email protected]"]);
yield* git(["config", "user.name", "Test"]);
yield* fs.writeFileString(path.join(cwd, "agent.ts"), "before\n");
yield* fs.writeFileString(path.join(cwd, "user.ts"), "before\n");
yield* git(["add", "."]);
yield* git(["commit", "-m", "initial"]);
const threadId = ThreadId.make("thread:external-edit");
const runId = RunId.make("run:external-edit");
const scopeId = CheckpointScopeId.make("scope:external-edit");
const baseline = yield* checkpointRefForScopeOrdinal({ scopeId, ordinalWithinScope: 0 });
const turnEnd = CheckpointRef.make("refs/t3/test/external-edit-after");
yield* store.captureCheckpoint({ cwd, checkpointRef: baseline });
yield* fs.writeFileString(path.join(cwd, "agent.ts"), "agent edit\n");
// An editor outside the agent saves a file while the turn is running.
yield* fs.writeFileString(path.join(cwd, "user.ts"), "external edit\n");
yield* store.captureCheckpoint({ cwd, checkpointRef: turnEnd });
const query = yield* CheckpointDiffQuery.make.pipe(
Effect.provide(
Layer.mock(ThreadManagement.ThreadManagementService)({
getCheckpointContext: () =>
Effect.succeed({
runs: [{ id: runId, ordinal: 1, status: "completed" }],
checkpointScopes: [{ id: scopeId, runId, kind: "root_run", cwd }],
checkpoints: [
{
scopeId,
runId,
ordinalWithinScope: 1,
appRunOrdinal: 1,
status: "ready",
ref: turnEnd,
},
],
}),
}),
),
);
const turn = yield* query.getTurnDiff({ threadId, fromTurnCount: 0, toTurnCount: 1 });
assert.include(turn.diff, "agent.ts");
assert.notInclude(turn.diff, "user.ts");
}).pipe(Effect.provide(layerTest)),
);
Also out of date: docs/user/diffs.md describes Turn changes as "Files edited, committed, or conflict-resolved by a specific turn". In practice it shows every workspace change made while the turn ran.