feat(orchestration): track provider retries and thread visits

- Project retry progress and recovery for Codex and Claude turns
- Sync thread completion markers through server-side visit timestamps
This commit is contained in:
Julius Marminge committed 2026-08-07 13:27:21 +02:00
1 parent a04e807333
commit 844dad005a
73 files changed
+3918 -1273

No files matched your search

@@ -57,6 +57,39 @@ describe("isOrchestrationV2TurnItemVisible", () => {
).toBe(true);
});
it("hides queued user messages once their run is cancelled", () => {
expect(
isOrchestrationV2TurnItemVisible({
item: { type: "user_message", inputIntent: "queued_turn", runId, nodeId },
runs: [{ id: runId, status: "cancelled" }],
attempts: [],
items: [{ type: "user_message", inputIntent: "queued_turn", runId, nodeId }],
}),
).toBe(false);
});
it("keeps queued user messages while their run is queued", () => {
expect(
isOrchestrationV2TurnItemVisible({
item: { type: "user_message", inputIntent: "queued_turn", runId, nodeId },
runs: [{ id: runId, status: "queued" }],
attempts: [],
items: [{ type: "user_message", inputIntent: "queued_turn", runId, nodeId }],
}),
).toBe(true);
});
it("keeps non-queued user messages on cancelled runs", () => {
expect(
isOrchestrationV2TurnItemVisible({
item: { type: "user_message", inputIntent: "turn_start", runId, nodeId },
runs: [{ id: runId, status: "cancelled" }],
attempts: [],
items: [{ type: "user_message", inputIntent: "turn_start", runId, nodeId }],
}),
).toBe(true);
});
it("does not hide an interruption because another attempt was superseded", () => {
expect(
isOrchestrationV2TurnItemVisible({
+16 -1
View File
@@ -2,11 +2,14 @@ import type {
OrchestrationV2Run,
OrchestrationV2RunAttempt,
OrchestrationV2TurnItem,
OrchestrationV2UserMessageInputIntent,
} from "@t3tools/contracts";
type TimelineRun = Pick<OrchestrationV2Run, "id" | "status">;
type TimelineRunAttempt = Pick<OrchestrationV2RunAttempt, "runId" | "rootNodeId" | "status">;
type TimelineTurnItem = Pick<OrchestrationV2TurnItem, "type" | "runId" | "nodeId">;
type TimelineTurnItem = Pick<OrchestrationV2TurnItem, "type" | "runId" | "nodeId"> & {
readonly inputIntent?: OrchestrationV2UserMessageInputIntent;
};
export function isOrchestrationV2SupersededInterrupt(input: {
readonly item: TimelineTurnItem;
@@ -50,6 +53,18 @@ export function isOrchestrationV2TurnItemVisible(input: {
return false;
}
// A queued message is composer state, not conversation history. When its run
// is cancelled the input never reached the provider, so it must not surface
// as a transcript row.
if (
item.type === "user_message" &&
item.inputIntent === "queued_turn" &&
item.runId !== null &&
input.runs.some((run) => run.id === item.runId && run.status === "cancelled")
) {
return false;
}
return !isOrchestrationV2SupersededInterrupt({
item,
attempts: input.attempts,
@@ -35,6 +35,17 @@ describe("resolveT3McpToolPresentation", () => {
});
});
it("pretty prints preview T3 MCP tool names", () => {
expect(resolveT3McpToolPresentation("T3-code.preview_open")).toEqual({
displayName: "Open a page in the preview browser",
logo: "t3-code",
});
expect(resolveT3McpToolPresentation("mcp__t3-code__preview_status")).toEqual({
displayName: "Get preview browser status",
logo: "t3-code",
});
});
it("keeps unknown MCP tools on the generic renderer path", () => {
expect(resolveT3McpToolPresentation("mcp__github__search_issues")).toBeNull();
});
+18 -2
View File
@@ -25,6 +25,20 @@ const T3_MCP_TOOL_DISPLAY_NAMES: Record<string, string> = {
t3_thread_interrupt: "Interrupt a T3 thread",
t3_worktree_handoff: "Hand off thread to a git worktree",
t3_worktree_status: "Get thread worktree status",
preview_status: "Get preview browser status",
preview_open: "Open a page in the preview browser",
preview_navigate: "Navigate the preview browser",
preview_snapshot: "Snapshot the preview page",
preview_click: "Click in the preview browser",
preview_press: "Press a key in the preview browser",
preview_type: "Type in the preview browser",
preview_scroll: "Scroll the preview browser",
preview_resize: "Resize the preview browser",
preview_evaluate: "Evaluate script in the preview browser",
preview_wait_for: "Wait for the preview page",
preview_set_appearance: "Set preview browser appearance",
preview_recording_start: "Start recording the preview browser",
preview_recording_stop: "Stop recording the preview browser",
};
function normalizeT3McpToolLabel(value: string): string {
@@ -36,12 +50,14 @@ function resolveT3McpToolName(value: string): string | null {
const mcpMatch = /^mcp__(?<server>.+?)__(?<tool>.+)$/.exec(label);
if (mcpMatch?.groups) {
const { server, tool } = mcpMatch.groups;
return server !== undefined && tool !== undefined && T3_MCP_SERVER_ALIASES.has(server)
return server !== undefined &&
tool !== undefined &&
T3_MCP_SERVER_ALIASES.has(server.toLowerCase())
? tool
: null;
}
const namespaceMatch = /^(?<server>t3-code|t3_code|t3code)[.:/](?<tool>.+)$/.exec(label);
const namespaceMatch = /^(?<server>t3-code|t3_code|t3code)[.:/](?<tool>.+)$/i.exec(label);
if (namespaceMatch?.groups) {
return namespaceMatch.groups.tool ?? null;
}