Client-only sidebar v2: back settle with archive, revert all server changes
Makes the new sidebar/thread-list testable against existing unupgraded servers by removing every backend dependency of the settled feature: - apps/server, contracts orchestration schemas, and client-runtime command/reducer plumbing revert to main baseline (no thread.settle commands, no settled events/fields, no migration 033) - effectiveSettled() is now archive-based: archivedAt is the explicit settled signal; PR merged/closed and inactivity auto-settle keep working client-side. Blocked work (pending approval/input, live session) still never settles - settle/unsettle actions ride threadEnvironment.archive/unarchive on web and mobile — UI and UX unchanged - Archived threads stay visible as the settled tail: the live shell stream drops archived threads (thread.archived → thread-removed), so both clients merge them back from the archived shell snapshot and refresh it after settle/unsettle/archive actions - Client settings (sidebarV2Enabled, sidebarAutoSettleAfterDays) are kept — they persist client-side only Trade-offs vs the event-sourced model (still on t3code/sidebar-v2-mobile): no activity-driven auto-un-settle for archived threads, and no "keep active" override distinct from unarchiving. Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
a2f8028f13
commit
da08b588fa
50 files changed
+146
-1102
No files matched your search
@@ -21,13 +21,7 @@ import {
|
||||
import * as EnvironmentSupervisor from "../connection/supervisor.ts";
|
||||
import * as RpcSession from "../rpc/session.ts";
|
||||
import type { WsRpcProtocolClient } from "../rpc/protocol.ts";
|
||||
import {
|
||||
archiveThread,
|
||||
createProject,
|
||||
settleThread,
|
||||
stopThreadSession,
|
||||
unsettleThread,
|
||||
} from "./commands.ts";
|
||||
import { archiveThread, createProject, stopThreadSession } from "./commands.ts";
|
||||
|
||||
const TEST_CRYPTO_LAYER = Layer.succeed(
|
||||
Crypto.Crypto,
|
||||
@@ -140,35 +134,4 @@ describe("environment commands", () => {
|
||||
]);
|
||||
}).pipe(Effect.provide(TEST_CRYPTO_LAYER)),
|
||||
);
|
||||
|
||||
it.effect("dispatches settle and unsettle commands without timestamps", () =>
|
||||
Effect.gen(function* () {
|
||||
const dispatched: ClientOrchestrationCommand[] = [];
|
||||
const supervisor = yield* makeSupervisor(dispatched);
|
||||
|
||||
yield* settleThread({
|
||||
commandId: CommandId.make("settle-command"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
}).pipe(Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor));
|
||||
yield* unsettleThread({
|
||||
commandId: CommandId.make("unsettle-command"),
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
reason: "user",
|
||||
}).pipe(Effect.provideService(EnvironmentSupervisor.EnvironmentSupervisor, supervisor));
|
||||
|
||||
expect(dispatched).toEqual([
|
||||
{
|
||||
type: "thread.settle",
|
||||
commandId: "settle-command",
|
||||
threadId: "thread-1",
|
||||
},
|
||||
{
|
||||
type: "thread.unsettle",
|
||||
commandId: "unsettle-command",
|
||||
threadId: "thread-1",
|
||||
reason: "user",
|
||||
},
|
||||
]);
|
||||
}).pipe(Effect.provide(TEST_CRYPTO_LAYER)),
|
||||
);
|
||||
});
|
||||
@@ -35,8 +35,6 @@ export type CreateThreadInput = CommandInput<"thread.create">;
|
||||
export type DeleteThreadInput = CommandInput<"thread.delete">;
|
||||
export type ArchiveThreadInput = CommandInput<"thread.archive">;
|
||||
export type UnarchiveThreadInput = CommandInput<"thread.unarchive">;
|
||||
export type SettleThreadInput = CommandInput<"thread.settle">;
|
||||
export type UnsettleThreadInput = CommandInput<"thread.unsettle">;
|
||||
export type UpdateThreadMetadataInput = CommandInput<"thread.meta.update">;
|
||||
export type SetThreadRuntimeModeInput = CommandInput<"thread.runtime-mode.set">;
|
||||
export type SetThreadInteractionModeInput = CommandInput<"thread.interaction-mode.set">;
|
||||
@@ -155,26 +153,6 @@ export const unarchiveThread: (input: UnarchiveThreadInput) => CommandEffect = E
|
||||
});
|
||||
});
|
||||
|
||||
export const settleThread: (input: SettleThreadInput) => CommandEffect = Effect.fn(
|
||||
"EnvironmentCommands.settleThread",
|
||||
)(function* (input) {
|
||||
return yield* dispatch({
|
||||
...input,
|
||||
type: "thread.settle",
|
||||
commandId: yield* commandId(input),
|
||||
});
|
||||
});
|
||||
|
||||
export const unsettleThread: (input: UnsettleThreadInput) => CommandEffect = Effect.fn(
|
||||
"EnvironmentCommands.unsettleThread",
|
||||
)(function* (input) {
|
||||
return yield* dispatch({
|
||||
...input,
|
||||
type: "thread.unsettle",
|
||||
commandId: yield* commandId(input),
|
||||
});
|
||||
});
|
||||
|
||||
export const updateThreadMetadata: (input: UpdateThreadMetadataInput) => CommandEffect = Effect.fn(
|
||||
"EnvironmentCommands.updateThreadMetadata",
|
||||
)(function* (input) {
|
||||
|
||||
@@ -96,8 +96,6 @@ const THREAD_SHELL = {
|
||||
createdAt: "2026-06-01T00:00:00.000Z",
|
||||
updatedAt: "2026-06-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
session: null,
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: false,
|
||||
|
||||
@@ -36,8 +36,6 @@ const stubThread = {
|
||||
createdAt: "2026-04-01T00:00:00.000Z",
|
||||
updatedAt: "2026-04-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: false,
|
||||
hasPendingUserInput: false,
|
||||
|
||||
@@ -12,11 +12,9 @@ import {
|
||||
type RevertThreadCheckpointInput,
|
||||
type SetThreadInteractionModeInput,
|
||||
type SetThreadRuntimeModeInput,
|
||||
type SettleThreadInput,
|
||||
type StartThreadTurnInput,
|
||||
type StopThreadSessionInput,
|
||||
type UnarchiveThreadInput,
|
||||
type UnsettleThreadInput,
|
||||
type UpdateThreadMetadataInput,
|
||||
archiveThread,
|
||||
createThread,
|
||||
@@ -27,11 +25,9 @@ import {
|
||||
revertThreadCheckpoint,
|
||||
setThreadInteractionMode,
|
||||
setThreadRuntimeMode,
|
||||
settleThread,
|
||||
startThreadTurn,
|
||||
stopThreadSession,
|
||||
unarchiveThread,
|
||||
unsettleThread,
|
||||
updateThreadMetadata,
|
||||
} from "../operations/commands.ts";
|
||||
import type { EnvironmentRegistry } from "../connection/registry.ts";
|
||||
@@ -46,11 +42,9 @@ export type {
|
||||
RevertThreadCheckpointInput,
|
||||
SetThreadInteractionModeInput,
|
||||
SetThreadRuntimeModeInput,
|
||||
SettleThreadInput,
|
||||
StartThreadTurnInput,
|
||||
StopThreadSessionInput,
|
||||
UnarchiveThreadInput,
|
||||
UnsettleThreadInput,
|
||||
UpdateThreadMetadataInput,
|
||||
} from "../operations/commands.ts";
|
||||
|
||||
@@ -88,18 +82,6 @@ export function createThreadEnvironmentAtoms<R, E>(
|
||||
scheduler,
|
||||
concurrency,
|
||||
}),
|
||||
settle: createEnvironmentCommand(runtime, {
|
||||
label: "environment-data:commands:thread:settle",
|
||||
execute: (input: SettleThreadInput) => settleThread(input),
|
||||
scheduler,
|
||||
concurrency,
|
||||
}),
|
||||
unsettle: createEnvironmentCommand(runtime, {
|
||||
label: "environment-data:commands:thread:unsettle",
|
||||
execute: (input: UnsettleThreadInput) => unsettleThread(input),
|
||||
scheduler,
|
||||
concurrency,
|
||||
}),
|
||||
updateMetadata: createEnvironmentCommand(runtime, {
|
||||
label: "environment-data:commands:thread:update-metadata",
|
||||
execute: (input: UpdateThreadMetadataInput) => updateThreadMetadata(input),
|
||||
|
||||
@@ -57,8 +57,6 @@ export function mergeEnvironmentThread(
|
||||
createdAt: shell.createdAt,
|
||||
updatedAt: shell.updatedAt,
|
||||
archivedAt: shell.archivedAt,
|
||||
settledOverride: shell.settledOverride,
|
||||
settledAt: shell.settledAt,
|
||||
session: shell.session,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@ const baseThread: OrchestrationThread = {
|
||||
createdAt: "2026-04-01T00:00:00.000Z",
|
||||
updatedAt: "2026-04-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
@@ -166,62 +164,6 @@ describe("applyThreadDetailEvent", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("thread.settled / thread.unsettled", () => {
|
||||
it("sets the settled override and timestamp", () => {
|
||||
const settledAt = "2026-04-01T05:00:00.000Z";
|
||||
const result = applyThreadDetailEvent(baseThread, {
|
||||
...baseEventFields,
|
||||
sequence: 5,
|
||||
occurredAt: settledAt,
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.make("thread-1"),
|
||||
type: "thread.settled",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
settledAt,
|
||||
updatedAt: settledAt,
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.kind).toBe("updated");
|
||||
if (result.kind === "updated") {
|
||||
expect(result.thread.settledOverride).toBe("settled");
|
||||
expect(result.thread.settledAt).toBe(settledAt);
|
||||
}
|
||||
});
|
||||
|
||||
it.each([
|
||||
["user", "active"],
|
||||
["activity", null],
|
||||
] as const)("unsettles for %s with override %s", (reason, settledOverride) => {
|
||||
const settledThread: OrchestrationThread = {
|
||||
...baseThread,
|
||||
settledOverride: "settled",
|
||||
settledAt: "2026-04-01T05:00:00.000Z",
|
||||
};
|
||||
const updatedAt = "2026-04-01T06:00:00.000Z";
|
||||
const result = applyThreadDetailEvent(settledThread, {
|
||||
...baseEventFields,
|
||||
sequence: 6,
|
||||
occurredAt: updatedAt,
|
||||
aggregateKind: "thread",
|
||||
aggregateId: ThreadId.make("thread-1"),
|
||||
type: "thread.unsettled",
|
||||
payload: {
|
||||
threadId: ThreadId.make("thread-1"),
|
||||
reason,
|
||||
updatedAt,
|
||||
},
|
||||
});
|
||||
|
||||
expect(result.kind).toBe("updated");
|
||||
if (result.kind === "updated") {
|
||||
expect(result.thread.settledOverride).toBe(settledOverride);
|
||||
expect(result.thread.settledAt).toBeNull();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("thread.meta-updated", () => {
|
||||
it("patches title and branch", () => {
|
||||
const result = applyThreadDetailEvent(baseThread, {
|
||||
|
||||
@@ -72,8 +72,6 @@ export function applyThreadDetailEvent(
|
||||
createdAt: event.payload.createdAt,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
@@ -102,28 +100,6 @@ export function applyThreadDetailEvent(
|
||||
thread: { ...thread, archivedAt: null, updatedAt: event.payload.updatedAt },
|
||||
};
|
||||
|
||||
case "thread.settled":
|
||||
return {
|
||||
kind: "updated",
|
||||
thread: {
|
||||
...thread,
|
||||
settledOverride: "settled",
|
||||
settledAt: event.payload.settledAt,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
},
|
||||
};
|
||||
|
||||
case "thread.unsettled":
|
||||
return {
|
||||
kind: "updated",
|
||||
thread: {
|
||||
...thread,
|
||||
settledOverride: event.payload.reason === "user" ? "active" : null,
|
||||
settledAt: null,
|
||||
updatedAt: event.payload.updatedAt,
|
||||
},
|
||||
};
|
||||
|
||||
// ── Thread metadata ─────────────────────────────────────────────
|
||||
case "thread.meta-updated":
|
||||
return {
|
||||
|
||||
@@ -18,7 +18,7 @@ const FRESH = "2026-04-09T00:00:00.000Z";
|
||||
const STALE = "2026-04-06T23:59:59.999Z";
|
||||
|
||||
function makeShell(input: {
|
||||
readonly settledOverride: OrchestrationThreadShell["settledOverride"];
|
||||
readonly archivedAt: string | null;
|
||||
readonly activityAt: string | null;
|
||||
readonly sessionStatus?: "starting" | "running";
|
||||
readonly pending?: "approval" | "user-input";
|
||||
@@ -46,9 +46,7 @@ function makeShell(input: {
|
||||
},
|
||||
createdAt: "2026-04-01T00:00:00.000Z",
|
||||
updatedAt: NOW,
|
||||
archivedAt: null,
|
||||
settledOverride: input.settledOverride,
|
||||
settledAt: input.settledOverride === "settled" ? NOW : null,
|
||||
archivedAt: input.archivedAt,
|
||||
session:
|
||||
input.sessionStatus === undefined
|
||||
? null
|
||||
@@ -70,7 +68,7 @@ function makeShell(input: {
|
||||
|
||||
describe("threadLastActivityAt", () => {
|
||||
it("returns the latest real user or turn activity and ignores thread/session updates", () => {
|
||||
const shell = makeShell({ settledOverride: null, activityAt: null, sessionStatus: "running" });
|
||||
const shell = makeShell({ archivedAt: null, activityAt: null, sessionStatus: "running" });
|
||||
const withActivity: OrchestrationThreadShell = {
|
||||
...shell,
|
||||
latestUserMessageAt: "2026-04-04T00:00:00.000Z",
|
||||
@@ -90,7 +88,7 @@ describe("threadLastActivityAt", () => {
|
||||
});
|
||||
|
||||
describe("effectiveSettled", () => {
|
||||
const overrides = ["settled", "active", null] as const;
|
||||
const archivedCases = [null, NOW] as const;
|
||||
const changeRequestStates = [undefined, "open", "merged"] as const;
|
||||
const inactivityCases = [
|
||||
["fresh", FRESH],
|
||||
@@ -99,23 +97,23 @@ describe("effectiveSettled", () => {
|
||||
] as const;
|
||||
const runningCases = [false, true] as const;
|
||||
const pendingCases = [undefined, "approval", "user-input"] as const;
|
||||
const truthTable = overrides.flatMap((settledOverride) =>
|
||||
const truthTable = archivedCases.flatMap((archivedAt) =>
|
||||
changeRequestStates.flatMap((changeRequestState) =>
|
||||
inactivityCases.flatMap(([inactivity, activityAt]) =>
|
||||
runningCases.flatMap((running) =>
|
||||
pendingCases.map((pending) => ({
|
||||
settledOverride,
|
||||
archivedAt,
|
||||
changeRequestState,
|
||||
inactivity,
|
||||
activityAt,
|
||||
running,
|
||||
pending,
|
||||
// Settled iff nothing blocks (pending work / live session) AND
|
||||
// any positive signal holds: archived, merged PR, or staleness.
|
||||
expected:
|
||||
pending === undefined &&
|
||||
(settledOverride === "settled" ||
|
||||
(settledOverride === null &&
|
||||
!running &&
|
||||
(changeRequestState === "merged" || inactivity === "stale"))),
|
||||
!running &&
|
||||
(archivedAt !== null || changeRequestState === "merged" || inactivity === "stale"),
|
||||
})),
|
||||
),
|
||||
),
|
||||
@@ -123,10 +121,10 @@ describe("effectiveSettled", () => {
|
||||
);
|
||||
|
||||
it.each(truthTable)(
|
||||
"override=$settledOverride pr=$changeRequestState inactivity=$inactivity running=$running pending=$pending",
|
||||
({ settledOverride, changeRequestState, activityAt, running, pending, expected }) => {
|
||||
"archived=$archivedAt pr=$changeRequestState inactivity=$inactivity running=$running pending=$pending",
|
||||
({ archivedAt, changeRequestState, activityAt, running, pending, expected }) => {
|
||||
const shell = makeShell({
|
||||
settledOverride,
|
||||
archivedAt,
|
||||
activityAt,
|
||||
...(running ? { sessionStatus: "running" as const } : {}),
|
||||
...(pending === undefined ? {} : { pending }),
|
||||
@@ -147,7 +145,7 @@ describe("effectiveSettled", () => {
|
||||
);
|
||||
|
||||
it("treats closed change requests like merged ones", () => {
|
||||
const shell = makeShell({ settledOverride: null, activityAt: null });
|
||||
const shell = makeShell({ archivedAt: null, activityAt: null });
|
||||
expect(
|
||||
effectiveSettled(shell, {
|
||||
now: NOW,
|
||||
@@ -157,9 +155,9 @@ describe("effectiveSettled", () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("never auto-settles a starting session", () => {
|
||||
it("never settles a starting session, even when archived", () => {
|
||||
const shell = makeShell({
|
||||
settledOverride: null,
|
||||
archivedAt: NOW,
|
||||
activityAt: STALE,
|
||||
sessionStatus: "starting",
|
||||
});
|
||||
@@ -174,10 +172,10 @@ describe("effectiveSettled", () => {
|
||||
|
||||
it("uses a strict inactivity boundary and honors a null threshold", () => {
|
||||
const boundary = makeShell({
|
||||
settledOverride: null,
|
||||
archivedAt: null,
|
||||
activityAt: "2026-04-07T00:00:00.000Z",
|
||||
});
|
||||
const stale = makeShell({ settledOverride: null, activityAt: STALE });
|
||||
const stale = makeShell({ archivedAt: null, activityAt: STALE });
|
||||
|
||||
expect(effectiveSettled(boundary, { now: NOW, autoSettleAfterDays: 3 })).toBe(false);
|
||||
expect(effectiveSettled(stale, { now: NOW, autoSettleAfterDays: null })).toBe(false);
|
||||
|
||||
@@ -26,6 +26,17 @@ export function threadLastActivityAt(shell: OrchestrationThreadShell): string |
|
||||
return latest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Client-only settled resolution, backed by the pre-existing archive
|
||||
* lifecycle instead of dedicated settle commands — no server, protocol, or
|
||||
* database changes required. "Settled" here means: the user archived the
|
||||
* thread, its PR merged/closed, or it has been inactive past the auto-settle
|
||||
* window.
|
||||
*
|
||||
* Trade-offs vs the event-sourced settled model (kept on the main feature
|
||||
* branch): activity does not auto-un-settle an archived thread, and there is
|
||||
* no distinct "keep active" override — un-settling is just unarchiving.
|
||||
*/
|
||||
export function effectiveSettled(
|
||||
shell: OrchestrationThreadShell,
|
||||
options: {
|
||||
@@ -36,9 +47,8 @@ export function effectiveSettled(
|
||||
): boolean {
|
||||
// Blocked work must remain visible even when a user explicitly settled it.
|
||||
if (shell.hasPendingApprovals || shell.hasPendingUserInput) return false;
|
||||
if (shell.settledOverride === "settled") return true;
|
||||
if (shell.settledOverride === "active") return false;
|
||||
if (shell.session?.status === "starting" || shell.session?.status === "running") return false;
|
||||
if (shell.archivedAt !== null) return true;
|
||||
if (options.changeRequestState === "merged" || options.changeRequestState === "closed") {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -67,8 +67,6 @@ const BASE_THREAD: OrchestrationThread = {
|
||||
createdAt: "2026-04-01T00:00:00.000Z",
|
||||
updatedAt: "2026-04-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
settledOverride: null,
|
||||
settledAt: null,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
|
||||
@@ -15,8 +15,6 @@ import {
|
||||
ProjectMetaUpdatedPayload,
|
||||
OrchestrationProposedPlan,
|
||||
OrchestrationSession,
|
||||
OrchestrationThread,
|
||||
OrchestrationThreadShell,
|
||||
ProjectCreateCommand,
|
||||
ThreadMetaUpdatedPayload,
|
||||
ThreadTurnStartCommand,
|
||||
@@ -39,8 +37,6 @@ const decodeThreadTurnStartRequestedPayload = Schema.decodeUnknownEffect(
|
||||
const decodeOrchestrationLatestTurn = Schema.decodeUnknownEffect(OrchestrationLatestTurn);
|
||||
const decodeOrchestrationProposedPlan = Schema.decodeUnknownEffect(OrchestrationProposedPlan);
|
||||
const decodeOrchestrationSession = Schema.decodeUnknownEffect(OrchestrationSession);
|
||||
const decodeOrchestrationThread = Schema.decodeUnknownEffect(OrchestrationThread);
|
||||
const decodeOrchestrationThreadShell = Schema.decodeUnknownEffect(OrchestrationThreadShell);
|
||||
const encodeThreadCreatedPayload = Schema.encodeEffect(ThreadCreatedPayload);
|
||||
|
||||
function getOptionValue(
|
||||
@@ -348,65 +344,6 @@ it.effect("decodes thread archive and unarchive commands", () =>
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("decodes thread settle and unsettle commands", () =>
|
||||
Effect.gen(function* () {
|
||||
const settle = yield* decodeOrchestrationCommand({
|
||||
type: "thread.settle",
|
||||
commandId: "cmd-settle-1",
|
||||
threadId: "thread-1",
|
||||
});
|
||||
const unsettle = yield* decodeOrchestrationCommand({
|
||||
type: "thread.unsettle",
|
||||
commandId: "cmd-unsettle-1",
|
||||
threadId: "thread-1",
|
||||
reason: "activity",
|
||||
});
|
||||
|
||||
assert.strictEqual(settle.type, "thread.settle");
|
||||
assert.strictEqual(unsettle.type, "thread.unsettle");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("defaults settled fields when decoding historical thread data", () =>
|
||||
Effect.gen(function* () {
|
||||
const common = {
|
||||
id: "thread-1",
|
||||
projectId: "project-1",
|
||||
title: "Historical thread",
|
||||
modelSelection: { provider: "codex", model: "gpt-5.4" },
|
||||
runtimeMode: "full-access",
|
||||
interactionMode: "default",
|
||||
branch: null,
|
||||
worktreePath: null,
|
||||
latestTurn: null,
|
||||
createdAt: "2026-01-01T00:00:00.000Z",
|
||||
updatedAt: "2026-01-01T00:00:00.000Z",
|
||||
archivedAt: null,
|
||||
session: null,
|
||||
};
|
||||
const thread = yield* decodeOrchestrationThread({
|
||||
...common,
|
||||
deletedAt: null,
|
||||
messages: [],
|
||||
proposedPlans: [],
|
||||
activities: [],
|
||||
checkpoints: [],
|
||||
});
|
||||
const shell = yield* decodeOrchestrationThreadShell({
|
||||
...common,
|
||||
latestUserMessageAt: null,
|
||||
hasPendingApprovals: false,
|
||||
hasPendingUserInput: false,
|
||||
hasActionableProposedPlan: false,
|
||||
});
|
||||
|
||||
assert.strictEqual(thread.settledOverride, null);
|
||||
assert.strictEqual(thread.settledAt, null);
|
||||
assert.strictEqual(shell.settledOverride, null);
|
||||
assert.strictEqual(shell.settledAt, null);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("decodes thread archived and unarchived events", () =>
|
||||
Effect.gen(function* () {
|
||||
const archived = yield* decodeOrchestrationEvent({
|
||||
@@ -451,48 +388,6 @@ it.effect("decodes thread archived and unarchived events", () =>
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("decodes thread settled and unsettled events", () =>
|
||||
Effect.gen(function* () {
|
||||
const settled = yield* decodeOrchestrationEvent({
|
||||
sequence: 1,
|
||||
eventId: "event-settle-1",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: "thread-1",
|
||||
type: "thread.settled",
|
||||
occurredAt: "2026-01-01T00:00:00.000Z",
|
||||
commandId: "cmd-settle-1",
|
||||
causationEventId: null,
|
||||
correlationId: "cmd-settle-1",
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
settledAt: "2026-01-01T00:00:00.000Z",
|
||||
updatedAt: "2026-01-01T00:00:00.000Z",
|
||||
},
|
||||
});
|
||||
const unsettled = yield* decodeOrchestrationEvent({
|
||||
sequence: 2,
|
||||
eventId: "event-unsettle-1",
|
||||
aggregateKind: "thread",
|
||||
aggregateId: "thread-1",
|
||||
type: "thread.unsettled",
|
||||
occurredAt: "2026-01-02T00:00:00.000Z",
|
||||
commandId: "cmd-unsettle-1",
|
||||
causationEventId: null,
|
||||
correlationId: "cmd-unsettle-1",
|
||||
metadata: {},
|
||||
payload: {
|
||||
threadId: "thread-1",
|
||||
reason: "user",
|
||||
updatedAt: "2026-01-02T00:00:00.000Z",
|
||||
},
|
||||
});
|
||||
|
||||
assert.strictEqual(settled.type, "thread.settled");
|
||||
assert.strictEqual(unsettled.type, "thread.unsettled");
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("accepts provider-scoped model options in thread.turn.start", () =>
|
||||
Effect.gen(function* () {
|
||||
const parsed = yield* decodeThreadTurnStartCommand({
|
||||
|
||||
@@ -356,10 +356,6 @@ export const OrchestrationThread = Schema.Struct({
|
||||
createdAt: IsoDateTime,
|
||||
updatedAt: IsoDateTime,
|
||||
archivedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
|
||||
settledOverride: Schema.NullOr(Schema.Literals(["settled", "active"])).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(null)),
|
||||
),
|
||||
settledAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
|
||||
deletedAt: Schema.NullOr(IsoDateTime),
|
||||
messages: Schema.Array(OrchestrationMessage),
|
||||
proposedPlans: Schema.Array(OrchestrationProposedPlan).pipe(
|
||||
@@ -406,10 +402,6 @@ export const OrchestrationThreadShell = Schema.Struct({
|
||||
createdAt: IsoDateTime,
|
||||
updatedAt: IsoDateTime,
|
||||
archivedAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
|
||||
settledOverride: Schema.NullOr(Schema.Literals(["settled", "active"])).pipe(
|
||||
Schema.withDecodingDefault(Effect.succeed(null)),
|
||||
),
|
||||
settledAt: Schema.NullOr(IsoDateTime).pipe(Schema.withDecodingDefault(Effect.succeed(null))),
|
||||
session: Schema.NullOr(OrchestrationSession),
|
||||
latestUserMessageAt: Schema.NullOr(IsoDateTime),
|
||||
hasPendingApprovals: Schema.Boolean,
|
||||
@@ -553,19 +545,6 @@ const ThreadUnarchiveCommand = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
});
|
||||
|
||||
const ThreadSettleCommand = Schema.Struct({
|
||||
type: Schema.Literal("thread.settle"),
|
||||
commandId: CommandId,
|
||||
threadId: ThreadId,
|
||||
});
|
||||
|
||||
const ThreadUnsettleCommand = Schema.Struct({
|
||||
type: Schema.Literal("thread.unsettle"),
|
||||
commandId: CommandId,
|
||||
threadId: ThreadId,
|
||||
reason: Schema.Literals(["user", "activity"]),
|
||||
});
|
||||
|
||||
const ThreadMetaUpdateCommand = Schema.Struct({
|
||||
type: Schema.Literal("thread.meta.update"),
|
||||
commandId: CommandId,
|
||||
@@ -708,8 +687,6 @@ const DispatchableClientOrchestrationCommand = Schema.Union([
|
||||
ThreadDeleteCommand,
|
||||
ThreadArchiveCommand,
|
||||
ThreadUnarchiveCommand,
|
||||
ThreadSettleCommand,
|
||||
ThreadUnsettleCommand,
|
||||
ThreadMetaUpdateCommand,
|
||||
ThreadRuntimeModeSetCommand,
|
||||
ThreadInteractionModeSetCommand,
|
||||
@@ -731,8 +708,6 @@ export const ClientOrchestrationCommand = Schema.Union([
|
||||
ThreadDeleteCommand,
|
||||
ThreadArchiveCommand,
|
||||
ThreadUnarchiveCommand,
|
||||
ThreadSettleCommand,
|
||||
ThreadUnsettleCommand,
|
||||
ThreadMetaUpdateCommand,
|
||||
ThreadRuntimeModeSetCommand,
|
||||
ThreadInteractionModeSetCommand,
|
||||
@@ -835,8 +810,6 @@ export const OrchestrationEventType = Schema.Literals([
|
||||
"thread.deleted",
|
||||
"thread.archived",
|
||||
"thread.unarchived",
|
||||
"thread.settled",
|
||||
"thread.unsettled",
|
||||
"thread.meta-updated",
|
||||
"thread.runtime-mode-set",
|
||||
"thread.interaction-mode-set",
|
||||
@@ -916,18 +889,6 @@ export const ThreadUnarchivedPayload = Schema.Struct({
|
||||
updatedAt: IsoDateTime,
|
||||
});
|
||||
|
||||
export const ThreadSettledPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
settledAt: IsoDateTime,
|
||||
updatedAt: IsoDateTime,
|
||||
});
|
||||
|
||||
export const ThreadUnsettledPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
reason: Schema.Literals(["user", "activity"]),
|
||||
updatedAt: IsoDateTime,
|
||||
});
|
||||
|
||||
export const ThreadMetaUpdatedPayload = Schema.Struct({
|
||||
threadId: ThreadId,
|
||||
title: Schema.optional(TrimmedNonEmptyString),
|
||||
@@ -1095,16 +1056,6 @@ export const OrchestrationEvent = Schema.Union([
|
||||
type: Schema.Literal("thread.unarchived"),
|
||||
payload: ThreadUnarchivedPayload,
|
||||
}),
|
||||
Schema.Struct({
|
||||
...EventBaseFields,
|
||||
type: Schema.Literal("thread.settled"),
|
||||
payload: ThreadSettledPayload,
|
||||
}),
|
||||
Schema.Struct({
|
||||
...EventBaseFields,
|
||||
type: Schema.Literal("thread.unsettled"),
|
||||
payload: ThreadUnsettledPayload,
|
||||
}),
|
||||
Schema.Struct({
|
||||
...EventBaseFields,
|
||||
type: Schema.Literal("thread.meta-updated"),
|
||||
|
||||
Reference in new issue
Block a user