@devries-cameron20 / t3code-1 / commits / 6d1381f04c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): a fork renamed before its first message keeps that name (#38683)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Srijan Dubey committed Nov 19, 2026 at 03:15 UTC 6d1381f04c3655dfddb5ea38521a9a76bfe1184c
6 files changed +126 -4
apps/server/src/orchestration-v2/Orchestrator.ts
+6 -3
@@ -733,11 +733,12 @@ function pendingThreadTitleGenerationEffect(
733
734 // Clients seed a new thread with its first message, and empty threads start as "New thread" or
735 // an agent's placeholder. Any other title on a thread without messages was chosen on purpose.
736 -// Forks and side chats are titled from their source history instead.
736 +// A fork or side chat starts with a title its first message replaces, so only a rename keeps it.
737 function hasTitleSetBeforeFirstMessage(
738 thread: OrchestrationV2AppThread,
739 titleSeed: string | undefined,
740 ): boolean {
741 + if (thread.titleRenamed === true) return true;
742 const title = thread.title.trim();
743 return (
744 thread.forkedFrom === null &&
@@ -4831,7 +4832,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
4832 };
4833 return {
4834 ...thread,
4834 - ...(command.title === undefined ? {} : { title: command.title }),
4835 + ...(command.title === undefined ? {} : { title: command.title, titleRenamed: true }),
4836 ...(command.limitRecovery === undefined ? {} : { limitRecovery }),
4837 ...(command.limitRecovery !== undefined &&
4838 limitRecovery?.snooze === true &&
@@ -5158,7 +5159,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
5159 return thread.titleRegeneration?.requestId === command.requestId
5160 ? {
5161 ...thread,
5161 - ...(command.title === undefined ? {} : { title: command.title }),
5162 + ...(command.title === undefined
5163 + ? {}
5164 + : { title: command.title, titleRenamed: false }),
5165 ...(command.outcome === undefined
5166 ? {}
5167 : {
apps/server/src/orchestration-v2/ThreadForkService.ts
+2 -1
@@ -111,8 +111,9 @@ export const layer: Layer.Layer<ThreadForkServiceV2> = Layer.succeed(
111 creationSource: input.creationSource,
112 id: input.targetThreadId,
113 title: input.title ?? `${input.sourceProjection.thread.title} fork`,
114 - // The source's title job completes only on the source thread.
114 + // The source's title job and rename stay with the source thread.
115 titleRegeneration: null,
116 + titleRenamed: false,
117 activeProviderThreadId: null,
118 lineage: {
119 parentThreadId: input.sourceProjection.thread.id,
apps/server/src/orchestration-v2/ThreadTitleRegenerationService.test.ts
+79
@@ -390,6 +390,85 @@ describe("ThreadTitleRegenerationService", () => {
390 }),
391 );
392
393 + it.effect("keeps a fork's own rename when its first message arrives", () =>
394 + Effect.gen(function* () {
395 + const seed = "Try SQLite instead";
396 + const harness = makeHarness();
397 + yield* Effect.gen(function* () {
398 + const threads = yield* ThreadManagement.ThreadManagementService;
399 + const titleRegeneration = yield* ThreadTitleRegeneration.ThreadTitleRegenerationService;
400 + const outbox = yield* EffectOutbox.EffectOutboxV2;
401 + const prefix = "thread:title:renamed-fork";
402 + const { sourceThreadId, forkRunId, forkThreadId } = yield* forkSeededSource(prefix);
403 + const rename = (key: string, threadId: ThreadId, title: string) =>
404 + threads.dispatch({
405 + type: "thread.metadata.update",
406 + commandId: CommandId.make(`${prefix}:${key}:rename`),
407 + threadId,
408 + title,
409 + });
410 + const fork = (key: string) =>
411 + Effect.gen(function* () {
412 + const targetThreadId = ThreadId.make(`${prefix}:${key}`);
413 + yield* threads.dispatch({
414 + type: "thread.fork",
415 + commandId: CommandId.make(`${prefix}:${key}:fork`),
416 + sourceThreadId,
417 + targetThreadId,
418 + sourcePoint: { type: "run", runId: forkRunId },
419 + createdBy: "user",
420 + creationSource: "web",
421 + });
422 + return targetThreadId;
423 + });
424 + yield* rename("renamed", forkThreadId, "Storage migration notes");
425 + yield* rename("source", sourceThreadId, "Renamed source");
426 + const forkOfRenamedSource = yield* fork("fork-of-renamed-source");
427 + const regenerated = yield* fork("regenerated");
428 + yield* rename("regenerated", regenerated, "Scratch name");
429 + yield* titleRegeneration.execute({
430 + threadId: regenerated,
431 + requestId: yield* armRegeneration({
432 + command: `${prefix}:regenerated:regenerate`,
433 + threadId: regenerated,
434 + }),
435 + kind: { type: "regenerate" },
436 + });
437 +
438 + for (const [key, threadId, expectedTitle, generates] of [
439 + ["renamed", forkThreadId, "Storage migration notes", false],
440 + ["fork of a renamed source", forkOfRenamedSource, seed, true],
441 + ["renamed, then regenerated", regenerated, seed, true],
442 + ] as const) {
443 + const requestId = CommandId.make(`${prefix}:${key}:message`);
444 + yield* threads.dispatch({
445 + type: "message.dispatch",
446 + commandId: requestId,
447 + threadId,
448 + messageId: MessageId.make(`${prefix}:${key}:message:message`),
449 + text: seed,
450 + titleSeed: seed,
451 + attachments: [],
452 + modelSelection,
453 + dispatchMode: { type: "defer_start" },
454 + createdBy: "user",
455 + creationSource: "web",
456 + });
457 +
458 + const settled = yield* threads.getThreadProjection(threadId);
459 + assert.equal(settled.thread.title, expectedTitle, key);
460 + assert.equal(
461 + (yield* outbox.listByCommandId(requestId)).some(
462 + (effect) => effect.request.type === "thread-title.generate",
463 + ),
464 + generates,
465 + key,
466 + );
467 + }
468 + }).pipe(Effect.provide(harness.layer));
469 + }),
470 + );
471 +
472 it.effect(
473 "titles an image-only first message without sending bootstrap text to the title model",
474 () =>
packages/contracts/src/orchestrationV2.ts
+2
@@ -532,6 +532,8 @@ export const OrchestrationV2AppThread = Schema.Struct({
532 ),
533 ),
534 lastTitleRegeneration: Schema.optional(Schema.NullOr(OrchestrationV2LastTitleRegeneration)),
535 + /** Set by a rename until a generated title replaces it; absent reads as false. */
536 + titleRenamed: Schema.optional(Schema.Boolean),
537 rollbackRequestId: Schema.optional(CommandId),
538 rollbackFailure: Schema.optional(
539 Schema.NullOr(
packages/provider-core/src/server/subagentProjection.ts
+1
@@ -71,6 +71,7 @@ export function makeSubagentChildThread(input: {
71 id: input.childThreadId,
72 title: input.title,
73 titleRegeneration: null,
74 + titleRenamed: false,
75 linkedPullRequest: null,
76 pullRequests: [],
77 historyOrigin: undefined,
scripts/scenarios/renamed-fork-keeps-its-name.e2e.ts new
+36
@@ -0,0 +1,36 @@
1 +import { expect } from "e2e";
2 +
3 +import { test, WEB } from "./t3.ts";
4 +
5 +test(
6 + "A fork renamed before its first message keeps that name",
7 + WEB,
8 + async ({ t3, app, screen }) => {
9 + const project = await t3.project("demo");
10 + const thread = await t3.thread({ project, title: "Earlier work", messages: ["first"] });
11 + await t3.open(thread);
12 +
13 + await expect(screen.getByText("first fixture turn complete", { exact: false })).toBeVisible();
14 + await screen.getByRole("button", "Fork from this response").first().tap();
15 + const forkActions = screen.getByRole("button", "Thread actions for Earlier work fork");
16 + await expect(forkActions).toBeVisible();
17 +
18 + await forkActions.tap();
19 + await screen.getByRole("menuitem", "Rename thread").tap();
20 + const title = screen.getByRole("textbox", "Thread title");
21 + await title.fill("Storage notes");
22 + await title.press("Enter");
23 + const renamedActions = screen.getByRole("button", "Thread actions for Storage notes");
24 + await expect(renamedActions).toBeVisible();
25 +
26 + const composer = screen.getByRole("textbox");
27 + await composer.pressSequentially("Try SQLite instead");
28 + await composer.press("Enter");
29 + // The fork shows its source's reply too, so the second one is the fork's own.
30 + await expect(
31 + screen.getByText("first fixture turn complete", { exact: false }).nth(1),
32 + ).toBeVisible();
33 + await app.screenshot("after-first-message");
34 + await expect(renamedActions).toBeVisible();
35 + },
36 +);