fix(claude): emit plan events for TodoWrite during input streaming (#1541)
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]> Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: codex <[email protected]>
This commit is contained in:
10 files changed
+288
-29
No files matched your search
@@ -465,6 +465,7 @@ function runtimeEventToActivities(
|
||||
payload: {
|
||||
itemType: event.payload.itemType,
|
||||
...(event.payload.detail ? { detail: truncateDetail(event.payload.detail) } : {}),
|
||||
...(event.payload.data !== undefined ? { data: event.payload.data } : {}),
|
||||
},
|
||||
turnId: toTurnId(event.turnId) ?? null,
|
||||
...maybeSequence,
|
||||
|
||||
@@ -966,6 +966,97 @@ describe("ClaudeAdapterLive", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.effect("falls back to a default plan step label for blank TodoWrite content", () => {
|
||||
const harness = makeHarness();
|
||||
return Effect.gen(function* () {
|
||||
const adapter = yield* ClaudeAdapter;
|
||||
|
||||
const runtimeEventsFiber = yield* Stream.take(adapter.streamEvents, 10).pipe(
|
||||
Stream.runCollect,
|
||||
Effect.forkChild,
|
||||
);
|
||||
|
||||
const session = yield* adapter.startSession({
|
||||
threadId: THREAD_ID,
|
||||
provider: "claudeAgent",
|
||||
runtimeMode: "full-access",
|
||||
});
|
||||
|
||||
const turn = yield* adapter.sendTurn({
|
||||
threadId: session.threadId,
|
||||
input: "hello",
|
||||
attachments: [],
|
||||
});
|
||||
|
||||
harness.query.emit({
|
||||
type: "stream_event",
|
||||
session_id: "sdk-session-todo-plan",
|
||||
uuid: "stream-todo-start",
|
||||
parent_tool_use_id: null,
|
||||
event: {
|
||||
type: "content_block_start",
|
||||
index: 1,
|
||||
content_block: {
|
||||
type: "tool_use",
|
||||
id: "tool-todo-1",
|
||||
name: "TodoWrite",
|
||||
input: {},
|
||||
},
|
||||
},
|
||||
} as unknown as SDKMessage);
|
||||
|
||||
harness.query.emit({
|
||||
type: "stream_event",
|
||||
session_id: "sdk-session-todo-plan",
|
||||
uuid: "stream-todo-input",
|
||||
parent_tool_use_id: null,
|
||||
event: {
|
||||
type: "content_block_delta",
|
||||
index: 1,
|
||||
delta: {
|
||||
type: "input_json_delta",
|
||||
partial_json:
|
||||
'{"todos":[{"content":" ","status":"in_progress"},{"content":"Ship it","status":"completed"}]}',
|
||||
},
|
||||
},
|
||||
} as unknown as SDKMessage);
|
||||
|
||||
harness.query.emit({
|
||||
type: "stream_event",
|
||||
session_id: "sdk-session-todo-plan",
|
||||
uuid: "stream-todo-stop",
|
||||
parent_tool_use_id: null,
|
||||
event: {
|
||||
type: "content_block_stop",
|
||||
index: 1,
|
||||
},
|
||||
} as unknown as SDKMessage);
|
||||
|
||||
harness.query.emit({
|
||||
type: "result",
|
||||
subtype: "success",
|
||||
is_error: false,
|
||||
errors: [],
|
||||
session_id: "sdk-session-todo-plan",
|
||||
uuid: "result-todo-plan",
|
||||
} as unknown as SDKMessage);
|
||||
|
||||
const runtimeEvents = Array.from(yield* Fiber.join(runtimeEventsFiber));
|
||||
const planUpdated = runtimeEvents.find((event) => event.type === "turn.plan.updated");
|
||||
assert.equal(planUpdated?.type, "turn.plan.updated");
|
||||
if (planUpdated?.type === "turn.plan.updated") {
|
||||
assert.equal(String(planUpdated.turnId), String(turn.turnId));
|
||||
assert.deepEqual(planUpdated.payload.plan, [
|
||||
{ step: "Task", status: "inProgress" },
|
||||
{ step: "Ship it", status: "completed" },
|
||||
]);
|
||||
}
|
||||
}).pipe(
|
||||
Effect.provideService(Random.Random, makeDeterministicRandomService()),
|
||||
Effect.provide(harness.layer),
|
||||
);
|
||||
});
|
||||
|
||||
it.effect("classifies Claude Task tool invocations as collaboration agent work", () => {
|
||||
const harness = makeHarness();
|
||||
return Effect.gen(function* () {
|
||||
|
||||
@@ -459,6 +459,34 @@ function classifyRequestType(toolName: string): CanonicalRequestType {
|
||||
: "dynamic_tool_call";
|
||||
}
|
||||
|
||||
function isTodoTool(toolName: string): boolean {
|
||||
return toolName.toLowerCase().includes("todowrite");
|
||||
}
|
||||
|
||||
type PlanStep = { step: string; status: "pending" | "inProgress" | "completed" };
|
||||
|
||||
function extractPlanStepsFromTodoInput(input: Record<string, unknown>): PlanStep[] | null {
|
||||
// TodoWrite format: { todos: [{ content, status, activeForm? }] }
|
||||
const todos = input.todos;
|
||||
if (!Array.isArray(todos) || todos.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return todos
|
||||
.filter((t): t is Record<string, unknown> => t !== null && typeof t === "object")
|
||||
.map((todo) => ({
|
||||
step:
|
||||
typeof todo.content === "string" && todo.content.trim().length > 0
|
||||
? todo.content.trim()
|
||||
: "Task",
|
||||
status:
|
||||
todo.status === "completed"
|
||||
? "completed"
|
||||
: todo.status === "in_progress"
|
||||
? "inProgress"
|
||||
: "pending",
|
||||
}));
|
||||
}
|
||||
|
||||
function summarizeToolRequest(toolName: string, input: Record<string, unknown>): string {
|
||||
const commandValue = input.command ?? input.cmd;
|
||||
const command = typeof commandValue === "string" ? commandValue : undefined;
|
||||
@@ -466,6 +494,20 @@ function summarizeToolRequest(toolName: string, input: Record<string, unknown>):
|
||||
return `${toolName}: ${command.trim().slice(0, 400)}`;
|
||||
}
|
||||
|
||||
// For agent/subagent tools, prefer human-readable description or prompt over raw JSON
|
||||
const itemType = classifyToolItemType(toolName);
|
||||
if (itemType === "collab_agent_tool_call") {
|
||||
const description =
|
||||
typeof input.description === "string" ? input.description.trim() : undefined;
|
||||
const prompt = typeof input.prompt === "string" ? input.prompt.trim() : undefined;
|
||||
const subagentType =
|
||||
typeof input.subagent_type === "string" ? input.subagent_type.trim() : undefined;
|
||||
const label = description || (prompt ? prompt.slice(0, 200) : undefined);
|
||||
if (label) {
|
||||
return subagentType ? `${subagentType}: ${label}` : label;
|
||||
}
|
||||
}
|
||||
|
||||
const serialized = JSON.stringify(input);
|
||||
if (serialized.length <= 400) {
|
||||
return `${toolName}: ${serialized}`;
|
||||
@@ -1616,6 +1658,26 @@ const makeClaudeAdapter = Effect.fn("makeClaudeAdapter")(function* (
|
||||
payload: message,
|
||||
},
|
||||
});
|
||||
|
||||
// Emit plan update when TodoWrite input is parsed
|
||||
if (parsedInput && isTodoTool(nextTool.toolName)) {
|
||||
const planSteps = extractPlanStepsFromTodoInput(parsedInput);
|
||||
if (planSteps && planSteps.length > 0) {
|
||||
const planStamp = yield* makeEventStamp();
|
||||
yield* offerRuntimeEvent({
|
||||
type: "turn.plan.updated",
|
||||
eventId: planStamp.eventId,
|
||||
provider: PROVIDER,
|
||||
createdAt: planStamp.createdAt,
|
||||
threadId: context.session.threadId,
|
||||
...(context.turnState ? { turnId: asCanonicalTurnId(context.turnState.turnId) } : {}),
|
||||
payload: {
|
||||
plan: planSteps,
|
||||
},
|
||||
providerRefs: nativeProviderRefs(context),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1107,6 +1107,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
() => deriveActivePlanState(threadActivities, activeLatestTurn?.turnId ?? undefined),
|
||||
[activeLatestTurn?.turnId, threadActivities],
|
||||
);
|
||||
const planSidebarLabel = sidebarProposedPlan || interactionMode === "plan" ? "Plan" : "Tasks";
|
||||
const showPlanFollowUpPrompt =
|
||||
pendingUserInputs.length === 0 &&
|
||||
interactionMode === "plan" &&
|
||||
@@ -1888,10 +1889,8 @@ export default function ChatView(props: ChatViewProps) {
|
||||
const togglePlanSidebar = useCallback(() => {
|
||||
setPlanSidebarOpen((open) => {
|
||||
if (open) {
|
||||
const turnKey = activePlan?.turnId ?? sidebarProposedPlan?.turnId ?? null;
|
||||
if (turnKey) {
|
||||
planSidebarDismissedForTurnRef.current = turnKey;
|
||||
}
|
||||
planSidebarDismissedForTurnRef.current =
|
||||
activePlan?.turnId ?? sidebarProposedPlan?.turnId ?? "__dismissed__";
|
||||
} else {
|
||||
planSidebarDismissedForTurnRef.current = null;
|
||||
}
|
||||
@@ -1989,6 +1988,18 @@ export default function ChatView(props: ChatViewProps) {
|
||||
planSidebarDismissedForTurnRef.current = null;
|
||||
}, [activeThread?.id]);
|
||||
|
||||
// Auto-open the plan sidebar when plan/todo steps arrive for the current turn.
|
||||
// Don't auto-open for plans carried over from a previous turn (the user can open manually).
|
||||
useEffect(() => {
|
||||
if (!activePlan) return;
|
||||
if (planSidebarOpen) return;
|
||||
const latestTurnId = activeLatestTurn?.turnId ?? null;
|
||||
if (latestTurnId && activePlan.turnId !== latestTurnId) return;
|
||||
const turnKey = activePlan.turnId ?? sidebarProposedPlan?.turnId ?? "__dismissed__";
|
||||
if (planSidebarDismissedForTurnRef.current === turnKey) return;
|
||||
setPlanSidebarOpen(true);
|
||||
}, [activePlan, activeLatestTurn?.turnId, planSidebarOpen, sidebarProposedPlan?.turnId]);
|
||||
|
||||
useEffect(() => {
|
||||
setIsRevertingCheckpoint(false);
|
||||
}, [activeThread?.id]);
|
||||
@@ -3298,6 +3309,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
activeProposedPlan={activeProposedPlan}
|
||||
activePlan={activePlan as { turnId?: TurnId } | null}
|
||||
sidebarProposedPlan={sidebarProposedPlan as { turnId?: TurnId } | null}
|
||||
planSidebarLabel={planSidebarLabel}
|
||||
planSidebarOpen={planSidebarOpen}
|
||||
runtimeMode={runtimeMode}
|
||||
interactionMode={interactionMode}
|
||||
@@ -3386,6 +3398,7 @@ export default function ChatView(props: ChatViewProps) {
|
||||
<PlanSidebar
|
||||
activePlan={activePlan}
|
||||
activeProposedPlan={sidebarProposedPlan}
|
||||
label={planSidebarLabel}
|
||||
environmentId={environmentId}
|
||||
markdownCwd={gitCwd ?? undefined}
|
||||
workspaceRoot={activeWorkspaceRoot}
|
||||
@@ -3393,10 +3406,8 @@ export default function ChatView(props: ChatViewProps) {
|
||||
onClose={() => {
|
||||
setPlanSidebarOpen(false);
|
||||
// Track that the user explicitly dismissed for this turn so auto-open won't fight them.
|
||||
const turnKey = activePlan?.turnId ?? sidebarProposedPlan?.turnId ?? null;
|
||||
if (turnKey) {
|
||||
planSidebarDismissedForTurnRef.current = turnKey;
|
||||
}
|
||||
planSidebarDismissedForTurnRef.current =
|
||||
activePlan?.turnId ?? sidebarProposedPlan?.turnId ?? "__dismissed__";
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -54,6 +54,7 @@ function stepStatusIcon(status: string): React.ReactNode {
|
||||
interface PlanSidebarProps {
|
||||
activePlan: ActivePlanState | null;
|
||||
activeProposedPlan: LatestProposedPlanState | null;
|
||||
label?: string;
|
||||
environmentId: EnvironmentId;
|
||||
markdownCwd: string | undefined;
|
||||
workspaceRoot: string | undefined;
|
||||
@@ -64,6 +65,7 @@ interface PlanSidebarProps {
|
||||
const PlanSidebar = memo(function PlanSidebar({
|
||||
activePlan,
|
||||
activeProposedPlan,
|
||||
label = "Plan",
|
||||
environmentId,
|
||||
markdownCwd,
|
||||
workspaceRoot,
|
||||
@@ -129,7 +131,7 @@ const PlanSidebar = memo(function PlanSidebar({
|
||||
variant="secondary"
|
||||
className="rounded-md bg-blue-500/10 px-1.5 py-0 text-[10px] font-semibold tracking-wide text-blue-400 uppercase"
|
||||
>
|
||||
Plan
|
||||
{label}
|
||||
</Badge>
|
||||
{activePlan ? (
|
||||
<span className="text-[11px] text-muted-foreground/60">
|
||||
@@ -170,7 +172,7 @@ const PlanSidebar = memo(function PlanSidebar({
|
||||
size="icon-xs"
|
||||
variant="ghost"
|
||||
onClick={onClose}
|
||||
aria-label="Close plan sidebar"
|
||||
aria-label={`Close ${label.toLowerCase()} sidebar`}
|
||||
className="text-muted-foreground/50 hover:text-foreground/70"
|
||||
>
|
||||
<PanelRightCloseIcon className="size-3.5" />
|
||||
|
||||
@@ -162,6 +162,7 @@ const ComposerFooterModeControls = memo(function ComposerFooterModeControls(prop
|
||||
interactionMode: ProviderInteractionMode;
|
||||
runtimeMode: RuntimeMode;
|
||||
showPlanToggle: boolean;
|
||||
planSidebarLabel: string;
|
||||
planSidebarOpen: boolean;
|
||||
onToggleInteractionMode: () => void;
|
||||
onRuntimeModeChange: (mode: RuntimeMode) => void;
|
||||
@@ -243,10 +244,14 @@ const ComposerFooterModeControls = memo(function ComposerFooterModeControls(prop
|
||||
size="sm"
|
||||
type="button"
|
||||
onClick={props.onTogglePlanSidebar}
|
||||
title={props.planSidebarOpen ? "Hide plan sidebar" : "Show plan sidebar"}
|
||||
title={
|
||||
props.planSidebarOpen
|
||||
? `Hide ${props.planSidebarLabel.toLowerCase()} sidebar`
|
||||
: `Show ${props.planSidebarLabel.toLowerCase()} sidebar`
|
||||
}
|
||||
>
|
||||
<ListTodoIcon />
|
||||
<span className="sr-only sm:not-sr-only">Plan</span>
|
||||
<span className="sr-only sm:not-sr-only">{props.planSidebarLabel}</span>
|
||||
</Button>
|
||||
</>
|
||||
) : null}
|
||||
@@ -380,6 +385,7 @@ export interface ChatComposerProps {
|
||||
activeProposedPlan: Thread["proposedPlans"][number] | null;
|
||||
activePlan: { turnId?: TurnId } | null;
|
||||
sidebarProposedPlan: { turnId?: TurnId } | null;
|
||||
planSidebarLabel: string;
|
||||
planSidebarOpen: boolean;
|
||||
|
||||
// Mode
|
||||
@@ -474,6 +480,7 @@ export const ChatComposer = memo(
|
||||
activeProposedPlan,
|
||||
activePlan,
|
||||
sidebarProposedPlan,
|
||||
planSidebarLabel,
|
||||
planSidebarOpen,
|
||||
runtimeMode,
|
||||
interactionMode,
|
||||
@@ -1923,6 +1930,7 @@ export const ChatComposer = memo(
|
||||
<CompactComposerControlsMenu
|
||||
activePlan={showPlanSidebarToggle}
|
||||
interactionMode={interactionMode}
|
||||
planSidebarLabel={planSidebarLabel}
|
||||
planSidebarOpen={planSidebarOpen}
|
||||
runtimeMode={runtimeMode}
|
||||
traitsMenuContent={providerTraitsMenuContent}
|
||||
@@ -1945,6 +1953,7 @@ export const ChatComposer = memo(
|
||||
interactionMode={interactionMode}
|
||||
runtimeMode={runtimeMode}
|
||||
showPlanToggle={showPlanSidebarToggle}
|
||||
planSidebarLabel={planSidebarLabel}
|
||||
planSidebarOpen={planSidebarOpen}
|
||||
onToggleInteractionMode={toggleInteractionMode}
|
||||
onRuntimeModeChange={handleRuntimeModeChange}
|
||||
|
||||
@@ -123,6 +123,7 @@ async function mountMenu(props?: { modelSelection?: ModelSelection; prompt?: str
|
||||
<CompactComposerControlsMenu
|
||||
activePlan={false}
|
||||
interactionMode="default"
|
||||
planSidebarLabel="Plan"
|
||||
planSidebarOpen={false}
|
||||
runtimeMode="approval-required"
|
||||
traitsMenuContent={
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
export const CompactComposerControlsMenu = memo(function CompactComposerControlsMenu(props: {
|
||||
activePlan: boolean;
|
||||
interactionMode: ProviderInteractionMode;
|
||||
planSidebarLabel: string;
|
||||
planSidebarOpen: boolean;
|
||||
runtimeMode: RuntimeMode;
|
||||
traitsMenuContent?: ReactNode;
|
||||
@@ -72,7 +73,9 @@ export const CompactComposerControlsMenu = memo(function CompactComposerControls
|
||||
<MenuDivider />
|
||||
<MenuItem onClick={props.onTogglePlanSidebar}>
|
||||
<ListTodoIcon className="size-4 shrink-0" />
|
||||
{props.planSidebarOpen ? "Hide plan sidebar" : "Show plan sidebar"}
|
||||
{props.planSidebarOpen
|
||||
? `Hide ${props.planSidebarLabel.toLowerCase()} sidebar`
|
||||
: `Show ${props.planSidebarLabel.toLowerCase()} sidebar`}
|
||||
</MenuItem>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
@@ -343,6 +343,30 @@ describe("deriveActivePlanState", () => {
|
||||
steps: [{ step: "Implement Codex user input", status: "inProgress" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to the most recent plan from a previous turn", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "plan-from-turn-1",
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
kind: "turn.plan.updated",
|
||||
summary: "Plan updated",
|
||||
tone: "info",
|
||||
turnId: "turn-1",
|
||||
payload: {
|
||||
plan: [{ step: "Write tests", status: "completed" }],
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
// Current turn is turn-2, which has no plan activity — should fall back to turn-1's plan
|
||||
const result = deriveActivePlanState(activities, TurnId.make("turn-2"));
|
||||
expect(result).toEqual({
|
||||
createdAt: "2026-02-23T00:00:01.000Z",
|
||||
turnId: "turn-1",
|
||||
steps: [{ step: "Write tests", status: "completed" }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("findLatestProposedPlan", () => {
|
||||
@@ -568,7 +592,7 @@ describe("deriveWorkLogEntries", () => {
|
||||
expect(entries.map((entry) => entry.id)).toEqual(["tool-complete"]);
|
||||
});
|
||||
|
||||
it("omits task start and completion lifecycle entries", () => {
|
||||
it("omits task.started but shows task.progress and task.completed", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "task-start",
|
||||
@@ -594,7 +618,40 @@ describe("deriveWorkLogEntries", () => {
|
||||
];
|
||||
|
||||
const entries = deriveWorkLogEntries(activities, undefined);
|
||||
expect(entries.map((entry) => entry.id)).toEqual(["task-progress"]);
|
||||
expect(entries.map((entry) => entry.id)).toEqual(["task-progress", "task-complete"]);
|
||||
});
|
||||
|
||||
it("uses payload summary as label for task entries when available", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "task-progress-with-summary",
|
||||
createdAt: "2026-02-23T00:00:02.000Z",
|
||||
kind: "task.progress",
|
||||
summary: "Reasoning update",
|
||||
tone: "info",
|
||||
payload: { summary: "Searching for API endpoints" },
|
||||
}),
|
||||
];
|
||||
|
||||
const entries = deriveWorkLogEntries(activities, undefined);
|
||||
expect(entries[0]?.label).toBe("Searching for API endpoints");
|
||||
});
|
||||
|
||||
it("uses payload detail as label for task.completed and preserves error tone", () => {
|
||||
const activities: OrchestrationThreadActivity[] = [
|
||||
makeActivity({
|
||||
id: "task-completed-failed",
|
||||
createdAt: "2026-02-23T00:00:03.000Z",
|
||||
kind: "task.completed",
|
||||
summary: "Task failed",
|
||||
tone: "error",
|
||||
payload: { detail: "Failed to deploy changes" },
|
||||
}),
|
||||
];
|
||||
|
||||
const entries = deriveWorkLogEntries(activities, undefined);
|
||||
expect(entries[0]?.label).toBe("Failed to deploy changes");
|
||||
expect(entries[0]?.tone).toBe("error");
|
||||
});
|
||||
|
||||
it("filters by turn id when provided", () => {
|
||||
|
||||
@@ -348,16 +348,15 @@ export function deriveActivePlanState(
|
||||
latestTurnId: TurnId | undefined,
|
||||
): ActivePlanState | null {
|
||||
const ordered = [...activities].toSorted(compareActivitiesByOrder);
|
||||
const candidates = ordered.filter((activity) => {
|
||||
if (activity.kind !== "turn.plan.updated") {
|
||||
return false;
|
||||
}
|
||||
if (!latestTurnId) {
|
||||
return true;
|
||||
}
|
||||
return activity.turnId === latestTurnId;
|
||||
});
|
||||
const latest = candidates.at(-1);
|
||||
const allPlanActivities = ordered.filter((activity) => activity.kind === "turn.plan.updated");
|
||||
// Prefer plan from the current turn; fall back to the most recent plan from any turn
|
||||
// so that TodoWrite tasks persist across follow-up messages.
|
||||
const latest =
|
||||
(latestTurnId
|
||||
? allPlanActivities.filter((activity) => activity.turnId === latestTurnId).at(-1)
|
||||
: undefined) ??
|
||||
allPlanActivities.at(-1) ??
|
||||
null;
|
||||
if (!latest) {
|
||||
return null;
|
||||
}
|
||||
@@ -472,7 +471,7 @@ export function deriveWorkLogEntries(
|
||||
const entries = ordered
|
||||
.filter((activity) => (latestTurnId ? activity.turnId === latestTurnId : true))
|
||||
.filter((activity) => activity.kind !== "tool.started")
|
||||
.filter((activity) => activity.kind !== "task.started" && activity.kind !== "task.completed")
|
||||
.filter((activity) => activity.kind !== "task.started")
|
||||
.filter((activity) => activity.kind !== "context-window.updated")
|
||||
.filter((activity) => activity.summary !== "Checkpoint captured")
|
||||
.filter((activity) => !isPlanBoundaryToolActivity(activity))
|
||||
@@ -502,16 +501,39 @@ function toDerivedWorkLogEntry(activity: OrchestrationThreadActivity): DerivedWo
|
||||
const commandPreview = extractToolCommand(payload);
|
||||
const changedFiles = extractChangedFiles(payload);
|
||||
const title = extractToolTitle(payload);
|
||||
const isTaskActivity = activity.kind === "task.progress" || activity.kind === "task.completed";
|
||||
const taskSummary =
|
||||
isTaskActivity && typeof payload?.summary === "string" && payload.summary.length > 0
|
||||
? payload.summary
|
||||
: null;
|
||||
const taskDetailAsLabel =
|
||||
isTaskActivity &&
|
||||
!taskSummary &&
|
||||
typeof payload?.detail === "string" &&
|
||||
payload.detail.length > 0
|
||||
? payload.detail
|
||||
: null;
|
||||
const taskLabel = taskSummary || taskDetailAsLabel;
|
||||
const entry: DerivedWorkLogEntry = {
|
||||
id: activity.id,
|
||||
createdAt: activity.createdAt,
|
||||
label: activity.summary,
|
||||
tone: activity.tone === "approval" ? "info" : activity.tone,
|
||||
label: taskLabel || activity.summary,
|
||||
tone:
|
||||
activity.kind === "task.progress"
|
||||
? "thinking"
|
||||
: activity.tone === "approval"
|
||||
? "info"
|
||||
: activity.tone,
|
||||
activityKind: activity.kind,
|
||||
};
|
||||
const itemType = extractWorkLogItemType(payload);
|
||||
const requestKind = extractWorkLogRequestKind(payload);
|
||||
if (payload && typeof payload.detail === "string" && payload.detail.length > 0) {
|
||||
if (
|
||||
!taskDetailAsLabel &&
|
||||
payload &&
|
||||
typeof payload.detail === "string" &&
|
||||
payload.detail.length > 0
|
||||
) {
|
||||
const detail = stripTrailingExitCode(payload.detail).output;
|
||||
if (detail) {
|
||||
entry.detail = detail;
|
||||
|
||||
Reference in new issue
Block a user