feat: rewind conversations while keeping file changes (#11358)
Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
1 parent
25da986037
commit
efccda9ac9
10 files changed
+478
-164
No files matched your search
@@ -24,6 +24,7 @@ import type { WsRpcProtocolClient } from "../rpc/protocol.ts";
|
||||
import {
|
||||
archiveThread,
|
||||
createProject,
|
||||
revertThreadCheckpoint,
|
||||
reorderActiveThread,
|
||||
settleThread,
|
||||
stopThreadSession,
|
||||
@@ -101,6 +102,27 @@ describe("environment commands", () => {
|
||||
}).pipe(Effect.provide(TEST_CRYPTO_LAYER)),
|
||||
);
|
||||
|
||||
it.effect("uses a distinct command when keeping workspace changes", () =>
|
||||
Effect.gen(function* () {
|
||||
const dispatched: ClientOrchestrationCommand[] = [];
|
||||
const supervisor = yield* makeSupervisor(dispatched);
|
||||
for (const restoreFiles of [undefined, true, false]) {
|
||||
yield* revertThreadCheckpoint({
|
||||
commandId: CommandId.make("rewind-command"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
turnCount: 0,
|
||||
...(restoreFiles !== undefined ? { restoreFiles } : {}),
|
||||
createdAt: "2026-06-06T00:01:00.000Z",
|
||||
}).pipe(Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor));
|
||||
}
|
||||
expect(dispatched.map((command) => command.type)).toEqual([
|
||||
"thread.checkpoint.revert",
|
||||
"thread.checkpoint.revert",
|
||||
"thread.conversation.revert",
|
||||
]);
|
||||
}).pipe(Effect.provide(TEST_CRYPTO_LAYER)),
|
||||
);
|
||||
|
||||
it.effect("preserves caller metadata for idempotent queued commands", () =>
|
||||
Effect.gen(function* () {
|
||||
const dispatched: ClientOrchestrationCommand[] = [];
|
||||
|
||||
@@ -53,7 +53,9 @@ export type InterruptThreadTurnInput = CommandInput<"thread.turn.interrupt">;
|
||||
export type RespondToThreadApprovalInput = CommandInput<"thread.approval.respond">;
|
||||
export type RespondToThreadUserInputInput = CommandInput<"thread.user-input.respond">;
|
||||
export type DismissThreadUserInputInput = CommandInput<"thread.user-input.dismiss">;
|
||||
export type RevertThreadCheckpointInput = CommandInput<"thread.checkpoint.revert">;
|
||||
export type RevertThreadCheckpointInput = CommandInput<"thread.checkpoint.revert"> & {
|
||||
readonly restoreFiles?: boolean;
|
||||
};
|
||||
export type StopThreadSessionInput = CommandInput<"thread.session.stop">;
|
||||
|
||||
type DispatchTag = typeof ORCHESTRATION_WS_METHODS.dispatchCommand;
|
||||
@@ -355,9 +357,10 @@ export const dismissThreadUserInput: (input: DismissThreadUserInputInput) => Com
|
||||
export const revertThreadCheckpoint: (input: RevertThreadCheckpointInput) => CommandEffect =
|
||||
Effect.fn("EnvironmentCommands.revertThreadCheckpoint")(function* (input) {
|
||||
const metadata = yield* timestampedCommandMetadata(input);
|
||||
const { restoreFiles, ...command } = input;
|
||||
return yield* dispatch({
|
||||
...input,
|
||||
type: "thread.checkpoint.revert",
|
||||
...command,
|
||||
type: restoreFiles === false ? "thread.conversation.revert" : "thread.checkpoint.revert",
|
||||
commandId: metadata.commandId,
|
||||
createdAt: metadata.createdAt,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user