Files
PaperClipAI/ui/src/components/task-chat/TaskChatThreadView.tsx
T
DottaandClaude Opus 5.5 3b4c3265ed fix(recovery): offer Try again on a model-unavailable failure and recheck the model first (#21244)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - When a native run fails, the task thread shows a failure marker, and
some markers offer Try again
> - A `native_provider_model_rejected` failure blocks the task for the
person and shows "Model unavailable", but it has no Try again control
> - Recovery must just work: after the person fixes the model, they need
one obvious control that continues the task, and that control must not
start a run that is sure to fail
> - This pull request shows Try again on the "Model unavailable" marker
and makes the retry recheck the selected model before it starts a run
> - The benefit is that the person fixes the model, presses Try again,
and the task completes, and a too-early press explains which setting to
change instead of failing again

## Linked Issue or Issue Description

Refs #21210

**What happened?**
Paid run 43321773136, `recovery.retry-exhausted` (OpenCode,
`openrouter/deepseek/deepseek-v4.1-flash-1017`). The run failed with
`native_provider_model_rejected`. The task stayed blocked and the thread
showed "Model unavailable", but no Try again control appeared
(`task-chat-run-failed-try-again` not found in 30 s). Only the "Run
failed" and "Usage limit reached" markers offer Try again.

**Expected behavior**
The "Model unavailable" marker offers Try again. Pressing it checks the
selected model first. If the provider-rejected model is still selected,
no run starts, and the person sees which setting to change with a link
to it. After the person changes the model, Try again starts one retry of
the original run.

**Steps to reproduce**
1. Set an agent's model to an id the provider rejects.
2. Assign it a task. The run fails with
`native_provider_model_rejected`.
3. Open the task. Before this change, the marker has no Try again.

## What Changed

- `server/src/services/native-runtime/model-rejected-retry.ts`:
`rejectedModelRetryRefusal` reads the model the failed run sent
(`runnerProfileJson.nativeExecutionInput.provider.model`) and the model
a new run would use (the task's model override for its assignee, else
the agent's model). If they are the same, it returns a 409 refusal with
code `native_provider_model_still_unavailable`, the setting to change
(`agent_model` or `task_model_override`) and the rejected model.
- `server/src/routes/agents.ts`: the exact failed-run retry (`POST
/agents/:id/wakeup`, `reason: retry_failed_run`) applies this check
before it queues anything.
- `ui/src/components/task-chat/adjacent-errors.ts`,
`TaskChatThreadView.tsx`: one `isRetryableFailureMarker` rule, now
including "Model unavailable".
- `ui/src/lib/model-retry-refusal.ts`, `ui/src/pages/IssueDetail.tsx`: a
refused retry shows "Model still unavailable" with the server's message
and an "Open <agent> model settings" link to `/agents/<agent>/runtime`.
A task override refusal names the override in the message.
- Eval `recovery.retry-exhausted` (oracle `runtime.retry-exhausted.v7`):
the rejected model stays selected after the failure. The person presses
Try again (409, toast names the model, its link opens the agent's model
settings, no run starts in 20 s, task stays blocked), restores the
working model, presses Try again (202), and the one retry of the
original run uses the working model, saves the brief and completes the
task. 3 runs: failed 1, succeeded 2. The budget-hold and two follow-up
chat phases are removed; the case now tests the model recheck.
`recovery.yaml` context and expected outcome updated, recorded in
`chat-full-catalog-testops-manifest.json` `changedFields`, pinned in its
test, descriptors and inventory digest updated.

## Verification

- RED on master: `TaskChatThread.test.tsx` "offers Try again on a
model-unavailable failure and retries that run" fails (no control).
`agent-live-run-routes.test.ts` "refuses a retry while the rejected
model is still selected and starts no run" fails (the route queues the
run).
- GREEN: both pass. `agent-live-run-routes.test.ts` 101/101.
- `server/src/services/native-runtime/model-rejected-retry.test.ts`
(embedded PostgreSQL), 6/6: refuses while the agent still selects the
rejected model (names the agent setting); names the task override;
allows the retry when the agent or the override now selects another
model, or the run failed for another reason; ignores another company's
run.
- `ui/src/lib/model-retry-refusal.test.ts`: names the setting and links
to `/agents/morgan/runtime`; no link for a task override; other errors
fall through to the generic toast.
- Server `tsc --noEmit` clean. UI `tsc` clean apart from the
pre-existing generated storybook catalog. `node
scripts/check-token-gates.mjs`: clean.
- Eval: `npx vitest run --config tests/runner-e2e/vitest.config.ts
tests/runner-e2e/chat-catalog tests/runner-e2e/chat-catalog-domains
tests/runner-e2e/chat-*.test.ts`: 339 files pass. New calibration
rejects an accepted early retry, a run started while the model is
rejected, a refusal without the model, setting link or blocked task, a
retry that used the old model, and duplicate or missing retries. `pnpm
test:e2e:runner:typecheck`: pass. Manifest test 10/10.
`source-sdk-public-inputs --check`: `changed: false`.
- Paid run: Runner Full-Stack E2E 43338695850 on throwaway branch
`chat-eval/qa-mr-paid`. Result to follow in a comment.

## Risks

- The recheck compares the selected model with the model the provider
rejected. It does not call the provider. A model the provider rejected
stays refused until the person selects another one; a different but also
unsupported model starts a run that fails with the same marker again.
- The refusal message is a toast (15 s). The marker detail still says to
choose a supported model.
- No persisted shape changes; runs saved by older builds carry the same
`runnerProfileJson` field.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude
Code with tool use and code execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 21:42:52 -06:00

494 lines
19 KiB
TypeScript

import { groupImageResources } from "./image-resources";
import { McpAppTurnViews } from "@/components/mcp-app/McpAppTurnViews";
import { TaskBrowserActivity } from "../task-side-panel/TaskBrowserActivity";
import { TaskChatProjectCreatedCard } from "./TaskChatProjectCreatedCard";
import { TaskChatSkillCreatedCard } from "./TaskChatSkillCreatedCard";
import { TaskChatTaskCreatedCard } from "./TaskChatTaskCreatedCard";
import { useMemo, type ReactNode } from "react";
import type { IssueAttachment } from "@paperclipai/shared";
import { cn } from "@/lib/utils";
import { useStreamlinedTaskChatPresentation } from "./presentation-mode";
import type {
TaskChatInteractionItem,
TaskChatItem,
TaskChatMessageItem,
TaskChatRuntimeRequestDecision,
TaskChatRuntimeRequestItem,
} from "./task-chat-model";
import { TaskChatTurn } from "./TaskChatTurn";
import { TaskChatBubble } from "./TaskChatBubble";
import { TaskChatMarker } from "./TaskChatMarker";
import { TaskChatStatusPill } from "./TaskChatStatusPill";
import { TaskChatToolCard } from "./TaskChatToolCard";
import { TaskChatUsageReadout } from "./TaskChatUsageReadout";
import { TaskChatSubagentTree } from "./TaskChatSubagentCard";
import { TaskChatRunnerActivityGroup } from "./TaskChatRunnerActivityGroup";
import { TaskChatActivityPhase } from "./TaskChatActivityPhase";
import { TaskChatThinking } from "./TaskChatThinking";
import { TaskMessageScroller, type ScrollingHistory } from "./TaskMessageScroller";
import { TaskChatProtocolCard } from "./TaskChatProtocolCard";
import { TaskChatProtocolActivityRow } from "./TaskChatProtocolActivityRow";
import { TaskChatPlanPreviewCard } from "./TaskChatPlanPreviewCard";
import { compactAdjacentErrors, isRetryableFailureMarker } from "./adjacent-errors";
import { CoordinatorChatTaskHandoff } from "@/components/coordinator/CoordinatorChatTaskHandoffs";
import { CoordinatorChatDecisionReceipt } from "@/components/coordinator/CoordinatorChatDecisionReceipts";
import { CoordinatorChatPendingQuestion } from "@/components/coordinator/CoordinatorChatPendingQuestions";
const EMPTY_ATTACHMENTS: IssueAttachment[] = [];
interface TaskChatThreadViewProps {
scrollingHistory?: ScrollingHistory;
items: TaskChatItem[];
/**
* Content rendered above the first message INSIDE the scroll viewport (the
* issue header when hosted by the live thread) — it scrolls away with the
* messages instead of staying pinned above the thread.
*/
header?: ReactNode;
onApprovalDecision?: (statusItemId: string, optionId: string) => void;
onRuntimeRequestDecision?: (
item: TaskChatRuntimeRequestItem,
decision: TaskChatRuntimeRequestDecision,
) => void | Promise<void>;
/**
* Renders an interleaved issue-thread interaction (the live thread supplies
* TaskChatInteractionCard bound to its accept/reject handlers). Interaction
* items render nothing without it — the harness has no control plane.
*/
renderInteraction?: (item: TaskChatInteractionItem) => ReactNode;
/**
* Renders the description-as-first-bubble placeholder (PAP-375). The live
* thread binds TaskChatDescriptionBubble to the issue; brief items render
* nothing without it.
*/
renderBrief?: () => ReactNode;
/**
* Renders the copy/👍/👎 action cluster prepended to an agent bubble's footer
* line (PAP-413). The live thread binds it to the feedback-vote API; harness
* fixtures omit it and the bubbles render actionless.
*/
renderMessageActions?: (item: TaskChatMessageItem) => ReactNode;
/** Renders an interrupt action beside a queued human message. */
renderQueuedAction?: (item: TaskChatMessageItem) => ReactNode;
/** Requeues a blocked task from its no-live-execution-path failure surfaces. */
onTryAgainNoLiveExecutionPath?: () => Promise<void> | void;
tryAgainNoLiveExecutionPathPending?: boolean;
onRetryFailedRun?: (runId: string) => Promise<void> | void;
retryFailedRunId?: string | null;
/** Content appended inside the transcript scroller after the settled thread. */
tail?: ReactNode;
/** Optional streaming-aware key when `tail` changes without changing `items`. */
contentKey?: unknown;
className?: string;
/** When false, render the list without the scroll container (e.g. previews). */
scroll?: boolean;
attachments?: IssueAttachment[];
onOpenSkill?: (skillId: string, name: string) => void;
onOpenBrowser?: (browserId: string) => void;
}
function renderItem(
item: TaskChatItem,
onApprovalDecision?: (statusItemId: string, optionId: string) => void,
renderInteraction?: (item: TaskChatInteractionItem) => ReactNode,
renderBrief?: () => ReactNode,
renderMessageActions?: (item: TaskChatMessageItem) => ReactNode,
renderQueuedAction?: (item: TaskChatMessageItem) => ReactNode,
onRuntimeRequestDecision?: (
item: TaskChatRuntimeRequestItem,
decision: TaskChatRuntimeRequestDecision,
) => void | Promise<void>,
activityAppearance: "classic" | "runner" = "classic",
onTryAgainNoLiveExecutionPath?: () => Promise<void> | void,
tryAgainNoLiveExecutionPathPending = false,
retryableMarkerId?: string,
onRetryFailedRun?: (runId: string) => Promise<void> | void,
retryFailedRunId?: string | null,
attachments: IssueAttachment[] = [],
onOpenSkill?: (skillId: string, name: string) => void,
onOpenBrowser?: (browserId: string) => void,
) {
switch (item.kind) {
case "pending_question": return <CoordinatorChatPendingQuestion item={item.question} />;
case "task_handoff": return <CoordinatorChatTaskHandoff handoff={item.handoff} animateEntry={item.animateEntry} />;
case "decision_receipt": return <CoordinatorChatDecisionReceipt receipt={item.receipt} />;
case "browser": return <TaskBrowserActivity browser={item.browser} label={item.label} onOpen={onOpenBrowser} />;
case "project_created": return <TaskChatProjectCreatedCard item={item} />;
case "skill_created": return <TaskChatSkillCreatedCard item={item} onOpen={onOpenSkill} />;
case "task_created": return <TaskChatTaskCreatedCard item={item} />;
case "message": {
// Compute the actions once: the bubble renders them for a runless reply
// (footer = actions + timestamp), while an attached turn hands them to
// TaskChatTurn's `leading` slot so they ride the summary line and stay
// put when the tool history expands (PAP-413). The two paths are mutually
// exclusive at runtime, so only one host ever mounts the node.
const actions = renderMessageActions?.(item);
const attachedTurnItem = item.attachedTurn?.standaloneHeader
? {
...item.attachedTurn,
agentName: item.attachedTurn.agentName ?? item.authorName,
agentIcon: item.attachedTurn.agentIcon ?? item.agentIcon,
agent: item.attachedTurn.agent ?? item.agent,
}
: item.attachedTurn;
const turn = attachedTurnItem ? (
<TaskChatTurn
item={attachedTurnItem}
timestampPrefix={
attachedTurnItem.standaloneHeader ? undefined : item.timestamp
}
leading={attachedTurnItem.standaloneHeader ? undefined : actions}
renderChild={(child) =>
renderItem(
child,
onApprovalDecision,
undefined,
undefined,
undefined,
undefined,
onRuntimeRequestDecision,
item.attachedTurn?.standaloneHeader ? "runner" : "classic",
undefined,
false,
undefined,
undefined,
undefined,
attachments,
onOpenSkill,
onOpenBrowser,
)
}
/>
) : undefined;
// MCP Apps views ride with the reply, outside the folded tool history.
const appViews = item.author === "agent" && item.sourceRunId
? <McpAppTurnViews runId={item.sourceRunId} notBeforeMs={item.createdAtIso ? Date.parse(item.createdAtIso) : undefined} />
: null;
const bubble = (
<TaskChatBubble
item={item}
// Hydration and live-to-durable reconciliation may move a logical
// message between parents. Mounting must never replay a fade.
animateEntry={false}
actions={
item.attachedTurn?.standaloneHeader
? actions
: item.attachedTurn
? undefined
: actions
}
queuedAction={renderQueuedAction?.(item)}
beforeTurn={item.attachedTurn?.standaloneHeader ? <>{turn}{appViews}</> : undefined}
attachedTurn={item.attachedTurn?.standaloneHeader ? undefined : turn}
hideAgentIdentity={Boolean(item.attachedTurn?.standaloneHeader)}
onTryAgainNoLiveExecutionPath={onTryAgainNoLiveExecutionPath}
tryAgainNoLiveExecutionPathPending={
tryAgainNoLiveExecutionPathPending
}
attachments={attachments}
/>
);
return appViews && !item.attachedTurn?.standaloneHeader ? <>{appViews}{bubble}</> : bubble;
}
case "marker":
return (
<TaskChatMarker
item={item}
onTryAgain={
item.id === retryableMarkerId && item.retryable !== false
? item.runId && onRetryFailedRun
? () => onRetryFailedRun(item.runId!)
: onTryAgainNoLiveExecutionPath
: undefined
}
tryAgainPending={
item.runId
? retryFailedRunId === item.runId
: tryAgainNoLiveExecutionPathPending
}
/>
);
case "thinking":
return <TaskChatThinking item={item} />;
case "tool":
return <TaskChatToolCard item={item} />;
case "status":
return (
<TaskChatStatusPill
item={item}
onApprovalDecision={(optionId) =>
onApprovalDecision?.(item.id, optionId)
}
/>
);
case "usage":
return <TaskChatUsageReadout item={item} />;
case "activity_phase":
// Legacy adapter transcripts and native runner transcripts now share the
// same compact activity treatment. Keeping this decision at the common
// renderer boundary also gives old persisted runs the current taxonomy,
// alignment, one-line targets, and collapsed-by-default behavior.
return <TaskChatRunnerActivityGroup item={item} />;
case "interaction":
return renderInteraction ? renderInteraction(item) : null;
case "plan_document":
return (
<TaskChatPlanPreviewCard
source={{ kind: "saved", document: item.document }}
testId={
item.placement === "fallback"
? "task-chat-plan-preview-fallback"
: "task-chat-plan-preview"
}
/>
);
case "brief":
return renderBrief ? renderBrief() : null;
case "subagent_group":
return <TaskChatSubagentTree subagents={item.subagents} />;
case "turn":
return (
<TaskChatTurn
item={item}
renderChild={(child) =>
renderItem(
child,
onApprovalDecision,
undefined,
undefined,
undefined,
undefined,
onRuntimeRequestDecision,
item.standaloneHeader ? "runner" : "classic",
undefined,
false,
undefined,
undefined,
undefined,
attachments,
onOpenSkill,
onOpenBrowser,
)
}
/>
);
case "protocol":
return (
<TaskChatProtocolCard
item={item}
onRuntimeRequestDecision={onRuntimeRequestDecision}
/>
);
default: {
// Exhaustiveness guard: a new item kind must add a branch above.
const _never: never = item;
return _never;
}
}
}
function isSystemLikeItem(item: TaskChatItem): boolean {
return (
item.kind === "marker" ||
(item.kind === "message" && item.author === "system")
);
}
export function taskChatItemSpacingClass(
item: TaskChatItem,
previousItem: TaskChatItem | null,
): string | undefined {
if (!previousItem) return undefined;
const currentIsSystemLike = isSystemLikeItem(item);
const previousIsSystemLike = isSystemLikeItem(previousItem);
if (currentIsSystemLike && previousIsSystemLike) return "mt-2";
if (currentIsSystemLike || previousIsSystemLike) return "mt-3";
if (item.kind === "turn" || previousItem.kind === "turn") return "mt-3";
if (item.kind === "interaction" || previousItem.kind === "interaction")
return "mt-4";
return "mt-6";
}
/**
* Presentational render layer for the redesigned task thread. Consumed by both
* the live thread (adapter over comment/run props) and the dev harness
* (synthetic fixtures). Owns no data fetching — it maps a normalized
* TaskChatItem[] onto the primitives inside the auto-follow scroller.
*/
export function TaskChatThreadView({
scrollingHistory,
items,
header,
onApprovalDecision,
onRuntimeRequestDecision,
renderInteraction,
renderBrief,
renderMessageActions,
renderQueuedAction,
onTryAgainNoLiveExecutionPath,
tryAgainNoLiveExecutionPathPending = false,
onRetryFailedRun,
retryFailedRunId = null,
tail,
contentKey,
className,
scroll = true,
attachments = EMPTY_ATTACHMENTS,
onOpenSkill,
onOpenBrowser,
}: TaskChatThreadViewProps) {
const streamlined = useStreamlinedTaskChatPresentation();
const { items: compactedItems, retryMarkers } = useMemo(() => compactAdjacentErrors(items), [items]);
const visibleItems = useMemo(() => groupImageResources(compactedItems), [compactedItems]);
const retryableMarkerId =
onRetryFailedRun || onTryAgainNoLiveExecutionPath
? [...visibleItems]
.reverse()
.find(
(item) => {
const marker = item.kind === "marker" ? item : retryMarkers.get(item.id);
return !!marker && isRetryableFailureMarker(marker);
},
)?.id
: undefined;
// Streaming tail and header updates must not rebuild settled markdown/tool trees.
const history = useMemo(() => {
const renderVisibleItem = (item: TaskChatItem) => {
const marker = item.id === retryableMarkerId ? retryMarkers.get(item.id) : undefined;
const runId = marker?.retryable !== false ? marker?.runId : undefined;
const runRetry = !onTryAgainNoLiveExecutionPath && onRetryFailedRun && runId
? () => onRetryFailedRun(runId)
: undefined;
return renderItem(
item, onApprovalDecision, renderInteraction, renderBrief, renderMessageActions,
renderQueuedAction, onRuntimeRequestDecision, "classic",
runRetry ?? onTryAgainNoLiveExecutionPath,
runRetry ? retryFailedRunId === runId : tryAgainNoLiveExecutionPathPending,
retryableMarkerId, onRetryFailedRun, retryFailedRunId, attachments, onOpenSkill, onOpenBrowser,
);
};
const renderedItems = streamlined
? visibleItems.map((item) => ({ item, content: renderVisibleItem(item) }))
.filter((entry) => entry.content !== null)
: [];
return (
<>
{streamlined
? renderedItems.map(({ item, content }, index) => (
<div
key={
item.kind === "message" ? (item.renderKey ?? item.id) : item.id
}
data-conversation-typography=""
data-thread-anchor={
item.kind === "message" ? (item.renderKey ?? item.id) : item.id
}
id={item.kind === "message" ? `comment-${item.id}` : undefined}
className={taskChatItemSpacingClass(
item,
renderedItems[index - 1]?.item ?? null,
)}
data-thread-item-kind={
item.kind === "message" ? item.author : item.kind
}
>
{content}
</div>
))
: visibleItems.map((item, index) => (
<div
key={
item.kind === "message" ? (item.renderKey ?? item.id) : item.id
}
data-conversation-typography=""
data-thread-anchor={
item.kind === "message" ? (item.renderKey ?? item.id) : item.id
}
id={item.kind === "message" ? `comment-${item.id}` : undefined}
className={cn(
index > 0 &&
item.kind === "interaction" &&
item.interaction.status !== "pending" &&
"-mt-3",
)}
>
{renderVisibleItem(item)}
</div>
))}
</>
);
}, [
visibleItems, retryMarkers, streamlined, onApprovalDecision, onRuntimeRequestDecision,
renderInteraction, renderBrief, renderMessageActions, renderQueuedAction,
onTryAgainNoLiveExecutionPath, tryAgainNoLiveExecutionPathPending,
retryableMarkerId, onRetryFailedRun, retryFailedRunId, attachments, onOpenSkill, onOpenBrowser,
]);
const body = (
<div
className={cn(
"paperclip-mobile-thread mx-auto flex w-full max-w-(--tc-shell-max-w) flex-col px-1 py-3 md:px-4 md:py-4",
streamlined ? "md:px-0" : "gap-5",
className,
)}
>
{header ? (
<div
className={cn("flex flex-col gap-6", streamlined ? "pb-4" : "pb-2")}
data-testid="task-chat-thread-header"
>
{header}
</div>
) : null}
{history}
{tail ? <div data-conversation-typography="" className={streamlined ? "mt-4" : undefined}>{tail}</div> : null}
</div>
);
if (!scroll) return body;
return (
<TaskMessageScroller contentKey={contentKey ?? taskChatContentKey(items)} scrollingHistory={scrollingHistory}>
{body}
</TaskMessageScroller>
);
}
// Cheap content signature so streaming growth (text lengthening without the
// item count changing) still advances the auto-follow key. Shared by the
// shared message scroller on desktop and mobile (TaskChatThread).
function signatureOf(it: TaskChatItem): number {
if (it.kind === "message") return it.text.length + (it.attachedTurn ? 1 : 0);
if (it.kind === "thinking") return it.lines.reduce((n, l) => n + l.length, 0);
if (it.kind === "tool")
return (it.diff?.lines?.length ?? 0) + (it.status === "completed" ? 1 : 0);
if (it.kind === "plan_document") {
return it.document.body.length + it.document.latestRevisionNumber;
}
if (it.kind === "turn") {
if (it.settled) return 1 + (it.finalResponse?.text.length ?? 0);
// The live parent row's header changes (gerund ↔ tool-state flashes,
// streaming interstitial text growing) count too, so the collapsed
// single-line turn still advances the key.
const headerSig = it.liveStatus
? it.liveStatus.label.length +
(it.liveStatus.detail?.length ?? 0) +
(it.liveStatus.selfTalk?.length ?? 0)
: 0;
return it.items.reduce(
(n, child) => n + signatureOf(child),
it.items.length + headerSig + (it.finalResponse?.text.length ?? 0),
);
}
if (it.kind === "activity_phase") {
return it.items.reduce(
(n, child) => n + signatureOf(child),
it.summary.length + (it.interstitial?.text.length ?? 0),
);
}
return 1;
}
export function taskChatContentKey(items: TaskChatItem[]): number {
return items.reduce((acc, it) => acc + signatureOf(it), items.length);
}