GeezerVison is showing github.com — fix(codex): preserve concurrent thread renames · pingdotgg/t3code@9bf0a9f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration/decider.titleRegeneration.test.ts +42Lines changed: 42 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,6 +46,48 @@ const readModel: OrchestrationReadModel = { | 46 | 46 | }; | 47 | 47 |
| 48 | 48 | it.layer(NodeServices.layer)("title regeneration decider", (it) => { | | 49 | + it.effect("applies a title update while the expected title is still current", () => | | 50 | + Effect.gen(function* () { | | 51 | + const result = yield* decideOrchestrationCommand({ | | 52 | + command: { | | 53 | + type: "thread.meta.update", | | 54 | + commandId: CommandId.make("cmd-title-update-current"), | | 55 | + threadId: ThreadId.make("thread-1"), | | 56 | + title: "Provider title", | | 57 | + expectedTitle: "Manual title", | | 58 | + }, | | 59 | + readModel, | | 60 | + }); | | 61 | + const event = Array.isArray(result) ? result[0] : result; | | 62 | + | | 63 | + expect(event.type).toBe("thread.meta-updated"); | | 64 | + if (event.type === "thread.meta-updated") { | | 65 | + expect(event.payload.title).toBe("Provider title"); | | 66 | + } | | 67 | + }), | | 68 | + ); | | 69 | + | | 70 | + it.effect("does not replace a title that changed after the caller sampled it", () => | | 71 | + Effect.gen(function* () { | | 72 | + const result = yield* decideOrchestrationCommand({ | | 73 | + command: { | | 74 | + type: "thread.meta.update", | | 75 | + commandId: CommandId.make("cmd-title-update-stale"), | | 76 | + threadId: ThreadId.make("thread-1"), | | 77 | + title: "Provider title", | | 78 | + expectedTitle: "Previous provider title", | | 79 | + }, | | 80 | + readModel, | | 81 | + }); | | 82 | + const event = Array.isArray(result) ? result[0] : result; | | 83 | + | | 84 | + expect(event.type).toBe("thread.meta-updated"); | | 85 | + if (event.type === "thread.meta-updated") { | | 86 | + expect(event.payload.title).toBeUndefined(); | | 87 | + } | | 88 | + }), | | 89 | + ); | | 90 | + | 49 | 91 | it.effect("preserves updatedAt for a stale completion", () => | 50 | 92 | Effect.gen(function* () { | 51 | 93 | const result = yield* decideOrchestrationCommand({ | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/orchestration/decider.ts +8-2Lines changed: 8 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -805,6 +805,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand" | 805 | 805 | thread.branch !== command.expectedBranch | 806 | 806 | ? thread.branch | 807 | 807 | : command.branch; | | 808 | + const title = | | 809 | + command.title !== undefined && | | 810 | + command.expectedTitle !== undefined && | | 811 | + thread.title !== command.expectedTitle | | 812 | + ? undefined | | 813 | + : command.title; | 808 | 814 | const occurredAt = yield* nowIso; | 809 | 815 | return { | 810 | 816 | ...(yield* withEventBase({ | @@ -816,7 +822,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand" | 816 | 822 | type: "thread.meta-updated", | 817 | 823 | payload: { | 818 | 824 | threadId: command.threadId, | 819 | | - ...(command.title !== undefined ? { title: command.title } : {}), | | 825 | + ...(title !== undefined ? { title } : {}), | 820 | 826 | ...(command.regenerateTitle === true | 821 | 827 | ? { | 822 | 828 | regenerateTitle: true as const, | @@ -827,7 +833,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand" | 827 | 833 | }, | 828 | 834 | } | 829 | 835 | : {}), | 830 | | - ...(command.title !== undefined && thread.titleRegeneration != null | | 836 | + ...(title !== undefined && thread.titleRegeneration != null | 831 | 837 | ? { titleRegeneration: null } | 832 | 838 | : {}), | 833 | 839 | ...(command.modelSelection !== undefined | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/Layers/ProviderThreadDiscovery.test.ts +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -308,6 +308,10 @@ it.effect("refreshes imported metadata without replacing the projected session s | 308 | 308 | commands[0]?.type === "thread.meta.update" && commands[0].title, | 309 | 309 | "Fresh Codex title", | 310 | 310 | ); | | 311 | + NodeAssert.equal( | | 312 | + commands[0]?.type === "thread.meta.update" && commands[0].expectedTitle, | | 313 | + originalTitle, | | 314 | + ); | 311 | 315 | NodeAssert.equal(bindings[0]?.status, undefined); | 312 | 316 | NodeAssert.equal(bindings[0]?.runtimeMode, undefined); | 313 | 317 | NodeAssert.equal(readModel.threads[0]?.title, originalTitle); | |
Collapse file Copy file name to clipboardExpand all lines: apps/server/src/provider/Layers/ProviderThreadDiscovery.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -298,7 +298,9 @@ export const synchronizeDiscoveredProviderThreads = Effect.fn( | 298 | 298 | discovered.updatedAt, | 299 | 299 | ), | 300 | 300 | threadId: linkedThread.id, | 301 | | - ...(providerOwnsTitle && title !== metadata.providerTitle ? { title } : {}), | | 301 | + ...(providerOwnsTitle && title !== metadata.providerTitle | | 302 | + ? { title, expectedTitle: metadata.providerTitle } | | 303 | + : {}), | 302 | 304 | }); | 303 | 305 | if (providerOwnsTitle && title !== metadata.providerTitle) { | 304 | 306 | linkedThread.title = title; | |
Collapse file Copy file name to clipboardExpand all lines: packages/contracts/src/orchestration.ts +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -753,6 +753,7 @@ const ThreadMetaUpdateCommand = Schema.Struct({ | 753 | 753 | commandId: CommandId, | 754 | 754 | threadId: ThreadId, | 755 | 755 | title: Schema.optional(TrimmedNonEmptyString), | | 756 | + expectedTitle: Schema.optional(TrimmedNonEmptyString), | 756 | 757 | regenerateTitle: Schema.optional(Schema.Literal(true)), | 757 | 758 | modelSelection: Schema.optional(ModelSelection), | 758 | 759 | branch: Schema.optional(Schema.NullOr(TrimmedNonEmptyString)), | |
|