The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 18:30 UTC
fix(projects): preserve grouped renames to repository names (#25244)
Co-authored-by: MacKinley Smith <1738501+mackinleysmith@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
maria committed
Nov 13, 2026 at 00:16 UTC
56d227836bd815e0cff5d62196299156985cd8d7
16 files changed
+202
-17
apps/server/src/orchestration-v2/ProjectCommands.test.ts
+1
@@ -19,6 +19,7 @@ const row = (overrides: Partial<ProjectRow> = {}): ProjectRow => ({
19
workspaceRoot: "/tmp/scripts",
20
defaultModelSelection: null,
21
defaultThreadEnvMode: null,
22
+ hasCustomTitle: false,
23
autoPull: false,
24
faviconPath: null,
25
projectIcon: null,
apps/server/src/orchestration-v2/ProjectStore.test.ts
+64
@@ -96,5 +96,69 @@ it.layer(ProjectStore.layer.pipe(Layer.provideMerge(SqlitePersistence.layerMemor
96
assert.strictEqual(project?.archivedAt, at);
97
}),
98
);
99
+
100
+ it.effect("marks a project's title as custom only once it is renamed", () =>
101
+ Effect.gen(function* () {
102
+ const projects = yield* ProjectStore.ProjectStoreV2;
103
+ const projectId = ProjectId.make("project-renamed");
104
+ const event = {
105
+ aggregateKind: "project",
106
+ aggregateId: projectId,
107
+ occurredAt: "2026-03-24T00:00:00.000Z",
108
+ commandId: null,
109
+ causationEventId: null,
110
+ correlationId: null,
111
+ metadata: {},
112
+ } as const;
113
+ const hasCustomTitle = () =>
114
+ projects
115
+ .getShell(projectId)
116
+ .pipe(Effect.map((shell) => Option.getOrNull(shell)?.hasCustomTitle));
117
+ yield* projects.apply({
118
+ ...event,
119
+ sequence: 1,
120
+ eventId: EventId.make("event-renamed-created"),
121
+ type: "project.created",
122
+ payload: {
123
+ projectId,
124
+ title: "repo",
125
+ workspaceRoot: "/tmp/repo",
126
+ defaultModelSelection: null,
127
+ scripts: [],
128
+ createdAt: "2026-03-24T00:00:00.000Z",
129
+ updatedAt: "2026-03-24T00:00:00.000Z",
130
+ },
131
+ });
132
+ assert.strictEqual(yield* hasCustomTitle(), false);
133
+ yield* projects.apply({
134
+ ...event,
135
+ sequence: 2,
136
+ eventId: EventId.make("event-renamed-title"),
137
+ type: "project.meta-updated",
138
+ payload: { projectId, title: "custom repo", updatedAt: "2026-03-24T00:00:02.000Z" },
139
+ });
140
+ assert.strictEqual(yield* hasCustomTitle(), true);
141
+ yield* projects.apply({
142
+ ...event,
143
+ sequence: 3,
144
+ eventId: EventId.make("migration:39:project:project-renamed:baseline"),
145
+ type: "project.created",
146
+ payload: {
147
+ projectId,
148
+ title: "repo",
149
+ workspaceRoot: "/tmp/repo",
150
+ defaultModelSelection: null,
151
+ scripts: [],
152
+ createdAt: "2026-03-24T00:00:00.000Z",
153
+ updatedAt: "2026-03-24T00:00:03.000Z",
154
+ },
155
+ });
156
+ assert.strictEqual(yield* hasCustomTitle(), true);
157
+ assert.strictEqual(
158
+ Option.getOrNull(yield* projects.getShell(projectId))?.title,
159
+ "custom repo",
160
+ );
161
+ }),
162
+ );
163
},
164
);
apps/server/src/orchestration-v2/ProjectStore.ts
+14
-2
@@ -32,6 +32,7 @@ export class ProjectStoreV2Error extends Schema.TaggedError<ProjectStoreV2Error>
32
export const ProjectRow = Schema.Struct({
33
projectId: ProjectId,
34
title: Schema.String,
35
+ hasCustomTitle: Schema.Boolean,
36
workspaceRoot: Schema.String,
37
defaultModelSelection: Schema.NullOr(ModelSelection),
38
defaultThreadEnvMode: Schema.NullOr(ThreadEnvMode),
@@ -50,6 +51,7 @@ export type ProjectRow = typeof ProjectRow.Type;
51
const ProjectDbRow = Schema.Struct({
52
...ProjectRow.fields,
53
defaultModelSelection: Schema.NullOr(Schema.fromJsonString(ModelSelection)),
54
+ hasCustomTitle: Schema.BooleanFromBit,
55
autoPull: Schema.BooleanFromBit,
56
projectIcon: Schema.NullOr(Schema.fromJsonString(StoredProjectIcon)),
57
scripts: Schema.fromJsonString(Schema.Array(ProjectScript)),
@@ -59,6 +61,7 @@ function toShell(row: ProjectRow): OrchestrationProjectShell {
61
return {
62
id: row.projectId,
63
title: row.title,
64
+ hasCustomTitle: row.hasCustomTitle,
65
workspaceRoot: row.workspaceRoot,
66
repositoryIdentity: null,
67
defaultModelSelection: row.defaultModelSelection,
@@ -117,6 +120,7 @@ export const make = Effect.gen(function* () {
120
SELECT
121
project_id AS "projectId",
122
title,
123
+ has_custom_title AS "hasCustomTitle",
124
workspace_root AS "workspaceRoot",
125
default_model_selection_json AS "defaultModelSelection",
126
default_thread_env_mode AS "defaultThreadEnvMode",
@@ -149,6 +153,7 @@ export const make = Effect.gen(function* () {
153
INSERT INTO projection_projects (
154
project_id,
155
title,
156
+ has_custom_title,
157
workspace_root,
158
default_model_selection_json,
159
default_thread_env_mode,
@@ -165,6 +170,7 @@ export const make = Effect.gen(function* () {
170
VALUES (
171
${encoded.projectId},
172
${encoded.title},
173
+ ${encoded.hasCustomTitle},
174
${encoded.workspaceRoot},
175
${encoded.defaultModelSelection},
176
${encoded.defaultThreadEnvMode},
@@ -180,7 +186,12 @@ export const make = Effect.gen(function* () {
186
)
187
ON CONFLICT (project_id)
188
DO UPDATE SET
183
- title = excluded.title,
189
+ title = CASE
190
+ WHEN projection_projects.has_custom_title = 1 AND excluded.has_custom_title = 0
191
+ THEN projection_projects.title
192
+ ELSE excluded.title
193
+ END,
194
+ has_custom_title = MAX(projection_projects.has_custom_title, excluded.has_custom_title),
195
workspace_root = excluded.workspace_root,
196
default_model_selection_json = excluded.default_model_selection_json,
197
default_thread_env_mode = excluded.default_thread_env_mode,
@@ -231,6 +242,7 @@ export const make = Effect.gen(function* () {
242
return yield* upsertRow({
243
projectId: payload.projectId,
244
title: payload.title,
245
+ hasCustomTitle: false,
246
workspaceRoot: payload.workspaceRoot,
247
defaultModelSelection: payload.defaultModelSelection,
248
defaultThreadEnvMode: payload.defaultThreadEnvMode ?? null,
@@ -258,7 +270,7 @@ export const make = Effect.gen(function* () {
270
const payload = event.payload;
271
yield* upsertRow({
272
...row,
261
- ...(payload.title === undefined ? {} : { title: payload.title }),
273
+ ...(payload.title === undefined ? {} : { title: payload.title, hasCustomTitle: true }),
274
...(payload.workspaceRoot === undefined ? {} : { workspaceRoot: payload.workspaceRoot }),
275
...(payload.defaultModelSelection === undefined
276
? {}
apps/server/src/orchestration-v2/RuntimePolicy.test.ts
+1
@@ -99,6 +99,7 @@ const layerWithPolicy = (policy?: ManagedPolicySummary) =>
99
workspaceRoot: "/project-root",
100
defaultModelSelection: null,
101
defaultThreadEnvMode: null,
102
+ hasCustomTitle: false,
103
autoPull: false,
104
faviconPath: null,
105
projectIcon: null,
apps/server/src/orchestration-v2/ThreadLaunchService.test.ts
+1
@@ -257,6 +257,7 @@ function makeHarness(options: HarnessOptions = {}) {
257
workspaceRoot: project.workspaceRoot,
258
defaultModelSelection: project.defaultModelSelection,
259
defaultThreadEnvMode: null,
260
+ hasCustomTitle: false,
261
autoPull: false,
262
faviconPath: null,
263
projectIcon: null,
apps/server/src/orchestration-v2/ThreadTitleRegenerationService.test.ts
+1
@@ -81,6 +81,7 @@ function makeHarness(
81
workspaceRoot: "/repo",
82
defaultModelSelection: modelSelection,
83
defaultThreadEnvMode: null,
84
+ hasCustomTitle: false,
85
autoPull: false,
86
faviconPath: null,
87
projectIcon: null,
apps/server/src/persistence/Migrations.ts
+2
@@ -94,6 +94,7 @@ import Migration0083 from "./Migrations/083_CommandReadIndexes.ts";
94
import Migration0084 from "./Migrations/084_LastExecutedRunIndex.ts";
95
import Migration0085 from "./Migrations/085_TurnItemCounts.ts";
96
import Migration0086 from "./Migrations/086_QueuedTurnInputIndex.ts";
97
+import Migration0087 from "./Migrations/087_ProjectionProjectsCustomTitle.ts";
98
99
const migrationEntries = [
100
[1, "OrchestrationEvents", Migration0001],
@@ -183,6 +184,7 @@ const migrationEntries = [
184
[84, "LastExecutedRunIndex", Migration0084],
185
[85, "TurnItemCounts", Migration0085],
186
[86, "QueuedTurnInputIndex", Migration0086],
187
+ [87, "ProjectionProjectsCustomTitle", Migration0087],
188
] as const;
189
190
export const migrationManifest = migrationEntries.map(([id, name]) => [id, name] as const);
apps/server/src/persistence/Migrations/087_ProjectionProjectsCustomTitle.test.ts
new
+41
@@ -0,0 +1,41 @@
1
+import { assert, it } from "@effect/vitest";
2
+import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
3
+import * as Effect from "effect/Effect";
4
+import * as SqlClient from "effect/sql/SqlClient";
5
+
6
+import { runMigrations } from "../Migrations.ts";
7
+
8
+const layer = it.layer(NodeSqliteClient.layer({ filename: ":memory:" }));
9
+
10
+layer("087_ProjectionProjectsCustomTitle", (it) => {
11
+ it.effect("marks projects with a recorded title update as renamed", () =>
12
+ Effect.gen(function* () {
13
+ const sql = yield* SqlClient.SqlClient;
14
+ yield* runMigrations({ toMigrationInclusive: 86 });
15
+ for (const projectId of ["renamed", "untouched"]) {
16
+ yield* sql`
17
+ INSERT INTO projection_projects
18
+ (project_id, title, workspace_root, scripts_json, created_at, updated_at)
19
+ VALUES (${projectId}, 'repo', ${"/tmp/" + projectId}, '[]', '2026-10-01', '2026-10-01')
20
+ `;
21
+ yield* sql`
22
+ INSERT INTO orchestration_events
23
+ (event_id, aggregate_kind, stream_id, stream_version, event_type, occurred_at,
24
+ actor_kind, payload_json, metadata_json, application_event_version)
25
+ VALUES (${projectId}, 'project', ${projectId}, 1, 'project.meta-updated', '2026-10-01',
26
+ 'client', ${JSON.stringify(projectId === "renamed" ? { title: "repo" } : { autoPull: true })}, '{}', 2)
27
+ `;
28
+ }
29
+ // Builds of this change before renumbering already added the column.
30
+ yield* sql`ALTER TABLE projection_projects ADD COLUMN has_custom_title INTEGER NOT NULL DEFAULT 0`;
31
+ yield* runMigrations();
32
+ assert.deepStrictEqual(
33
+ yield* sql`SELECT project_id, has_custom_title FROM projection_projects ORDER BY project_id`,
34
+ [
35
+ { project_id: "renamed", has_custom_title: 1 },
36
+ { project_id: "untouched", has_custom_title: 0 },
37
+ ],
38
+ );
39
+ }),
40
+ );
41
+});
apps/server/src/persistence/Migrations/087_ProjectionProjectsCustomTitle.ts
new
+26
@@ -0,0 +1,26 @@
1
+import * as Effect from "effect/Effect";
2
+import * as SqlClient from "effect/sql/SqlClient";
3
+
4
+export default Effect.gen(function* () {
5
+ const sql = yield* SqlClient.SqlClient;
6
+ // Earlier builds of this change shipped the column under another migration id.
7
+ const columns = yield* sql<{ readonly name: string }>`
8
+ PRAGMA table_info(projection_projects)
9
+ `;
10
+ if (!columns.some((column) => column.name === "has_custom_title")) {
11
+ yield* sql`
12
+ ALTER TABLE projection_projects
13
+ ADD COLUMN has_custom_title INTEGER NOT NULL DEFAULT 0
14
+ `;
15
+ }
16
+ yield* sql`
17
+ UPDATE projection_projects
18
+ SET has_custom_title = 1
19
+ WHERE project_id IN (
20
+ SELECT stream_id FROM orchestration_events
21
+ WHERE aggregate_kind = 'project'
22
+ AND event_type = 'project.meta-updated'
23
+ AND json_type(payload_json, '$.title') = 'text'
24
+ )
25
+ `;
26
+});
apps/server/src/persistence/reconcileV2PreviewMigration.test.ts
+2
@@ -66,6 +66,7 @@ describe("V2 preview upgrade", () => {
66
[84, "LastExecutedRunIndex"],
67
[85, "TurnItemCounts"],
68
[86, "QueuedTurnInputIndex"],
69
+ [87, "ProjectionProjectsCustomTitle"],
70
]);
71
assert.deepStrictEqual(yield* runMigrations(), []);
72
assert.deepStrictEqual(yield* sql`SELECT * FROM orchestration_v2_legacy_imports`, imports);
@@ -175,6 +176,7 @@ describe("V2 preview upgrade", () => {
176
[84, "LastExecutedRunIndex"],
177
[85, "TurnItemCounts"],
178
[86, "QueuedTurnInputIndex"],
179
+ [87, "ProjectionProjectsCustomTitle"],
180
]);
181
}).pipe(Effect.provide(NodeSqliteClient.layer({ filename: ":memory:" }))),
182
);
apps/web/src/components/settings/ProjectSettingsPanel.logic.test.ts
+21
-1
@@ -4,7 +4,10 @@ import { planProjectRemoval } from "@t3tools/client-runtime/state/projects";
4
5
import { buildSidebarProjectSnapshots } from "../../sidebarProjectGrouping";
6
import type { Project } from "../../types";
7
-import { scopeProjectSettingsGroup } from "./ProjectSettingsPanel.logic";
7
+import {
8
+ projectGroupTitleNeedsUpdate,
9
+ scopeProjectSettingsGroup,
10
+} from "./ProjectSettingsPanel.logic";
11
12
const localEnvironmentId = EnvironmentId.make("local");
13
const remoteEnvironmentId = EnvironmentId.make("remote");
@@ -171,3 +174,20 @@ describe("project removal confirmation", () => {
174
);
175
});
176
});
177
+
178
+describe("projectGroupTitleNeedsUpdate", () => {
179
+ const folderTitle = { title: "repo" };
180
+ const renamed = { title: "repo", hasCustomTitle: true };
181
+
182
+ // regression: #15049 renaming to the default folder title was never saved
183
+ it("saves a title that matches the folder default so the rename is recorded", () => {
184
+ expect(projectGroupTitleNeedsUpdate([folderTitle, folderTitle], "repo", true)).toBe(true);
185
+ });
186
+
187
+ it("skips untouched fields and renames every member already carries", () => {
188
+ expect(projectGroupTitleNeedsUpdate([folderTitle, { title: "other" }], "repo", false)).toBe(
189
+ false,
190
+ );
191
+ expect(projectGroupTitleNeedsUpdate([renamed, renamed], "repo", true)).toBe(false);
192
+ });
193
+});
apps/web/src/components/settings/ProjectSettingsPanel.logic.ts
+5
-2
@@ -25,11 +25,14 @@ export function scopeProjectSettingsGroup(
25
}
26
27
export function projectGroupTitleNeedsUpdate(
28
- memberTitles: ReadonlyArray<string>,
28
+ members: ReadonlyArray<Pick<Project, "title" | "hasCustomTitle">>,
29
nextTitle: string,
30
wasEdited: boolean,
31
): boolean {
32
- return wasEdited && memberTitles.some((title) => title !== nextTitle);
32
+ return (
33
+ wasEdited &&
34
+ members.some((member) => member.title !== nextTitle || member.hasCustomTitle !== true)
35
+ );
36
}
37
38
export function defaultProjectIcon(project: Pick<Project, "isScratch">) {
apps/web/src/components/settings/ProjectSettingsPanel.tsx
+1
-9
@@ -311,15 +311,7 @@ function ProjectDetail({
311
toastManager.add({ type: "warning", title: "Project title cannot be empty" });
312
return;
313
}
314
- if (
315
- !projectGroupTitleNeedsUpdate(
316
- group.memberProjects.map((member) => member.title),
317
- title,
318
- wasEdited,
319
- )
320
- ) {
321
- return;
322
- }
314
+ if (!projectGroupTitleNeedsUpdate(group.memberProjects, title, wasEdited)) return;
315
await updateAllMembers({ title }, "Failed to rename project");
316
};
317
packages/client-runtime/src/state/projectGrouping.test.ts
+14
@@ -289,6 +289,20 @@ describe("buildProjectGroups", () => {
289
expect(groups[1]?.label).toBe("julius/t3code-fork");
290
});
291
292
+ // regression: #15049 a rename to the repository name snapped back to the display path
293
+ it("labels a renamed group by its title even when it matches the repository name", () => {
294
+ const folderTitles = [
295
+ makeProject("t3code", "/work/t3code", { title: "t3code" }),
296
+ makeProject("t3code-2", "/work/t3code-2", { title: "t3code" }),
297
+ ];
298
+ const renamed = folderTitles.map((project) => ({ ...project, hasCustomTitle: true }));
299
+
300
+ const label = (projects: ReadonlyArray<EnvironmentProject>) =>
301
+ buildProjectGroups({ projects, settings: settings("repository") })[0]?.label;
302
+ expect(label(folderTitles)).toBe("T3 Code");
303
+ expect(label(renamed)).toBe("t3code");
304
+ });
305
+
306
it("applies a physical-project override without dropping its siblings", () => {
307
const first = makeProject("t3code", "/work/t3code");
308
const second = makeProject("t3code-2", "/work/t3code-2");
packages/client-runtime/src/state/projectGrouping.ts
+5
-3
@@ -200,7 +200,9 @@ export function resolveScratchProjectScopeKey(
200
201
export function deriveProjectGroupLabel(input: {
202
readonly representative: Pick<EnvironmentProject, "title" | "repositoryIdentity">;
203
- readonly members: ReadonlyArray<Pick<EnvironmentProject, "title" | "repositoryIdentity">>;
203
+ readonly members: ReadonlyArray<
204
+ Pick<EnvironmentProject, "title" | "hasCustomTitle" | "repositoryIdentity">
205
+ >;
206
}): string {
207
const sharedTitles = uniqueNonEmptyValues(input.members.map((member) => member.title));
208
const sharedDisplayNames = uniqueNonEmptyValues(
@@ -215,8 +217,8 @@ export function deriveProjectGroupLabel(input: {
217
if (
218
sharedTitles.length === 1 &&
219
sharedTitle !== undefined &&
218
- !sharedDisplayNames.includes(sharedTitle) &&
219
- !sharedRepositoryNames.includes(sharedTitle)
220
+ (input.members.some((member) => member.hasCustomTitle === true) ||
221
+ (!sharedDisplayNames.includes(sharedTitle) && !sharedRepositoryNames.includes(sharedTitle)))
222
) {
223
return sharedTitle;
224
}
packages/contracts/src/orchestrationProject.ts
+3
@@ -8,6 +8,9 @@ import { ProjectScript, ReceivedProjectIcon } from "./project.ts";
8
export const OrchestrationProjectShell = Schema.Struct({
9
id: ProjectId,
10
title: TrimmedNonEmptyString,
11
+ // Set once someone renames the project. A folder-default title can equal the
12
+ // repository name, so grouped labels need this to tell a chosen name apart.
13
+ hasCustomTitle: Schema.optional(Schema.Boolean),
14
workspaceRoot: TrimmedNonEmptyString,
15
repositoryIdentity: Schema.optional(Schema.NullOr(RepositoryIdentity)),
16
defaultModelSelection: Schema.NullOr(ModelSelection),