From 8dcbdcac52e989cf9a43b677f7dcb752ab2fdabc Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 13 Aug 2026 21:31:55 +0200 Subject: [PATCH] feat(contracts): track thread title regeneration - Add optional title regeneration request and start time to thread shells - Cover cache serialization on mobile and client runtime --- .../src/connection/environment-cache-store.test.ts | 8 ++++++++ .../src/platform/orchestrationCache.test.ts | 10 ++++++++++ packages/contracts/src/orchestrationV2.ts | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/apps/mobile/src/connection/environment-cache-store.test.ts b/apps/mobile/src/connection/environment-cache-store.test.ts index 1488038c98..8cf7551a66 100644 --- a/apps/mobile/src/connection/environment-cache-store.test.ts +++ b/apps/mobile/src/connection/environment-cache-store.test.ts @@ -1,5 +1,6 @@ import { ORCHESTRATION_CACHE_SCHEMA_VERSION } from "@t3tools/client-runtime/platform"; import { + CommandId, EnvironmentId, ProjectId, ProviderInstanceId, @@ -74,6 +75,10 @@ const SHELL_SNAPSHOT: OrchestrationV2ShellSnapshot = { settledOverride: null, settledAt: NOW, lastVisitedAt: null, + titleRegeneration: { + requestId: CommandId.make("title-regeneration-1"), + startedAt: NOW, + }, deletedAt: null, }, ], @@ -205,6 +210,9 @@ describe("mobile SQLite environment cache store", () => { expect(DateTime.formatIso(shell.threads[0]!.latestUserMessageAt!)).toBe( "2026-07-29T12:00:00.000Z", ); + expect(DateTime.formatIso(shell.threads[0]!.titleRegeneration!.startedAt)).toBe( + "2026-07-29T12:00:00.000Z", + ); expect(DateTime.formatIso(thread.projection.thread.updatedAt)).toBe( "2026-07-29T12:00:00.000Z", ); diff --git a/packages/client-runtime/src/platform/orchestrationCache.test.ts b/packages/client-runtime/src/platform/orchestrationCache.test.ts index 7b79069df3..33b30f8f67 100644 --- a/packages/client-runtime/src/platform/orchestrationCache.test.ts +++ b/packages/client-runtime/src/platform/orchestrationCache.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from "@effect/vitest"; import { + CommandId, EnvironmentId, MessageId, RuntimeRequestId, @@ -59,6 +60,10 @@ const shellSnapshotWithSummaries: OrchestrationV2ShellSnapshot = { }, latestUserMessageAt: v2Now, settledAt: v2Now, + titleRegeneration: { + requestId: CommandId.make("title-regeneration-v2"), + startedAt: v2Now, + }, }, ], }; @@ -98,6 +103,11 @@ describe("orchestration cache envelopes", () => { ? null : DateTime.formatIso(threadShell.settledAt), ).toBe("2026-06-20T00:00:00.000Z"); + expect( + threadShell?.titleRegeneration === null || threadShell?.titleRegeneration === undefined + ? null + : DateTime.formatIso(threadShell.titleRegeneration.startedAt), + ).toBe("2026-06-20T00:00:00.000Z"); expect(DateTime.formatIso(thread.snapshot.projection.thread.updatedAt)).toBe( "2026-06-20T00:00:00.000Z", ); diff --git a/packages/contracts/src/orchestrationV2.ts b/packages/contracts/src/orchestrationV2.ts index 68dffeb4c6..d58739aa99 100644 --- a/packages/contracts/src/orchestrationV2.ts +++ b/packages/contracts/src/orchestrationV2.ts @@ -1780,6 +1780,14 @@ export const OrchestrationV2ThreadShellJson = OrchestrationV2ThreadShell.mapFiel snoozedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtcFromString)), pinnedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtcFromString)), lastVisitedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtcFromString)), + titleRegeneration: Schema.optional( + Schema.NullOr( + Schema.Struct({ + requestId: CommandId, + startedAt: Schema.DateTimeUtcFromString, + }), + ), + ), deletedAt: Schema.NullOr(Schema.DateTimeUtcFromString), })); export type OrchestrationV2ThreadShellJson = typeof OrchestrationV2ThreadShellJson.Type;