Skip to content

Commit 9a79f13

Browse files
saphidclaude
andcommitted
fix(client): project removal counts only listed threads, not side chats or subagents
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 61c3794 commit 9a79f13

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

‎apps/web/src/components/settings/ProjectSettingsPanel.logic.test.ts‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from "vite-plus/test";
2-
import { EnvironmentId, ProjectId } from "@t3tools/contracts";
2+
import { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";
33
import { planProjectRemoval } from "@t3tools/client-runtime/state/projects";
44

55
describe("project removal confirmation", () => {
@@ -16,18 +16,32 @@ describe("project removal confirmation", () => {
1616
environmentLabel: "Remote",
1717
};
1818

19-
it("limits a checkout's thread count to its environment and project", () => {
19+
const parentId = ThreadId.make("parent");
20+
const listed = { rootThreadId: parentId, parentThreadId: null, relationshipToParent: null };
21+
const child = { rootThreadId: parentId, parentThreadId: parentId };
22+
23+
it("limits a checkout's thread count to its listed threads in that environment and project", () => {
2024
const plan = planProjectRemoval({
2125
members: [local],
2226
groupMemberCount: 2,
2327
hasOtherMembers: false,
2428
displayName: "Repo",
2529
threads: [
26-
{ environmentId: local.environmentId, projectId: local.id },
27-
{ environmentId: remote.environmentId, projectId: remote.id },
30+
{ environmentId: local.environmentId, projectId: local.id, lineage: listed },
31+
{
32+
environmentId: local.environmentId,
33+
projectId: local.id,
34+
lineage: { ...child, relationshipToParent: "subagent" },
35+
},
36+
{
37+
environmentId: local.environmentId,
38+
projectId: local.id,
39+
lineage: { ...child, relationshipToParent: "fork", sideChat: true },
40+
},
41+
{ environmentId: remote.environmentId, projectId: remote.id, lineage: listed },
2842
],
2943
});
30-
expect(plan.projectThreads).toHaveLength(1);
44+
expect(plan.projectThreads).toHaveLength(3);
3145
expect(plan.confirmationMessage).toBe(
3246
'Remove checkout "Repo" and delete its 1 thread?\nPath: /work/repo\nEnvironment: Local\nThose threads and any archived threads are deleted from T3 Code. Provider sessions are kept.\nOther entries in this grouped project are unaffected.\nThis action cannot be undone.',
3347
);

‎packages/client-runtime/src/state/projectRemoval.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { isListedThreadLineage } from "@t3tools/contracts";
2+
13
import type { EnvironmentProject, EnvironmentThreadShell } from "./models.ts";
24

35
export function planProjectRemoval<
4-
Thread extends Pick<EnvironmentThreadShell, "environmentId" | "projectId">,
6+
Thread extends Pick<EnvironmentThreadShell, "environmentId" | "projectId" | "lineage">,
57
>(options: {
68
readonly members: ReadonlyArray<
79
Pick<EnvironmentProject, "id" | "environmentId" | "title" | "workspaceRoot"> & {
@@ -20,7 +22,10 @@ export function planProjectRemoval<
2022
const projectThreads = threads.filter((thread) =>
2123
memberKeys.has(`${thread.environmentId}:${thread.projectId}`),
2224
);
23-
const threadCount = projectThreads.length + (options.unloadedThreadCount ?? 0);
25+
// Side chats and subagents go with their parent but never show in thread lists.
26+
const threadCount =
27+
projectThreads.filter((thread) => isListedThreadLineage(thread.lineage)).length +
28+
(options.unloadedThreadCount ?? 0);
2429
const isWholeGroup = members.length === groupMemberCount;
2530
const targetKind = hasOtherMembers || !isWholeGroup ? "checkout" : "project";
2631
const singleMember = members.length === 1 ? members[0]! : null;

0 commit comments

Comments
 (0)