diff --git a/apps/server/src/environmentTheme.test.ts b/apps/server/src/environmentTheme.test.ts index 6fcd5fdca5ed..e7183b1a6898 100644 --- a/apps/server/src/environmentTheme.test.ts +++ b/apps/server/src/environmentTheme.test.ts @@ -63,6 +63,7 @@ const withEnvironmentThemes = ( /** Receives each theme and appearance the service makes the environment default. */ selected?: Array<{ readonly theme?: string; readonly appearance?: string }>; wrapFileSystem?: (fs: FileSystem.FileSystem) => FileSystem.FileSystem; + linkedDirectory?: string; } = {}, ) => Effect.gen(function* () { @@ -70,9 +71,14 @@ const withEnvironmentThemes = ( const path = yield* Path.Path; const baseDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-environment-theme-" }); const themesDir = path.join(baseDir, "userdata", "themes"); - yield* fs.makeDirectory(themesDir, { recursive: true }); - for (const [filename, contents] of Object.entries(seeds)) { - yield* fs.writeFileString(path.join(themesDir, filename), contents); + if (options.linkedDirectory === undefined) { + yield* fs.makeDirectory(themesDir, { recursive: true }); + for (const [filename, contents] of Object.entries(seeds)) { + yield* fs.writeFileString(path.join(themesDir, filename), contents); + } + } else { + yield* fs.makeDirectory(path.dirname(themesDir), { recursive: true }); + yield* fs.symlink(options.linkedDirectory, themesDir); } return yield* body.pipe( @@ -111,6 +117,38 @@ const currentThemes = Effect.gen(function* () { return yield* environmentTheme.current; }); +type ReplaceWatchedDirectory = (replace: Effect.Effect) => Effect.Effect; + +const withWatchedEnvironmentThemes = ( + seeds: Readonly>, + body: ( + awaitWatch: Effect.Effect, + replaceWatchedDirectory: ReplaceWatchedDirectory, + ) => Parameters>[1], + linkedDirectory?: string, +) => + Effect.gen(function* () { + const watchReady = yield* Queue.sliding(1); + const awaitWatch = Queue.take(watchReady); + const replaceWatchedDirectory = (replace: Effect.Effect) => + Queue.clear(watchReady).pipe(Effect.andThen(replace), Effect.andThen(awaitWatch)); + yield* withEnvironmentThemes(seeds, body(awaitWatch, replaceWatchedDirectory), { + ...(linkedDirectory === undefined ? {} : { linkedDirectory }), + wrapFileSystem: (fs) => + FileSystem.FileSystem.of({ + ...fs, + watch: (directory, options) => + fs.watch(directory, { + ...options, + onReady: () => { + options?.onReady?.(); + Queue.offerUnsafe(watchReady, undefined); + }, + }), + }), + }); + }); + describe("environment theme", () => { it.effect("follows the directory rather than the set read at start", () => withEnvironmentThemes( @@ -208,9 +246,12 @@ describe("environment theme", () => { it.live.skipIf(!symlinksSupported)( "publishes edits after the target of a symlinked themes directory is restored", () => - withEnvironmentThemes( + withWatchedEnvironmentThemes( { "nightfall.json": encodeThemeFile(NIGHTFALL_THEME) }, - Effect.gen(function* () { + Effect.fnUntraced(function* ( + awaitWatch: Effect.Effect, + replaceWatchedDirectory: ReplaceWatchedDirectory, + ) { const service = yield* EnvironmentTheme.EnvironmentThemeService; const { environmentThemesDir } = yield* ServerConfig.ServerConfig; const fs = yield* FileSystem.FileSystem; @@ -245,8 +286,12 @@ describe("environment theme", () => { ); assert.deepEqual(yield* Queue.take(snapshots), ["Nightfall"]); - yield* fs.rename(environmentThemesDir, path.join(outside, "original")); - yield* fs.symlink(linkTarget, environmentThemesDir); + yield* awaitWatch; + yield* replaceWatchedDirectory( + fs + .rename(environmentThemesDir, path.join(outside, "original")) + .pipe(Effect.andThen(fs.symlink(linkTarget, environmentThemesDir))), + ); assert.deepEqual( yield* Stream.fromQueue(snapshots).pipe( Stream.filter((names) => names.length > 0), @@ -263,8 +308,9 @@ describe("environment theme", () => { assert.deepEqual(yield* Queue.take(snapshots), ["Nightfall", "Shared Light"]); yield* fs.rename(target, path.join(outside, "previous")); + assert.deepEqual(yield* service.current, []); assert.deepEqual(yield* Queue.take(snapshots), []); - yield* fs.rename(restored, target); + yield* replaceWatchedDirectory(fs.rename(restored, target)); assert.deepEqual(yield* Queue.take(snapshots), ["Nightfall"]); yield* fs.writeFileString( @@ -283,8 +329,9 @@ describe("environment theme", () => { ); yield* fs.rename(targetParent, path.join(outside, "previous-parent")); + assert.deepEqual(yield* service.current, []); assert.deepEqual(yield* Queue.take(snapshots), []); - yield* fs.rename(restoredParent, targetParent); + yield* replaceWatchedDirectory(fs.rename(restoredParent, targetParent)); assert.deepEqual(yield* Queue.take(snapshots), ["Shared Light"]); yield* fs.writeFileString( @@ -299,58 +346,55 @@ describe("environment theme", () => { it.live.skipIf(!symlinksSupported)( "publishes later edits after a linked theme directory's grandparent is restored", () => - withEnvironmentThemes( - { "nightfall.json": encodeThemeFile(NIGHTFALL_THEME) }, - Effect.gen(function* () { - const service = yield* EnvironmentTheme.EnvironmentThemeService; - const { environmentThemesDir } = yield* ServerConfig.ServerConfig; - const fs = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const fixture = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-linked-themes-" }); - const active = path.join(fixture, "active"); - const restored = path.join(fixture, "restored"); - const target = path.join(active, "shared", "themes"); - const restoredTarget = path.join(restored, "shared", "themes"); - for (const directory of [target, restoredTarget]) { - yield* fs.makeDirectory(directory, { recursive: true }); - yield* fs.writeFileString( - path.join(directory, "shared-light.json"), - encodeThemeFile(SHARED_THEME), - ); - } - - const snapshots = yield* service.streamChanges.pipe( - Stream.map((themes) => themes.map((theme) => theme.name)), - Stream.toQueue({ capacity: "unbounded" }), - ); - assert.deepEqual(yield* Queue.take(snapshots), ["Nightfall"]); - yield* fs.rename(environmentThemesDir, path.join(fixture, "original")); - yield* fs.symlink(target, environmentThemesDir); - assert.deepEqual( - yield* Stream.fromQueue(snapshots).pipe( - Stream.filter((names) => names.length > 0), - Stream.runHead, - Effect.map((names) => names.valueOrUndefined), - ), - ["Shared Light"], + Effect.gen(function* () { + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const fixture = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-linked-themes-" }); + const active = path.join(fixture, "active"); + const restored = path.join(fixture, "restored"); + const target = path.join(active, "shared", "themes"); + const restoredTarget = path.join(restored, "shared", "themes"); + for (const directory of [target, restoredTarget]) { + yield* fs.makeDirectory(directory, { recursive: true }); + yield* fs.writeFileString( + path.join(directory, "shared-light.json"), + encodeThemeFile(SHARED_THEME), ); + } + + yield* withWatchedEnvironmentThemes( + {}, + Effect.fnUntraced(function* ( + awaitWatch: Effect.Effect, + replaceWatchedDirectory: ReplaceWatchedDirectory, + ) { + const service = yield* EnvironmentTheme.EnvironmentThemeService; + const snapshots = yield* service.streamChanges.pipe( + Stream.map((themes) => themes.map((theme) => theme.name)), + Stream.toQueue({ capacity: "unbounded" }), + ); + assert.deepEqual(yield* Queue.take(snapshots), ["Shared Light"]); + yield* awaitWatch; - yield* fs.rename(active, path.join(fixture, "active-previous")); - assert.deepEqual(yield* Queue.take(snapshots), []); - yield* fs.rename(restored, active); - assert.deepEqual(yield* Queue.take(snapshots), ["Shared Light"]); + yield* fs.rename(active, path.join(fixture, "active-previous")); + assert.deepEqual(yield* service.current, []); + assert.deepEqual(yield* Queue.take(snapshots), []); + yield* replaceWatchedDirectory(fs.rename(restored, active)); + assert.deepEqual(yield* Queue.take(snapshots), ["Shared Light"]); - yield* fs.writeFileString( - path.join(fixture, "active-previous", "shared", "themes", "nightfall.json"), - encodeThemeFile(NIGHTFALL_THEME), - ); - yield* fs.writeFileString( - path.join(target, "shared-light.json"), - encodeThemeFile({ ...SHARED_THEME, name: "Edited Shared Light" }), - ); - assert.deepEqual(yield* Queue.take(snapshots), ["Edited Shared Light"]); - }), - ), + yield* fs.writeFileString( + path.join(fixture, "active-previous", "shared", "themes", "nightfall.json"), + encodeThemeFile(NIGHTFALL_THEME), + ); + yield* fs.writeFileString( + path.join(target, "shared-light.json"), + encodeThemeFile({ ...SHARED_THEME, name: "Edited Shared Light" }), + ); + assert.deepEqual(yield* Queue.take(snapshots), ["Edited Shared Light"]); + }), + target, + ); + }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), ); it.live.skipIf(!symlinksSupported)( @@ -361,38 +405,30 @@ describe("environment theme", () => { let linkedEntry: string | undefined; let moveAfterListing: Effect.Effect | undefined; let holdProbes = false; + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const fixture = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-linked-themes-" }); + const active = path.join(fixture, "active"); + const previous = path.join(fixture, "previous"); + const target = path.join(active, "shared", "themes"); + yield* fs.makeDirectory(target, { recursive: true }); + yield* fs.writeFileString( + path.join(target, "shared-light.json"), + encodeThemeFile(SHARED_THEME), + ); + yield* withEnvironmentThemes( - { "nightfall.json": encodeThemeFile(NIGHTFALL_THEME) }, + {}, Effect.gen(function* () { const service = yield* EnvironmentTheme.EnvironmentThemeService; const { environmentThemesDir } = yield* ServerConfig.ServerConfig; const fs = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const fixture = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-linked-themes-" }); - const active = path.join(fixture, "active"); - const previous = path.join(fixture, "previous"); - const target = path.join(active, "shared", "themes"); - yield* fs.makeDirectory(target, { recursive: true }); - yield* fs.writeFileString( - path.join(target, "shared-light.json"), - encodeThemeFile(SHARED_THEME), - ); - const snapshots = yield* service.streamChanges.pipe( Stream.map((themes) => themes.map((theme) => theme.name)), Stream.toQueue({ capacity: "unbounded" }), ); - assert.deepEqual(yield* Queue.take(snapshots), ["Nightfall"]); + assert.deepEqual(yield* Queue.take(snapshots), ["Shared Light"]); linkedEntry = environmentThemesDir; - yield* fs.rename(environmentThemesDir, path.join(fixture, "original")); - yield* fs.symlink(target, environmentThemesDir); - assert.deepEqual( - (yield* Stream.fromQueue(snapshots).pipe( - Stream.filter((names) => names.length > 0), - Stream.runHead, - )).valueOrUndefined, - ["Shared Light"], - ); // The next listing succeeds, then the tree moves before its files are opened. moveAfterListing = Effect.orDie(fs.rename(active, previous)); @@ -401,12 +437,14 @@ describe("environment theme", () => { path.join(target, "nightfall.json"), encodeThemeFile(NIGHTFALL_THEME), ); + assert.deepEqual(yield* service.current, []); assert.deepEqual(yield* Queue.take(snapshots), []); yield* fs.rename(previous, active); yield* Deferred.succeed(resumeProbes, undefined); assert.deepEqual(yield* Queue.take(snapshots), ["Nightfall", "Shared Light"]); }), { + linkedDirectory: target, wrapFileSystem: (fs) => FileSystem.FileSystem.of({ ...fs, @@ -428,7 +466,7 @@ describe("environment theme", () => { }), }, ); - }), + }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), ); it.live.skipIf(!symlinksSupported)( @@ -438,38 +476,30 @@ describe("environment theme", () => { const resumeProbes = yield* Deferred.make(); let linkedEntry: string | undefined; let holdProbes = false; + const fs = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const fixture = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-linked-themes-" }); + const active = path.join(fixture, "active"); + const previous = path.join(fixture, "previous"); + const target = path.join(active, "shared", "themes"); + yield* fs.makeDirectory(target, { recursive: true }); + yield* fs.writeFileString( + path.join(target, "shared-light.json"), + encodeThemeFile(SHARED_THEME), + ); + yield* withEnvironmentThemes( - { "nightfall.json": encodeThemeFile(NIGHTFALL_THEME) }, + {}, Effect.gen(function* () { const service = yield* EnvironmentTheme.EnvironmentThemeService; const { environmentThemesDir } = yield* ServerConfig.ServerConfig; const fs = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const fixture = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-linked-themes-" }); - const active = path.join(fixture, "active"); - const previous = path.join(fixture, "previous"); - const target = path.join(active, "shared", "themes"); - yield* fs.makeDirectory(target, { recursive: true }); - yield* fs.writeFileString( - path.join(target, "shared-light.json"), - encodeThemeFile(SHARED_THEME), - ); - const snapshots = yield* service.streamChanges.pipe( Stream.map((themes) => themes.map((theme) => theme.name)), Stream.toQueue({ capacity: "unbounded" }), ); - assert.deepEqual(yield* Queue.take(snapshots), ["Nightfall"]); + assert.deepEqual(yield* Queue.take(snapshots), ["Shared Light"]); linkedEntry = environmentThemesDir; - yield* fs.rename(environmentThemesDir, path.join(fixture, "original")); - yield* fs.symlink(target, environmentThemesDir); - assert.deepEqual( - (yield* Stream.fromQueue(snapshots).pipe( - Stream.filter((names) => names.length > 0), - Stream.runHead, - )).valueOrUndefined, - ["Shared Light"], - ); holdProbes = true; yield* fs.rename(active, previous); @@ -477,12 +507,14 @@ describe("environment theme", () => { path.join(previous, "shared", "themes", "nightfall.json"), encodeThemeFile(NIGHTFALL_THEME), ); + assert.deepEqual(yield* service.current, []); assert.deepEqual(yield* Queue.take(snapshots), []); yield* fs.rename(previous, active); yield* Deferred.succeed(resumeProbes, undefined); assert.deepEqual(yield* Queue.take(snapshots), ["Nightfall", "Shared Light"]); }), { + linkedDirectory: target, wrapFileSystem: (fs) => FileSystem.FileSystem.of({ ...fs, @@ -495,7 +527,7 @@ describe("environment theme", () => { }), }, ); - }), + }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), ); it.effect("skips invalid files while keeping valid ones", () => diff --git a/apps/server/src/feedback/FeedbackReport.ts b/apps/server/src/feedback/FeedbackReport.ts index f7c026700b0e..e9d94927b8c8 100644 --- a/apps/server/src/feedback/FeedbackReport.ts +++ b/apps/server/src/feedback/FeedbackReport.ts @@ -129,6 +129,7 @@ export const T3_CLI_COMMANDS: ReadonlyArray = [ "t3 help", "t3 serve", "t3 app", + "t3 app network-access", "t3 pair", "t3 auth", "t3 auth connect-device", @@ -158,6 +159,65 @@ export const T3_CLI_COMMANDS: ReadonlyArray = [ "t3 thread start", "t3 thread send", "t3 thread show", + "t3 thread answer", + "t3 thread archive", + "t3 thread delete", + "t3 thread export", + "t3 thread fork", + "t3 thread hide", + "t3 thread move", + "t3 thread rename", + "t3 thread resume", + "t3 thread rollback", + "t3 thread search", + "t3 thread settle", + "t3 thread stop", + "t3 thread unarchive", + "t3 thread unhide", + "t3 thread unsettle", + "t3 draft", + "t3 draft create", + "t3 draft delete", + "t3 draft list", + "t3 draft send", + "t3 import", + "t3 import list", + "t3 integration", + "t3 integration discord", + "t3 integration discord connect", + "t3 integration discord leave", + "t3 integration discord servers", + "t3 integration login", + "t3 integration logout", + "t3 integration status", + "t3 provider", + "t3 provider disable", + "t3 provider enable", + "t3 provider list", + "t3 provider refresh", + "t3 schedule", + "t3 schedule create", + "t3 schedule delete", + "t3 schedule disable", + "t3 schedule enable", + "t3 schedule list", + "t3 schedule run", + "t3 schedule show", + "t3 schedule update", + "t3 schedule webhook", + "t3 schedule webhook deliveries", + "t3 schedule webhook rotate", + "t3 settings", + "t3 settings set", + "t3 settings show", + "t3 settings unset", + "t3 usage", + "t3 usage cost", + "t3 usage tokens", + "t3 worktree", + "t3 worktree cleanup", + "t3 worktree list", + "t3 worktree remove", "t3 feedback", "t3 feedback list", "t3 workflow", diff --git a/apps/server/src/keybindings.test.ts b/apps/server/src/keybindings.test.ts index 44048330c3ae..81288c277ad3 100644 --- a/apps/server/src/keybindings.test.ts +++ b/apps/server/src/keybindings.test.ts @@ -45,6 +45,20 @@ const writeKeybindingsConfig = (configPath: string, rules: readonly KeybindingRu yield* fileSystem.writeFileString(configPath, encoded); }); +const fillerRulesToKeepDefault = (target: KeybindingRule) => { + const defaults = SharedKeybindings.DEFAULT_KEYBINDINGS; + const index = defaults.findIndex( + (rule) => + rule.command === target.command && rule.key === target.key && rule.when === target.when, + ); + assert.isAtLeast(index, 0); + const visibleDefaults = SharedKeybindings.compileResolvedKeybindingsConfig(defaults.slice(index)); + return Array.from({ length: MAX_KEYBINDINGS_COUNT - visibleDefaults.length }, (_, index) => ({ + key: "mod+alt+f1", + command: `script.filler-${index}.run` as const, + })); +}; + const readKeybindingsConfig = (configPath: string) => Effect.gen(function* () { const fileSystem = yield* FileSystem.FileSystem; @@ -533,15 +547,8 @@ it.layer(NodeServices.layer)("keybindings", (it) => { Effect.gen(function* () { const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig; const keybindings = yield* Keybindings.Keybindings; - yield* writeKeybindingsConfig( - keybindingsConfigPath, - Array.from({ length: 210 }, (_, index) => ({ - key: "mod+alt+f1", - command: `script.filler-${index}.run` as const, - })), - ); - const target = { key: "mod+shift+o", command: "chat.new", when: "!terminalFocus" } as const; + yield* writeKeybindingsConfig(keybindingsConfigPath, fillerRulesToKeepDefault(target)); const local = { ...target, key: "mod+shift+n", command: "chat.newLocal" } as const; const relevant = (rule: { readonly command: KeybindingCommand }) => rule.command === target.command || rule.command === local.command; @@ -566,15 +573,8 @@ it.layer(NodeServices.layer)("keybindings", (it) => { Effect.gen(function* () { const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig; const keybindings = yield* Keybindings.Keybindings; - yield* writeKeybindingsConfig( - keybindingsConfigPath, - Array.from({ length: 209 }, (_, index) => ({ - key: "mod+alt+f1", - command: `script.filler-${index}.run` as const, - })), - ); - const target = { key: "mod+n", command: "chat.new", when: "!terminalFocus" } as const; + yield* writeKeybindingsConfig(keybindingsConfigPath, fillerRulesToKeepDefault(target)); const sibling = { ...target, key: "mod+shift+o" }; const isChatNew = (binding: { readonly command: KeybindingCommand }) => binding.command === target.command; diff --git a/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts b/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts index 55576ea5f362..50439ea7f512 100644 --- a/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts +++ b/apps/server/src/orchestration-v2/Adapters/MuseAdapterV2.testkit.ts @@ -117,6 +117,39 @@ function withRequestId(expected: unknown, actual: unknown): unknown { : expected; } +// Runtime instructions occupy their own input part and change independently of the protocol. +function normalizeTurnStartInstructions(frame: unknown): unknown { + if (!isRecord(frame) || frame.method !== "turn/start" || !isRecord(frame.params)) { + return frame; + } + const input = frame.params.input; + if (!Array.isArray(input)) return frame; + const [instructions, ...messageParts] = input; + if ( + !isRecord(instructions) || + instructions.type !== "text" || + typeof instructions.text !== "string" || + !instructions.text.startsWith("") || + !instructions.text.includes("") + ) { + return frame; + } + return { + ...frame, + params: { + ...frame.params, + input: [{ ...instructions, text: "" }, ...messageParts], + }, + }; +} + +function replayFrameMatches(expected: unknown, actual: unknown): boolean { + return replayValueMatches( + normalizeTurnStartInstructions(withRequestId(expected, actual)), + normalizeTurnStartInstructions(actual), + ); +} + /** A write may not match past one of these: it would be a turn early. */ function startsTurn(entry: ProviderReplayEntryType): boolean { if (entry.type !== "expect_outbound" || !isRecord(entry.frame)) return false; @@ -250,9 +283,7 @@ class MuseReplayController { const entry = entries[index]!; const pending = entry.type === "expect_outbound" && !this.consumed.has(index); possible = - pending && - entryHost(entry) === host.ordinal && - replayValueMatches(withRequestId(entry.frame, actual), actual); + pending && entryHost(entry) === host.ordinal && replayFrameMatches(entry.frame, actual); if (!possible && pending && startsTurn(entry)) break; } if (!possible) { @@ -310,7 +341,7 @@ class MuseReplayController { const entry = entries[index]!; if (entry.type !== "expect_outbound") return false; if (this.consumed.has(index) || entryHost(entry) !== host.ordinal) continue; - if (!replayValueMatches(withRequestId(entry.frame, actual), actual)) continue; + if (!replayFrameMatches(entry.frame, actual)) continue; const recordedId = clientRequestId(entry.frame); const actualId = clientRequestId(actual); if (recordedId !== undefined && actualId !== undefined) host.ids.set(recordedId, actualId); diff --git a/apps/server/src/orchestration-v2/WorkspaceChangeDetach.integration.test.ts b/apps/server/src/orchestration-v2/WorkspaceChangeDetach.integration.test.ts index b223f6436ed5..df4cd9075b8d 100644 --- a/apps/server/src/orchestration-v2/WorkspaceChangeDetach.integration.test.ts +++ b/apps/server/src/orchestration-v2/WorkspaceChangeDetach.integration.test.ts @@ -10,7 +10,6 @@ import { ProviderTurnId, ThreadId, TurnItemId, - type OrchestrationV2DomainEvent, } from "@t3tools/contracts"; import * as DateTime from "effect/DateTime"; import * as Effect from "effect/Effect"; @@ -18,7 +17,6 @@ import * as Layer from "effect/Layer"; import * as ProviderInstanceRegistry from "../provider/ProviderInstanceRegistry.ts"; import * as WorkspaceFolders from "../workspace/WorkspaceFolders.ts"; import * as RuntimePolicy from "./RuntimePolicy.ts"; -import * as Fiber from "effect/Fiber"; import * as Result from "effect/Result"; import { planProjectCommand } from "./ProjectCommands.ts"; import * as Queue from "effect/Queue"; @@ -141,15 +139,14 @@ it.effect.each([ const worker = yield* EffectWorker.OrchestrationEffectWorkerV2; const sink = yield* EventSink.EventSinkV2; const threadId = ThreadId.make("thread:workspace-change-detach"); - const providerTurnRunning = () => - orchestrator.streamDomainEvents.pipe( + const awaitRunningTurn = (afterSequence: number) => + sink.stream({ threadId, afterSequence, eventType: "provider-turn.updated" }).pipe( Stream.filter( - (event: OrchestrationV2DomainEvent) => + ({ event }) => event.type === "provider-turn.updated" && event.payload.status === "running", ), Stream.take(1), Stream.runDrain, - Effect.forkScoped, ); yield* orchestrator.dispatch({ type: "thread.create", @@ -165,7 +162,7 @@ it.effect.each([ createdBy: "user", creationSource: "web", }); - const firstRunning = yield* providerTurnRunning(); + const beforeFirstTurn = yield* sink.latestSequence({ threadId }); yield* orchestrator.dispatch({ type: "message.dispatch", commandId: CommandId.make("investigate"), @@ -178,7 +175,7 @@ it.effect.each([ creationSource: "web", }); yield* worker.drain(); - yield* Fiber.join(firstRunning); + yield* awaitRunningTurn(beforeFirstTurn); const first = started[0]!; const providerTurn = (yield* orchestrator.getThreadProjection(threadId)) .providerTurns[0]!; @@ -271,7 +268,7 @@ it.effect.each([ ), }); } - const continuationRunning = yield* providerTurnRunning(); + const beforeMove = yield* sink.latestSequence({ threadId }); const move = { type: "thread.project.move" as const, commandId: CommandId.make("handoff"), @@ -308,7 +305,19 @@ it.effect.each([ creationSource: "mcp", }); yield* worker.drain(); - yield* Fiber.join(continuationRunning); + // The checkpoint can schedule queue promotion after the outbox drain returns. + yield* sink.stream({ threadId, afterSequence: beforeMove }).pipe( + Stream.filter( + ({ event }) => + (event.type === "run.updated" || event.type === "run.created") && + event.payload.id !== first.runId && + event.payload.status === "starting", + ), + Stream.take(1), + Stream.runDrain, + ); + yield* worker.drain(); + yield* awaitRunningTurn(beforeMove); const after = yield* orchestrator.getThreadProjection(threadId); assert.deepEqual( diff --git a/packages/client-runtime/src/state/sharedSettings.test.ts b/packages/client-runtime/src/state/sharedSettings.test.ts index 4c1c5eb35f13..e9e24360fb6f 100644 --- a/packages/client-runtime/src/state/sharedSettings.test.ts +++ b/packages/client-runtime/src/state/sharedSettings.test.ts @@ -333,7 +333,7 @@ describe("findSharedSettingsMismatches", () => { environmentId: boxId, label: "Remote Box", syncEligible: true, - settings: DEFAULT_SERVER_SETTINGS, + settings: { ...primarySettings, sidebarAutoSettleAfterDays: 14 }, }, ], }); diff --git a/packages/shared/src/t3ProjectFile.test.ts b/packages/shared/src/t3ProjectFile.test.ts index 06ed1a74c6cf..82634798ce31 100644 --- a/packages/shared/src/t3ProjectFile.test.ts +++ b/packages/shared/src/t3ProjectFile.test.ts @@ -35,8 +35,11 @@ describe("buildT3ProjectFileJsonSchema", () => { "$schema", "defaultThreadEnvMode", "iconPath", + "ignoreRepositories", "pythonInterpreterPath", "scripts", + "worktreeLayout", + "worktreeSparsePatternsPath", "worktreeSubmodules", ]); expect(schema.required).toBeUndefined();