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:
1 parent
3f8a05150b
commit
5887de1521
24 files changed
+269
-70
No files matched your search
@@ -143,10 +143,7 @@ export const make = Effect.gen(function* () {
|
||||
threadSettlement: true,
|
||||
threadSnooze: true,
|
||||
threadVisitedTracking: true,
|
||||
// Deliberately not advertised: the v1 reactor that served regeneration is
|
||||
// deleted here and the v2 orchestrator port has not landed yet. Clients
|
||||
// hide the sidebar action when the capability is absent.
|
||||
// TODO(orchestration-v2): port thread title regeneration to the v2 runtime.
|
||||
threadTitleRegeneration: true,
|
||||
...(serverSelfUpdate === null ? {} : { serverSelfUpdate }),
|
||||
...(serverSelfUpdate === "boot-service" || serverSelfUpdate === "respawn"
|
||||
? { serverSelfUpdateProgress: true }
|
||||
|
||||
@@ -1164,6 +1164,13 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
|
||||
...(command.title === undefined ? {} : { title: command.title }),
|
||||
...(command.branch === undefined ? {} : { branch: command.branch }),
|
||||
...(command.worktreePath === undefined ? {} : { worktreePath: command.worktreePath }),
|
||||
// regenerateTitle: true arms the in-flight marker; a landing title
|
||||
// or an explicit false (generation failed/abandoned) clears it.
|
||||
...(command.regenerateTitle === true
|
||||
? { titleRegeneration: { requestId: command.commandId, startedAt: now } }
|
||||
: command.regenerateTitle === false || command.title !== undefined
|
||||
? { titleRegeneration: null }
|
||||
: {}),
|
||||
updatedAt: now,
|
||||
};
|
||||
case "thread.runtime-mode.set":
|
||||
|
||||
@@ -847,6 +847,7 @@ export function threadShellFromProjection(
|
||||
snoozedUntil: projection.thread.snoozedUntil ?? null,
|
||||
snoozedAt: projection.thread.snoozedAt ?? null,
|
||||
lastVisitedAt: projection.thread.lastVisitedAt,
|
||||
titleRegeneration: projection.thread.titleRegeneration ?? null,
|
||||
deletedAt: projection.thread.deletedAt,
|
||||
};
|
||||
}
|
||||
@@ -1015,6 +1016,7 @@ function shellFromState(input: {
|
||||
snoozedUntil: input.state.thread.snoozedUntil ?? null,
|
||||
snoozedAt: input.state.thread.snoozedAt ?? null,
|
||||
lastVisitedAt: input.state.thread.lastVisitedAt,
|
||||
titleRegeneration: input.state.thread.titleRegeneration ?? null,
|
||||
deletedAt: input.state.thread.deletedAt,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
import { type ChatAttachment, CommandId, type ThreadId } from "@t3tools/contracts";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
import * as Stream from "effect/Stream";
|
||||
|
||||
import * as ProjectService from "../project/ProjectService.ts";
|
||||
import * as TextGeneration from "../textGeneration/TextGeneration.ts";
|
||||
import { ThreadManagementService } from "./ThreadManagementService.ts";
|
||||
|
||||
const MAX_REGENERATION_ATTACHMENTS = 4;
|
||||
const MAX_THREAD_TITLE_CONTEXT_CHARS = 8_000;
|
||||
const THREAD_TITLE_CONTEXT_TRUNCATION_MARKER = "[Earlier content truncated]\n\n";
|
||||
|
||||
/**
|
||||
* Newest-first conversation digest for the title prompt: walk messages from
|
||||
* the end, keep whole sections while they fit the char budget, and mark
|
||||
* truncation once older content stops fitting. Ported from the v1 reactor's
|
||||
* regeneration flow.
|
||||
*/
|
||||
export function formatThreadTitleContext(
|
||||
messages: ReadonlyArray<{
|
||||
readonly role: "user" | "assistant" | "system";
|
||||
readonly text: string;
|
||||
readonly attachments?: ReadonlyArray<ChatAttachment> | undefined;
|
||||
}>,
|
||||
): {
|
||||
readonly message: string;
|
||||
readonly attachments: ReadonlyArray<ChatAttachment>;
|
||||
} {
|
||||
let context = "";
|
||||
let truncated = false;
|
||||
const retainedAttachments: Array<ChatAttachment> = [];
|
||||
|
||||
for (const message of messages.toReversed()) {
|
||||
if (message.role === "system") {
|
||||
continue;
|
||||
}
|
||||
const text = message.text.trim();
|
||||
const attachmentSummary = (message.attachments ?? [])
|
||||
.map((attachment) => attachment.name)
|
||||
.join(", ");
|
||||
const contents = [
|
||||
...(text.length > 0 ? [text] : []),
|
||||
...(attachmentSummary.length > 0 ? [`[Attachments: ${attachmentSummary}]`] : []),
|
||||
].join("\n");
|
||||
if (contents.length === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const section = `${message.role.toUpperCase()}:\n${contents}`;
|
||||
const separator = context.length > 0 ? "\n\n" : "";
|
||||
const available = MAX_THREAD_TITLE_CONTEXT_CHARS - context.length - separator.length;
|
||||
if (section.length > available) {
|
||||
truncated = true;
|
||||
break;
|
||||
}
|
||||
context = `${section}${separator}${context}`;
|
||||
for (const attachment of message.attachments ?? []) {
|
||||
if (retainedAttachments.length < MAX_REGENERATION_ATTACHMENTS) {
|
||||
retainedAttachments.push(attachment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
message: truncated ? `${THREAD_TITLE_CONTEXT_TRUNCATION_MARKER}${context}` : context,
|
||||
attachments: retainedAttachments,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reacts to thread.metadata-updated events that arm the titleRegeneration
|
||||
* marker: generates a title from the thread's conversation and lands it via a
|
||||
* follow-up metadata update (which clears the marker), or clears the marker
|
||||
* explicitly when generation fails. Event-driven so every dispatch surface
|
||||
* (ws, MCP, mobile) gets the same behavior.
|
||||
*/
|
||||
export const workerLive = Layer.effectDiscard(
|
||||
Effect.gen(function* () {
|
||||
const threads = yield* ThreadManagementService;
|
||||
const projects = yield* ProjectService.ProjectService;
|
||||
const textGeneration = yield* TextGeneration.TextGeneration;
|
||||
const handledRequestIds = new Set<string>();
|
||||
|
||||
const regenerate = Effect.fn("ThreadTitleRegenerationService.regenerate")(function* (
|
||||
threadId: ThreadId,
|
||||
requestId: CommandId,
|
||||
) {
|
||||
const projection = yield* threads.getThreadProjection(threadId);
|
||||
if (projection.thread.titleRegeneration?.requestId !== requestId) {
|
||||
return;
|
||||
}
|
||||
const project = yield* projects.getById(projection.thread.projectId);
|
||||
if (Option.isNone(project)) {
|
||||
return;
|
||||
}
|
||||
const context = formatThreadTitleContext(
|
||||
projection.messages.filter((message) => !message.streaming),
|
||||
);
|
||||
if (context.message.length === 0) {
|
||||
yield* threads.dispatch({
|
||||
type: "thread.metadata.update",
|
||||
commandId: CommandId.make(`${requestId}:title-clear`),
|
||||
threadId,
|
||||
regenerateTitle: false,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const result = yield* textGeneration.generateThreadTitle({
|
||||
cwd: projection.thread.worktreePath ?? Option.getOrThrow(project).workspaceRoot,
|
||||
message: context.message,
|
||||
attachments: context.attachments,
|
||||
modelSelection: projection.thread.modelSelection,
|
||||
});
|
||||
yield* threads.dispatch({
|
||||
type: "thread.metadata.update",
|
||||
commandId: CommandId.make(`${requestId}:title`),
|
||||
threadId,
|
||||
title: result.title,
|
||||
});
|
||||
});
|
||||
|
||||
yield* threads.streamDomainEvents.pipe(
|
||||
Stream.runForEach((event) => {
|
||||
if (event.type !== "thread.metadata-updated") {
|
||||
return Effect.void;
|
||||
}
|
||||
const marker = event.payload.titleRegeneration;
|
||||
if (marker === null || marker === undefined || handledRequestIds.has(marker.requestId)) {
|
||||
return Effect.void;
|
||||
}
|
||||
handledRequestIds.add(marker.requestId);
|
||||
return regenerate(event.threadId, marker.requestId).pipe(
|
||||
Effect.catchCause((cause) =>
|
||||
Effect.logWarning("Thread title regeneration failed", {
|
||||
threadId: event.threadId,
|
||||
requestId: marker.requestId,
|
||||
cause,
|
||||
}).pipe(
|
||||
Effect.andThen(
|
||||
threads
|
||||
.dispatch({
|
||||
type: "thread.metadata.update",
|
||||
commandId: CommandId.make(`${marker.requestId}:title-clear`),
|
||||
threadId: event.threadId,
|
||||
regenerateTitle: false,
|
||||
})
|
||||
.pipe(Effect.ignore),
|
||||
),
|
||||
),
|
||||
),
|
||||
Effect.forkDetach,
|
||||
Effect.asVoid,
|
||||
);
|
||||
}),
|
||||
Effect.forkScoped,
|
||||
);
|
||||
}),
|
||||
);
|
||||
@@ -27,6 +27,7 @@ import { layer as projectionMaintenanceLayer } from "./ProjectionMaintenance.ts"
|
||||
import { layerFromProviderInstanceRegistry as providerAdapterRegistryLayerFromProviderInstances } from "./ProviderAdapterRegistry.ts";
|
||||
import { layer as providerContinuationRequestsLayer } from "./ProviderContinuationRequests.ts";
|
||||
import { workerLive as providerContinuationWorkerLive } from "./ProviderContinuationService.ts";
|
||||
import { workerLive as threadTitleRegenerationWorkerLive } from "./ThreadTitleRegenerationService.ts";
|
||||
import { layer as providerEventIngestorLayer } from "./ProviderEventIngestor.ts";
|
||||
import { layer as providerSessionManagerLayer } from "./ProviderSessionManager.ts";
|
||||
import { layer as providerRuntimeRecoveryLayer } from "./ProviderRuntimeRecoveryService.ts";
|
||||
@@ -236,6 +237,9 @@ const providerContinuationWorkerProvided = providerContinuationWorkerLive.pipe(
|
||||
Layer.mergeAll(providerContinuationRequestsLayer, threadManagementProvided, idAllocatorLayer),
|
||||
),
|
||||
);
|
||||
const threadTitleRegenerationWorkerProvided = threadTitleRegenerationWorkerLive.pipe(
|
||||
Layer.provide(Layer.merge(threadManagementProvided, ProjectServiceLayerLive)),
|
||||
);
|
||||
|
||||
export const OrchestrationV2LayerLive = Layer.mergeAll(
|
||||
orchestratorProvided,
|
||||
@@ -250,6 +254,7 @@ export const OrchestrationV2LayerLive = Layer.mergeAll(
|
||||
export const OrchestrationV2ProductionLayerLive = Layer.mergeAll(
|
||||
OrchestrationLayerLive,
|
||||
OrchestrationV2LayerLive,
|
||||
threadTitleRegenerationWorkerProvided,
|
||||
ProjectServiceLayerLive,
|
||||
threadLaunchProvided,
|
||||
threadLifecycleProvided,
|
||||
|
||||
@@ -47,16 +47,16 @@ import Migration0031 from "./Migrations/031_AuthAuthorizationScopes.ts";
|
||||
import Migration0032 from "./Migrations/032_AuthPairingProofKeyThumbprint.ts";
|
||||
import Migration0033 from "./Migrations/033_ProjectionThreadsSettled.ts";
|
||||
import Migration0034 from "./Migrations/034_ProjectionThreadsSnoozed.ts";
|
||||
import Migration0035 from "./Migrations/035_OrchestrationV2.ts";
|
||||
import Migration0036 from "./Migrations/036_OrchestrationV2Subagents.ts";
|
||||
import Migration0037 from "./Migrations/037_OrchestrationV2Foundation.ts";
|
||||
import Migration0038 from "./Migrations/038_OrchestrationV2ProviderSessionBindings.ts";
|
||||
import Migration0039 from "./Migrations/039_OrchestrationV2ThreadLaunchWorkflows.ts";
|
||||
import Migration0040 from "./Migrations/040_ApplicationEventSource.ts";
|
||||
import Migration0041 from "./Migrations/041_OrchestrationV2EffectCancellation.ts";
|
||||
import Migration0042 from "./Migrations/042_ScheduledTasks.ts";
|
||||
import Migration0043 from "./Migrations/043_LegacyV1ImportState.ts";
|
||||
import Migration0044 from "./Migrations/044_ProjectionThreadTitleRegeneration.ts";
|
||||
import Migration0035 from "./Migrations/035_ProjectionThreadTitleRegeneration.ts";
|
||||
import Migration0036 from "./Migrations/036_OrchestrationV2.ts";
|
||||
import Migration0037 from "./Migrations/037_OrchestrationV2Subagents.ts";
|
||||
import Migration0038 from "./Migrations/038_OrchestrationV2Foundation.ts";
|
||||
import Migration0039 from "./Migrations/039_OrchestrationV2ProviderSessionBindings.ts";
|
||||
import Migration0040 from "./Migrations/040_OrchestrationV2ThreadLaunchWorkflows.ts";
|
||||
import Migration0041 from "./Migrations/041_ApplicationEventSource.ts";
|
||||
import Migration0042 from "./Migrations/042_OrchestrationV2EffectCancellation.ts";
|
||||
import Migration0043 from "./Migrations/043_ScheduledTasks.ts";
|
||||
import Migration0044 from "./Migrations/044_LegacyV1ImportState.ts";
|
||||
|
||||
/**
|
||||
* Migration loader with all migrations defined inline.
|
||||
@@ -103,16 +103,16 @@ export const migrationEntries = [
|
||||
[32, "AuthPairingProofKeyThumbprint", Migration0032],
|
||||
[33, "ProjectionThreadsSettled", Migration0033],
|
||||
[34, "ProjectionThreadsSnoozed", Migration0034],
|
||||
[35, "OrchestrationV2", Migration0035],
|
||||
[36, "OrchestrationV2Subagents", Migration0036],
|
||||
[37, "OrchestrationV2Foundation", Migration0037],
|
||||
[38, "OrchestrationV2ProviderSessionBindings", Migration0038],
|
||||
[39, "OrchestrationV2ThreadLaunchWorkflows", Migration0039],
|
||||
[40, "ApplicationEventSource", Migration0040],
|
||||
[41, "OrchestrationV2EffectCancellation", Migration0041],
|
||||
[42, "ScheduledTasks", Migration0042],
|
||||
[43, "LegacyV1ImportState", Migration0043],
|
||||
[44, "ProjectionThreadTitleRegeneration", Migration0044],
|
||||
[35, "ProjectionThreadTitleRegeneration", Migration0035],
|
||||
[36, "OrchestrationV2", Migration0036],
|
||||
[37, "OrchestrationV2Subagents", Migration0037],
|
||||
[38, "OrchestrationV2Foundation", Migration0038],
|
||||
[39, "OrchestrationV2ProviderSessionBindings", Migration0039],
|
||||
[40, "OrchestrationV2ThreadLaunchWorkflows", Migration0040],
|
||||
[41, "ApplicationEventSource", Migration0041],
|
||||
[42, "OrchestrationV2EffectCancellation", Migration0042],
|
||||
[43, "ScheduledTasks", Migration0043],
|
||||
[44, "LegacyV1ImportState", Migration0044],
|
||||
] as const;
|
||||
|
||||
export const makeMigrationLoader = (throughId?: number) =>
|
||||
|
||||
+3
-3
@@ -8,13 +8,13 @@ import * as NodeSqliteClient from "../NodeSqliteClient.ts";
|
||||
|
||||
const layer = it.layer(Layer.mergeAll(NodeSqliteClient.layerMemory()));
|
||||
|
||||
layer("044_ProjectionThreadTitleRegeneration", (it) => {
|
||||
layer("035_ProjectionThreadTitleRegeneration", (it) => {
|
||||
it.effect("adds pending title regeneration columns", () =>
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
yield* runMigrations({ toMigrationInclusive: 43 });
|
||||
yield* runMigrations({ toMigrationInclusive: 44 });
|
||||
yield* runMigrations({ toMigrationInclusive: 34 });
|
||||
yield* runMigrations({ toMigrationInclusive: 35 });
|
||||
|
||||
const columns = yield* sql<{ readonly name: string }>`
|
||||
PRAGMA table_info(projection_threads)
|
||||
File renamed without changes.
+25
-24
@@ -8,7 +8,7 @@ import * as NodeSqliteClient from "../NodeSqliteClient.ts";
|
||||
|
||||
const layer = it.layer(Layer.mergeAll(NodeSqliteClient.layerMemory()));
|
||||
|
||||
layer("035_036_OrchestrationV2", (it) => {
|
||||
layer("036_037_OrchestrationV2", (it) => {
|
||||
it.effect("keeps released and private migration ids contiguous", () =>
|
||||
Effect.sync(() => {
|
||||
assert.deepStrictEqual(
|
||||
@@ -22,7 +22,7 @@ layer("035_036_OrchestrationV2", (it) => {
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
yield* runMigrations({ toMigrationInclusive: 36 });
|
||||
yield* runMigrations({ toMigrationInclusive: 37 });
|
||||
|
||||
const migrations = yield* sql<{
|
||||
readonly migration_id: number;
|
||||
@@ -30,24 +30,24 @@ layer("035_036_OrchestrationV2", (it) => {
|
||||
}>`
|
||||
SELECT migration_id, name
|
||||
FROM effect_sql_migrations
|
||||
WHERE migration_id IN (33, 34, 35, 36)
|
||||
WHERE migration_id IN (34, 35, 36, 37)
|
||||
ORDER BY migration_id
|
||||
`;
|
||||
assert.deepStrictEqual(migrations, [
|
||||
{
|
||||
migration_id: 33,
|
||||
name: "ProjectionThreadsSettled",
|
||||
},
|
||||
{
|
||||
migration_id: 34,
|
||||
name: "ProjectionThreadsSnoozed",
|
||||
},
|
||||
{
|
||||
migration_id: 35,
|
||||
name: "OrchestrationV2",
|
||||
name: "ProjectionThreadTitleRegeneration",
|
||||
},
|
||||
{
|
||||
migration_id: 36,
|
||||
name: "OrchestrationV2",
|
||||
},
|
||||
{
|
||||
migration_id: 37,
|
||||
name: "OrchestrationV2Subagents",
|
||||
},
|
||||
]);
|
||||
@@ -67,7 +67,7 @@ layer("035_036_OrchestrationV2", (it) => {
|
||||
it.effect("backfills provider-session thread bindings in migration 038", () =>
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
yield* runMigrations({ toMigrationInclusive: 37 });
|
||||
yield* runMigrations({ toMigrationInclusive: 38 });
|
||||
yield* sql`
|
||||
INSERT INTO orchestration_v2_projection_provider_sessions (
|
||||
provider_session_id,
|
||||
@@ -92,7 +92,7 @@ layer("035_036_OrchestrationV2", (it) => {
|
||||
)
|
||||
`;
|
||||
|
||||
yield* runMigrations({ toMigrationInclusive: 38 });
|
||||
yield* runMigrations({ toMigrationInclusive: 39 });
|
||||
|
||||
const bindings = yield* sql<{
|
||||
readonly provider_session_id: string;
|
||||
@@ -113,7 +113,7 @@ layer("035_036_OrchestrationV2", (it) => {
|
||||
it.effect("preserves turn items with colliding ordinals in migration 037", () =>
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
yield* runMigrations({ toMigrationInclusive: 36 });
|
||||
yield* runMigrations({ toMigrationInclusive: 37 });
|
||||
yield* sql`
|
||||
INSERT INTO orchestration_v2_projection_runs (
|
||||
run_id,
|
||||
@@ -150,7 +150,7 @@ layer("035_036_OrchestrationV2", (it) => {
|
||||
('turn-item:d', 'thread:two', NULL, 42, 'assistant_message', 'completed', '2026-01-01T00:00:00.000Z', '{}')
|
||||
`;
|
||||
|
||||
yield* runMigrations({ toMigrationInclusive: 37 });
|
||||
yield* runMigrations({ toMigrationInclusive: 38 });
|
||||
|
||||
const positions = yield* sql<{
|
||||
readonly thread_id: string;
|
||||
@@ -175,14 +175,14 @@ it.effect("upgrades a database already at released main migration 034", () =>
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
|
||||
yield* runMigrations({ toMigrationInclusive: 34 });
|
||||
yield* runMigrations({ toMigrationInclusive: 35 });
|
||||
const snoozeColumns = yield* sql<{ readonly name: string }>`
|
||||
PRAGMA table_info(projection_threads)
|
||||
`;
|
||||
assert.ok(snoozeColumns.some((column) => column.name === "snoozed_until"));
|
||||
assert.ok(snoozeColumns.some((column) => column.name === "snoozed_at"));
|
||||
|
||||
yield* runMigrations({ toMigrationInclusive: 43 });
|
||||
yield* runMigrations({ toMigrationInclusive: 44 });
|
||||
|
||||
const migrations = yield* sql<{
|
||||
readonly migration_id: number;
|
||||
@@ -190,22 +190,23 @@ it.effect("upgrades a database already at released main migration 034", () =>
|
||||
}>`
|
||||
SELECT migration_id, name
|
||||
FROM effect_sql_migrations
|
||||
WHERE migration_id BETWEEN 34 AND 43
|
||||
WHERE migration_id BETWEEN 34 AND 44
|
||||
ORDER BY migration_id
|
||||
`;
|
||||
assert.deepStrictEqual(
|
||||
migrations.map(({ migration_id, name }) => [migration_id, name]),
|
||||
[
|
||||
[34, "ProjectionThreadsSnoozed"],
|
||||
[35, "OrchestrationV2"],
|
||||
[36, "OrchestrationV2Subagents"],
|
||||
[37, "OrchestrationV2Foundation"],
|
||||
[38, "OrchestrationV2ProviderSessionBindings"],
|
||||
[39, "OrchestrationV2ThreadLaunchWorkflows"],
|
||||
[40, "ApplicationEventSource"],
|
||||
[41, "OrchestrationV2EffectCancellation"],
|
||||
[42, "ScheduledTasks"],
|
||||
[43, "LegacyV1ImportState"],
|
||||
[35, "ProjectionThreadTitleRegeneration"],
|
||||
[36, "OrchestrationV2"],
|
||||
[37, "OrchestrationV2Subagents"],
|
||||
[38, "OrchestrationV2Foundation"],
|
||||
[39, "OrchestrationV2ProviderSessionBindings"],
|
||||
[40, "OrchestrationV2ThreadLaunchWorkflows"],
|
||||
[41, "ApplicationEventSource"],
|
||||
[42, "OrchestrationV2EffectCancellation"],
|
||||
[43, "ScheduledTasks"],
|
||||
[44, "LegacyV1ImportState"],
|
||||
],
|
||||
);
|
||||
|
||||
File renamed without changes.
File renamed without changes.
+2
-2
@@ -8,7 +8,7 @@ import * as NodeSqliteClient from "../NodeSqliteClient.ts";
|
||||
it.effect("backfills the V2 event driver from payload before the legacy provider column", () =>
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
yield* runMigrations({ toMigrationInclusive: 36 });
|
||||
yield* runMigrations({ toMigrationInclusive: 37 });
|
||||
|
||||
yield* sql`
|
||||
INSERT INTO orchestration_v2_events (
|
||||
@@ -37,7 +37,7 @@ it.effect("backfills the V2 event driver from payload before the legacy provider
|
||||
)
|
||||
`;
|
||||
|
||||
yield* runMigrations({ toMigrationInclusive: 37 });
|
||||
yield* runMigrations({ toMigrationInclusive: 38 });
|
||||
|
||||
const events = yield* sql<{
|
||||
readonly event_id: string;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -12,7 +12,7 @@ layer("040_ApplicationEventSource", (it) => {
|
||||
it.effect("moves V2 events and current project state behind one global sequence", () =>
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
yield* runMigrations({ toMigrationInclusive: 39 });
|
||||
yield* runMigrations({ toMigrationInclusive: 40 });
|
||||
|
||||
yield* sql`
|
||||
INSERT INTO orchestration_v2_events (
|
||||
@@ -84,7 +84,7 @@ layer("040_ApplicationEventSource", (it) => {
|
||||
)
|
||||
`;
|
||||
|
||||
yield* runMigrations({ toMigrationInclusive: 40 });
|
||||
yield* runMigrations({ toMigrationInclusive: 41 });
|
||||
|
||||
const events = yield* sql<{
|
||||
readonly sequence: number;
|
||||
File renamed without changes.
+2
-2
@@ -12,7 +12,7 @@ layer("041_OrchestrationV2EffectCancellation", (it) => {
|
||||
it.effect("preserves existing effects and adds the cancelled terminal status", () =>
|
||||
Effect.gen(function* () {
|
||||
const sql = yield* SqlClient.SqlClient;
|
||||
yield* runMigrations({ toMigrationInclusive: 40 });
|
||||
yield* runMigrations({ toMigrationInclusive: 41 });
|
||||
yield* sql`
|
||||
INSERT INTO orchestration_v2_effect_outbox (
|
||||
effect_id,
|
||||
@@ -47,7 +47,7 @@ layer("041_OrchestrationV2EffectCancellation", (it) => {
|
||||
)
|
||||
`;
|
||||
|
||||
yield* runMigrations({ toMigrationInclusive: 41 });
|
||||
yield* runMigrations({ toMigrationInclusive: 42 });
|
||||
yield* sql`
|
||||
UPDATE orchestration_v2_effect_outbox
|
||||
SET
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -97,12 +97,7 @@ export interface UpdateThreadMetadataInput extends ThreadCommandInput {
|
||||
readonly modelSelection?: ModelSelection;
|
||||
readonly branch?: string | null;
|
||||
readonly worktreePath?: string | null;
|
||||
/**
|
||||
* Accepted but currently a no-op against v2 servers: the sidebar only
|
||||
* offers regeneration when the environment advertises the
|
||||
* threadTitleRegeneration capability, which v2 servers do not yet.
|
||||
* TODO(orchestration-v2): dispatch a real regeneration command once ported.
|
||||
*/
|
||||
/** Kick off an async title regeneration for the thread. */
|
||||
readonly regenerateTitle?: boolean;
|
||||
}
|
||||
|
||||
@@ -438,7 +433,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",
|
||||
@@ -447,6 +443,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,12 +101,7 @@ export interface EnvironmentThreadShell {
|
||||
* local visited state they keep.
|
||||
*/
|
||||
readonly lastVisitedAt?: string | null;
|
||||
/**
|
||||
* Pending title regeneration marker. Never set by the v2 orchestrator yet —
|
||||
* the sidebar's regeneration UI is additionally gated on the
|
||||
* threadTitleRegeneration capability, which v2 servers do not advertise.
|
||||
* TODO(orchestration-v2): populate when title regeneration is ported.
|
||||
*/
|
||||
/** 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;
|
||||
@@ -205,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,
|
||||
};
|
||||
|
||||
@@ -327,6 +327,15 @@ export const OrchestrationV2AppThread = Schema.Struct({
|
||||
lastVisitedAt: Schema.NullOr(Schema.DateTimeUtc).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(null)),
|
||||
),
|
||||
/** In-flight title regeneration marker; cleared when a new title lands. */
|
||||
titleRegeneration: Schema.optional(
|
||||
Schema.NullOr(
|
||||
Schema.Struct({
|
||||
requestId: CommandId,
|
||||
startedAt: Schema.DateTimeUtc,
|
||||
}),
|
||||
),
|
||||
),
|
||||
deletedAt: Schema.NullOr(Schema.DateTimeUtc),
|
||||
});
|
||||
export type OrchestrationV2AppThread = typeof OrchestrationV2AppThread.Type;
|
||||
@@ -1223,6 +1232,15 @@ export const OrchestrationV2ThreadShell = Schema.Struct({
|
||||
* back to their local visited state when the field is absent.
|
||||
*/
|
||||
lastVisitedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtc)),
|
||||
/** In-flight title regeneration marker; null/absent when no request is pending. */
|
||||
titleRegeneration: Schema.optional(
|
||||
Schema.NullOr(
|
||||
Schema.Struct({
|
||||
requestId: CommandId,
|
||||
startedAt: Schema.DateTimeUtc,
|
||||
}),
|
||||
),
|
||||
),
|
||||
deletedAt: Schema.NullOr(Schema.DateTimeUtc),
|
||||
});
|
||||
export type OrchestrationV2ThreadShell = typeof OrchestrationV2ThreadShell.Type;
|
||||
@@ -1300,6 +1318,14 @@ export const OrchestrationV2AppThreadJson = OrchestrationV2AppThread.mapFields((
|
||||
lastVisitedAt: Schema.NullOr(Schema.DateTimeUtcFromString).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(null)),
|
||||
),
|
||||
titleRegeneration: Schema.optional(
|
||||
Schema.NullOr(
|
||||
Schema.Struct({
|
||||
requestId: CommandId,
|
||||
startedAt: Schema.DateTimeUtcFromString,
|
||||
}),
|
||||
),
|
||||
),
|
||||
deletedAt: Schema.NullOr(Schema.DateTimeUtcFromString),
|
||||
}));
|
||||
export type OrchestrationV2AppThreadJson = typeof OrchestrationV2AppThreadJson.Type;
|
||||
@@ -1907,6 +1933,8 @@ export const OrchestrationV2Command = Schema.Union([
|
||||
commandId: CommandId,
|
||||
threadId: ThreadId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
/** Kick off (true) or abandon (false) an async title regeneration. */
|
||||
regenerateTitle: Schema.optional(Schema.Boolean),
|
||||
branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
worktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
expectedWorktreePath: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)),
|
||||
|
||||
Reference in new issue
Block a user