feat(orchestration): port thread title regeneration to the v2 runtime

Follow-ups from the main merge:

- Migration numbering: main's 035_ProjectionThreadTitleRegeneration is
  released and keeps its id; this branch's unreleased v2 migrations shift
  to 036-044 instead (a released migration can never be renumbered).
- thread.metadata.update accepts regenerateTitle: true arms an in-flight
  titleRegeneration marker on the thread payload (requestId + startedAt),
  a landing title or explicit false clears it. The marker projects onto
  thread shells and through the client-runtime shell model, so the
  sidebar's Regenerating state works unchanged.
- New ThreadTitleRegenerationService worker reacts to armed markers on
  the live domain-event stream (so ws, MCP, and mobile dispatches all
  behave the same): builds a newest-first conversation digest from the
  v2 projection (8k-char budget, retained attachments — ported from the
  v1 reactor), generates via TextGeneration, and lands the title with a
  follow-up metadata update. Failures clear the marker and log.
- The server advertises threadTitleRegeneration again, and the client
  updateThreadMetadata dispatches regenerateTitle-only updates.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Fable 5 authored and maria-rcks committed 2026-08-03 11:45:15 -04:00
1 parent 607ddc3618
commit 353f352c1e
22 files changed
+272 -49

No files matched your search

@@ -84,6 +84,8 @@ export interface UpdateThreadMetadataInput extends ThreadCommandInput {
readonly modelSelection?: ModelSelection;
readonly branch?: string | null;
readonly worktreePath?: string | null;
/** Kick off an async title regeneration for the thread. */
readonly regenerateTitle?: boolean;
}
export interface SetThreadRuntimeModeInput extends ThreadCommandInput {
@@ -418,7 +420,8 @@ export const updateThreadMetadata = Effect.fn("EnvironmentCommands.updateThreadM
if (
input.title !== undefined ||
input.branch !== undefined ||
input.worktreePath !== undefined
input.worktreePath !== undefined ||
input.regenerateTitle !== undefined
) {
result = yield* dispatch({
type: "thread.metadata.update",
@@ -427,6 +430,7 @@ export const updateThreadMetadata = Effect.fn("EnvironmentCommands.updateThreadM
...(input.title === undefined ? {} : { title: input.title }),
...(input.branch === undefined ? {} : { branch: input.branch }),
...(input.worktreePath === undefined ? {} : { worktreePath: input.worktreePath }),
...(input.regenerateTitle === undefined ? {} : { regenerateTitle: input.regenerateTitle }),
});
}
if (input.modelSelection !== undefined) {
@@ -101,6 +101,8 @@ export interface EnvironmentThreadShell {
* local visited state they keep.
*/
readonly lastVisitedAt?: string | null;
/** Pending title regeneration marker; null when no request is in flight. */
readonly titleRegeneration?: { readonly requestId: string; readonly startedAt: string } | null;
readonly deletedAt: string | null;
readonly source: OrchestrationV2ThreadShell;
}
@@ -198,6 +200,13 @@ export function presentThreadShell(
...(thread.lastVisitedAt === undefined
? {}
: { lastVisitedAt: nullableIso(thread.lastVisitedAt) }),
titleRegeneration:
thread.titleRegeneration == null
? null
: {
requestId: thread.titleRegeneration.requestId,
startedAt: iso(thread.titleRegeneration.startedAt),
},
deletedAt: nullableIso(thread.deletedAt),
source: thread,
};