From 244439ebd7d9d76c1a45fc14f4b67ca933df2a93 Mon Sep 17 00:00:00 2001 From: Dotta Date: Thu, 3 Dec 2026 15:31:35 -0600 Subject: [PATCH] fix(budgets): address review feedback on pricing rates, incomplete accounting card, and paused notice extraction - Fix claude-sonnet-4-5 to standard API rates (/) and add legacy claude-opus-4/4-1 (/) - Keep [1m] suffixes unstripped so long-context variants fall back conservatively to the family maximum - Freeze ANTHROPIC_FAMILY_MAX_RATE_CARDS as immutable reviewed constants with a regression test - Update budget-live-usage.test.ts for Claude family-max live projection - Broaden below-limit BudgetIncidentCard copy to cover all incomplete-accounting causes (unpriced or unaccounted usage) and omit the guaranteed-422 Raise budget & resume form on incomplete-accounting stops - Extract IssueAssigneePausedNotice into its own component file and align the Storybook story with real server recovery behavior Co-Authored-By: Paperclip --- server/src/services/anthropic-pricing.test.ts | 52 +++++++- server/src/services/anthropic-pricing.ts | 66 ++++----- server/src/services/budget-live-usage.test.ts | 6 +- ui/src/components/BudgetIncidentCard.tsx | 74 ++++++----- .../components/IssueAssigneePausedNotice.tsx | 125 ++++++++++++++++++ ui/src/components/IssueChatThread.tsx | 117 +--------------- .../components/PausedBudgetNotices.test.tsx | 10 +- .../paused-agent-chat-notice.stories.tsx | 10 +- 8 files changed, 257 insertions(+), 203 deletions(-) create mode 100644 ui/src/components/IssueAssigneePausedNotice.tsx diff --git a/server/src/services/anthropic-pricing.test.ts b/server/src/services/anthropic-pricing.test.ts index a2c0b1a673b..c57f4f326d7 100644 --- a/server/src/services/anthropic-pricing.test.ts +++ b/server/src/services/anthropic-pricing.test.ts @@ -1,6 +1,12 @@ import { describe, expect, it } from "vitest"; +import { usdToUnits } from "@paperclipai/shared"; import type { AdapterUsageCheckpoint } from "@paperclipai/adapter-utils"; -import { priceAnthropicReceipt } from "./anthropic-pricing.js"; +import { + ANTHROPIC_FAMILY_MAX_RATE_CARDS, + ANTHROPIC_RATE_CARDS, + anthropicModelFamily, + priceAnthropicReceipt, +} from "./anthropic-pricing.js"; const receipt: AdapterUsageCheckpoint = { complete: true, usageBasis: "per_run", provider: "anthropic", biller: "anthropic", billingType: "metered_api", model: "claude-sonnet-5", costUsd: null, costStatus: "unpriced", @@ -26,7 +32,7 @@ describe("complete Anthropic receipt pricing", () => { expect(priced.pricingProvenance).toMatchObject({ source: "rate_card" }); expect(priced.pricingProvenance?.evidence).toMatch(/one-hour upper rate used; not an invoice; observed usage is a lower bound$/); }); - it("prices Fable 5.2 (including [1m] suffix) and other shipped Anthropic models", () => { + it("prices Fable 5.2, Sonnet 4.5 standard rates, legacy Opus 4.1, and other shipped Anthropic models", () => { const fable52 = priceAnthropicReceipt({ ...receipt, model: "claude-fable-5-2" }); expect(fable52.costStatus).toBe("estimated"); expect(fable52.pricingProvenance).toMatchObject({ @@ -38,9 +44,35 @@ describe("complete Anthropic receipt pricing", () => { outputCentsPerMillion: "4000", }); + // Long-context [1m] variants are not silently discounted to the base card; + // they conservatively fall back to the family maximum. const fable52Long = priceAnthropicReceipt({ ...receipt, model: "claude-fable-5-2[1m]" }); - expect(fable52Long.costUsdExact).toBe(fable52.costUsdExact); - expect(fable52Long.pricingProvenance?.version).toBe("anthropic-standard-2026-12-03"); + expect(fable52Long.pricingProvenance).toMatchObject({ + source: "rate_card", + version: "anthropic-fable-family-max-2026-12-03", + inputCentsPerMillion: "1000", + cachedInputCentsPerMillion: "100", + cacheWriteCentsPerMillion: "2000", + outputCentsPerMillion: "5000", + }); + + const sonnet45 = priceAnthropicReceipt({ ...receipt, model: "claude-sonnet-4-5" }); + expect(sonnet45.costStatus).toBe("estimated"); + expect(sonnet45.pricingProvenance).toMatchObject({ + inputCentsPerMillion: "300", + cachedInputCentsPerMillion: "30", + cacheWriteCentsPerMillion: "600", + outputCentsPerMillion: "1500", + }); + + const opus41 = priceAnthropicReceipt({ ...receipt, model: "claude-opus-4-1" }); + expect(opus41.costStatus).toBe("estimated"); + expect(opus41.pricingProvenance).toMatchObject({ + inputCentsPerMillion: "1500", + cachedInputCentsPerMillion: "150", + cacheWriteCentsPerMillion: "3000", + outputCentsPerMillion: "7500", + }); const sonnet55 = priceAnthropicReceipt({ ...receipt, model: "claude-sonnet-5-5" }); expect(sonnet55.costStatus).toBe("estimated"); @@ -60,10 +92,20 @@ describe("complete Anthropic receipt pricing", () => { outputCentsPerMillion: "500", }); }); + it("keeps every immutable family-max fallback >= every explicit card in its family", () => { + for (const [modelId, card] of Object.entries(ANTHROPIC_RATE_CARDS)) { + const family = anthropicModelFamily(modelId); + expect(family).not.toBeNull(); + const maxCard = ANTHROPIC_FAMILY_MAX_RATE_CARDS[family!]; + for (let i = 0; i < 4; i++) { + expect(usdToUnits(maxCard.rates[i])).toBeGreaterThanOrEqual(usdToUnits(card.rates[i])); + } + } + }); it.each([ { model: "claude-fable-5-9", family: "fable", input: "1000", cached: "100", cacheWrite: "2000", output: "5000" }, { model: "claude-mythos-6", family: "mythos", input: "1000", cached: "100", cacheWrite: "2000", output: "5000" }, - { model: "claude-opus-6", family: "opus", input: "500", cached: "50", cacheWrite: "1000", output: "2500" }, + { model: "claude-opus-6", family: "opus", input: "1500", cached: "150", cacheWrite: "3000", output: "7500" }, { model: "claude-sonnet-latest", family: "sonnet", input: "300", cached: "30", cacheWrite: "600", output: "1500" }, { model: "claude-haiku-6", family: "haiku", input: "100", cached: "10", cacheWrite: "200", output: "500" }, ])("defaults uncataloged $model to the most expensive rate in the $family group", ({ model, family, input, cached, cacheWrite, output }) => { diff --git a/server/src/services/anthropic-pricing.ts b/server/src/services/anthropic-pricing.ts index 88e1994dbdc..b664611157b 100644 --- a/server/src/services/anthropic-pricing.ts +++ b/server/src/services/anthropic-pricing.ts @@ -10,7 +10,9 @@ type RateCard = { type AnthropicModelFamily = "fable" | "mythos" | "opus" | "sonnet" | "haiku"; -const RATE_CARDS: Record = { +// Standard direct Anthropic API list prices (USD per 1M tokens: input, cache read, 1h cache write, output). +// Source: https://platform.claude.com/docs/en/about-claude/pricing +export const ANTHROPIC_RATE_CARDS: Readonly> = Object.freeze({ // Fable / Mythos "claude-fable-5-2": { rates: ["8", "0.2", "16", "40"], version: "anthropic-standard-2026-12-03" }, "claude-fable-5-1": { rates: ["10", "0.25", "20", "50"], version: "anthropic-standard-2026-12-03" }, @@ -18,71 +20,59 @@ const RATE_CARDS: Record = { "claude-mythos-5-2": { rates: ["8", "0.2", "16", "40"], version: "anthropic-standard-2026-12-03" }, "claude-mythos-5-1": { rates: ["10", "0.25", "20", "50"], version: "anthropic-standard-2026-12-03" }, "claude-mythos-5": { rates: ["10", "1", "20", "50"], version: "anthropic-standard-2026-12-03" }, - // Opus + // Opus (including legacy Opus 4 / 4.1 at $15/$75) "claude-opus-5-5": { rates: ["4", "0.2", "8", "20"], version: "anthropic-standard-2026-10-12" }, "claude-opus-5": { rates: ["5", "0.5", "10", "25"], version: "anthropic-standard-2026-12-03" }, "claude-opus-4-8": { rates: ["5", "0.5", "10", "25"], version: "anthropic-standard-2026-12-03" }, "claude-opus-4-7": { rates: ["5", "0.5", "10", "25"], version: "anthropic-standard-2026-12-03" }, "claude-opus-4-6": { rates: ["5", "0.5", "10", "25"], version: "anthropic-standard-2026-12-03" }, "claude-opus-4-5": { rates: ["5", "0.5", "10", "25"], version: "anthropic-standard-2026-12-03" }, - // Sonnet + "claude-opus-4-1": { rates: ["15", "1.5", "30", "75"], version: "anthropic-standard-2026-12-03" }, + "claude-opus-4": { rates: ["15", "1.5", "30", "75"], version: "anthropic-standard-2026-12-03" }, + // Sonnet (standard API rates, never Batch API rates) "claude-sonnet-5-5": { rates: ["2", "0.1", "4", "10"], version: "anthropic-standard-2026-12-03" }, "claude-sonnet-5": { rates: ["2", "0.2", "4", "10"], version: "anthropic-standard-2026-10-07" }, "claude-sonnet-4-6": { rates: ["3", "0.3", "6", "15"], version: "anthropic-standard-2026-12-03" }, - "claude-sonnet-4-5": { rates: ["1.5", "0.15", "3", "7.5"], version: "anthropic-standard-2026-12-03" }, + "claude-sonnet-4-5": { rates: ["3", "0.3", "6", "15"], version: "anthropic-standard-2026-12-03" }, // Haiku "claude-haiku-5-5": { rates: ["0.5", "0.05", "1", "2.5"], version: "anthropic-standard-2026-12-03" }, "claude-haiku-4-5": { rates: ["1", "0.1", "2", "5"], version: "anthropic-standard-2026-12-03" }, -}; +}); + +// Reviewed, immutable per-family conservative maximums (must be >= every card in that family). +// Bump the version date whenever a family maximum changes so stored provenance stays reproducible. +export const ANTHROPIC_FAMILY_MAX_RATE_CARDS: Readonly> = Object.freeze({ + fable: { rates: ["10", "1", "20", "50"], version: "anthropic-fable-family-max-2026-12-03" }, + mythos: { rates: ["10", "1", "20", "50"], version: "anthropic-mythos-family-max-2026-12-03" }, + opus: { rates: ["15", "1.5", "30", "75"], version: "anthropic-opus-family-max-2026-12-03" }, + sonnet: { rates: ["3", "0.3", "6", "15"], version: "anthropic-sonnet-family-max-2026-12-03" }, + haiku: { rates: ["1", "0.1", "2", "5"], version: "anthropic-haiku-family-max-2026-12-03" }, +}); const ANTHROPIC_FAMILY_RE = /^claude-(fable|mythos|opus|sonnet|haiku)(?:[-@].*)?$/; function normalizeAnthropicModelId(model: string): string { - return model.trim().toLowerCase().replace(/\[1m\]$/, ""); + // Preserve variant suffixes such as `[1m]` so long-context variants do not + // silently fall down to a cheaper standard card; they fall back to the + // conservative family maximum instead. + return model.trim().toLowerCase(); } -function anthropicModelFamily(normalizedModel: string): AnthropicModelFamily | null { +export function anthropicModelFamily(normalizedModel: string): AnthropicModelFamily | null { const match = ANTHROPIC_FAMILY_RE.exec(normalizedModel); return (match?.[1] as AnthropicModelFamily | undefined) ?? null; } -function maxRateString(a: string, b: string): string { - return usdToUnits(b) > usdToUnits(a) ? b : a; -} - -const FAMILY_MAX_RATE_CARDS: Record = (() => { - const result = {} as Record; - for (const [modelId, card] of Object.entries(RATE_CARDS)) { - const family = anthropicModelFamily(modelId); - if (!family) continue; - const existing = result[family]; - if (!existing) { - result[family] = { - rates: [card.rates[0], card.rates[1], card.rates[2], card.rates[3]], - version: `anthropic-${family}-family-max-2026-12-03`, - }; - } else { - existing.rates = [ - maxRateString(existing.rates[0], card.rates[0]), - maxRateString(existing.rates[1], card.rates[1]), - maxRateString(existing.rates[2], card.rates[2]), - maxRateString(existing.rates[3], card.rates[3]), - ]; - } - } - return result; -})(); - function resolveAnthropicRateCard(model: string | null | undefined): { card: RateCard; fallbackFamily: AnthropicModelFamily | null } | null { if (!model) return null; const normalized = normalizeAnthropicModelId(model); if (!normalized) return null; - if (Object.hasOwn(RATE_CARDS, normalized)) { - return { card: RATE_CARDS[normalized], fallbackFamily: null }; + if (Object.hasOwn(ANTHROPIC_RATE_CARDS, normalized)) { + return { card: ANTHROPIC_RATE_CARDS[normalized], fallbackFamily: null }; } const family = anthropicModelFamily(normalized); - if (family && Object.hasOwn(FAMILY_MAX_RATE_CARDS, family)) { - return { card: FAMILY_MAX_RATE_CARDS[family], fallbackFamily: family }; + if (family && Object.hasOwn(ANTHROPIC_FAMILY_MAX_RATE_CARDS, family)) { + return { card: ANTHROPIC_FAMILY_MAX_RATE_CARDS[family], fallbackFamily: family }; } return null; } diff --git a/server/src/services/budget-live-usage.test.ts b/server/src/services/budget-live-usage.test.ts index 6c8b078f945..ee3d0589459 100644 --- a/server/src/services/budget-live-usage.test.ts +++ b/server/src/services/budget-live-usage.test.ts @@ -48,8 +48,12 @@ describe("live run budget pricing", () => { expect(liveRunUsageCostCents({ ...openai, ...override })).toBeNull(); }); + it("projects uncataloged Claude family models at the conservative family maximum", () => { + expect(liveRunUsageCostCents({ ...anthropic, model: "claude-sonnet-latest" })).toBe("23.3951400"); + }); + it.each([ - { biller: "aws_bedrock" }, { model: "claude-sonnet-latest" }, { pricingContext: { serviceTier: "priority" } }, + { biller: "aws_bedrock" }, { model: "claude-unknown-1" }, { pricingContext: { serviceTier: "priority" } }, { usage: { inputTokens: 1, outputTokens: 1 } }, { usage: { inputTokens: 1, cacheWriteTokens: 2, cachedInputTokens: 0, outputTokens: 1 } }, ] as Partial[])("retains Anthropic rate-card restrictions: %j", override => { diff --git a/ui/src/components/BudgetIncidentCard.tsx b/ui/src/components/BudgetIncidentCard.tsx index b78a1b8eb4c..8a1146b5dae 100644 --- a/ui/src/components/BudgetIncidentCard.tsx +++ b/ui/src/components/BudgetIncidentCard.tsx @@ -37,7 +37,7 @@ export function BudgetIncidentCard({ isMutating?: boolean; }) { const isWarning = incident.thresholdType === "soft"; - const isUnpricedHardStop = + const isIncompleteAccountingHardStop = incident.thresholdType === "hard" && incident.amountObserved < incident.amountLimit; const [draftAmount, setDraftAmount] = useState( centsInputValue(isWarning @@ -56,7 +56,7 @@ export function BudgetIncidentCard({
- {incident.scopeType} {isWarning ? "budget warning" : isUnpricedHardStop ? "unpriced usage stop" : "hard stop"} + {incident.scopeType} {isWarning ? "budget warning" : isIncompleteAccountingHardStop ? "incomplete accounting stop" : "hard stop"}
{stateLabel} @@ -64,8 +64,8 @@ export function BudgetIncidentCard({ {incident.scopeName} - {isUnpricedHardStop - ? `Known spend is ${formatCents(incident.amountObserved)} of ${formatCents(incident.amountLimit)}, but recent runs have unpriced model usage and this policy blocks unpriced usage.` + {isIncompleteAccountingHardStop + ? `Known spend is ${formatCents(incident.amountObserved)} of ${formatCents(incident.amountLimit)}, but accounting is incomplete (unpriced or unaccounted usage) and this policy blocks incomplete accounting.` : `Spending reached ${formatCents(incident.amountObserved)} against a limit of ${formatCents(incident.amountLimit)}.`} @@ -92,10 +92,10 @@ export function BudgetIncidentCard({
- {isUnpricedHardStop + {isIncompleteAccountingHardStop ? incident.scopeType === "project" - ? "Project execution is paused because unpriced usage is blocked. Allow unpriced usage in this policy or wait for pricing, then resume." - : "This scope is paused because unpriced usage is blocked. Messages and new runs won’t start until unpriced usage is allowed or priced and this scope is resumed." + ? "Project execution is paused because this policy blocks unpriced or unaccounted usage. Update the policy to allow unpriced usage or wait for accounting to finish, then resume." + : "This scope is paused because this policy blocks unpriced or unaccounted usage. Messages and new runs won’t start until unpriced usage is allowed in the policy (or accounting finishes) and this scope is resumed." : incident.scopeType === "project" ? "Project execution is paused. New work in this project will not start until you raise the budget and resume." : "This scope is paused. Messages and new runs won’t start until you raise the budget and resume."} @@ -103,34 +103,40 @@ export function BudgetIncidentCard({
)} -
- -
- setDraftAmount(event.target.value)} - inputMode="decimal" - placeholder="0.00" - /> - + {isIncompleteAccountingHardStop ? ( +
+ Raising the dollar limit will not clear this stop while unpriced or unaccounted usage is blocked. Review this scope’s budget policy to allow unpriced usage or wait for pending accounting to settle, then resume.
- {parsed !== null && parsed <= incident.amountObserved ? ( -

- The new budget must exceed current observed spend. -

- ) : null} -
+ ) : ( +
+ +
+ setDraftAmount(event.target.value)} + inputMode="decimal" + placeholder="0.00" + /> + +
+ {parsed !== null && parsed <= incident.amountObserved ? ( +

+ The new budget must exceed current observed spend. +

+ ) : null} +
+ )}
{!isWarning ? ( diff --git a/ui/src/components/IssueAssigneePausedNotice.tsx b/ui/src/components/IssueAssigneePausedNotice.tsx new file mode 100644 index 00000000000..08a2f7f8996 --- /dev/null +++ b/ui/src/components/IssueAssigneePausedNotice.tsx @@ -0,0 +1,125 @@ +import type { Agent } from "@paperclipai/shared"; +import { PauseCircle } from "lucide-react"; +import { Link } from "@/lib/router"; +import { agentUrl } from "@/lib/utils"; +import { InlineBanner } from "./InlineBanner"; +import { Button } from "@/components/ui/button"; + +function isTerminalIssueDisposition(issueStatus: string | undefined): boolean { + return issueStatus === "done" || issueStatus === "cancelled"; +} + +export function IssueAssigneePausedNotice({ + agent, + issueStatus, + onResume, + resuming, +}: { + agent: Agent | null; + issueStatus: string | undefined; + onResume?: () => Promise | void; + resuming?: boolean; +}) { + if (!agent || agent.status !== "paused" || isTerminalIssueDisposition(issueStatus)) return null; + + // Lifecycle setup is shown by the queued turn and its inline connection card. + // Resume changes operator holds; it cannot complete verification. + if (!agent.pauseReason && ["preparing", "verifying", "resuming"].includes(agent.lifecycleState ?? "")) return null; + + // A freshly created agent is stored as paused with pauseReason "setup" until + // its setup finishes. That is not an operator pause, so say what is actually + // happening and point at the real recovery path instead of "Resume agent". + if (agent.pauseReason === "setup") { + // Only computer preparation advances on its own (matches NewAgentSetup). + // A "verifying" or parked draft waits for the user to finish the wizard. + const stillPreparing = ["preparing", "pausing"].includes(agent.lifecycleState ?? ""); + return ( +
+ + {agent.name} is still being set up. + + } + actions={ + stillPreparing ? undefined : ( + + ) + } + > + {stillPreparing + ? "Its computer is being prepared. Runs start automatically when setup finishes." + : "Its setup isn't finished yet. Finish setup to let it start runs."} + +
+ ); + } + + const isBudgetPause = agent.pauseReason === "budget"; + const pauseDetail = + agent.pauseReason === "import" + ? "It arrived paused from an organization import — imported agents stay parked until you resume them." + : agent.pauseReason === "system" + ? "It was paused by the system." + : agent.pauseReason === "manual" + ? "It was paused manually." + : ""; + // Budget pauses clear when the budget stop is resolved and archive pauses + // clear when the company is restored; resuming directly from chat would fight + // either, so budget pauses link to the agent's budget page instead. + const canResume = Boolean(onResume) && !isBudgetPause && agent.pauseReason !== "company_archived"; + + const title = isBudgetPause ? ( + <> + {agent.name} is paused by a budget stop. + + ) : ( + <> + {agent.name} is paused. + + ); + + const body = isBudgetPause + ? `Messages you send won’t get a reply until the budget stop is resolved and ${agent.name} is resumed.` + : agent.pauseReason === "company_archived" + ? "Messages you send won’t get a reply while this company is archived." + : `Messages you send won’t get a reply until ${agent.name} is resumed.${pauseDetail ? ` ${pauseDetail}` : ""}`; + + const actions = isBudgetPause ? ( + + ) : canResume ? ( + + ) : undefined; + + return ( +
+ + {body} + +
+ ); +} diff --git a/ui/src/components/IssueChatThread.tsx b/ui/src/components/IssueChatThread.tsx index b88081a5b48..d828c959c6e 100644 --- a/ui/src/components/IssueChatThread.tsx +++ b/ui/src/components/IssueChatThread.tsx @@ -12,6 +12,8 @@ import type { ComposerRunSettings } from "./task-chat/composer-run-settings"; import { ComposerRunSettingsPicker } from "./task-chat/ComposerRunSettingsPicker"; import { ComposerAddMenu, ComposerModeChip } from "./task-chat/ComposerAddMenu"; import { TaskChatPausedTakeover, type TaskComposerPause } from "./task-chat/TaskChatPausedTakeover"; +import { IssueAssigneePausedNotice } from "./IssueAssigneePausedNotice"; +export { IssueAssigneePausedNotice }; import { useEmailComment } from "./EmailMessageCard"; import { AssistantRuntimeProvider } from "@assistant-ui/react"; import type { @@ -826,121 +828,6 @@ class IssueChatErrorBoundary extends Component< } } -export function IssueAssigneePausedNotice({ - agent, - issueStatus, - onResume, - resuming, -}: { - agent: Agent | null; - issueStatus: string | undefined; - onResume?: () => Promise | void; - resuming?: boolean; -}) { - if (!agent || agent.status !== "paused" || issueStatusIsTerminalDisposition(issueStatus)) return null; - - // Lifecycle setup is shown by the queued turn and its inline connection card. - // Resume changes operator holds; it cannot complete verification. - if (!agent.pauseReason && ["preparing", "verifying", "resuming"].includes(agent.lifecycleState ?? "")) return null; - - // A freshly created agent is stored as paused with pauseReason "setup" until - // its setup finishes. That is not an operator pause, so say what is actually - // happening and point at the real recovery path instead of "Resume agent". - if (agent.pauseReason === "setup") { - // Only computer preparation advances on its own (matches NewAgentSetup). - // A "verifying" or parked draft waits for the user to finish the wizard. - const stillPreparing = ["preparing", "pausing"].includes(agent.lifecycleState ?? ""); - return ( -
- - {agent.name} is still being set up. - - } - actions={ - stillPreparing ? undefined : ( - - ) - } - > - {stillPreparing - ? "Its computer is being prepared. Runs start automatically when setup finishes." - : "Its setup isn't finished yet. Finish setup to let it start runs."} - -
- ); - } - - const isBudgetPause = agent.pauseReason === "budget"; - const pauseDetail = - agent.pauseReason === "import" - ? "It arrived paused from an organization import — imported agents stay parked until you resume them." - : agent.pauseReason === "system" - ? "It was paused by the system." - : agent.pauseReason === "manual" - ? "It was paused manually." - : ""; - // Budget pauses clear when the budget stop is resolved and archive pauses - // clear when the company is restored; resuming directly from chat would fight - // either, so budget pauses link to the agent's budget page instead. - const canResume = Boolean(onResume) && !isBudgetPause && agent.pauseReason !== "company_archived"; - - const title = isBudgetPause ? ( - <> - {agent.name} is paused by a budget stop. - - ) : ( - <> - {agent.name} is paused. - - ); - - const body = isBudgetPause - ? `Messages you send won’t get a reply until the budget stop is resolved and ${agent.name} is resumed.` - : agent.pauseReason === "company_archived" - ? "Messages you send won’t get a reply while this company is archived." - : `Messages you send won’t get a reply until ${agent.name} is resumed.${pauseDetail ? ` ${pauseDetail}` : ""}`; - - const actions = isBudgetPause ? ( - - ) : canResume ? ( - - ) : undefined; - - return ( -
- - {body} - -
- ); -} - function fallbackAuthorLabel(message: ThreadMessage) { const custom = message.metadata?.custom as Record | undefined; diff --git a/ui/src/components/PausedBudgetNotices.test.tsx b/ui/src/components/PausedBudgetNotices.test.tsx index f20aa5c72ff..54af74666a2 100644 --- a/ui/src/components/PausedBudgetNotices.test.tsx +++ b/ui/src/components/PausedBudgetNotices.test.tsx @@ -5,7 +5,7 @@ import { createRoot, type Root } from "react-dom/client"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { Agent, BudgetIncident } from "@paperclipai/shared"; import { MemoryRouter } from "@/lib/router"; -import { IssueAssigneePausedNotice } from "./IssueChatThread"; +import { IssueAssigneePausedNotice } from "./IssueAssigneePausedNotice"; import { BudgetIncidentCard } from "./BudgetIncidentCard"; vi.mock("@/context/CompanyContext", () => ({ @@ -118,7 +118,7 @@ describe("IssueAssigneePausedNotice and BudgetIncidentCard", () => { expect(onResume).toHaveBeenCalledTimes(1); }); - it("distinguishes unpriced-usage budget stops from spend-limit stops on BudgetIncidentCard", () => { + it("distinguishes incomplete-accounting stops from spend-limit stops and omits the invalid raise-budget action", () => { act(() => { root.render( { ); }); - expect(container.textContent).toContain("unpriced usage stop"); + expect(container.textContent).toContain("incomplete accounting stop"); expect(container.textContent).toContain("$1.67 of $1,000.00"); - expect(container.textContent).toContain("unpriced model usage"); + expect(container.textContent).toContain("unpriced or unaccounted usage"); + expect(container.textContent).toContain("Raising the dollar limit will not clear this stop"); expect(container.textContent).toContain("Keeping paused dismisses this alert without resuming work."); + expect(container.textContent).not.toContain("Raise budget & resume"); }); }); diff --git a/ui/storybook/stories/budgets-costs/paused-agent-chat-notice.stories.tsx b/ui/storybook/stories/budgets-costs/paused-agent-chat-notice.stories.tsx index cd2152c0512..5b52f81f920 100644 --- a/ui/storybook/stories/budgets-costs/paused-agent-chat-notice.stories.tsx +++ b/ui/storybook/stories/budgets-costs/paused-agent-chat-notice.stories.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import type { Meta, StoryObj } from "@storybook/react-vite"; import type { Agent, BudgetIncident } from "@paperclipai/shared"; import { expect, userEvent, within } from "storybook/test"; -import { IssueAssigneePausedNotice } from "@/components/IssueChatThread"; +import { IssueAssigneePausedNotice } from "@/components/IssueAssigneePausedNotice"; import { BudgetIncidentCard } from "@/components/BudgetIncidentCard"; import { TaskChatBubble } from "@/components/task-chat/TaskChatBubble"; @@ -92,10 +92,7 @@ function PausedAgentChatSurface({
{ - setIncidentStatus("resolved"); - setResumed(true); - }} + onRaiseAndResume={() => undefined} onKeepPaused={() => setIncidentStatus("dismissed")} />
@@ -138,8 +135,9 @@ export const BudgetPausedWithUnpricedIncident: Story = { args: { pauseReason: "budget", showIncidentCard: true }, play: async ({ canvasElement }) => { const c = within(canvasElement); - await expect(c.getByText(/unpriced usage stop/i)).toBeInTheDocument(); + await expect(c.getByText(/incomplete accounting stop/i)).toBeInTheDocument(); await expect(c.getByText(/\$1\.67 of \$1,000\.00/)).toBeInTheDocument(); + await expect(c.queryByRole("button", { name: "Raise budget & resume" })).not.toBeInTheDocument(); await expect( c.getByText(/Keeping paused dismisses this alert without resuming work\./), ).toBeInTheDocument();