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:
Theo BrowneandClaude Fable 5 committed 2026-07-15 21:31:50 -07:00
1 parent a2f8028f13
commit da08b588fa
50 files changed
+146 -1102

No files matched your search

@@ -41,8 +41,6 @@ function makeThread(
hasPendingUserInput: false,
hasActionableProposedPlan: false,
...input,
settledOverride: input.settledOverride ?? null,
settledAt: input.settledAt ?? null,
};
}
+31 -10
View File
@@ -23,7 +23,8 @@ import { useThemeColor } from "../../lib/useThemeColor";
import { EmptyState } from "../../components/EmptyState";
import type { WorkspaceState } from "../../state/workspaceModel";
import type { SavedRemoteConnection } from "../../lib/connection";
import { scopedProjectKey } from "../../lib/scopedEntities";
import { scopedProjectKey, scopedThreadKey } from "../../lib/scopedEntities";
import { useArchivedThreadSnapshots } from "../archive/useArchivedThreadSnapshots";
import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences";
import type { PendingNewTask } from "../../state/use-pending-new-tasks";
import {
@@ -284,17 +285,37 @@ export function HomeScreen(props: HomeScreenProps) {
// Thread List v2 (beta): one flat list in creation order, no grouping.
// Settled threads collapse into a recency tail below the card block.
const threadListV2Items = useMemo(
// Settle = archive in the client-only model, and the live shell stream
// drops archived threads — merge them back from the archived snapshot so
// they render as the settled tail. Live shells win on overlap.
const archivedEnvironmentIds = useMemo(
() =>
threadListV2Enabled
? buildThreadListV2Items({
threads: props.threads,
environmentId: props.selectedEnvironmentId,
searchQuery: props.searchQuery,
})
: [],
[props.searchQuery, props.selectedEnvironmentId, props.threads, threadListV2Enabled],
threadListV2Enabled ? props.environments.map((environment) => environment.environmentId) : [],
[props.environments, threadListV2Enabled],
);
const { snapshots: archivedSnapshots } = useArchivedThreadSnapshots(archivedEnvironmentIds);
const threadListV2Items = useMemo(() => {
if (!threadListV2Enabled) return [];
const liveKeys = new Set(
props.threads.map((thread) => scopedThreadKey(thread.environmentId, thread.id)),
);
const archived = archivedSnapshots.flatMap(({ environmentId, snapshot }) =>
snapshot.threads
.map((thread) => ({ ...thread, environmentId }))
.filter((thread) => !liveKeys.has(scopedThreadKey(thread.environmentId, thread.id))),
);
return buildThreadListV2Items({
threads: [...props.threads, ...archived],
environmentId: props.selectedEnvironmentId,
searchQuery: props.searchQuery,
});
}, [
archivedSnapshots,
props.searchQuery,
props.selectedEnvironmentId,
props.threads,
threadListV2Enabled,
]);
const renderV2Item = useCallback(
({ item }: LegendListRenderItemProps<ThreadListV2Item>) => (
@@ -47,8 +47,6 @@ function makeThread(id: string, projectId: ProjectId): EnvironmentThreadShell {
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,
@@ -41,8 +41,6 @@ function makeThread(
hasPendingUserInput: false,
hasActionableProposedPlan: false,
...input,
settledOverride: input.settledOverride ?? null,
settledAt: input.settledAt ?? null,
};
}
@@ -6,6 +6,7 @@ import { Alert } from "react-native";
import { showConfirmDialog } from "../../components/ConfirmDialogHost";
import { scopedThreadKey } from "../../lib/scopedEntities";
import { refreshArchivedThreadsForEnvironment } from "../archive/useArchivedThreadSnapshots";
import { threadEnvironment } from "../../state/threads";
import { useAtomCommand } from "../../state/use-atom-command";
@@ -45,8 +46,10 @@ function useThreadActionExecutor(
const archiveMutation = useAtomCommand(threadEnvironment.archive, { reportFailure: false });
const unarchiveMutation = useAtomCommand(threadEnvironment.unarchive, { reportFailure: false });
const deleteMutation = useAtomCommand(threadEnvironment.delete, { reportFailure: false });
const settleMutation = useAtomCommand(threadEnvironment.settle, { reportFailure: false });
const unsettleMutation = useAtomCommand(threadEnvironment.unsettle, { reportFailure: false });
// Client-only settled model: settle/unsettle ride the archive lifecycle so
// no server upgrade is required. See client-runtime threadSettled.ts.
const settleMutation = archiveMutation;
const unsettleMutation = unarchiveMutation;
const inFlightThreadKeys = useRef(new Set<string>());
const executeAction = useCallback(
@@ -59,31 +62,30 @@ function useThreadActionExecutor(
inFlightThreadKeys.current.add(key);
selectionHaptic();
try {
const result =
const mutation =
action === "settle"
? await settleMutation({
environmentId: thread.environmentId,
input: { threadId: thread.id },
})
? settleMutation
: action === "unsettle"
? await unsettleMutation({
environmentId: thread.environmentId,
input: { threadId: thread.id, reason: "user" },
})
: await (
action === "archive"
? archiveMutation
: action === "unarchive"
? unarchiveMutation
: deleteMutation
)({
environmentId: thread.environmentId,
input: { threadId: thread.id },
});
? unsettleMutation
: action === "archive"
? archiveMutation
: action === "unarchive"
? unarchiveMutation
: deleteMutation;
const result = await mutation({
environmentId: thread.environmentId,
input: { threadId: thread.id },
});
if (result._tag === "Failure") {
Alert.alert(actionFailureTitle(action), actionFailureMessage(action, result.cause));
return;
}
// Settle rides archive, and archiving drops the thread from the live
// shell stream — refresh the archived snapshot so the v2 list can
// show it as a settled row without waiting for a manual reload.
if (action === "settle" || action === "unsettle" || action === "archive") {
refreshArchivedThreadsForEnvironment(thread.environmentId);
}
onCompleted?.(action, thread);
} finally {
inFlightThreadKeys.current.delete(key);
@@ -31,8 +31,6 @@ function makeThread(
hasPendingUserInput: false,
hasActionableProposedPlan: false,
...input,
settledOverride: input.settledOverride ?? null,
settledAt: input.settledAt ?? null,
};
}
@@ -77,19 +75,19 @@ describe("sortThreadsForListV2", () => {
});
describe("buildThreadListV2Items", () => {
it("partitions settled threads into a slim tail with one divider", () => {
it("partitions archived (settled) threads into a slim tail with one divider", () => {
const items = buildThreadListV2Items({
threads: [
makeThread({ id: ThreadId.make("active"), title: "Active" }),
makeThread({
id: ThreadId.make("settled"),
title: "Settled",
settledOverride: "settled",
archivedAt: NOW,
}),
makeThread({
id: ThreadId.make("settled-2"),
title: "Settled 2",
settledOverride: "settled",
archivedAt: NOW,
}),
],
environmentId: null,
@@ -129,7 +127,7 @@ describe("buildThreadListV2Items", () => {
expect(items.map((item) => item.thread.id)).toEqual(["newer-created", "older-created"]);
});
it("excludes archived threads and filters by search query", () => {
it("keeps archived threads in the tail and filters by search query", () => {
const items = buildThreadListV2Items({
threads: [
makeThread({ id: ThreadId.make("match"), title: "Fix login bug" }),
@@ -145,6 +143,9 @@ describe("buildThreadListV2Items", () => {
now: NOW,
});
expect(items.map((item) => item.thread.id)).toEqual(["match"]);
expect(items.map((item) => [item.thread.id, item.variant])).toEqual([
["match", "card"],
["archived", "slim"],
]);
});
});
@@ -73,11 +73,12 @@ export function buildThreadListV2Items(input: {
const active: EnvironmentThreadShell[] = [];
const settled: EnvironmentThreadShell[] = [];
for (const thread of input.threads) {
if (thread.archivedAt !== null) continue;
// Archived threads stay in the list: in the client-only settled model,
// archive IS settle, so they render as the settled tail.
if (input.environmentId !== null && thread.environmentId !== input.environmentId) continue;
if (query.length > 0 && !thread.title.toLocaleLowerCase().includes(query)) continue;
// PR state feeds the web partition per-row; mobile shells don't watch PRs
// from the list, so the partition here is override/session/inactivity.
// from the list, so the partition here is archive/session/inactivity.
if (effectiveSettled(thread, { now, autoSettleAfterDays, changeRequestState: null })) {
settled.push(thread);
} else {
@@ -38,8 +38,6 @@ function makeThread(
hasPendingUserInput: false,
hasActionableProposedPlan: false,
...input,
settledOverride: input.settledOverride ?? null,
settledAt: input.settledAt ?? null,
};
}
@@ -50,8 +50,6 @@ function makeThread(
checkpoints: [],
session: null,
...input,
settledOverride: input.settledOverride ?? null,
settledAt: input.settledAt ?? null,
};
}
@@ -58,8 +58,6 @@ function threadDetailToShell(
createdAt: thread.createdAt,
updatedAt: thread.updatedAt,
archivedAt: thread.archivedAt,
settledOverride: thread.settledOverride,
settledAt: thread.settledAt,
session: thread.session,
latestUserMessageAt: latestUserMessageAt(thread),
hasPendingApprovals: false,
@@ -146,8 +146,6 @@ describe("OrchestrationEngine", () => {
createdAt: "2026-03-03T00:00:02.000Z",
updatedAt: "2026-03-03T00:00:03.000Z",
archivedAt: null,
settledOverride: null,
settledAt: null,
deletedAt: null,
messages: [],
proposedPlans: [],
@@ -607,8 +607,6 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
createdAt: event.payload.createdAt,
updatedAt: event.payload.updatedAt,
archivedAt: null,
settledOverride: null,
settledAt: null,
latestUserMessageAt: null,
pendingApprovalCount: 0,
pendingUserInputCount: 0,
@@ -647,38 +645,6 @@ const makeOrchestrationProjectionPipeline = Effect.fn("makeOrchestrationProjecti
return;
}
case "thread.settled": {
const existingRow = yield* projectionThreadRepository.getById({
threadId: event.payload.threadId,
});
if (Option.isNone(existingRow)) {
return;
}
yield* projectionThreadRepository.upsert({
...existingRow.value,
settledOverride: "settled",
settledAt: event.payload.settledAt,
updatedAt: event.payload.updatedAt,
});
return;
}
case "thread.unsettled": {
const existingRow = yield* projectionThreadRepository.getById({
threadId: event.payload.threadId,
});
if (Option.isNone(existingRow)) {
return;
}
yield* projectionThreadRepository.upsert({
...existingRow.value,
settledOverride: event.payload.reason === "user" ? "active" : null,
settledAt: null,
updatedAt: event.payload.updatedAt,
});
return;
}
case "thread.meta-updated": {
const existingRow = yield* projectionThreadRepository.getById({
threadId: event.payload.threadId,
@@ -308,8 +308,6 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
createdAt: "2026-02-24T00:00:02.000Z",
updatedAt: "2026-02-24T00:00:03.000Z",
archivedAt: null,
settledOverride: null,
settledAt: null,
deletedAt: null,
messages: [
{
@@ -420,8 +418,6 @@ projectionSnapshotLayer("ProjectionSnapshotQuery", (it) => {
createdAt: "2026-02-24T00:00:02.000Z",
updatedAt: "2026-02-24T00:00:03.000Z",
archivedAt: null,
settledOverride: null,
settledAt: null,
session: {
threadId: ThreadId.make("thread-1"),
status: "running",
@@ -334,8 +334,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
created_at AS "createdAt",
updated_at AS "updatedAt",
archived_at AS "archivedAt",
settled_override AS "settledOverride",
settled_at AS "settledAt",
latest_user_message_at AS "latestUserMessageAt",
pending_approval_count AS "pendingApprovalCount",
pending_user_input_count AS "pendingUserInputCount",
@@ -364,8 +362,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
created_at AS "createdAt",
updated_at AS "updatedAt",
archived_at AS "archivedAt",
settled_override AS "settledOverride",
settled_at AS "settledAt",
latest_user_message_at AS "latestUserMessageAt",
pending_approval_count AS "pendingApprovalCount",
pending_user_input_count AS "pendingUserInputCount",
@@ -396,8 +392,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
created_at AS "createdAt",
updated_at AS "updatedAt",
archived_at AS "archivedAt",
settled_override AS "settledOverride",
settled_at AS "settledAt",
latest_user_message_at AS "latestUserMessageAt",
pending_approval_count AS "pendingApprovalCount",
pending_user_input_count AS "pendingUserInputCount",
@@ -760,8 +754,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
created_at AS "createdAt",
updated_at AS "updatedAt",
archived_at AS "archivedAt",
settled_override AS "settledOverride",
settled_at AS "settledAt",
latest_user_message_at AS "latestUserMessageAt",
pending_approval_count AS "pendingApprovalCount",
pending_user_input_count AS "pendingUserInputCount",
@@ -1194,8 +1186,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
createdAt: row.createdAt,
updatedAt: row.updatedAt,
archivedAt: row.archivedAt,
settledOverride: row.settledOverride,
settledAt: row.settledAt,
deletedAt: row.deletedAt,
messages: messagesByThread.get(row.threadId) ?? [],
proposedPlans: proposedPlansByThread.get(row.threadId) ?? [],
@@ -1394,8 +1384,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
createdAt: row.createdAt,
updatedAt: row.updatedAt,
archivedAt: row.archivedAt,
settledOverride: row.settledOverride,
settledAt: row.settledAt,
deletedAt: row.deletedAt,
messages: [],
proposedPlans: proposedPlansByThread.get(row.threadId) ?? [],
@@ -1525,8 +1513,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
createdAt: row.createdAt,
updatedAt: row.updatedAt,
archivedAt: row.archivedAt,
settledOverride: row.settledOverride,
settledAt: row.settledAt,
session: sessionByThread.get(row.threadId) ?? null,
latestUserMessageAt: row.latestUserMessageAt,
hasPendingApprovals: row.pendingApprovalCount > 0,
@@ -1661,8 +1647,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
createdAt: row.createdAt,
updatedAt: row.updatedAt,
archivedAt: row.archivedAt,
settledOverride: row.settledOverride,
settledAt: row.settledAt,
session: sessionByThread.get(row.threadId) ?? null,
latestUserMessageAt: row.latestUserMessageAt,
hasPendingApprovals: row.pendingApprovalCount > 0,
@@ -1903,8 +1887,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
createdAt: threadRow.value.createdAt,
updatedAt: threadRow.value.updatedAt,
archivedAt: threadRow.value.archivedAt,
settledOverride: threadRow.value.settledOverride,
settledAt: threadRow.value.settledAt,
session: Option.isSome(sessionRow) ? mapSessionRow(sessionRow.value) : null,
latestUserMessageAt: threadRow.value.latestUserMessageAt,
hasPendingApprovals: threadRow.value.pendingApprovalCount > 0,
@@ -1999,8 +1981,6 @@ const makeProjectionSnapshotQuery = Effect.gen(function* () {
createdAt: threadRow.value.createdAt,
updatedAt: threadRow.value.updatedAt,
archivedAt: threadRow.value.archivedAt,
settledOverride: threadRow.value.settledOverride,
settledAt: threadRow.value.settledAt,
deletedAt: null,
messages: messageRows.map((row) => {
const message = {
-4
View File
@@ -4,13 +4,11 @@ import {
ProjectDeletedPayload as ContractsProjectDeletedPayloadSchema,
ThreadCreatedPayload as ContractsThreadCreatedPayloadSchema,
ThreadArchivedPayload as ContractsThreadArchivedPayloadSchema,
ThreadSettledPayload as ContractsThreadSettledPayloadSchema,
ThreadMetaUpdatedPayload as ContractsThreadMetaUpdatedPayloadSchema,
ThreadRuntimeModeSetPayload as ContractsThreadRuntimeModeSetPayloadSchema,
ThreadInteractionModeSetPayload as ContractsThreadInteractionModeSetPayloadSchema,
ThreadDeletedPayload as ContractsThreadDeletedPayloadSchema,
ThreadUnarchivedPayload as ContractsThreadUnarchivedPayloadSchema,
ThreadUnsettledPayload as ContractsThreadUnsettledPayloadSchema,
ThreadMessageSentPayload as ContractsThreadMessageSentPayloadSchema,
ThreadProposedPlanUpsertedPayload as ContractsThreadProposedPlanUpsertedPayloadSchema,
ThreadSessionSetPayload as ContractsThreadSessionSetPayloadSchema,
@@ -31,13 +29,11 @@ export const ProjectDeletedPayload = ContractsProjectDeletedPayloadSchema;
export const ThreadCreatedPayload = ContractsThreadCreatedPayloadSchema;
export const ThreadArchivedPayload = ContractsThreadArchivedPayloadSchema;
export const ThreadSettledPayload = ContractsThreadSettledPayloadSchema;
export const ThreadMetaUpdatedPayload = ContractsThreadMetaUpdatedPayloadSchema;
export const ThreadRuntimeModeSetPayload = ContractsThreadRuntimeModeSetPayloadSchema;
export const ThreadInteractionModeSetPayload = ContractsThreadInteractionModeSetPayloadSchema;
export const ThreadDeletedPayload = ContractsThreadDeletedPayloadSchema;
export const ThreadUnarchivedPayload = ContractsThreadUnarchivedPayloadSchema;
export const ThreadUnsettledPayload = ContractsThreadUnsettledPayloadSchema;
export const MessageSentPayloadSchema = ContractsThreadMessageSentPayloadSchema;
export const ThreadProposedPlanUpsertedPayload = ContractsThreadProposedPlanUpsertedPayloadSchema;
@@ -68,8 +68,6 @@ const readModel: OrchestrationReadModel = {
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
latestTurn: null,
messages: [],
session: null,
@@ -93,8 +91,6 @@ const readModel: OrchestrationReadModel = {
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
latestTurn: null,
messages: [],
session: null,
@@ -1,322 +0,0 @@
import {
CommandId,
EventId,
MessageId,
ProjectId,
ProviderInstanceId,
ThreadId,
type OrchestrationReadModel,
type OrchestrationSession,
type OrchestrationThread,
} from "@t3tools/contracts";
import * as NodeServices from "@effect/platform-node/NodeServices";
import { expect, it } from "@effect/vitest";
import * as Effect from "effect/Effect";
import { decideOrchestrationCommand } from "./decider.ts";
const NOW = "2026-01-01T00:00:00.000Z";
const SETTLED_AT = "2025-12-30T00:00:00.000Z";
function makeReadModel(
settledOverride: OrchestrationThread["settledOverride"],
archivedAt: string | null = null,
): OrchestrationReadModel {
return {
snapshotSequence: 0,
projects: [],
threads: [
{
id: ThreadId.make("thread-1"),
projectId: ProjectId.make("project-1"),
title: "Thread",
modelSelection: { instanceId: ProviderInstanceId.make("codex"), model: "gpt-5.4" },
runtimeMode: "full-access",
interactionMode: "default",
branch: null,
worktreePath: null,
latestTurn: null,
createdAt: NOW,
updatedAt: NOW,
archivedAt,
settledOverride,
settledAt: settledOverride === "settled" ? SETTLED_AT : null,
deletedAt: null,
messages: [],
proposedPlans: [],
activities: [],
checkpoints: [],
session: null,
},
],
updatedAt: NOW,
};
}
function makeSession(status: OrchestrationSession["status"]): OrchestrationSession {
return {
threadId: ThreadId.make("thread-1"),
status,
providerName: "Codex",
runtimeMode: "full-access",
activeTurnId: null,
lastError: null,
updatedAt: NOW,
};
}
it.layer(NodeServices.layer)("settled thread decider", (it) => {
it.effect("settles active threads and re-emits idempotently for settled ones", () =>
Effect.gen(function* () {
const event = yield* decideOrchestrationCommand({
command: {
type: "thread.settle",
commandId: CommandId.make("cmd-settle"),
threadId: ThreadId.make("thread-1"),
},
readModel: makeReadModel(null),
});
const events = Array.isArray(event) ? event : [event];
expect(events).toHaveLength(1);
expect(events[0]?.type).toBe("thread.settled");
if (events[0]?.type === "thread.settled") {
expect(events[0].payload.settledAt).toBe(events[0].payload.updatedAt);
}
// Already settled: the engine rejects zero-event commands, so idempotency
// is by re-emission — preserving the original settledAt.
const reEmit = yield* decideOrchestrationCommand({
command: {
type: "thread.settle",
commandId: CommandId.make("cmd-settle-again"),
threadId: ThreadId.make("thread-1"),
},
readModel: makeReadModel("settled"),
});
const reEmitEvents = Array.isArray(reEmit) ? reEmit : [reEmit];
expect(reEmitEvents).toHaveLength(1);
expect(reEmitEvents[0]?.type).toBe("thread.settled");
if (reEmitEvents[0]?.type === "thread.settled") {
expect(reEmitEvents[0].payload.settledAt).toBe(SETTLED_AT);
expect(reEmitEvents[0].payload.updatedAt).toBe(SETTLED_AT);
}
}),
);
it.effect("rejects settling and unsettling archived threads", () =>
Effect.gen(function* () {
const settleError = yield* decideOrchestrationCommand({
command: {
type: "thread.settle",
commandId: CommandId.make("cmd-settle-archived"),
threadId: ThreadId.make("thread-1"),
},
readModel: makeReadModel(null, NOW),
}).pipe(Effect.flip);
expect(settleError._tag).toBe("OrchestrationCommandInvariantError");
const unsettleError = yield* decideOrchestrationCommand({
command: {
type: "thread.unsettle",
commandId: CommandId.make("cmd-unsettle-archived"),
threadId: ThreadId.make("thread-1"),
reason: "user",
},
readModel: makeReadModel("settled", NOW),
}).pipe(Effect.flip);
expect(unsettleError._tag).toBe("OrchestrationCommandInvariantError");
}),
);
it.effect("maps unsettle reasons to overrides and re-emits idempotently", () =>
Effect.gen(function* () {
const userEvent = yield* decideOrchestrationCommand({
command: {
type: "thread.unsettle",
commandId: CommandId.make("cmd-unsettle-user"),
threadId: ThreadId.make("thread-1"),
reason: "user",
},
readModel: makeReadModel("settled"),
});
const userEvents = Array.isArray(userEvent) ? userEvent : [userEvent];
expect(userEvents).toHaveLength(1);
expect(userEvents[0]?.type).toBe("thread.unsettled");
if (userEvents[0]?.type === "thread.unsettled") {
expect(userEvents[0].payload.reason).toBe("user");
}
// Re-dispatching against the already-reached state re-emits rather than
// producing zero events (the engine rejects empty commands).
const userAgain = yield* decideOrchestrationCommand({
command: {
type: "thread.unsettle",
commandId: CommandId.make("cmd-unsettle-user-again"),
threadId: ThreadId.make("thread-1"),
reason: "user",
},
readModel: makeReadModel("active"),
});
const userAgainEvents = Array.isArray(userAgain) ? userAgain : [userAgain];
expect(userAgainEvents).toHaveLength(1);
expect(userAgainEvents[0]?.type).toBe("thread.unsettled");
}),
);
it.effect("prepends activity unsets for turn starts and live session updates", () =>
Effect.gen(function* () {
const turnResult = yield* decideOrchestrationCommand({
command: {
type: "thread.turn.start",
commandId: CommandId.make("cmd-turn-start"),
threadId: ThreadId.make("thread-1"),
message: {
messageId: MessageId.make("message-1"),
role: "user",
text: "Continue",
attachments: [],
},
runtimeMode: "full-access",
interactionMode: "default",
createdAt: NOW,
},
readModel: makeReadModel("settled"),
});
const turnEvents = Array.isArray(turnResult) ? turnResult : [turnResult];
expect(turnEvents.map((event) => event.type)).toEqual([
"thread.unsettled",
"thread.message-sent",
"thread.turn-start-requested",
]);
const sessionResult = yield* decideOrchestrationCommand({
command: {
type: "thread.session.set",
commandId: CommandId.make("cmd-session-set"),
threadId: ThreadId.make("thread-1"),
session: makeSession("running"),
createdAt: NOW,
},
readModel: makeReadModel("active"),
});
const sessionEvents = Array.isArray(sessionResult) ? sessionResult : [sessionResult];
expect(sessionEvents.map((event) => event.type)).toEqual(["thread.session-set"]);
}),
);
it.effect("preserves an explicit active override during activity", () =>
Effect.gen(function* () {
const turnResult = yield* decideOrchestrationCommand({
command: {
type: "thread.turn.start",
commandId: CommandId.make("cmd-active-turn-start"),
threadId: ThreadId.make("thread-1"),
message: {
messageId: MessageId.make("message-active"),
role: "user",
text: "Continue",
attachments: [],
},
runtimeMode: "full-access",
interactionMode: "default",
createdAt: NOW,
},
readModel: makeReadModel("active"),
});
const turnEvents = Array.isArray(turnResult) ? turnResult : [turnResult];
expect(turnEvents.map((event) => event.type)).toEqual([
"thread.message-sent",
"thread.turn-start-requested",
]);
const activityResult = yield* decideOrchestrationCommand({
command: {
type: "thread.activity.append",
commandId: CommandId.make("cmd-active-approval"),
threadId: ThreadId.make("thread-1"),
activity: {
id: EventId.make("activity-active"),
tone: "approval",
kind: "approval.requested",
summary: "Command approval requested",
payload: null,
turnId: null,
createdAt: NOW,
},
createdAt: NOW,
},
readModel: makeReadModel("active"),
});
const activityEvents = Array.isArray(activityResult) ? activityResult : [activityResult];
expect(activityEvents.map((event) => event.type)).toEqual(["thread.activity-appended"]);
}),
);
it.effect("does not unsettle for session stop/error status writes", () =>
Effect.gen(function* () {
for (const status of ["stopped", "error", "ready", "idle"] as const) {
const result = yield* decideOrchestrationCommand({
command: {
type: "thread.session.set",
commandId: CommandId.make(`cmd-session-${status}`),
threadId: ThreadId.make("thread-1"),
session: makeSession(status),
createdAt: NOW,
},
readModel: makeReadModel("settled"),
});
const events = Array.isArray(result) ? result : [result];
expect(events.map((event) => event.type)).toEqual(["thread.session-set"]);
}
}),
);
it.effect("unsettles for approval and user-input activities but not others", () =>
Effect.gen(function* () {
const approvalResult = yield* decideOrchestrationCommand({
command: {
type: "thread.activity.append",
commandId: CommandId.make("cmd-activity-approval"),
threadId: ThreadId.make("thread-1"),
activity: {
id: EventId.make("activity-1"),
tone: "approval",
kind: "approval.requested",
summary: "Command approval requested",
payload: null,
turnId: null,
createdAt: NOW,
},
createdAt: NOW,
},
readModel: makeReadModel("settled"),
});
const approvalEvents = Array.isArray(approvalResult) ? approvalResult : [approvalResult];
expect(approvalEvents.map((event) => event.type)).toEqual([
"thread.unsettled",
"thread.activity-appended",
]);
const routineResult = yield* decideOrchestrationCommand({
command: {
type: "thread.activity.append",
commandId: CommandId.make("cmd-activity-routine"),
threadId: ThreadId.make("thread-1"),
activity: {
id: EventId.make("activity-2"),
tone: "info",
kind: "tool.completed",
summary: "Tool completed",
payload: null,
turnId: null,
createdAt: NOW,
},
createdAt: NOW,
},
readModel: makeReadModel("settled"),
});
const routineEvents = Array.isArray(routineResult) ? routineResult : [routineResult];
expect(routineEvents.map((event) => event.type)).toEqual(["thread.activity-appended"]);
}),
);
});
+5 -123
View File
@@ -312,61 +312,6 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
};
}
case "thread.settle": {
const thread = yield* requireThreadNotArchived({
readModel,
command,
threadId: command.threadId,
});
const occurredAt = yield* nowIso;
// Settling an already-settled thread re-emits with the original
// settledAt: the engine rejects zero-event commands, and bulk-settle /
// double-click must stay silent no-ops rather than surface errors.
const settledAt =
thread.settledOverride === "settled" && thread.settledAt !== null
? thread.settledAt
: occurredAt;
return {
...(yield* withEventBase({
aggregateKind: "thread",
aggregateId: command.threadId,
occurredAt,
commandId: command.commandId,
})),
type: "thread.settled",
payload: {
threadId: command.threadId,
settledAt,
updatedAt: settledAt,
},
};
}
case "thread.unsettle": {
yield* requireThreadNotArchived({
readModel,
command,
threadId: command.threadId,
});
// Idempotent by re-emission (see thread.settle): reducing the event a
// second time lands on the same override state.
const occurredAt = yield* nowIso;
return {
...(yield* withEventBase({
aggregateKind: "thread",
aggregateId: command.threadId,
occurredAt,
commandId: command.commandId,
})),
type: "thread.unsettled",
payload: {
threadId: command.threadId,
reason: command.reason,
updatedAt: occurredAt,
},
};
}
case "thread.meta.update": {
const thread = yield* requireThread({
readModel,
@@ -519,24 +464,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
createdAt: command.createdAt,
},
};
if (targetThread.settledOverride !== "settled") {
return [userMessageEvent, turnStartRequestedEvent];
}
const unsettledEvent: Omit<OrchestrationEvent, "sequence"> = {
...(yield* withEventBase({
aggregateKind: "thread",
aggregateId: command.threadId,
occurredAt: command.createdAt,
commandId: command.commandId,
})),
type: "thread.unsettled",
payload: {
threadId: command.threadId,
reason: "activity",
updatedAt: command.createdAt,
},
};
return [unsettledEvent, userMessageEvent, turnStartRequestedEvent];
return [userMessageEvent, turnStartRequestedEvent];
}
case "thread.turn.interrupt": {
@@ -657,12 +585,12 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
}
case "thread.session.set": {
const thread = yield* requireThread({
yield* requireThread({
readModel,
command,
threadId: command.threadId,
});
const sessionSetEvent: Omit<OrchestrationEvent, "sequence"> = {
return {
...(yield* withEventBase({
aggregateKind: "thread",
aggregateId: command.threadId,
@@ -676,29 +604,6 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
session: command.session,
},
};
// Only a session coming alive is activity worth waking a settled thread
// for — status writes like ready/stopped/error arrive after the fact and
// must not fight a user's explicit settle.
const isSessionActivity =
command.session.status === "starting" || command.session.status === "running";
if (thread.settledOverride !== "settled" || !isSessionActivity) {
return sessionSetEvent;
}
const unsettledEvent: Omit<OrchestrationEvent, "sequence"> = {
...(yield* withEventBase({
aggregateKind: "thread",
aggregateId: command.threadId,
occurredAt: command.createdAt,
commandId: command.commandId,
})),
type: "thread.unsettled",
payload: {
threadId: command.threadId,
reason: "activity",
updatedAt: command.createdAt,
},
};
return [unsettledEvent, sessionSetEvent];
}
case "thread.message.assistant.delta": {
@@ -825,7 +730,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
}
case "thread.activity.append": {
const thread = yield* requireThread({
yield* requireThread({
readModel,
command,
threadId: command.threadId,
@@ -838,7 +743,7 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
? ((command.activity.payload as { requestId: string })
.requestId as OrchestrationEvent["metadata"]["requestId"])
: undefined;
const activityAppendedEvent: Omit<OrchestrationEvent, "sequence"> = {
return {
...(yield* withEventBase({
aggregateKind: "thread",
aggregateId: command.threadId,
@@ -852,29 +757,6 @@ export const decideOrchestrationCommand = Effect.fn("decideOrchestrationCommand"
activity: command.activity,
},
};
// An approval or user-input request is blocked-on-you work — it must
// never stay hidden inside a settled slim row.
const wakesSettledThread =
command.activity.kind === "approval.requested" ||
command.activity.kind === "user-input.requested";
if (thread.settledOverride !== "settled" || !wakesSettledThread) {
return activityAppendedEvent;
}
const unsettledEvent: Omit<OrchestrationEvent, "sequence"> = {
...(yield* withEventBase({
aggregateKind: "thread",
aggregateId: command.threadId,
occurredAt: command.createdAt,
commandId: command.commandId,
})),
type: "thread.unsettled",
payload: {
threadId: command.threadId,
reason: "activity",
updatedAt: command.createdAt,
},
};
return [unsettledEvent, activityAppendedEvent];
}
default: {
@@ -1,88 +0,0 @@
import {
CommandId,
EventId,
ProjectId,
ThreadId,
type OrchestrationEvent,
} from "@t3tools/contracts";
import { expect, it } from "@effect/vitest";
import * as Effect from "effect/Effect";
import { createEmptyReadModel, projectEvent } from "./projector.ts";
function makeEvent(input: {
readonly sequence: number;
readonly type: OrchestrationEvent["type"];
readonly payload: unknown;
}): OrchestrationEvent {
return {
sequence: input.sequence,
eventId: EventId.make(`event-${input.sequence}`),
type: input.type,
aggregateKind: "thread",
aggregateId: ThreadId.make("thread-1"),
occurredAt: "2026-01-01T00:00:00.000Z",
commandId: CommandId.make(`command-${input.sequence}`),
causationEventId: null,
correlationId: null,
metadata: {},
payload: input.payload as never,
} as OrchestrationEvent;
}
it.effect("projects settled lifecycle events", () =>
Effect.gen(function* () {
const now = "2026-01-01T00:00:00.000Z";
const created = yield* projectEvent(
createEmptyReadModel(now),
makeEvent({
sequence: 1,
type: "thread.created",
payload: {
threadId: ThreadId.make("thread-1"),
projectId: ProjectId.make("project-1"),
title: "Thread",
modelSelection: { provider: "codex", model: "gpt-5.4" },
runtimeMode: "full-access",
interactionMode: "default",
branch: null,
worktreePath: null,
createdAt: now,
updatedAt: now,
},
}),
);
const settled = yield* projectEvent(
created,
makeEvent({
sequence: 2,
type: "thread.settled",
payload: { threadId: ThreadId.make("thread-1"), settledAt: now, updatedAt: now },
}),
);
expect(settled.threads[0]?.settledOverride).toBe("settled");
expect(settled.threads[0]?.settledAt).toBe(now);
const userUnsettled = yield* projectEvent(
settled,
makeEvent({
sequence: 3,
type: "thread.unsettled",
payload: { threadId: ThreadId.make("thread-1"), reason: "user", updatedAt: now },
}),
);
expect(userUnsettled.threads[0]?.settledOverride).toBe("active");
expect(userUnsettled.threads[0]?.settledAt).toBeNull();
const activityUnsettled = yield* projectEvent(
userUnsettled,
makeEvent({
sequence: 4,
type: "thread.unsettled",
payload: { threadId: ThreadId.make("thread-1"), reason: "activity", updatedAt: now },
}),
);
expect(activityUnsettled.threads[0]?.settledOverride).toBeNull();
expect(activityUnsettled.threads[0]?.settledAt).toBeNull();
}),
);
@@ -89,8 +89,6 @@ describe("orchestration projector", () => {
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
deletedAt: null,
messages: [],
proposedPlans: [],
@@ -22,9 +22,7 @@ import {
ThreadMetaUpdatedPayload,
ThreadProposedPlanUpsertedPayload,
ThreadRuntimeModeSetPayload,
ThreadSettledPayload,
ThreadUnarchivedPayload,
ThreadUnsettledPayload,
ThreadRevertedPayload,
ThreadSessionSetPayload,
ThreadTurnDiffCompletedPayload,
@@ -288,8 +286,6 @@ export function projectEvent(
createdAt: payload.createdAt,
updatedAt: payload.updatedAt,
archivedAt: null,
settledOverride: null,
settledAt: null,
deletedAt: null,
messages: [],
activities: [],
@@ -341,30 +337,6 @@ export function projectEvent(
})),
);
case "thread.settled":
return decodeForEvent(ThreadSettledPayload, event.payload, event.type, "payload").pipe(
Effect.map((payload) => ({
...nextBase,
threads: updateThread(nextBase.threads, payload.threadId, {
settledOverride: "settled",
settledAt: payload.settledAt,
updatedAt: payload.updatedAt,
}),
})),
);
case "thread.unsettled":
return decodeForEvent(ThreadUnsettledPayload, event.payload, event.type, "payload").pipe(
Effect.map((payload) => ({
...nextBase,
threads: updateThread(nextBase.threads, payload.threadId, {
settledOverride: payload.reason === "user" ? "active" : null,
settledAt: null,
updatedAt: payload.updatedAt,
}),
})),
);
case "thread.meta-updated":
return decodeForEvent(ThreadMetaUpdatedPayload, event.payload, event.type, "payload").pipe(
Effect.map((payload) => ({
@@ -91,8 +91,6 @@ projectionRepositoriesLayer("Projection repositories", (it) => {
createdAt: "2026-03-24T00:00:00.000Z",
updatedAt: "2026-03-24T00:00:00.000Z",
archivedAt: null,
settledOverride: null,
settledAt: null,
latestUserMessageAt: null,
pendingApprovalCount: 0,
pendingUserInputCount: 0,
@@ -43,8 +43,6 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
created_at,
updated_at,
archived_at,
settled_override,
settled_at,
latest_user_message_at,
pending_approval_count,
pending_user_input_count,
@@ -64,8 +62,6 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
${row.createdAt},
${row.updatedAt},
${row.archivedAt},
${row.settledOverride},
${row.settledAt},
${row.latestUserMessageAt},
${row.pendingApprovalCount},
${row.pendingUserInputCount},
@@ -85,8 +81,6 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
created_at = excluded.created_at,
updated_at = excluded.updated_at,
archived_at = excluded.archived_at,
settled_override = excluded.settled_override,
settled_at = excluded.settled_at,
latest_user_message_at = excluded.latest_user_message_at,
pending_approval_count = excluded.pending_approval_count,
pending_user_input_count = excluded.pending_user_input_count,
@@ -113,8 +107,6 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
created_at AS "createdAt",
updated_at AS "updatedAt",
archived_at AS "archivedAt",
settled_override AS "settledOverride",
settled_at AS "settledAt",
latest_user_message_at AS "latestUserMessageAt",
pending_approval_count AS "pendingApprovalCount",
pending_user_input_count AS "pendingUserInputCount",
@@ -143,8 +135,6 @@ const makeProjectionThreadRepository = Effect.gen(function* () {
created_at AS "createdAt",
updated_at AS "updatedAt",
archived_at AS "archivedAt",
settled_override AS "settledOverride",
settled_at AS "settledAt",
latest_user_message_at AS "latestUserMessageAt",
pending_approval_count AS "pendingApprovalCount",
pending_user_input_count AS "pendingUserInputCount",
@@ -45,7 +45,6 @@ import Migration0029 from "./Migrations/029_ProjectionThreadDetailOrderingIndexe
import Migration0030 from "./Migrations/030_ProjectionThreadShellArchiveIndexes.ts";
import Migration0031 from "./Migrations/031_AuthAuthorizationScopes.ts";
import Migration0032 from "./Migrations/032_AuthPairingProofKeyThumbprint.ts";
import Migration0033 from "./Migrations/033_ProjectionThreadsSettled.ts";
/**
* Migration loader with all migrations defined inline.
@@ -90,7 +89,6 @@ export const migrationEntries = [
[30, "ProjectionThreadShellArchiveIndexes", Migration0030],
[31, "AuthAuthorizationScopes", Migration0031],
[32, "AuthPairingProofKeyThumbprint", Migration0032],
[33, "ProjectionThreadsSettled", Migration0033],
] as const;
export const makeMigrationLoader = (throughId?: number) =>
@@ -1,23 +0,0 @@
import * as Effect from "effect/Effect";
import * as SqlClient from "effect/unstable/sql/SqlClient";
export default Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient;
const columns = yield* sql<{ readonly name: string }>`
PRAGMA table_info(projection_threads)
`;
if (!columns.some((column) => column.name === "settled_override")) {
yield* sql`
ALTER TABLE projection_threads
ADD COLUMN settled_override TEXT
`;
}
if (!columns.some((column) => column.name === "settled_at")) {
yield* sql`
ALTER TABLE projection_threads
ADD COLUMN settled_at TEXT
`;
}
});
@@ -36,8 +36,6 @@ export const ProjectionThread = Schema.Struct({
createdAt: IsoDateTime,
updatedAt: IsoDateTime,
archivedAt: Schema.NullOr(IsoDateTime),
settledOverride: Schema.NullOr(Schema.Literals(["settled", "active"])),
settledAt: Schema.NullOr(IsoDateTime),
latestUserMessageAt: Schema.NullOr(IsoDateTime),
pendingApprovalCount: NonNegativeInt,
pendingUserInputCount: NonNegativeInt,
@@ -100,8 +100,6 @@ function makeReadModel(
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
latestUserMessageAt: null,
hasPendingApprovals: false,
hasPendingUserInput: false,
@@ -305,8 +305,6 @@ describe.sequential("signRelayAgentActivityPublishProof", () => {
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
session: null,
latestUserMessageAt: null,
hasPendingApprovals: false,
@@ -453,8 +451,6 @@ describe.sequential("signRelayAgentActivityPublishProof", () => {
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
session: {
threadId,
status: "running",
@@ -610,8 +606,6 @@ describe.sequential("signRelayAgentActivityPublishProof", () => {
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
session: {
threadId,
status: "running",
-6
View File
@@ -163,8 +163,6 @@ const makeDefaultOrchestrationReadModel = () => {
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
latestTurn: null,
messages: [],
session: null,
@@ -194,8 +192,6 @@ const makeDefaultOrchestrationThreadShell = (
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
session: null,
latestUserMessageAt: null,
hasPendingApprovals: false,
@@ -5499,8 +5495,6 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
latestTurn: null,
messages: [],
session: null,
@@ -42,8 +42,6 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
createdAt: now,
updatedAt: now,
archivedAt: null,
settledOverride: null,
settledAt: null,
deletedAt: null,
latestTurn: null,
branch: null,
@@ -45,8 +45,6 @@ export function buildLocalDraftThread(
createdAt: draftThread.createdAt,
updatedAt: draftThread.createdAt,
archivedAt: null,
settledOverride: null,
settledAt: null,
deletedAt: null,
latestTurn: null,
branch: draftThread.branch,
@@ -24,8 +24,6 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
proposedPlans: [],
createdAt: "2026-03-01T00:00:00.000Z",
archivedAt: null,
settledOverride: null,
settledAt: null,
deletedAt: null,
updatedAt: "2026-03-01T00:00:00.000Z",
latestTurn: null,
@@ -910,8 +910,6 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
proposedPlans: [],
createdAt: "2026-03-09T10:00:00.000Z",
archivedAt: null,
settledOverride: null,
settledAt: null,
deletedAt: null,
updatedAt: "2026-03-09T10:00:00.000Z",
latestTurn: null,
+39 -6
View File
@@ -43,6 +43,10 @@ import { readLocalApi } from "../localApi";
import { useUiStateStore } from "../uiStateStore";
import { useThreadSelectionStore } from "../threadSelectionStore";
import { useThreadActions } from "../hooks/useThreadActions";
import {
refreshArchivedThreadsForEnvironment,
useArchivedThreadSnapshots,
} from "../lib/archivedThreadsState";
import { useHandleNewThread } from "../hooks/useHandleNewThread";
import { useOpenAddProjectCommandPalette } from "../commandPaletteContext";
import { onOpenNewThreadPicker } from "../newThreadPickerBus";
@@ -702,14 +706,37 @@ export default function SidebarV2() {
}
}, [projectScopeKey, projects]);
// Archived threads ARE the settled tail in the client-only settled model,
// but the live shell stream drops a thread the moment it is archived
// (thread.archived → thread-removed). Merge them back in from the archived
// snapshot query; live shells win on the (brief) overlap.
const archivedEnvironmentIds = useMemo(
() => environments.map((environment) => environment.environmentId),
[environments],
);
const { snapshots: archivedSnapshots } = useArchivedThreadSnapshots(archivedEnvironmentIds);
const allThreads = useMemo(() => {
const liveKeys = new Set(
threads.map((thread) => scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id))),
);
const archived = archivedSnapshots.flatMap(({ environmentId, snapshot }) =>
snapshot.threads
.map((thread) => ({ ...thread, environmentId }))
.filter(
(thread) =>
!liveKeys.has(scopedThreadKey(scopeThreadRef(thread.environmentId, thread.id))),
),
);
return [...threads, ...archived];
}, [archivedSnapshots, threads]);
const { activeThreads, settledThreads } = useMemo(() => {
const now = `${nowMinute}:00.000Z`;
const visible = threads.filter(
const visible = allThreads.filter(
(thread) =>
thread.archivedAt === null &&
(scopedProject === null ||
(thread.environmentId === scopedProject.environmentId &&
thread.projectId === scopedProject.id)),
scopedProject === null ||
(thread.environmentId === scopedProject.environmentId &&
thread.projectId === scopedProject.id),
);
const active: EnvironmentThreadShell[] = [];
const settled: EnvironmentThreadShell[] = [];
@@ -730,7 +757,7 @@ export default function SidebarV2() {
Date.parse(left.latestUserMessageAt ?? left.updatedAt),
),
};
}, [autoSettleAfterDays, changeRequestStateByKey, nowMinute, scopedProject, threads]);
}, [allThreads, autoSettleAfterDays, changeRequestStateByKey, nowMinute, scopedProject]);
const orderedThreads = useMemo(
() => [...activeThreads, ...settledThreads],
@@ -877,7 +904,11 @@ export default function SidebarV2() {
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
return;
}
// Settle = archive: the shell stream drops the thread, so pull the
// archived snapshot immediately to keep it visible as a settled row.
refreshArchivedThreadsForEnvironment(threadRef.environmentId);
})();
},
[settleThread],
@@ -895,7 +926,9 @@ export default function SidebarV2() {
description: error instanceof Error ? error.message : "An error occurred.",
}),
);
return;
}
refreshArchivedThreadsForEnvironment(threadRef.environmentId);
})();
},
[unsettleThread],
+6 -4
View File
@@ -54,10 +54,12 @@ export function useThreadActions() {
const deleteThreadMutation = useAtomCommand(threadEnvironment.delete, {
reportFailure: false,
});
const settleThreadMutation = useAtomCommand(threadEnvironment.settle, {
// Client-only settled model: settle/unsettle ride the pre-existing archive
// lifecycle so no server upgrade is required. See threadSettled.ts.
const settleThreadMutation = useAtomCommand(threadEnvironment.archive, {
reportFailure: false,
});
const unsettleThreadMutation = useAtomCommand(threadEnvironment.unsettle, {
const unsettleThreadMutation = useAtomCommand(threadEnvironment.unarchive, {
reportFailure: false,
});
const stopThreadSession = useAtomCommand(threadEnvironment.stopSession);
@@ -416,7 +418,7 @@ export function useThreadActions() {
const stillOrphaned =
getOrphanedWorktreePathForThread(currentThreads, threadRef.threadId) ===
orphanedWorktreePath;
const stillSettled = currentShell?.settledOverride === "settled";
const stillSettled = currentShell?.archivedAt != null;
if (!stillOrphaned || !stillSettled) {
toastManager.add(
stackedThreadToast({
@@ -485,7 +487,7 @@ export function useThreadActions() {
(target: ScopedThreadRef) =>
unsettleThreadMutation({
environmentId: target.environmentId,
input: { threadId: target.threadId, reason: "user" },
input: { threadId: target.threadId },
}),
[unsettleThreadMutation],
);
-2
View File
@@ -26,8 +26,6 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
proposedPlans: [],
createdAt: "2026-03-09T10:00:00.000Z",
archivedAt: null,
settledOverride: null,
settledAt: null,
deletedAt: null,
updatedAt: "2026-03-09T10:00:00.000Z",
latestTurn: null,
-2
View File
@@ -30,8 +30,6 @@ function makeThread(overrides: Partial<Thread> = {}): Thread {
createdAt: "2026-02-13T00:00:00.000Z",
updatedAt: "2026-02-13T00:00:00.000Z",
archivedAt: null,
settledOverride: null,
settledAt: null,
deletedAt: null,
latestTurn: null,
branch: null,
@@ -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({
-49
View File
@@ -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"),