GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(server): forks keep their inherited message count after the source thread is deleted by only21mil · Pull Request #32760 · pingdotgg/t3code Conversation
|
| Revision | Fork itemCount before delete |
After delete | thread show after |
|---|---|---|---|
| main 6464729 | 9 | 0 | 9 |
| 62d0a27 merged with 6464729 | 9 | 9 | 9 |
Re-checked against main f419698 on 2026-11-12: the extended sql-project-shell case fails with that main's ProjectionStore.ts (expected +0 to equal 2) and passes with this change, the branch merges cleanly with that main, and the same steps on that main list the fork as itemCount: 11 before the source is deleted and itemCount: 0 after, while t3 thread show still reports 11.
| base a9e709f (first run) | 9 | 0 | 9 |
| 62d0a27 (first run, same data after the delete) | | 9 | 9 |
| 62d0a27 (first run, fresh fork) | 9 | 9 | |
Also verified by maria-rcks on 62d0a27 with real Codex turns, including a fork whose two ancestors were both deleted (comment below).
Not checked: performance on a large database (the change adds one primary-key row per deleted ancestor and no extra queries otherwise).
Problem (full text)
Deleting a thread does not delete its run forks. A fork keeps showing the source's messages, because getThreadProjection reads through the deleted source. The fork's shell count does not keep them. getThreadShell and getShellSnapshot load fork sources through selectShellThreadRows, which always filters deleted_at IS NULL. The deleted source is skipped, so visibleItemCount falls back to the fork's own items.
Who sees it: agents. t3_thread_list (and t3 thread list) reports itemCount: shell.visibleItemCount. After the source is deleted, a fork with its full history lists as itemCount: 0. t3_thread_read on the same fork still reports the full count. Web, desktop and mobile carry visibleItemCount but do not render it; their chat views count from the projection. The only client read is the > 0 check in threadShell.ts that decides whether a shell update is cosmetic.
Steps: start a thread, fork it from a finished reply, delete the source, then list the project's threads.
Change (full text)
selectShellThreadRows takes an includeDeleted option, off by default. The two fork-source walks set it for ancestors only:
readShellSnapshotRows passes it while walking sources. The snapshot's own threads still come from the first, fully filtered query, and only those become shells.getThreadShell passes it for every id except the requested thread, so a deleted thread still returns null.Deleted threads never appear as shells. They only supply the run and item counts their forks inherit, which matches how the projection already reads them.
Scope and approval (full text)
This is a small, focused fix for an obvious bug: one derived count disagrees with the data the same server returns for the same thread. It changes no contract, client or stored data, so it qualifies without a prior issue. The change stays focused on the shell read path, two files.
Related open PRs, none making this change:
selectRunForkFamily also keeps deleted members, but only for cleanup.selectShellRunItemCounts and selectShellItemCounts, not the source walks.Verification (full text)
Test, extended in the existing sql-project-shell case in ProjectionStore.test.ts. After thread.deleted on the source, it asserts:
visibleItemCount from getShellSnapshot() and getThreadShell is unchanged;threadShellFromProjection(getThreadProjection(fork));getThreadShell(source) is null.With this branch's test file, main 6464729 fails expected +0 to equal 2, and this branch merged locally with that main (59ab894b1b, not pushed) passes. On 62d0a27 itself, the whole ProjectionStore.test.ts passed (53) and vp run check:changed a9e709f15f825cacac1b6d665fa1920c328d68b7 exited 0.
Runtime: a dev server started with --no-seed in a sandbox named "Test machine", with a fake one-commit project. A source thread ran on the Replay (dev) provider. I made the fork with "Fork from this response" and deleted the source in the web UI, in the Browser panel, then read the fork with t3 thread list --json and t3 thread show. The count is server data, so the provider does not change it.
| Revision | Fork itemCount before delete |
After delete | thread show after |
|---|---|---|---|
| main 6464729 | 9 | 0 | 9 |
| 62d0a27 merged with 6464729 | 9 | 9 | 9 |
| base a9e709f (first run) | 9 | 0 | 9 |
| 62d0a27 (first run, same data after the delete) | 9 | 9 | |
| 62d0a27 (first run, fresh fork) | 9 | 9 |
Unedited output
Test, main 6464729 with this branch's test file:
# main 6464729c56 with only ProjectionStore.test.ts taken from 59ab894b1b
$ cd apps/server && vp test run src/orchestration-v2/ProjectionStore.test.ts -t "reads only the requested project's threads into a scoped shell snapshot" 2>&1 | sed 's/\x1b\[[0-9;]*m//g'
note: You are running `vp test` as a Vite+ built-in command. If you meant to run the test npm script, use `vpr test` instead.
RUN v5.0.5 /mnt/t3code/apps/server
(node:330373) ExperimentalWarning: SQLite is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
stdout | src/orchestration-v2/ProjectionStore.test.ts > ProjectionStoreV2 > reads only the requested project's threads into a scoped shell snapshot
[22:35:24.548] ERROR (#356): Error [AssertionError]: expected +0 to equal 2
at /mnt/t3code/apps/server/src/orchestration-v2/ProjectionStore.test.ts:4912:14 {
actual: 0,
expected: 2,
showDiff: true,
operator: 'strictEqual',
[cause]: undefined
}
❯ src/orchestration-v2/ProjectionStore.test.ts (53 tests | 1 failed | 52 skipped) 121ms
↓ routes full projection reads to readers and retains uncommitted writer state
↓ record reads restrict provider histories to delivery identities
↓ idle compaction filters keep the latest run, live work and the newest usage
↓ record reads filter notification sources without dropping matching message bodies
↓ shells flag a latest run triggered by a provider background wake
↓ SQL queue readiness skips held runs without bypassing active work
↓ SQL shells flag only an active turn blocked solely on T3 thread waits
↓ SQL shells use the latest subagent owner for duplicate provider-thread ids
↓ SQL projection keeps background thread updates out of updatedAt
↓ SQL shells read a subagent family and a worktree's threads
↓ SQL list older settled threads below a cursor
↓ SQL snapshot windows keep cards for requests still pending
↓ lists only active subagent IDs without loading shell data
↓ lists every thread in the shell snapshot past SQLite's bound variable limit
❯ ProjectionStoreV2 (39)
↓ returns a typed read error for malformed stored plan JSON
↓ indexes streamed payload timestamps without parsing the payload JSON
↓ SQL recovery selects unfinished runless native subagents
↓ worktree path and title lookups skip deleted threads, and can include archived ones
↓ keeps restart-cancelled work through a stale run.updated
↓ records restart-cancelled work without regressing a run that completed since
↓ record reads select subagents by id
↓ command reads skip finished leaf nodes of finished runs
↓ preserves stored provider usage when a terminal update omits it
↓ reads a fixed SQL turn-item window for long histories and repeated clients
↓ keeps an open question's row in the window after the run kept working
↓ scopes actionable provider state to the requested bounded thread
↓ projects root provider owners into the shell in first-use order
↓ shows the native goal of the active provider thread on the shell
↓ reads the shell snapshot first and decodes it in a separate step
× reads only the requested project's threads into a scoped shell snapshot 39ms
↓ looks up shell stop requests through the interrupt request index
↓ reads a run's turn-start items by thread and run, not by walking thread history
↓ counts each shell's own runless and live-run items, skipping rolled back and missing runs
↓ does not treat visited or marked-unread state as thread activity
↓ dates thread activity by a run event and leaves the rest of the thread alone
↓ preserves delegated completion ownership across stale run and task updates
↓ keeps the shell on the user's last turn only during T3 Code's idle compaction
↓ keeps the shell on the user's last turn only during compacting on return
↓ keeps the shell on the user's last turn only during a typed /compact
↓ keeps the shell on the user's last turn only during a normalized idle command
↓ keeps the shell on the user's last turn only during an ordinary prompt with idle metadata
↓ only exposes interruptible runs through the shell activeRunId
↓ selects only threads with runtime state that needs recovery
↓ projects only the latest failed root turn's limit into SQL and memory shells
↓ does not freshly arm limit recovery for a subagent of a put-away parent
↓ projects one shared provider session into multiple thread bindings
↓ looks up a thread's last provider error through its own session bindings
↓ selects the latest waiting secret only from active runs
↓ counts history inherited by fork shells, but not by side chats
↓ removes rolled back runs from the active visible projection
↓ keeps fork visible items stable after a source run is rolled back
↓ a pull request watch keeps a finished thread working until it ends
↓ dates a completion released by held background work at the release
⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯
FAIL src/orchestration-v2/ProjectionStore.test.ts > ProjectionStoreV2 > reads only the requested project's threads into a scoped shell snapshot
AssertionError: expected +0 to equal 2
- Expected
+ Received
- 2
+ 0
❯ src/orchestration-v2/ProjectionStore.test.ts:4912:14
4910| });
4911| const afterDelete = yield* projectionStore.getShellSnapshot();
4912| assert.strictEqual(
| ^
4913| afterDelete.threads.find((thread) => thread.id === forkThreadI…
4914| forkItemCount,
❯ ~effect/Effect/successCont ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:1482:28
❯ ~effect/Effect/evaluate ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/core.ts:587:30
❯ FiberImpl.runLoop ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:700:41
❯ FiberImpl.evaluate ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:635:23
❯ FiberImpl.evaluate ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:624:29
❯ Array.<anonymous> ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/internal/effect.ts:1076:13
❯ MixedSchedulerDispatcher.runTasks ../../node_modules/.pnpm/[email protected]/node_modules/effect/src/Scheduler.ts:254:17
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
Test Files 1 failed (1)
Tests 1 failed | 52 skipped (53)
Start at 22:35:10
Duration 14.40s (transform 81%, import 16%, setup 2%, tests 1%)
Test, 62d0a27 merged with main 6464729:
# head 62d0a27b15 merged with main 6464729c56 (59ab894b1b)
$ cd apps/server && vp test run src/orchestration-v2/ProjectionStore.test.ts -t "reads only the requested project's threads into a scoped shell snapshot" 2>&1 | sed 's/\x1b\[[0-9;]*m//g'
note: You are running `vp test` as a Vite+ built-in command. If you meant to run the test npm script, use `vpr test` instead.
RUN v5.0.5 /mnt/t3code/apps/server
(node:322632) ExperimentalWarning: SQLite is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
✓ src/orchestration-v2/ProjectionStore.test.ts (53 tests | 52 skipped) 110ms
Test Files 1 passed (1)
Tests 1 passed | 52 skipped (53)
Start at 22:34:40
Duration 15.38s (transform 82%, import 17%, setup 1%, tests 1%)
Runtime, main 6464729:
# main 6464729c56: before the source thread is deleted
$ node apps/server/src/bin.ts thread list --base-dir /mnt/t3home --project /mnt/demo-app --json --log-level error 2>/dev/null | jq '[.[] | {threadId, title, relationshipToParent, itemCount}]'
[
{
"threadId": "17105e3a-cef6-404b-b8be-06321b2793f3",
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
},
{
"threadId": "mcp:d77bfa46-7d52-484c-b872-e3a3dd9c9993",
"title": "Release notes draft",
"relationshipToParent": null,
"itemCount": 8
}
]
# main 6464729c56: after the source thread is deleted in the web UI
$ node apps/server/src/bin.ts thread list --base-dir /mnt/t3home --project /mnt/demo-app --json --log-level error 2>/dev/null | jq '[.[] | {threadId, title, relationshipToParent, itemCount}]'
[
{
"threadId": "17105e3a-cef6-404b-b8be-06321b2793f3",
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 0
}
]
# main 6464729c56: the same fork read in full
$ node apps/server/src/bin.ts thread show --base-dir /mnt/t3home --json --log-level error 17105e3a-cef6-404b-b8be-06321b2793f3 2>/dev/null | jq '{thread: (.thread | {title, relationshipToParent, itemCount}), messages: [.messages[] | {role, text}]}'
{
"thread": {
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
},
"messages": [
{
"role": "user",
"text": "go"
},
{
"role": "assistant",
"text": "I'll track the three steps and inspect both files."
},
{
"role": "assistant",
"text": "todo list fixture complete"
}
]
}
Runtime, 62d0a27 merged with main 6464729:
# head 62d0a27b15 merged with main 6464729c56 (59ab894b1b): before the source thread is deleted
$ node apps/server/src/bin.ts thread list --base-dir /mnt/t3home --project /mnt/demo-app --json --log-level error 2>/dev/null | jq '[.[] | {threadId, title, relationshipToParent, itemCount}]'
[
{
"threadId": "6fa56cff-eceb-40e8-b39f-3f233c5db17c",
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
},
{
"threadId": "mcp:c26a0acd-844c-46ef-95c3-aba32b1d3039",
"title": "Release notes draft",
"relationshipToParent": null,
"itemCount": 8
}
]
# head 62d0a27b15 merged with main 6464729c56 (59ab894b1b): after the source thread is deleted in the web UI
$ node apps/server/src/bin.ts thread list --base-dir /mnt/t3home --project /mnt/demo-app --json --log-level error 2>/dev/null | jq '[.[] | {threadId, title, relationshipToParent, itemCount}]'
[
{
"threadId": "6fa56cff-eceb-40e8-b39f-3f233c5db17c",
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
}
]
# head 62d0a27b15 merged with main 6464729c56 (59ab894b1b): the same fork read in full
$ node apps/server/src/bin.ts thread show --base-dir /mnt/t3home --json --log-level error 6fa56cff-eceb-40e8-b39f-3f233c5db17c 2>/dev/null | jq '{thread: (.thread | {title, relationshipToParent, itemCount}), messages: [.messages[] | {role, text}]}'
{
"thread": {
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
},
"messages": [
{
"role": "user",
"text": "go"
},
{
"role": "assistant",
"text": "I'll track the three steps and inspect both files."
},
{
"role": "assistant",
"text": "todo list fixture complete"
}
]
}
Runtime, first run on base a9e709f and 62d0a27. That run used a relative --base-dir and colour from jq -C; I removed only the colour codes.
Base a9e709f, before and after the delete:
# base a9e709f15: before the source thread is deleted
$ node apps/server/src/bin.ts thread list --base-dir .t3 --project 8b75110e-ba81-419a-8aaa-4248964ef818 --json --log-level error 2>/dev/null | jq -C '[.[] | {title, relationshipToParent, itemCount}]'
[
{
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
},
{
"title": "Release notes draft",
"relationshipToParent": null,
"itemCount": 8
}
]
# base a9e709f15: after the source thread is deleted in the web UI
$ node apps/server/src/bin.ts thread list --base-dir .t3 --project 8b75110e-ba81-419a-8aaa-4248964ef818 --json --log-level error 2>/dev/null | jq -C '[.[] | {title, relationshipToParent, itemCount}]'
[
{
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 0
}
]
Base a9e709f, the fork read in full after the delete:
# base a9e709f15: the fork after the delete still holds its inherited messages
$ node apps/server/src/bin.ts thread show --base-dir .t3 --json --log-level error 0938909c-d67c-4a12-8cca-938eafa602f8 2>/dev/null | jq -C '{thread: (.thread | {title, relationshipToParent, itemCount}), messages: [.messages[] | {role, text}]}'
{
"thread": {
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
},
"messages": [
{
"role": "user",
"text": "go"
},
{
"role": "assistant",
"text": "I'll track the three steps and inspect both files."
},
{
"role": "assistant",
"text": "todo list fixture complete"
}
]
}
62d0a27, the same data after the delete:
# candidate 62d0a27b1: same data, after the source thread was deleted
$ node apps/server/src/bin.ts thread list --base-dir .t3 --project 8b75110e-ba81-419a-8aaa-4248964ef818 --json --log-level error 2>/dev/null | jq -C '[.[] | {title, relationshipToParent, itemCount}]'
[
{
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
}
]
62d0a27, the same fork read in full:
# candidate 62d0a27b1: the same fork read in full
$ node apps/server/src/bin.ts thread show --base-dir .t3 --json --log-level error 0938909c-d67c-4a12-8cca-938eafa602f8 2>/dev/null | jq -C '{thread: (.thread | {title, relationshipToParent, itemCount}), messages: [.messages[] | {role, text}]}'
{
"thread": {
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
},
"messages": [
{
"role": "user",
"text": "go"
},
{
"role": "assistant",
"text": "I'll track the three steps and inspect both files."
},
{
"role": "assistant",
"text": "todo list fixture complete"
}
]
}
62d0a27, a fresh fork before and after its source is deleted:
# candidate 62d0a27b1: fresh fork, before its source is deleted
$ node apps/server/src/bin.ts thread list --base-dir .t3 --project 8b75110e-ba81-419a-8aaa-4248964ef818 --json --log-level error 2>/dev/null | jq -C '[.[] | {title, relationshipToParent, itemCount}]'
[
{
"title": "Changelog draft fork",
"relationshipToParent": "fork",
"itemCount": 9
},
{
"title": "Changelog draft",
"relationshipToParent": null,
"itemCount": 8
},
{
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
}
]
# candidate 62d0a27b1: fresh fork, after its source is deleted in the web UI
$ node apps/server/src/bin.ts thread list --base-dir .t3 --project 8b75110e-ba81-419a-8aaa-4248964ef818 --json --log-level error 2>/dev/null | jq -C '[.[] | {title, relationshipToParent, itemCount}]'
[
{
"title": "Changelog draft fork",
"relationshipToParent": "fork",
"itemCount": 9
},
{
"title": "Release notes draft fork",
"relationshipToParent": "fork",
"itemCount": 9
}
]
Also verified by maria-rcks on 62d0a27 with real Codex turns, including a fork whose two ancestors were both deleted (comment below).
Not checked: performance on a large database (the change adds one primary-key row per deleted ancestor and no extra queries otherwise).
Generated with Claude Opus 5.5 and GPT-6.1 Sol in T3 Code Nightly
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…e thread is deleted Deleting a run-fork's source thread dropped the fork's visibleItemCount to its own items, because the shell source walks skipped deleted rows. The walks now load deleted ancestors for their item counts, while deleted threads still never appear as shells. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Forks retain their inherited message counts after their source thread is deleted. Deleted threads remain hidden, and the change is confined to read-time count calculation without modifying stored data. You can add or adjust custom eligibility rules. Learn more. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Note Written by Verified in a real dev environmentverified as-is at
recording shows deleting the intermediate source and reopening the surviving nested fork. page-load waits were cut. uploaded playback and seeking checked. Not verifiednative ios/android and electron shells were not exercised on this linux web pass. other providers, remote/relay/tunnel connections, and large-database performance were not exercised. no performance claim. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Note 🤖 Opus 5.5 replying on behalf of Victor. Thank you, Maria, for testing this end to end with real Codex turns and app-created data. Your run reproduced the drop on main (the fork listed 0 after its source was deleted) and showed the PR head keeping it at 5. It also showed the count keeps growing after the fork continues (8). Your nested-fork check covers the one case the description lists as not checked at runtime: with both ancestors deleted, the fork still lists and reads 9 items, and the deleted threads stay out of the list. Noted that native, Electron, other providers, remote connections and large-database performance were outside this pass. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for this. Main has the change since #36657. Main now preserves inherited item counts in shell snapshots and single-thread shell reads after source deletion, while keeping deleted threads hidden. I compared your full production and test diff with the merge: the includeDeleted option and both ancestor walks are equivalent (SQL TRUE versus 1 = 1), and your regression assertions cover behavior main now provides. Closing as superseded. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.