fix: port main fixes stranded by the v2 rewrite

- Port thread pinning (#5312) into the orchestration-v2 command pipeline:
  thread.pin/unpin commands, thread.pinned/unpinned events, pinnedAt on the
  v2 thread state and projected shells, promotion semantics (pin clears
  settle/snooze, settle clears pin) matching the v1 decider, and client
  pin/unpin operations in the v2 dispatch style.
- Port the regenerated-title context anchoring (#5365) into
  ThreadTitleRegenerationService: pin the first user message ahead of the
  retained tail when the digest is truncated.
- Re-apply the right-panel controls positioning from #5260 to the v2
  ChatView title bar controls.
- Repair merge artifacts: committed conflict markers in BranchToolbar,
  duplicate capability keys, duplicate CommandPalette import, v1 turn
  naming in DiffPanel's focus-refresh effect, onSend signature merge.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Fable 5 committed 2026-08-14 11:23:32 +02:00
1 parent d7e5a004f5
commit 01a1dec618
16 files changed
+233 -65

No files matched your search

@@ -153,7 +153,6 @@ export const make = Effect.gen(function* () {
threadPinReorder: true,
threadTitleRegeneration: true,
threadVisitedTracking: true,
threadTitleRegeneration: true,
...(serverSelfUpdate === null ? {} : { serverSelfUpdate }),
...(serverSelfUpdate === "boot-service" ? { serverSelfUpdateProgress: true } : {}),
},
@@ -195,6 +195,8 @@ function commandThreadId(command: OrchestrationV2Command): ThreadId {
case "thread.unsettle":
case "thread.snooze":
case "thread.unsnooze":
case "thread.pin":
case "thread.unpin":
case "thread.visit":
case "thread.mark-unread":
case "thread.metadata.update":
@@ -1342,6 +1344,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
| "thread.unsettle"
| "thread.snooze"
| "thread.unsnooze"
| "thread.pin"
| "thread.unpin"
| "thread.visit"
| "thread.mark-unread"
| "thread.metadata.update"
@@ -1401,7 +1405,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
(command.type === "thread.settle" ||
command.type === "thread.unsettle" ||
command.type === "thread.snooze" ||
command.type === "thread.unsnooze") &&
command.type === "thread.unsnooze" ||
command.type === "thread.pin" ||
command.type === "thread.unpin") &&
thread.archivedAt !== null
) {
return yield* new OrchestratorDispatchError({
@@ -1514,11 +1520,16 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
updatedAt: now,
};
case "thread.settle": {
const alreadySettled = thread.settledOverride === "settled" && thread.settledAt !== null;
// Settling is "I'm done with this": it clears a pin the same way it
// parks the thread (mirrors the v1 decider's settle/pin exclusion).
const wasPinned = thread.pinnedAt != null;
const alreadySettled =
thread.settledOverride === "settled" && thread.settledAt !== null && !wasPinned;
return {
...thread,
settledOverride: "settled",
settledAt: alreadySettled ? thread.settledAt : now,
pinnedAt: null,
updatedAt: alreadySettled ? thread.updatedAt : now,
};
}
@@ -1553,6 +1564,31 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
updatedAt: alreadyAwake ? thread.updatedAt : now,
};
}
case "thread.pin": {
// Pinning is a promotion: it clears the parked states rather than
// silently outranking them — an explicit settle is un-settled and a
// snooze's return ticket is spent (the thread is on top NOW).
const alreadyPinned = thread.pinnedAt != null;
const promotes = thread.settledOverride === "settled" || thread.snoozedUntil != null;
return {
...thread,
pinnedAt: alreadyPinned ? thread.pinnedAt : now,
settledOverride:
thread.settledOverride === "settled" ? "active" : thread.settledOverride,
settledAt: thread.settledOverride === "settled" ? null : thread.settledAt,
snoozedUntil: null,
snoozedAt: null,
updatedAt: alreadyPinned && !promotes ? thread.updatedAt : now,
};
}
case "thread.unpin": {
const alreadyUnpinned = thread.pinnedAt == null;
return {
...thread,
pinnedAt: null,
updatedAt: alreadyUnpinned ? thread.updatedAt : now,
};
}
// Visited tracking records read state only; it must not bump updatedAt,
// otherwise viewing a thread would count as activity (and re-trigger the
// clients that dispatch thread.visit whenever updatedAt advances).
@@ -1620,6 +1656,10 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
return "thread.snoozed" as const;
case "thread.unsnooze":
return "thread.unsnoozed" as const;
case "thread.pin":
return "thread.pinned" as const;
case "thread.unpin":
return "thread.unpinned" as const;
case "thread.visit":
return "thread.visited" as const;
case "thread.mark-unread":
@@ -6650,6 +6690,8 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
case "thread.unsettle":
case "thread.snooze":
case "thread.unsnooze":
case "thread.pin":
case "thread.unpin":
case "thread.visit":
case "thread.mark-unread":
case "thread.metadata.update":
@@ -230,6 +230,8 @@ export const layer: Layer.Layer<
"thread.unsettled",
"thread.snoozed",
"thread.unsnoozed",
"thread.pinned",
"thread.unpinned",
"thread.metadata-updated",
"thread.runtime-mode-updated",
"thread.interaction-mode-updated",
@@ -206,6 +206,8 @@ export function applyToProjection(
case "thread.unsettled":
case "thread.snoozed":
case "thread.unsnoozed":
case "thread.pinned":
case "thread.unpinned":
case "thread.metadata-updated":
case "thread.runtime-mode-updated":
case "thread.interaction-mode-updated":
@@ -896,6 +898,7 @@ export function threadShellFromProjection(
settledAt: projection.thread.settledAt,
snoozedUntil: projection.thread.snoozedUntil ?? null,
snoozedAt: projection.thread.snoozedAt ?? null,
pinnedAt: projection.thread.pinnedAt ?? null,
lastVisitedAt: projection.thread.lastVisitedAt,
titleRegeneration: projection.thread.titleRegeneration ?? null,
deletedAt: projection.thread.deletedAt,
@@ -1065,6 +1068,7 @@ function shellFromState(input: {
settledAt: input.state.thread.settledAt,
snoozedUntil: input.state.thread.snoozedUntil ?? null,
snoozedAt: input.state.thread.snoozedAt ?? null,
pinnedAt: input.state.thread.pinnedAt ?? null,
lastVisitedAt: input.state.thread.lastVisitedAt,
titleRegeneration: input.state.thread.titleRegeneration ?? null,
deletedAt: input.state.thread.deletedAt,
@@ -1087,6 +1091,8 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
case "thread.unsettled":
case "thread.snoozed":
case "thread.unsnoozed":
case "thread.pinned":
case "thread.unpinned":
case "thread.visited":
case "thread.marked-unread":
case "thread.metadata-updated":
@@ -1886,6 +1892,8 @@ export const layer: Layer.Layer<ProjectionStoreV2, never, SqlClient.SqlClient> =
event.type !== "thread.unsettled" &&
event.type !== "thread.snoozed" &&
event.type !== "thread.unsnoozed" &&
event.type !== "thread.pinned" &&
event.type !== "thread.unpinned" &&
event.type !== "thread.visited" &&
event.type !== "thread.marked-unread" &&
event.type !== "thread.metadata-updated" &&
@@ -173,15 +173,26 @@ describe("formatThreadTitleContext", () => {
);
});
it("marks truncation once older content stops fitting the budget", () => {
it("pins the first user message ahead of the retained tail once content stops fitting", () => {
const context = formatThreadTitleContext([
{ role: "user", text: `Ancient context that no longer fits ${"x".repeat(600)}` },
{ role: "user", text: `Ancient context that anchors the topic ${"x".repeat(600)}` },
{ role: "assistant", text: "y".repeat(6_000) },
{ role: "user", text: "z".repeat(1_500) },
]);
assert.isTrue(context.message.startsWith("[Earlier content truncated]\n\n"));
assert.isFalse(context.message.includes("Ancient context"));
assert.isTrue(context.message.includes("ASSISTANT:"));
assert.isTrue(context.message.startsWith("USER:\nAncient context that anchors the topic"));
assert.isTrue(context.message.includes("[Earlier content truncated]\n\n"));
assert.isTrue(context.message.includes("y".repeat(100)));
});
it("truncates an oversized pinned first user message", () => {
const context = formatThreadTitleContext([
{ role: "user", text: `Topic anchor ${"a".repeat(4_000)}` },
{ role: "assistant", text: "y".repeat(9_000) },
{ role: "user", text: "z".repeat(1_500) },
]);
assert.isTrue(context.message.startsWith("USER:\nTopic anchor"));
assert.isTrue(context.message.includes("[First user message truncated]"));
assert.isTrue(context.message.includes("[Earlier content truncated]\n\n"));
});
it("retains at most four attachments from the newest messages", () => {
@@ -195,7 +206,7 @@ describe("formatThreadTitleContext", () => {
]);
assert.deepEqual(
context.attachments.map((entry) => entry.name),
["c.png", "d.png", "e.png", "a.png"],
["b.png", "c.png", "d.png", "e.png"],
);
});
});
@@ -20,62 +20,127 @@ import { ThreadManagementService } from "./ThreadManagementService.ts";
const MAX_REGENERATION_ATTACHMENTS = 4;
const MAX_THREAD_TITLE_CONTEXT_CHARS = 8_000;
const MAX_FIRST_USER_TITLE_CONTEXT_CHARS = 2_000;
const THREAD_TITLE_CONTEXT_TRUNCATION_MARKER = "[Earlier content truncated]\n\n";
const FIRST_USER_CONTEXT_TRUNCATION_MARKER = "\n[First user message truncated]";
/**
* Newest-first conversation digest for the title prompt: walk messages from
* the end, keep whole sections while they fit the char budget, and mark
* truncation once older content stops fitting. Ported from the v1 reactor's
* regeneration flow.
*/
export function formatThreadTitleContext(
messages: ReadonlyArray<{
readonly role: "user" | "assistant" | "system";
readonly text: string;
readonly attachments?: ReadonlyArray<ChatAttachment> | undefined;
}>,
type ThreadTitleMessage = {
readonly role: "user" | "assistant" | "system";
readonly text: string;
readonly attachments?: ReadonlyArray<ChatAttachment> | undefined;
};
function formatThreadTitleSection(message: ThreadTitleMessage): string | undefined {
if (message.role === "system") {
return undefined;
}
const text = message.text.trim();
const attachmentSummary = (message.attachments ?? [])
.map((attachment) => attachment.name)
.join(", ");
const contents = [
...(text.length > 0 ? [text] : []),
...(attachmentSummary.length > 0 ? [`[Attachments: ${attachmentSummary}]`] : []),
].join("\n");
return contents.length > 0 ? `${message.role.toUpperCase()}:\n${contents}` : undefined;
}
function limitFirstUserSection(section: string): string {
if (section.length <= MAX_FIRST_USER_TITLE_CONTEXT_CHARS) {
return section;
}
return `${section.slice(
0,
MAX_FIRST_USER_TITLE_CONTEXT_CHARS - FIRST_USER_CONTEXT_TRUNCATION_MARKER.length,
)}${FIRST_USER_CONTEXT_TRUNCATION_MARKER}`;
}
function collectRecentThreadTitleContext(
messages: ReadonlyArray<ThreadTitleMessage>,
maxChars: number,
): {
readonly message: string;
readonly context: string;
readonly attachments: ReadonlyArray<ChatAttachment>;
readonly truncated: boolean;
} {
let context = "";
let truncated = false;
const retainedAttachments: Array<ChatAttachment> = [];
for (const message of messages.toReversed()) {
if (message.role === "system") {
continue;
}
const text = message.text.trim();
const attachmentSummary = (message.attachments ?? [])
.map((attachment) => attachment.name)
.join(", ");
const contents = [
...(text.length > 0 ? [text] : []),
...(attachmentSummary.length > 0 ? [`[Attachments: ${attachmentSummary}]`] : []),
].join("\n");
if (contents.length === 0) {
const section = formatThreadTitleSection(message);
if (section === undefined) {
continue;
}
const section = `${message.role.toUpperCase()}:\n${contents}`;
const separator = context.length > 0 ? "\n\n" : "";
const available = MAX_THREAD_TITLE_CONTEXT_CHARS - context.length - separator.length;
const available = maxChars - context.length - separator.length;
if (section.length > available) {
if (available > 0) {
context = `${section.slice(-available)}${separator}${context}`;
retainedAttachments.unshift(...(message.attachments ?? []));
}
truncated = true;
break;
}
context = `${section}${separator}${context}`;
for (const attachment of message.attachments ?? []) {
if (retainedAttachments.length < MAX_REGENERATION_ATTACHMENTS) {
retainedAttachments.push(attachment);
}
}
retainedAttachments.unshift(...(message.attachments ?? []));
}
return { context, attachments: retainedAttachments, truncated };
}
/**
* Conversation digest for the title prompt. Recent messages fill the budget
* newest-first; when the conversation no longer fits, the first user message
* is pinned ahead of the recent tail so regenerated titles stay anchored to
* what the thread is actually about. Mirrors the v1 reactor's flow (#5365).
*/
export function formatThreadTitleContext(messages: ReadonlyArray<ThreadTitleMessage>): {
readonly message: string;
readonly attachments: ReadonlyArray<ChatAttachment>;
} {
const recent = collectRecentThreadTitleContext(messages, MAX_THREAD_TITLE_CONTEXT_CHARS);
if (!recent.truncated) {
return {
message: recent.context,
attachments: recent.attachments.slice(-MAX_REGENERATION_ATTACHMENTS),
};
}
const firstUserMessage = messages.find(
(message) => message.role === "user" && formatThreadTitleSection(message),
);
const firstUserSection = firstUserMessage
? formatThreadTitleSection(firstUserMessage)
: undefined;
if (!firstUserMessage || !firstUserSection) {
return {
message: `${THREAD_TITLE_CONTEXT_TRUNCATION_MARKER}${recent.context}`,
attachments: recent.attachments.slice(-MAX_REGENERATION_ATTACHMENTS),
};
}
const pinnedSection = limitFirstUserSection(firstUserSection);
const recentContextBudget =
MAX_THREAD_TITLE_CONTEXT_CHARS -
pinnedSection.length -
"\n\n".length -
THREAD_TITLE_CONTEXT_TRUNCATION_MARKER.length;
const retainedRecent = collectRecentThreadTitleContext(messages, recentContextBudget);
const pinnedAttachment = firstUserMessage.attachments?.[0];
const recentAttachments = retainedRecent.attachments.filter(
(attachment) => attachment.id !== pinnedAttachment?.id,
);
return {
message: truncated ? `${THREAD_TITLE_CONTEXT_TRUNCATION_MARKER}${context}` : context,
attachments: retainedAttachments,
message: `${pinnedSection}\n\n${THREAD_TITLE_CONTEXT_TRUNCATION_MARKER}${retainedRecent.context}`,
attachments: [
...(pinnedAttachment ? [pinnedAttachment] : []),
...recentAttachments.slice(
-(MAX_REGENERATION_ATTACHMENTS - (pinnedAttachment === undefined ? 0 : 1)),
),
],
};
}
@@ -105,6 +105,8 @@ function commandThreadIds(command: OrchestrationV2Command): ReadonlyArray<Thread
case "thread.unsettle":
case "thread.snooze":
case "thread.unsnooze":
case "thread.pin":
case "thread.unpin":
case "thread.visit":
case "thread.mark-unread":
case "thread.metadata.update":
@@ -506,20 +506,12 @@ export const BranchToolbar = memo(function BranchToolbar({
}
return (
<<<<<<< HEAD
<div
ref={setStripElement}
data-compact={labelsOverflow ? "" : undefined}
className="chat-composer-context-strip group/composer-context -mt-4 mx-auto flex w-[calc(100%-2.75rem)] max-w-[calc(48rem-2.75rem)] items-center gap-2 overflow-x-clip overflow-y-visible ps-1 pe-2 pt-5 pb-1"
>
<<<<<<< HEAD
{isMobile && showGitControls ? (
=======
=======
<div className="chat-composer-context-strip -mt-4 mx-auto flex w-[calc(100%-2.75rem)] max-w-[calc(48rem-2.75rem)] items-center gap-2 ps-1 pe-2 pt-5 pb-1">
>>>>>>> 2152c2ebce (fix: reconcile rebase with latest main)
{isMobile ? (
>>>>>>> 0c15987295 (fix: reconcile rebase with latest main)
<MobileRunContextSelector
envLocked={envLocked}
envModeLocked={envModeLocked}
+10 -3
View File
@@ -4963,11 +4963,11 @@ function ChatViewContent(props: ChatViewProps) {
const onSend = async (
e?: { preventDefault: () => void },
dispatchMode: ComposerDispatchMode = "auto",
directAnnotation?: {
annotation: PreviewAnnotationPayload;
image: ComposerImageAttachment | null;
},
dispatchMode: ComposerDispatchMode = "auto",
) => {
e?.preventDefault();
const notifyDirectAnnotationAttached = () => {
@@ -6075,7 +6075,7 @@ function ChatViewContent(props: ChatViewProps) {
configuredUrls={configuredPreviewUrls}
visible
onSendAnnotation={(annotation, image) => {
void onSend(undefined, { annotation, image });
void onSend(undefined, "auto", { annotation, image });
}}
/>
</Suspense>
@@ -6235,7 +6235,14 @@ function ChatViewContent(props: ChatViewProps) {
</div>
);
const panelLayoutControls = (
<div className="workspace-titlebar-controls z-50 gap-1 [-webkit-app-region:no-drag]">
<div
className={cn(
"workspace-titlebar-controls z-50 gap-1 [-webkit-app-region:no-drag]",
rightPanelOpen && !shouldUsePlanSidebarSheet
? "right-2 wco:right-[var(--workspace-controls-right)]"
: "mr-px",
)}
>
{rightPanelOpen && !shouldUsePlanSidebarSheet ? (
<RightPanelMaximizeControl
maximized={rightPanelMaximized}
@@ -96,7 +96,6 @@ import {
resolveProjectPickerTarget,
resolveWslProjectSelection,
} from "../wslPaths";
import { type Project } from "../types";
import {
ADDON_ICON_CLASS,
buildBrowseGroups,
+6 -6
View File
@@ -115,7 +115,7 @@ export default function DiffPanel({
const codeViewRef = useRef<AnnotatableCodeViewHandle>(null);
const lastCompletedTurnRefreshRef = useRef<{
readonly threadKey: string | null;
readonly turnId: TurnId | null;
readonly runId: RunId | null;
} | null>(null);
const routeThreadRef = useParams({
@@ -276,7 +276,7 @@ export default function DiffPanel({
: primaryBranchDiffPreview;
const refreshBranchDiffPreview = branchDiffPreview.refresh;
const canRefreshGitDiff =
isGitRepo && selectedTurnId === null && activeThread != null && activeCwd != null;
isGitRepo && selectedRunId === null && activeThread != null && activeCwd != null;
const activeThreadRefreshKey = routeThreadRef
? `${routeThreadRef.environmentId}:${routeThreadRef.threadId}`
: null;
@@ -291,7 +291,7 @@ export default function DiffPanel({
useEffect(() => {
const current = {
threadKey: activeThreadRefreshKey,
turnId: latestTurn?.turnId ?? null,
runId: latestTurn?.runId ?? null,
};
const previous = lastCompletedTurnRefreshRef.current;
if (!canRefreshGitDiff) {
@@ -301,17 +301,17 @@ export default function DiffPanel({
lastCompletedTurnRefreshRef.current = current;
return;
}
if (previous.turnId === current.turnId) return;
if (previous.runId === current.runId) return;
refreshBranchDiffPreview();
lastCompletedTurnRefreshRef.current = current;
}, [activeThreadRefreshKey, canRefreshGitDiff, latestTurn?.turnId, refreshBranchDiffPreview]);
}, [activeThreadRefreshKey, canRefreshGitDiff, latestTurn?.runId, refreshBranchDiffPreview]);
const selectedGitSource = branchDiffPreview.data?.sources.find(
(source) => source.kind === (selectedGitScope === "unstaged" ? "working-tree" : "branch-range"),
);
const loadDiffFiles = useMemo<FileDiffContentsLoader | undefined>(() => {
const preview = branchDiffPreview.data;
if (selectedTurnId !== null || !activeThread || !preview || !selectedGitSource) {
if (selectedRunId !== null || !activeThread || !preview || !selectedGitSource) {
return undefined;
}
@@ -77,6 +77,9 @@ export interface UnsettleThreadInput extends ThreadCommandInput {
readonly reason: "user";
}
export type PinThreadInput = ThreadCommandInput;
export type UnpinThreadInput = ThreadCommandInput;
export interface SnoozeThreadInput extends ThreadCommandInput {
readonly snoozedUntil: string;
}
@@ -340,7 +343,13 @@ export const createThread = Effect.fn("EnvironmentCommands.createThread")(functi
});
function simpleThreadCommand(
type: "thread.delete" | "thread.archive" | "thread.unarchive" | "thread.settle",
type:
| "thread.delete"
| "thread.archive"
| "thread.unarchive"
| "thread.settle"
| "thread.pin"
| "thread.unpin",
input: ThreadCommandInput,
) {
return allocateCommandId(input).pipe(
@@ -372,6 +381,18 @@ export const settleThread = Effect.fn("EnvironmentCommands.settleThread")(functi
return yield* simpleThreadCommand("thread.settle", input);
});
export const pinThread = Effect.fn("EnvironmentCommands.pinThread")(function* (
input: PinThreadInput,
) {
return yield* simpleThreadCommand("thread.pin", input);
});
export const unpinThread = Effect.fn("EnvironmentCommands.unpinThread")(function* (
input: UnpinThreadInput,
) {
return yield* simpleThreadCommand("thread.unpin", input);
});
export const unsettleThread = Effect.fn("EnvironmentCommands.unsettleThread")(function* (
input: UnsettleThreadInput,
) {
@@ -95,6 +95,7 @@ export interface EnvironmentThreadShell {
readonly settledAt: string | null;
readonly snoozedUntil: string | null;
readonly snoozedAt: string | null;
readonly pinnedAt: string | null;
/**
* Server-tracked visited watermark. `undefined` means the environment's
* server predates visited tracking and clients should fall back to any
@@ -197,6 +198,7 @@ export function presentThreadShell(
settledAt: nullableIso(thread.settledAt),
snoozedUntil: nullableIso(thread.snoozedUntil ?? null),
snoozedAt: nullableIso(thread.snoozedAt ?? null),
pinnedAt: nullableIso(thread.pinnedAt ?? null),
...(thread.lastVisitedAt === undefined
? {}
: { lastVisitedAt: nullableIso(thread.lastVisitedAt) }),
@@ -112,6 +112,8 @@ export function applyOrchestrationV2ProjectionEvent(
case "thread.unsettled":
case "thread.snoozed":
case "thread.unsnoozed":
case "thread.pinned":
case "thread.unpinned":
case "thread.metadata-updated":
case "thread.runtime-mode-updated":
case "thread.interaction-mode-updated":
-3
View File
@@ -72,9 +72,6 @@ export const ExecutionEnvironmentCapabilities = Schema.Struct({
threadSettlement: clients keep their local visited state against
servers that lack this. */
threadVisitedTracking: Schema.optionalKey(Schema.Boolean),
/** Server understands regenerateTitle on thread.meta.update. Absent on
older servers, so clients hide the action instead of sending it. */
threadTitleRegeneration: Schema.optionalKey(Schema.Boolean),
/** The update path clients should offer for this server. Absent on
servers that must be relaunched manually (dev checkouts, Windows
foreground runs, pre-update servers). */
+19
View File
@@ -324,6 +324,7 @@ export const OrchestrationV2AppThread = Schema.Struct({
),
snoozedUntil: Schema.optional(Schema.NullOr(Schema.DateTimeUtc)),
snoozedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtc)),
pinnedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtc)),
lastVisitedAt: Schema.NullOr(Schema.DateTimeUtc).pipe(
Schema.withDecodingDefault(Effect.succeed(null)),
),
@@ -1079,6 +1080,8 @@ export const OrchestrationV2DomainEvent = Schema.Union([
"thread.unsettled",
"thread.snoozed",
"thread.unsnoozed",
"thread.pinned",
"thread.unpinned",
"thread.visited",
"thread.marked-unread",
"thread.metadata-updated",
@@ -1272,6 +1275,8 @@ export const OrchestrationV2ThreadShell = Schema.Struct({
settledAt: Schema.NullOr(Schema.DateTimeUtc),
snoozedUntil: Schema.optional(Schema.NullOr(Schema.DateTimeUtc)),
snoozedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtc)),
/** Omitted by servers that predate thread pinning. */
pinnedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtc)),
/**
* Omitted by servers that predate server-side visited tracking; clients fall
* back to their local visited state when the field is absent.
@@ -1360,6 +1365,7 @@ export const OrchestrationV2AppThreadJson = OrchestrationV2AppThread.mapFields((
),
snoozedUntil: Schema.optional(Schema.NullOr(Schema.DateTimeUtcFromString)),
snoozedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtcFromString)),
pinnedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtcFromString)),
lastVisitedAt: Schema.NullOr(Schema.DateTimeUtcFromString).pipe(
Schema.withDecodingDefault(Effect.succeed(null)),
),
@@ -1742,6 +1748,7 @@ export const OrchestrationV2ThreadShellJson = OrchestrationV2ThreadShell.mapFiel
settledAt: Schema.NullOr(Schema.DateTimeUtcFromString),
snoozedUntil: Schema.optional(Schema.NullOr(Schema.DateTimeUtcFromString)),
snoozedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtcFromString)),
pinnedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtcFromString)),
lastVisitedAt: Schema.optional(Schema.NullOr(Schema.DateTimeUtcFromString)),
deletedAt: Schema.NullOr(Schema.DateTimeUtcFromString),
}));
@@ -1785,6 +1792,8 @@ export const OrchestrationV2DomainEventJson = Schema.Union([
"thread.unsettled",
"thread.snoozed",
"thread.unsnoozed",
"thread.pinned",
"thread.unpinned",
"thread.visited",
"thread.marked-unread",
"thread.metadata-updated",
@@ -1957,6 +1966,16 @@ export const OrchestrationV2Command = Schema.Union([
threadId: ThreadId,
reason: Schema.Literal("user"),
}),
Schema.Struct({
type: Schema.Literal("thread.pin"),
commandId: CommandId,
threadId: ThreadId,
}),
Schema.Struct({
type: Schema.Literal("thread.unpin"),
commandId: CommandId,
threadId: ThreadId,
}),
Schema.Struct({
type: Schema.Literal("thread.visit"),
commandId: CommandId,