pingdotgg / pingdotgg/t3code

Turn diffs show wrong file sets (1 file / only .ged files / whole repo)

Open
#7,781 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
23k
Forks
5.9k
Avg merge
11h 14m
Merged PRs (30d)
357

Description

Symptom

Turn-scoped diffs don't show what actually changed in that turn. Observed variants:

  • sometimes only 1 file,
  • sometimes only the .ged state files,
  • sometimes ~500 files (everything).

Mechanism (verified)

Turn diffs are checkpoint-pair diffs: CheckpointReactor captures git refs refs/t3/checkpoints/<base64url(threadId)>/turn/<n> per turn (Utils.ts:6-10, CheckpointReactor.ts:317,597,679 — including placeholder captures). CheckpointDiffQuery.getTurnDiff diffs checkpoint N-1 → N (Layers/CheckpointDiffQuery.ts:101-134); turn 0 uses a synthetic base ref. The client picks the range from per-turn summaries' checkpointTurnCount with an inferred fallback when absent (DiffPanel.tsx:225-251).

Root-cause hypotheses (ranked)

  1. Missed/placeholder-only capture for a turn → the adjacent checkpoint pair straddles only orchestration state writes (.ged/** files change every turn), producing the "only .ged files" / "1 file" variants. Capture happens on turn completion plus placeholder paths (CheckpointReactor.ts:441-506,850-876); a race between stage settlement commits and capture could attribute content to the wrong pair.
  2. Wrong turn-0 baseline → the "500 files" variant: if the turn-0 base ref is missing/stale (e.g. after worktree recreation the refs don't exist in the fresh clone), the diff runs against an empty or wrong tree and everything appears new.
  3. Client-side inferred turn→count mapping selecting the wrong pair when summaries lack checkpointTurnCount.

Fix plan

  1. Reproduce each variant; instrument capture (log ref, turn count, dirty state at capture).
  2. Fix capture timing/attribution so each checkpoint pair brackets exactly one turn's content changes (decide policy for mid-turn commits and .ged state writes — consider excluding orchestration-internal paths from turn attribution).
  3. Ensure turn-0 base ref exists in every workspace where diffs are computed; fail loudly (not "everything changed") when it doesn't.
  4. Replace or harden the client's inferred mapping so a missing count surfaces an explicit state instead of a wrong range.

Acceptance criteria

  • For a scripted multi-turn session with known per-turn file changes, each turn chip shows exactly that turn's files.
  • First-turn diff never shows the whole repo when the baseline ref is absent — explicit error or correct baseline.
  • Regression tests for capture attribution (mid-turn commit, .ged writes, worktree recreation).

Size: M

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the scripted multi-turn session, then inspect CheckpointReactor.ts and Layers/CheckpointDiffQuery.ts while logging checkpoint refs, turn counts, and dirty state at capture. Check DiffPanel.tsx for the inferred turn-to-count mapping and test worktree recreation, mid-turn commits, and .ged writes. Done means each turn chip shows only that turn's files, with an explicit error or correct baseline when the first-turn ref is absent.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, typescript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.