@arbidocs/blocks 0.5.128 → 0.5.130
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ConnectedCallDock-XJOYVVAH.cjs → ConnectedCallDock-CJ7RWP5B.cjs} +11 -11
- package/dist/{ConnectedCallDock-XJOYVVAH.cjs.map → ConnectedCallDock-CJ7RWP5B.cjs.map} +1 -1
- package/dist/{ConnectedCallRoom-CUDYAPQK.cjs → ConnectedCallRoom-JPJCXP6X.cjs} +11 -11
- package/dist/{ConnectedCallRoom-CUDYAPQK.cjs.map → ConnectedCallRoom-JPJCXP6X.cjs.map} +1 -1
- package/dist/{ConnectedNativeDocxComparison-JUF2TI2P.cjs → ConnectedNativeDocxComparison-5TZAIR4V.cjs} +9 -9
- package/dist/{ConnectedNativeDocxComparison-JUF2TI2P.cjs.map → ConnectedNativeDocxComparison-5TZAIR4V.cjs.map} +1 -1
- package/dist/{ConnectedPresentation-SI3L77J4.cjs → ConnectedPresentation-SEUUNFUA.cjs} +12 -12
- package/dist/{ConnectedPresentation-SI3L77J4.cjs.map → ConnectedPresentation-SEUUNFUA.cjs.map} +1 -1
- package/dist/{ConnectedSlidesTab-E76OVY34.cjs → ConnectedSlidesTab-3ATAKNSJ.cjs} +12 -12
- package/dist/{ConnectedSlidesTab-E76OVY34.cjs.map → ConnectedSlidesTab-3ATAKNSJ.cjs.map} +1 -1
- package/dist/{ConnectedStreamedWordArtifact-Q64DRRQD.cjs → ConnectedStreamedWordArtifact-BKPOMQ6G.cjs} +9 -9
- package/dist/{ConnectedStreamedWordArtifact-Q64DRRQD.cjs.map → ConnectedStreamedWordArtifact-BKPOMQ6G.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-C7XHGK36.cjs → FilesViewerDialog-EFRMXIM5.cjs} +20 -20
- package/dist/{FilesViewerDialog-C7XHGK36.cjs.map → FilesViewerDialog-EFRMXIM5.cjs.map} +1 -1
- package/dist/{StreamedArtifactEditor-7KJ2HLLU.cjs → StreamedArtifactEditor-RSPUSZ2B.cjs} +5 -5
- package/dist/{StreamedArtifactEditor-7KJ2HLLU.cjs.map → StreamedArtifactEditor-RSPUSZ2B.cjs.map} +1 -1
- package/dist/{WorkspaceTableView-3XYAV4BV.cjs → WorkspaceTableView-QPROJRCF.cjs} +5 -5
- package/dist/{WorkspaceTableView-3XYAV4BV.cjs.map → WorkspaceTableView-QPROJRCF.cjs.map} +1 -1
- package/dist/agents/index.cjs +361 -361
- package/dist/agents/workflows/StepParts.d.ts +3 -0
- package/dist/agents/workflows/StepParts.js +20 -3
- package/dist/agents/workflows/StepParts.js.map +2 -2
- package/dist/agents/workflows/WorkflowStepAction.js +14 -3
- package/dist/agents/workflows/WorkflowStepAction.js.map +2 -2
- package/dist/agents/workflows/planSteps.js +6 -1
- package/dist/agents/workflows/planSteps.js.map +2 -2
- package/dist/agents/workflows/workflow.d.ts +11 -2
- package/dist/agents/workflows/workflow.js +16 -1
- package/dist/agents/workflows/workflow.js.map +2 -2
- package/dist/{ai-IEIR7SC2.cjs → ai-4XJ2VFNS.cjs} +23 -23
- package/dist/ai-4XJ2VFNS.cjs.map +1 -0
- package/dist/artifacts/VersionTimeline.d.ts +5 -1
- package/dist/artifacts/VersionTimeline.js +15 -0
- package/dist/artifacts/VersionTimeline.js.map +2 -2
- package/dist/artifacts/index.cjs +24 -24
- package/dist/calls/index.cjs +2 -2
- package/dist/chat/index.cjs +58 -58
- package/dist/{chunk-XF355M7O.cjs → chunk-2Z25MUAY.cjs} +17 -17
- package/dist/{chunk-XF355M7O.cjs.map → chunk-2Z25MUAY.cjs.map} +1 -1
- package/dist/{chunk-7JLJH5CW.cjs → chunk-5A6T4W46.cjs} +7 -7
- package/dist/{chunk-7JLJH5CW.cjs.map → chunk-5A6T4W46.cjs.map} +1 -1
- package/dist/{chunk-QG2U2JGX.cjs → chunk-7LEN65YI.cjs} +9 -9
- package/dist/{chunk-QG2U2JGX.cjs.map → chunk-7LEN65YI.cjs.map} +1 -1
- package/dist/{chunk-IDCD5TEZ.cjs → chunk-A6GBPE5E.cjs} +18 -18
- package/dist/{chunk-IDCD5TEZ.cjs.map → chunk-A6GBPE5E.cjs.map} +1 -1
- package/dist/{chunk-MMSHIIKG.cjs → chunk-AFXLRO6E.cjs} +4 -4
- package/dist/{chunk-MMSHIIKG.cjs.map → chunk-AFXLRO6E.cjs.map} +1 -1
- package/dist/{chunk-KNGZZC4O.cjs → chunk-B3BZ6MNI.cjs} +6 -6
- package/dist/{chunk-KNGZZC4O.cjs.map → chunk-B3BZ6MNI.cjs.map} +1 -1
- package/dist/{chunk-WAV762GP.cjs → chunk-DBN6GBRQ.cjs} +6 -6
- package/dist/{chunk-WAV762GP.cjs.map → chunk-DBN6GBRQ.cjs.map} +1 -1
- package/dist/{chunk-QGVOT7E4.cjs → chunk-EQTZQD66.cjs} +8 -8
- package/dist/{chunk-QGVOT7E4.cjs.map → chunk-EQTZQD66.cjs.map} +1 -1
- package/dist/{chunk-M2FOXGJU.cjs → chunk-F6CEPWIF.cjs} +7 -7
- package/dist/{chunk-M2FOXGJU.cjs.map → chunk-F6CEPWIF.cjs.map} +1 -1
- package/dist/{chunk-VWBYE3XY.cjs → chunk-FQRJCAT2.cjs} +6 -6
- package/dist/{chunk-VWBYE3XY.cjs.map → chunk-FQRJCAT2.cjs.map} +1 -1
- package/dist/{chunk-E3L5DB5F.cjs → chunk-GEZB3OEC.cjs} +4 -4
- package/dist/{chunk-E3L5DB5F.cjs.map → chunk-GEZB3OEC.cjs.map} +1 -1
- package/dist/{chunk-YP5EBGLU.cjs → chunk-GOQV6NOK.cjs} +73 -73
- package/dist/{chunk-YP5EBGLU.cjs.map → chunk-GOQV6NOK.cjs.map} +1 -1
- package/dist/{chunk-XCKHOXRP.cjs → chunk-H4ID6S4P.cjs} +6 -6
- package/dist/{chunk-XCKHOXRP.cjs.map → chunk-H4ID6S4P.cjs.map} +1 -1
- package/dist/{chunk-UFT22LAB.cjs → chunk-HBUHOCWF.cjs} +16 -16
- package/dist/{chunk-UFT22LAB.cjs.map → chunk-HBUHOCWF.cjs.map} +1 -1
- package/dist/{chunk-ZQNTYINE.cjs → chunk-HORAMB52.cjs} +91 -31
- package/dist/chunk-HORAMB52.cjs.map +1 -0
- package/dist/{chunk-3IH55CDE.cjs → chunk-IZBAWZTB.cjs} +16 -2
- package/dist/chunk-IZBAWZTB.cjs.map +1 -0
- package/dist/{chunk-QRAQZTJE.cjs → chunk-JN5YMHGI.cjs} +18 -3
- package/dist/chunk-JN5YMHGI.cjs.map +1 -0
- package/dist/{chunk-IZJ5L246.cjs → chunk-KWHGYHRC.cjs} +5 -5
- package/dist/{chunk-IZJ5L246.cjs.map → chunk-KWHGYHRC.cjs.map} +1 -1
- package/dist/{chunk-EG7EJFUE.cjs → chunk-MHIG6GGS.cjs} +17 -2
- package/dist/chunk-MHIG6GGS.cjs.map +1 -0
- package/dist/{chunk-IWMHQTVL.cjs → chunk-MI3N3ZOT.cjs} +80 -70
- package/dist/chunk-MI3N3ZOT.cjs.map +1 -0
- package/dist/{chunk-7NLO7ASW.cjs → chunk-MXGXKUSW.cjs} +17 -17
- package/dist/{chunk-7NLO7ASW.cjs.map → chunk-MXGXKUSW.cjs.map} +1 -1
- package/dist/{chunk-ZCU72Q76.cjs → chunk-NM7RWZ4E.cjs} +10 -10
- package/dist/{chunk-ZCU72Q76.cjs.map → chunk-NM7RWZ4E.cjs.map} +1 -1
- package/dist/{chunk-CQQQIZU4.cjs → chunk-OD6NGGL3.cjs} +133 -106
- package/dist/chunk-OD6NGGL3.cjs.map +1 -0
- package/dist/{chunk-TP5PGWIO.cjs → chunk-QFXOTJ6G.cjs} +20 -15
- package/dist/chunk-QFXOTJ6G.cjs.map +1 -0
- package/dist/{chunk-7L4X6QN2.cjs → chunk-QXMPATG6.cjs} +8 -8
- package/dist/{chunk-7L4X6QN2.cjs.map → chunk-QXMPATG6.cjs.map} +1 -1
- package/dist/{chunk-WXUU3COI.cjs → chunk-SUOHAB7N.cjs} +11 -11
- package/dist/{chunk-WXUU3COI.cjs.map → chunk-SUOHAB7N.cjs.map} +1 -1
- package/dist/{chunk-NTDQQLDD.cjs → chunk-TDA6KESI.cjs} +4 -4
- package/dist/{chunk-NTDQQLDD.cjs.map → chunk-TDA6KESI.cjs.map} +1 -1
- package/dist/{chunk-VLQCLQAS.cjs → chunk-TZYB22FM.cjs} +7 -7
- package/dist/{chunk-VLQCLQAS.cjs.map → chunk-TZYB22FM.cjs.map} +1 -1
- package/dist/{chunk-HSLPFBK2.cjs → chunk-VL7ZX4KQ.cjs} +6 -6
- package/dist/{chunk-HSLPFBK2.cjs.map → chunk-VL7ZX4KQ.cjs.map} +1 -1
- package/dist/{chunk-2F57IO7S.cjs → chunk-XCW6OY7E.cjs} +27 -27
- package/dist/{chunk-2F57IO7S.cjs.map → chunk-XCW6OY7E.cjs.map} +1 -1
- package/dist/{chunk-NG2EE7HR.cjs → chunk-YWHUWIHP.cjs} +9 -9
- package/dist/{chunk-NG2EE7HR.cjs.map → chunk-YWHUWIHP.cjs.map} +1 -1
- package/dist/connect/docx.cjs +12 -12
- package/dist/connect/index.cjs +1272 -520
- package/dist/connect/index.cjs.map +1 -1
- package/dist/connect/index.d.ts +2 -0
- package/dist/connect/index.js +12 -0
- package/dist/connect/index.js.map +2 -2
- package/dist/connect/viewer.cjs +9 -9
- package/dist/connection/ConnectedWorkflowBuilder.d.ts +12 -0
- package/dist/connection/ConnectedWorkflowBuilder.js +6 -1
- package/dist/connection/ConnectedWorkflowBuilder.js.map +2 -2
- package/dist/connection/assistant/AssistantDrafts.d.ts +21 -0
- package/dist/connection/assistant/AssistantDrafts.js +158 -0
- package/dist/connection/assistant/AssistantDrafts.js.map +7 -0
- package/dist/connection/assistant/AssistantPlan.d.ts +16 -0
- package/dist/connection/assistant/AssistantPlan.js +72 -0
- package/dist/connection/assistant/AssistantPlan.js.map +7 -0
- package/dist/connection/assistant/AssistantStatusPanel.d.ts +28 -0
- package/dist/connection/assistant/AssistantStatusPanel.js +206 -0
- package/dist/connection/assistant/AssistantStatusPanel.js.map +7 -0
- package/dist/connection/assistant/ConnectedAssistantPage.d.ts +39 -0
- package/dist/connection/assistant/ConnectedAssistantPage.js +377 -0
- package/dist/connection/assistant/ConnectedAssistantPage.js.map +7 -0
- package/dist/connection/billing/AddAddonDialog.d.ts +2 -2
- package/dist/connection/billing/AddAddonDialog.js.map +1 -1
- package/dist/connection/billing/ConnectedQuotaDialog.d.ts +1 -1
- package/dist/connection/billing/ConnectedQuotaDialog.js.map +1 -1
- package/dist/connection/billing/MonthlySpendCap.js +1 -1
- package/dist/connection/billing/MonthlySpendCap.js.map +1 -1
- package/dist/connection/billing/ProjectBilling.js.map +1 -1
- package/dist/connection/billing/ProjectPurchaseOptions.js +1 -1
- package/dist/connection/billing/ProjectPurchaseOptions.js.map +1 -1
- package/dist/connection/billing/ProjectUsageCard.js +1 -1
- package/dist/connection/billing/ProjectUsageCard.js.map +1 -1
- package/dist/connection/billing/ReduceAddonDialog.d.ts +1 -1
- package/dist/connection/billing/ReduceAddonDialog.js.map +1 -1
- package/dist/connection/billing/StripeCheckoutModal.d.ts +1 -1
- package/dist/connection/billing/StripeCheckoutModal.js.map +1 -1
- package/dist/connection/billing/addon-pricing.d.ts +4 -4
- package/dist/connection/billing/addon-pricing.js.map +1 -1
- package/dist/connection/billing/plan-constants.d.ts +3 -3
- package/dist/connection/billing/plan-constants.js +2 -2
- package/dist/connection/billing/plan-constants.js.map +1 -1
- package/dist/connection/billing/plan-pricing.d.ts +2 -2
- package/dist/connection/billing/plan-pricing.js.map +1 -1
- package/dist/connection/billing/useAddonPurchase.d.ts +1 -1
- package/dist/connection/billing/useAddonPurchase.js.map +1 -1
- package/dist/connection/conversation/AgentSteps.js +19 -2
- package/dist/connection/conversation/AgentSteps.js.map +2 -2
- package/dist/connection/viewer/ConnectedDocumentViewer.js +22 -2
- package/dist/connection/viewer/ConnectedDocumentViewer.js.map +2 -2
- package/dist/connection/viewer/useDocumentVersionRestore.d.ts +14 -0
- package/dist/connection/viewer/useDocumentVersionRestore.js +48 -0
- package/dist/connection/viewer/useDocumentVersionRestore.js.map +7 -0
- package/dist/connection/viewer/useViewerTabs.d.ts +1 -1
- package/dist/connection/viewer/useViewerTabs.js +6 -3
- package/dist/connection/viewer/useViewerTabs.js.map +2 -2
- package/dist/document-tools/VersionSnapshotBar.d.ts +4 -1
- package/dist/document-tools/VersionSnapshotBar.js +14 -0
- package/dist/document-tools/VersionSnapshotBar.js.map +2 -2
- package/dist/document-tools/index.cjs +13 -13
- package/dist/embed/index.cjs +19 -19
- package/dist/index.cjs +470 -470
- package/dist/office/index.cjs +5 -5
- package/dist/studio/index.cjs +14 -14
- package/dist/styles.css +1 -1
- package/dist/workflow-canvas/TriggerInspector.d.ts +7 -0
- package/dist/workflow-canvas/TriggerInspector.js +56 -0
- package/dist/workflow-canvas/TriggerInspector.js.map +2 -2
- package/dist/workflow-canvas/index.cjs +137 -76
- package/dist/workflow-canvas/index.cjs.map +1 -1
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/ai-IEIR7SC2.cjs.map +0 -1
- package/dist/chunk-3IH55CDE.cjs.map +0 -1
- package/dist/chunk-CQQQIZU4.cjs.map +0 -1
- package/dist/chunk-EG7EJFUE.cjs.map +0 -1
- package/dist/chunk-IWMHQTVL.cjs.map +0 -1
- package/dist/chunk-QRAQZTJE.cjs.map +0 -1
- package/dist/chunk-TP5PGWIO.cjs.map +0 -1
- package/dist/chunk-ZQNTYINE.cjs.map +0 -1
|
@@ -43,7 +43,7 @@ export declare const PAY_TODAY_UNPRICED = "Pay today: the difference for the res
|
|
|
43
43
|
export declare function addonPrice(price: ProductPrice | undefined, kind?: 'ai_usage' | 'storage'): AddonPrice | undefined;
|
|
44
44
|
/** Per add-on block of `kind` per month, ex VAT (annual plans: the monthly equivalent). */
|
|
45
45
|
export declare function addonMonthlyExVat(price: ProductPrice | undefined, kind?: 'ai_usage' | 'storage'): number | undefined;
|
|
46
|
-
/** What a checkout buys: "Pro", "Pro + 2 × £
|
|
46
|
+
/** What a checkout buys: "Pro", "Pro + 2 × £20 of AI credits + 1 × 20 GB". */
|
|
47
47
|
export declare function checkoutItemsLabel(aiBlocks: number, storageBlocks: number, collaboratorBlocks?: number, price?: ProductPrice): string;
|
|
48
48
|
/** The price of `packs` packs on this interval's price, if Stripe lists it (only one licence is listed). */
|
|
49
49
|
export declare function packPrice(price: ProductPrice | undefined, packs?: number): PackPrice | undefined;
|
|
@@ -57,6 +57,6 @@ export declare function findProPrices(products: ProductResponse[] | undefined):
|
|
|
57
57
|
export declare function calcSavingsPercent(monthlyPrice: ProductPrice | undefined, annualPrice: ProductPrice | undefined): number | null;
|
|
58
58
|
/** Most add-on blocks of each kind a checkout may include (the backend's limit). */
|
|
59
59
|
export declare const MAX_CHECKOUT_BLOCKS = 100;
|
|
60
|
-
/** "£
|
|
60
|
+
/** "£20/month ex VAT each", annual: "£180/year ex VAT each": one block on the chosen interval. */
|
|
61
61
|
export declare function checkoutBlockPriceText(price: ProductPrice | undefined, kind: 'ai_usage' | 'storage'): string | null;
|
|
62
62
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/billing/plan-pricing.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Pro plan price helpers. Prices come from Stripe via GET /v1/user/products (source of truth).\n * One plan is sold: Pro, one licence (\u00A310 of AI credits + 5 GB a month). Each price lists\n * `pack_prices` for that one licence \u2014 `amount` incl. UK VAT and `amount_ex_vat` \u2014 and\n * `addon_prices` (one add-on block on that interval). Display them as-is.\n * Legacy subscriptions with several packs keep working; their name and price come from the project.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { formatGbp } from '@arbidocs/react'\nimport { formatMoney } from './reward-balance'\nimport { formatPeriodEnd } from './addon-pricing'\nimport { taxSummary } from './tax-quote'\n\ntype PlanChangePreview = components['schemas']['PlanChangePreview']\ntype ProductPrice = components['schemas']['ProductPrice']\ntype ProductResponse = components['schemas']['ProductResponse']\ntype PackPrice = components['schemas']['PackPrice']\ntype AddonPrice = components['schemas']['AddonPrice']\n\nexport type PlanInterval = 'month' | 'year'\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** The headline price: \"\u00A340 ex VAT\". */\nexport function plusVat(exVatPence: number, currency = 'gbp'): string {\n return `${formatMoney(exVatPence, currency)} ex VAT`\n}\n\n/** The one licence Pro sells. Other pack counts exist only on legacy subscriptions (displayed, not sold). */\nexport const PRO_PACKS = 1\n\n/** A plan the pickers offer. */\nexport type PlanChoice = 'free' | 'pro'\n\n/** Packs per plan choice (0 = Free). */\nexport const PLAN_CHOICE_PACKS: Record<PlanChoice, number> = {\n free: 0,\n pro: PRO_PACKS,\n}\n\n/** \"Free\" (0), \"Pro\" (1), otherwise \"Pro \u00D7N\" (a legacy multi-pack plan; the API's own name wins). */\nexport function planNameForPacks(packs: number | null | undefined): string {\n const n = packs ?? 0\n if (n <= 0) return 'Free'\n if (n === PRO_PACKS) return 'Pro'\n return `Pro \u00D7${n}`\n}\n\n/** The plan-change panel's fixed lines, each with a test id. */\nexport interface PlanChangeLine {\n id: 'pay-today' | 'from' | 'current-until' | 'no-change' | 'awaiting-bank'\n text: string\n}\n\n/**\n * What a plan change costs, from the backend's Stripe invoice preview (taxed for the customer's\n * address), as fixed lines:\n * - \"Pay today \u00A342.00 incl. VAT (\u00A335.00 + \u00A37.00 VAT 20%)\" (\"Pay today \u00A30\" for a change that waits)\n * - \"From 16 Nov 2026: \u00A3210.00 incl. VAT (\u00A3175.00 + \u00A335.00 VAT 20%) a month\"\n * - \"Current plan until 16 Nov 2026\" for a change that waits for the period end.\n * \"No change\" when the selection is what the project already has; \"Waiting for your bank\" while\n * an earlier upgrade payment awaits 3-D Secure.\n */\nexport function planPreviewLines(preview: PlanChangePreview): PlanChangeLine[] {\n if (preview.unchanged) return [{ id: 'no-change', text: 'No change' }]\n const date = formatPeriodEnd(preview.next_renewal_at)\n const cadence = preview.interval === 'year' ? 'year' : 'month'\n const lines: PlanChangeLine[] = [\n preview.awaiting_confirmation\n ? { id: 'awaiting-bank', text: 'Waiting for your bank' }\n : {\n id: 'pay-today',\n text: preview.effective_now\n ? `Pay today ${taxSummary({\n subtotal: preview.due_now_ex_vat_pence,\n tax: preview.due_now_tax_pence,\n total: preview.due_now_pence,\n label: preview.tax_label,\n })}`\n : `Pay today ${gbp(0)}`,\n },\n {\n id: 'from',\n text: `${date ? `From ${date}` : 'From renewal'}: ${taxSummary({\n subtotal: preview.next_renewal_ex_vat_pence,\n tax: preview.next_renewal_tax_pence,\n total: preview.next_renewal_pence,\n label: preview.tax_label,\n })} a ${cadence}`,\n },\n ]\n if (!preview.effective_now) {\n lines.push({ id: 'current-until', text: `Current plan until ${date ?? 'renewal'}` })\n }\n return lines\n}\n\n/** Stand-in for \"Pay today\" when the preview failed for an upgrade. */\nexport const PAY_TODAY_UNPRICED = 'Pay today: the difference for the rest of this period'\n\n/** One add-on block's price on this interval's plan price (`addon_prices`), if listed. */\nexport function addonPrice(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): AddonPrice | undefined {\n return price?.addon_prices?.find((p) => p.kind === kind)\n}\n\n/** Per add-on block of `kind` per month, ex VAT (annual plans: the monthly equivalent). */\nexport function addonMonthlyExVat(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): number | undefined {\n return addonPrice(price, kind)?.monthly_ex_vat\n}\n\n/** What a checkout buys: \"Pro\", \"Pro + 2 \u00D7 \
|
|
4
|
+
"sourcesContent": ["/**\n * Pro plan price helpers. Prices come from Stripe via GET /v1/user/products (source of truth).\n * One plan is sold: Pro, one licence (\u00A310 of AI credits + 5 GB a month). Each price lists\n * `pack_prices` for that one licence \u2014 `amount` incl. UK VAT and `amount_ex_vat` \u2014 and\n * `addon_prices` (one add-on block on that interval). Display them as-is.\n * Legacy subscriptions with several packs keep working; their name and price come from the project.\n */\n\nimport type { components } from '@arbidocs/client'\nimport { formatGbp } from '@arbidocs/react'\nimport { formatMoney } from './reward-balance'\nimport { formatPeriodEnd } from './addon-pricing'\nimport { taxSummary } from './tax-quote'\n\ntype PlanChangePreview = components['schemas']['PlanChangePreview']\ntype ProductPrice = components['schemas']['ProductPrice']\ntype ProductResponse = components['schemas']['ProductResponse']\ntype PackPrice = components['schemas']['PackPrice']\ntype AddonPrice = components['schemas']['AddonPrice']\n\nexport type PlanInterval = 'month' | 'year'\n\nconst gbp = (pence: number) => formatMoney(pence, 'gbp')\n\n/** The headline price: \"\u00A340 ex VAT\". */\nexport function plusVat(exVatPence: number, currency = 'gbp'): string {\n return `${formatMoney(exVatPence, currency)} ex VAT`\n}\n\n/** The one licence Pro sells. Other pack counts exist only on legacy subscriptions (displayed, not sold). */\nexport const PRO_PACKS = 1\n\n/** A plan the pickers offer. */\nexport type PlanChoice = 'free' | 'pro'\n\n/** Packs per plan choice (0 = Free). */\nexport const PLAN_CHOICE_PACKS: Record<PlanChoice, number> = {\n free: 0,\n pro: PRO_PACKS,\n}\n\n/** \"Free\" (0), \"Pro\" (1), otherwise \"Pro \u00D7N\" (a legacy multi-pack plan; the API's own name wins). */\nexport function planNameForPacks(packs: number | null | undefined): string {\n const n = packs ?? 0\n if (n <= 0) return 'Free'\n if (n === PRO_PACKS) return 'Pro'\n return `Pro \u00D7${n}`\n}\n\n/** The plan-change panel's fixed lines, each with a test id. */\nexport interface PlanChangeLine {\n id: 'pay-today' | 'from' | 'current-until' | 'no-change' | 'awaiting-bank'\n text: string\n}\n\n/**\n * What a plan change costs, from the backend's Stripe invoice preview (taxed for the customer's\n * address), as fixed lines:\n * - \"Pay today \u00A342.00 incl. VAT (\u00A335.00 + \u00A37.00 VAT 20%)\" (\"Pay today \u00A30\" for a change that waits)\n * - \"From 16 Nov 2026: \u00A3210.00 incl. VAT (\u00A3175.00 + \u00A335.00 VAT 20%) a month\"\n * - \"Current plan until 16 Nov 2026\" for a change that waits for the period end.\n * \"No change\" when the selection is what the project already has; \"Waiting for your bank\" while\n * an earlier upgrade payment awaits 3-D Secure.\n */\nexport function planPreviewLines(preview: PlanChangePreview): PlanChangeLine[] {\n if (preview.unchanged) return [{ id: 'no-change', text: 'No change' }]\n const date = formatPeriodEnd(preview.next_renewal_at)\n const cadence = preview.interval === 'year' ? 'year' : 'month'\n const lines: PlanChangeLine[] = [\n preview.awaiting_confirmation\n ? { id: 'awaiting-bank', text: 'Waiting for your bank' }\n : {\n id: 'pay-today',\n text: preview.effective_now\n ? `Pay today ${taxSummary({\n subtotal: preview.due_now_ex_vat_pence,\n tax: preview.due_now_tax_pence,\n total: preview.due_now_pence,\n label: preview.tax_label,\n })}`\n : `Pay today ${gbp(0)}`,\n },\n {\n id: 'from',\n text: `${date ? `From ${date}` : 'From renewal'}: ${taxSummary({\n subtotal: preview.next_renewal_ex_vat_pence,\n tax: preview.next_renewal_tax_pence,\n total: preview.next_renewal_pence,\n label: preview.tax_label,\n })} a ${cadence}`,\n },\n ]\n if (!preview.effective_now) {\n lines.push({ id: 'current-until', text: `Current plan until ${date ?? 'renewal'}` })\n }\n return lines\n}\n\n/** Stand-in for \"Pay today\" when the preview failed for an upgrade. */\nexport const PAY_TODAY_UNPRICED = 'Pay today: the difference for the rest of this period'\n\n/** One add-on block's price on this interval's plan price (`addon_prices`), if listed. */\nexport function addonPrice(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): AddonPrice | undefined {\n return price?.addon_prices?.find((p) => p.kind === kind)\n}\n\n/** Per add-on block of `kind` per month, ex VAT (annual plans: the monthly equivalent). */\nexport function addonMonthlyExVat(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage' = 'ai_usage'\n): number | undefined {\n return addonPrice(price, kind)?.monthly_ex_vat\n}\n\n/** What a checkout buys: \"Pro\", \"Pro + 2 \u00D7 \u00A320 of AI credits + 1 \u00D7 20 GB\". */\nexport function checkoutItemsLabel(\n aiBlocks: number,\n storageBlocks: number,\n collaboratorBlocks = 0,\n price?: ProductPrice\n): string {\n const ai = addonPrice(price, 'ai_usage')?.ai_gbp\n const storage = addonPrice(price, 'storage')?.storage_gb\n const collaborators = price?.addon_prices?.find((p) => p.kind === 'collaborators')?.collaborators\n return [\n 'Pro',\n aiBlocks > 0 &&\n (ai != null\n ? `${aiBlocks} \u00D7 ${formatGbp(ai)} of AI credits`\n : `${aiBlocks} AI credits add-ons`),\n storageBlocks > 0 &&\n (storage != null ? `${storageBlocks} \u00D7 ${storage} GB` : `${storageBlocks} storage add-ons`),\n collaboratorBlocks > 0 &&\n (collaborators != null\n ? `${collaboratorBlocks * collaborators} extra collaborators`\n : `${collaboratorBlocks} collaborator add-ons`),\n ]\n .filter(Boolean)\n .join(' + ')\n}\n\n/** The price of `packs` packs on this interval's price, if Stripe lists it (only one licence is listed). */\nexport function packPrice(\n price: ProductPrice | undefined,\n packs: number = PRO_PACKS\n): PackPrice | undefined {\n return price?.pack_prices?.find((p) => p.packs === packs)\n}\n\nexport interface ProPrices {\n monthly?: ProductPrice\n annual?: ProductPrice\n}\n\n/** The Pro product's monthly and annual prices (default price per interval wins). */\nexport function findProPrices(products: ProductResponse[] | undefined): ProPrices {\n const prices = products?.[0]?.prices ?? []\n const pick = (interval: PlanInterval) =>\n prices.find((p) => p.interval === interval && p.default_price) ??\n prices.find((p) => p.interval === interval)\n return { monthly: pick('month'), annual: pick('year') }\n}\n\n/** Annual savings vs 12 \u00D7 monthly, as a whole percent (e.g. \u00A3360 vs \u00A3480 \u2192 25). */\nexport function calcSavingsPercent(\n monthlyPrice: ProductPrice | undefined,\n annualPrice: ProductPrice | undefined\n): number | null {\n const monthly = packPrice(monthlyPrice)?.amount ?? monthlyPrice?.amount\n const annual = packPrice(annualPrice)?.amount ?? annualPrice?.amount\n if (monthly == null || annual == null || monthly === 0) return null\n const savings = Math.round(((monthly * 12 - annual) / (monthly * 12)) * 100)\n return savings > 0 ? savings : null\n}\n\n/** Most add-on blocks of each kind a checkout may include (the backend's limit). */\nexport const MAX_CHECKOUT_BLOCKS = 100\n\n/** \"\u00A320/month ex VAT each\", annual: \"\u00A3180/year ex VAT each\": one block on the chosen interval. */\nexport function checkoutBlockPriceText(\n price: ProductPrice | undefined,\n kind: 'ai_usage' | 'storage'\n): string | null {\n const block = addonPrice(price, kind)\n if (!block) return null\n const currency = price?.currency ?? 'gbp'\n return price?.interval === 'year'\n ? `${formatMoney(block.amount_ex_vat, currency)}/year ex VAT each`\n : `${formatMoney(block.amount_ex_vat, currency)}/month ex VAT each`\n}\n"],
|
|
5
5
|
"mappings": ";AASA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,uBAAuB;AAChC,SAAS,kBAAkB;AAU3B,MAAM,MAAM,CAAC,UAAkB,YAAY,OAAO,KAAK;AAGhD,SAAS,QAAQ,YAAoB,WAAW,OAAe;AACpE,SAAO,GAAG,YAAY,YAAY,QAAQ,CAAC;AAC7C;AAGO,MAAM,YAAY;AAMlB,MAAM,oBAAgD;AAAA,EAC3D,MAAM;AAAA,EACN,KAAK;AACP;AAGO,SAAS,iBAAiB,OAA0C;AACzE,QAAM,IAAI,SAAS;AACnB,MAAI,KAAK,EAAG,QAAO;AACnB,MAAI,MAAM,UAAW,QAAO;AAC5B,SAAO,WAAQ,CAAC;AAClB;AAiBO,SAAS,iBAAiB,SAA8C;AAC7E,MAAI,QAAQ,UAAW,QAAO,CAAC,EAAE,IAAI,aAAa,MAAM,YAAY,CAAC;AACrE,QAAM,OAAO,gBAAgB,QAAQ,eAAe;AACpD,QAAM,UAAU,QAAQ,aAAa,SAAS,SAAS;AACvD,QAAM,QAA0B;AAAA,IAC9B,QAAQ,wBACJ,EAAE,IAAI,iBAAiB,MAAM,wBAAwB,IACrD;AAAA,MACE,IAAI;AAAA,MACJ,MAAM,QAAQ,gBACV,aAAa,WAAW;AAAA,QACtB,UAAU,QAAQ;AAAA,QAClB,KAAK,QAAQ;AAAA,QACb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AAGO,SAAS,UACd,OACA,QAAgB,WACO;AACvB,SAAO,OAAO,aAAa,KAAK,CAAC,MAAM,EAAE,UAAU,KAAK;AAC1D;AAQO,SAAS,cAAc,UAAoD;AAChF,QAAM,SAAS,WAAW,CAAC,GAAG,UAAU,CAAC;AACzC,QAAM,OAAO,CAAC,aACZ,OAAO,KAAK,CAAC,MAAM,EAAE,aAAa,YAAY,EAAE,aAAa,KAC7D,OAAO,KAAK,CAAC,MAAM,EAAE,aAAa,QAAQ;AAC5C,SAAO,EAAE,SAAS,KAAK,OAAO,GAAG,QAAQ,KAAK,MAAM,EAAE;AACxD;AAGO,SAAS,mBACd,cACA,aACe;AACf,QAAM,UAAU,UAAU,YAAY,GAAG,UAAU,cAAc;AACjE,QAAM,SAAS,UAAU,WAAW,GAAG,UAAU,aAAa;AAC9D,MAAI,WAAW,QAAQ,UAAU,QAAQ,YAAY,EAAG,QAAO;AAC/D,QAAM,UAAU,KAAK,OAAQ,UAAU,KAAK,WAAW,UAAU,MAAO,GAAG;AAC3E,SAAO,UAAU,IAAI,UAAU;AACjC;AAGO,MAAM,sBAAsB;AAG5B,SAAS,uBACd,OACA,MACe;AACf,QAAM,QAAQ,WAAW,OAAO,IAAI;AACpC,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,WAAW,OAAO,YAAY;AACpC,SAAO,OAAO,aAAa,SACvB,GAAG,YAAY,MAAM,eAAe,QAAQ,CAAC,sBAC7C,GAAG,YAAY,MAAM,eAAe,QAAQ,CAAC;AACnD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* useAddonPurchase — buy one add-on block (+£
|
|
2
|
+
* useAddonPurchase — buy one add-on block (+£20 of AI credits or +20 GB) for a Pro project and tell
|
|
3
3
|
* the user what happened. The monthly usage cap limits automatic top-ups only, so it never refuses a block
|
|
4
4
|
* bought here. The block is charged now for the current period and then renews every
|
|
5
5
|
* period until the user reduces it. Shared by the add-on confirm dialog (project Add-ons card,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/billing/useAddonPurchase.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * useAddonPurchase \u2014 buy one add-on block (+\
|
|
4
|
+
"sourcesContent": ["/**\n * useAddonPurchase \u2014 buy one add-on block (+\u00A320 of AI credits or +20 GB) for a Pro project and tell\n * the user what happened. The monthly usage cap limits automatic top-ups only, so it never refuses a block\n * bought here. The block is charged now for the current period and then renews every\n * period until the user reduces it. Shared by the add-on confirm dialog (project Add-ons card,\n * quota-exceeded modal).\n *\n * - `paid` \u2192 the block is live now.\n * - `requires_action` \u2192 the bank wants 3-D Secure: open Stripe's hosted invoice in a new tab;\n * the block is added once confirmed (the next refresh picks it up).\n * - 402 `{code, message}` (declined / no card / no billing address) \u2192 the\n * refusal template (\"\u2026 Nothing was charged. \u2026\"); any other failure leaves the outcome unknown:\n * `onUnknownError` lets the caller check the project before saying what happened.\n */\n\nimport { useCallback } from 'react'\nimport { formatGbp, useAddProjectAddonBlock, useArbiSessionStore } from '@arbidocs/react'\nimport { notify } from '@arbidocs/react/shell'\nimport {\n SEEN_ADDON_BLOCKS_VIEW,\n withAddonBlocksBought,\n type SeenAddonBlocks,\n} from '../runtime/requests'\nimport { refusal } from './refusal-copy'\nimport { apiErrorDetail } from './api-error'\nimport { ADDON_BLOCK_AI_GBP, STORAGE_BLOCK_GB } from './plan-constants'\nimport { entityNoun } from '@arbidocs/react/ui'\n\nexport type AddonKind = 'ai_usage' | 'storage'\n\nexport type AddonErrorCode =\n 'PAYMENT_DECLINED' | 'PAYMENT_METHOD_REQUIRED' | 'BILLING_ADDRESS_REQUIRED'\n\nconst FALLBACK_MESSAGES: Record<AddonErrorCode, string> = {\n PAYMENT_DECLINED: 'Card declined. Update your card and try again.',\n get PAYMENT_METHOD_REQUIRED() {\n return `Add a card to this ${entityNoun('PROJECT')} first.`\n },\n BILLING_ADDRESS_REQUIRED: 'Add a billing address first.',\n}\n\n/** The user-facing message for a failed add-on request (402 detail object or plain detail). */\nexport function addonErrorMessage(error: unknown): string {\n const detail = apiErrorDetail(error)\n if (detail && typeof detail === 'object') {\n const { code, message } = detail as { code?: string; message?: string }\n if (message) return message\n if (code && code in FALLBACK_MESSAGES) return FALLBACK_MESSAGES[code as AddonErrorCode]\n }\n if (typeof detail === 'string' && detail) return detail\n return \"The add-on didn't go through. Try again.\"\n}\n\nconst REFUSALS: Record<AddonErrorCode, string> = {\n PAYMENT_DECLINED: refusal('Card declined', 'Update your card and try again'),\n get PAYMENT_METHOD_REQUIRED() {\n return refusal(`No card on this ${entityNoun('PROJECT')}`, 'Add one with Update card')\n },\n get BILLING_ADDRESS_REQUIRED() {\n return refusal(\n `No billing address on this ${entityNoun('PROJECT')}`,\n 'Add one with Update card'\n )\n },\n}\n\n/** The refusal for a charge the backend turned down (402 with a known code), else null. */\nfunction chargeRefusalMessage(error: unknown): string | null {\n const code = addonErrorCode(error)\n return code ? REFUSALS[code] : null\n}\n\n/** The 402 code of a failed add-on request, if it has one. */\nexport function addonErrorCode(error: unknown): AddonErrorCode | null {\n const detail = apiErrorDetail(error)\n if (detail && typeof detail === 'object') {\n const code = (detail as { code?: string }).code\n if (code && code in FALLBACK_MESSAGES) return code as AddonErrorCode\n }\n return null\n}\n\n/** \"\u00A320 of AI credits added\" / \"20 GB added\". */\nconst addedMessage = (\n kind: AddonKind,\n blockAiGbp: number | undefined,\n blockStorageGb: number | undefined\n) =>\n kind === 'ai_usage'\n ? `${formatGbp(blockAiGbp ?? ADDON_BLOCK_AI_GBP)} of AI credits added`\n : `${blockStorageGb ?? STORAGE_BLOCK_GB} GB added`\n\nexport function useAddonPurchase() {\n const addBlock = useAddProjectAddonBlock()\n const { mutate } = addBlock\n const session = useArbiSessionStore()\n\n const buy = useCallback(\n (\n kind: AddonKind,\n projectExtId: string,\n options?: {\n onPaid?: () => void\n onRequiresAction?: () => void\n onError?: (code: AddonErrorCode | null) => void\n /** A failure that doesn't say whether the charge went through (timeout, 5xx). */\n onUnknownError?: () => void\n }\n ) => {\n mutate(\n { projectExtId, kind },\n {\n onSuccess: (result) => {\n if (result.status === 'requires_action') {\n if (result.confirm_url) window.open(result.confirm_url, '_blank', 'noopener')\n notify.info('Confirm the payment with your bank. The add-on starts once confirmed.')\n options?.onRequiresAction?.()\n return\n }\n // This add-on was bought here, so the arrival notice doesn't announce it again.\n const addons = result.project?.addons\n if (addons) {\n const seen = (session.getState().views.values[SEEN_ADDON_BLOCKS_VIEW] ??\n {}) as SeenAddonBlocks\n session.setViewValue(\n SEEN_ADDON_BLOCKS_VIEW,\n withAddonBlocksBought(seen, projectExtId, {\n ai: addons.ai_blocks,\n storage: addons.storage_blocks,\n })\n )\n }\n notify.success(addedMessage(kind, addons?.block_ai_gbp, addons?.block_storage_gb))\n options?.onPaid?.()\n },\n onError: (error) => {\n const refused = chargeRefusalMessage(error)\n if (refused || !options?.onUnknownError) {\n notify.error(refused ?? addonErrorMessage(error))\n } else {\n options.onUnknownError()\n }\n options?.onError?.(addonErrorCode(error))\n },\n }\n )\n },\n [mutate, session]\n )\n\n return { buy, isPending: addBlock.isPending }\n}\n"],
|
|
5
5
|
"mappings": ";AAeA,SAAS,mBAAmB;AAC5B,SAAS,WAAW,yBAAyB,2BAA2B;AACxE,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAC/B,SAAS,oBAAoB,wBAAwB;AACrD,SAAS,kBAAkB;AAO3B,MAAM,oBAAoD;AAAA,EACxD,kBAAkB;AAAA,EAClB,IAAI,0BAA0B;AAC5B,WAAO,sBAAsB,WAAW,SAAS,CAAC;AAAA,EACpD;AAAA,EACA,0BAA0B;AAC5B;AAGO,SAAS,kBAAkB,OAAwB;AACxD,QAAM,SAAS,eAAe,KAAK;AACnC,MAAI,UAAU,OAAO,WAAW,UAAU;AACxC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AAS,mBAAmB;AAC5B;AAAA,YACF;AAEA,kBAAM,SAAS,OAAO,SAAS;AAC/B,gBAAI,QAAQ;AACV,oBAAM,OAAQ,QAAQ,SAAS,EAAE,MAAM,OAAO,sBAAsB,KAClE,CAAC;AACH,sBAAQ;AAAA,gBACN;AAAA,gBACA,sBAAsB,MAAM,cAAc;AAAA,kBACxC,IAAI,OAAO;AAAA,kBACX,SAAS,OAAO;AAAA,gBAClB,CAAC;AAAA,cACH;AAAA,YACF;AACA,mBAAO,QAAQ,aAAa,MAAM,QAAQ,cAAc,QAAQ,gBAAgB,CAAC;AACjF,qBAAS,SAAS;AAAA,UACpB;AAAA,UACA,SAAS,CAAC,UAAU;AAClB,kBAAM,UAAU,qBAAqB,KAAK;AAC1C,gBAAI,WAAW,CAAC,SAAS,gBAAgB;AACvC,qBAAO,MAAM,WAAW,kBAAkB,KAAK,CAAC;AAAA,YAClD,OAAO;AACL,sBAAQ,eAAe;AAAA,YACzB;AACA,qBAAS,UAAU,eAAe,KAAK,CAAC;AAAA,UAC1C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,QAAQ,OAAO;AAAA,EAClB;AAEA,SAAO,EAAE,KAAK,WAAW,SAAS,UAAU;AAC9C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,8 +7,15 @@ import {
|
|
|
7
7
|
getDocumentTitle,
|
|
8
8
|
ProviderIcon
|
|
9
9
|
} from "@arbidocs/react/ui";
|
|
10
|
-
import {
|
|
11
|
-
|
|
10
|
+
import {
|
|
11
|
+
formatGbp,
|
|
12
|
+
useAvailableModels,
|
|
13
|
+
useDocuments,
|
|
14
|
+
useInvalidateWorkflows,
|
|
15
|
+
useInvalidateAssistant,
|
|
16
|
+
useUserSettings
|
|
17
|
+
} from "@arbidocs/react";
|
|
18
|
+
import React, { useEffect, useMemo } from "react";
|
|
12
19
|
import {
|
|
13
20
|
GoalCriteria,
|
|
14
21
|
StepDetail,
|
|
@@ -72,6 +79,16 @@ const AgentStepsComponent = ({
|
|
|
72
79
|
}) => {
|
|
73
80
|
const { data: userSettings } = useUserSettings();
|
|
74
81
|
const isDeveloper = userSettings?.developer === true;
|
|
82
|
+
const invalidateWorkflows = useInvalidateWorkflows();
|
|
83
|
+
const createdWorkflow = steps.some((step) => getStepTool(step) === "create_workflow");
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (createdWorkflow && !isStreaming) void invalidateWorkflows();
|
|
86
|
+
}, [createdWorkflow, isStreaming]);
|
|
87
|
+
const invalidateAssistant = useInvalidateAssistant();
|
|
88
|
+
const setBrief = steps.some((step) => getStepTool(step) === "set_assistant_brief");
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (setBrief && !isStreaming) void invalidateAssistant();
|
|
91
|
+
}, [setBrief, isStreaming]);
|
|
75
92
|
const { data: documents = [] } = useDocuments();
|
|
76
93
|
const docInfo = useMemo(() => {
|
|
77
94
|
const map = {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/conversation/AgentSteps.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * A turn's agent steps, bound to the session: the step trace (`StepTrace` and its rows) filled\n * from the step stream, with the workspace's document names, the model tiers, the developer\n * details and the live duration of the running step.\n */\n\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n getDocumentTitle,\n ProviderIcon,\n} from '@arbidocs/react/ui'\nimport { formatGbp, useAvailableModels, useDocuments, useUserSettings } from '@arbidocs/react'\nimport React, { useMemo } from 'react'\nimport {\n GoalCriteria,\n StepDetail,\n StepNarration,\n StepOutcome,\n StepParams,\n StepRow,\n StepSummary,\n StepTrace,\n StepTraceSummary,\n SubAgentLane,\n SubStepGroup,\n type GoalCriterionView,\n} from '../../agents/runs/AgentSteps'\nimport {\n getAgentStepPresentation,\n getModelIcon,\n MODEL_TIER_ICON_MAP,\n MODEL_TIER_LABELS,\n stepAccent,\n} from '../../agents/runs/step-presentation'\nimport { MessageLiveSeconds, type MessageTimerSubscription } from './MessageLiveSeconds'\nimport { ConnectedMarkdown } from './ConnectedMarkdown'\nimport {\n computeRunStats,\n extractSubagentLanes,\n formatTokens,\n getAgentStepLabel,\n getCurrentStep,\n getStepDisplay,\n getStepTool,\n isNearAiUsageBudget,\n mergeAgentSteps,\n subagentJobLabel,\n type AgentStepEvent,\n type ContextUsage,\n type DocInfoMap,\n} from '@arbidocs/sdk/browser'\n\n/** A workspace document, as the step trace names it. */\ntype StepDocument = { external_id: string; file_name?: string | null; n_pages?: number | null }\n\n/** Fields injected by the backend for display \u2014 excluded from param rendering */\nconst DISPLAY_FIELDS = new Set(['tool', 'label', 'icon', 'summary'])\n\n/**\n * Extract tool parameters from a detail entry, excluding display fields.\n * Returns key-value pairs for inline rendering.\n */\nfunction getToolParams(detail: Record<string, unknown>): Array<{ key: string; value: string }> {\n const params: Array<{ key: string; value: string }> = []\n for (const [key, value] of Object.entries(detail)) {\n if (DISPLAY_FIELDS.has(key) || value == null) continue\n const strValue = typeof value === 'string' ? value : JSON.stringify(value)\n params.push({ key, value: strValue })\n }\n return params\n}\n\nfunction StepModelIcon({ modelName, tag }: { modelName?: string | null; tag: string | null }) {\n // Premium \u2192 brand mark; Fast/Wise \u2192 their name icon; otherwise the tag icon.\n const cfg = tag === 'Premium' ? null : getModelIcon(modelName, tag)\n if (tag !== 'Premium' && !cfg) return null\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <span className=\"flex-shrink-0\">\n {tag === 'Premium' ? (\n <ProviderIcon modelName={modelName ?? undefined} size={11} />\n ) : (\n cfg && <cfg.icon className={cfg.className} style={{ width: 11, height: 11 }} />\n )}\n </span>\n </TooltipTrigger>\n <TooltipContent>{modelName}</TooltipContent>\n </Tooltip>\n )\n}\n\ninterface AgentStepsProps {\n steps: AgentStepEvent[]\n isStreaming: boolean\n className?: string\n /**\n * Total elapsed seconds for the message \u2014 used as a static fallback for the\n * last step's duration when `liveTimer` is not provided (e.g. messages\n * loaded from history). When `liveTimer` is provided this prop is forwarded\n * to the leaf as the post-generation fallback.\n */\n totalElapsedTime?: number\n /**\n * Optional live-timer subscription. When provided, the last step's duration\n * is rendered by a leaf component so the parent does not re-render at the\n * 100 ms timer cadence.\n */\n liveTimer?: MessageTimerSubscription\n /**\n * When true (the live bar's expander), hide what the bar already shows live \u2014\n * the agent's current step and any still-running sub-agents \u2014 so the expander\n * is purely \"what came before\", never a duplicate of the footer. Finished\n * sub-agents stay (they're history). No effect once settled.\n */\n hideLive?: boolean\n /**\n * This turn's settled context/AI usage (\u00A3) (`message.finalContextUsage`).\n * \u00A3 spent belongs here, on the turn that spent them \u2014 not on the\n * composer's forward-looking context bar, which is about future messages.\n */\n contextUsage?: ContextUsage | null\n}\n\nconst AgentStepsComponent: React.FC<AgentStepsProps> = ({\n steps,\n isStreaming,\n className,\n totalElapsedTime,\n liveTimer,\n hideLive = false,\n contextUsage,\n}) => {\n const { data: userSettings } = useUserSettings()\n const isDeveloper = userSettings?.developer === true\n\n // Build doc_ext_id \u2192 {name, pages} map from workspace documents (cached by React Query)\n const { data: documents = [] } = useDocuments()\n const docInfo = useMemo(() => {\n const map: DocInfoMap = {}\n const docArray = Array.isArray(documents) ? documents : []\n for (const doc of docArray) {\n if (doc && 'external_id' in doc) {\n const d = doc as StepDocument\n // Use the canonical document entity label (doc_metadata.title ?? file\n // name), not the raw file name, so references resolve to the same name\n // the rest of the app shows.\n map[d.external_id] = {\n name: getDocumentTitle(d, d.file_name ?? d.external_id),\n pages: d.n_pages ?? null,\n }\n }\n }\n return map\n }, [documents])\n\n // Resolve model name \u2192 tag for looking up tier icons\n const { data: availableModels } = useAvailableModels()\n const getModelTag = useMemo(() => {\n return (modelName?: string | null): string | null => {\n if (!modelName || !availableModels?.models) return null\n return availableModels.models.find((m) => m.model_name === modelName)?.tags?.[0] || null\n }\n }, [availableModels])\n\n // Raw SSE events \u2192 the logical steps a reader sees. Shared with the `Step N`\n // counter so the count always matches the rows rendered below.\n //\n // When `hideLive` (the live bar's expander), the current step STAYS \u2014 the\n // drawer is a complete, correctly-numbered list with the active step\n // highlighted as the last row, matching the \"Step N\" position on the bar.\n // (Dropping it made the drawer show N-1 rows while the bar said N, and marked\n // the *previous* step active.) Still-running sub-agents are the one thing\n // dropped: they have their own live lanes in the roster beneath the bar, so\n // showing them here too would double-render them.\n const mergedSteps = useMemo(() => {\n const merged = mergeAgentSteps(steps)\n if (!hideLive) return merged\n const runningHandles = new Set(\n extractSubagentLanes(merged)\n .filter((l) => l.status === 'running')\n .map((l) => l.handle)\n )\n return merged.filter((s) => !(s.subagent && runningHandles.has(s.subagent)))\n }, [steps, hideLive])\n\n // Compute step durations: duration = next_step.t - current_step.t\n // For the last step, use totalElapsedTime (frontend timer) if available\n const stepDurations = useMemo(() => {\n const durations: (number | null)[] = []\n for (let i = 0; i < mergedSteps.length; i++) {\n const currentT = mergedSteps[i].t\n if (currentT == null) {\n durations.push(null)\n continue\n }\n if (i + 1 < mergedSteps.length) {\n const nextT = mergedSteps[i + 1].t\n durations.push(nextT != null ? nextT - currentT : null)\n } else {\n // Last step: close it with the turn's total elapsed time.\n //\n // This is the one place two clocks meet \u2014 `totalElapsedTime` is the\n // client's wall-clock for a live turn, while `t` is the backend's\n // seconds-since-stream-start. They agree when the client watched the\n // whole stream, but a client that started late (a reconnect, or a\n // background conversation opened mid-run) measures less than the\n // backend, and the subtraction goes negative: the trace rendered\n // \"Answered \u221221.9s\". Show nothing rather than a duration we know is\n // wrong \u2014 a settled turn re-read from history uses the backend's own\n // completed `t`, so it stays consistent there.\n const remaining = totalElapsedTime != null ? totalElapsedTime - currentT : null\n durations.push(remaining != null && remaining >= 0 ? remaining : null)\n }\n }\n return durations\n }, [mergedSteps, totalElapsedTime])\n\n // Display step_tokens (per-step cost) directly from the backend.\n const stepTokens = useMemo(() => {\n return mergedSteps.map((step) => step.step_tokens ?? null)\n }, [mergedSteps])\n\n // Per-step \u00A3 cost \u2014 an estimate (cached model pricing, not the\n // authoritative LiteLLM cost), but useful to see which step is expensive\n // while the turn is still streaming. User-facing (unlike step_tokens,\n // which is raw and developer-gated) since \u00A3 is the budget unit the\n // user actually spends against.\n const stepGbp = useMemo(() => {\n return mergedSteps.map((step) => step.step_gbp ?? null)\n }, [mergedSteps])\n\n // Following the run is the HOST's job, not this list's: AgentBarShell pins\n // its drawer to the bottom while the user hasn't scrolled away. A\n // scrollIntoView here looked like it nudged \"the nearest scroll container\",\n // but it scrolls EVERY ancestor short of the viewport \u2014 each streamed tick\n // yanked the whole conversation back to this list while the user was\n // reading elsewhere on the page.\n const currentStepIndex = isStreaming ? getCurrentStep(mergedSteps)?.index : undefined\n\n if (mergedSteps.length === 0) return null\n\n // Two groupings run in one pass:\n // \u2022 Concurrent sub-agent LANES \u2014 steps carrying a `subagent` handle are pulled\n // into their own live lane (spawn marker \u2192 intermediate steps \u2192 done marker),\n // rendered as a card at the position of the lane's spawn. Multiple children\n // running at once each get their own lane, so fan-out reads as parallel work.\n // \u2022 Legacy parent_index NESTING \u2014 a handle-less sub-step (older single-child\n // relays) still indents under the parent tool step that spawned it.\n const posByIndex = new Map(mergedSteps.map((s, idx) => [s.index, idx]))\n const childrenByParent = new Map<number, AgentStepEvent[]>()\n const topLevelSteps: AgentStepEvent[] = []\n const laneStepsByHandle = new Map<string, AgentStepEvent[]>()\n const laneSpawnIndex = new Map<string, number>()\n for (const step of mergedSteps) {\n const handle = step.subagent\n if (handle) {\n const arr = laneStepsByHandle.get(handle)\n if (arr) arr.push(step)\n else {\n laneStepsByHandle.set(handle, [step])\n laneSpawnIndex.set(handle, step.index)\n }\n continue\n }\n const parent = step.parent_index\n if (parent != null && parent !== step.index && posByIndex.has(parent)) {\n const siblings = childrenByParent.get(parent) ?? []\n siblings.push(step)\n childrenByParent.set(parent, siblings)\n } else {\n topLevelSteps.push(step)\n }\n }\n\n // Interleave top-level steps and lanes by index, so a lane appears exactly where\n // its child was spawned in the parent's timeline.\n type DisplayRow = { index: number; step?: AgentStepEvent; lane?: string }\n const displayRows: DisplayRow[] = [\n ...topLevelSteps.map((s) => ({ index: s.index, step: s })),\n ...[...laneStepsByHandle.keys()].map((h) => ({ index: laneSpawnIndex.get(h) ?? 0, lane: h })),\n ].sort((a, b) => a.index - b.index)\n\n // Display numbers: top-level rows read 1..N (lanes count as a row); a fold's\n // inner rows read \"<parent>.<n>\".\n const displayNumber = new Map<number, string>()\n displayRows.forEach((r, i) => {\n if (r.lane) {\n // Lane inner steps read \"<lane>.<n>\".\n laneStepsByHandle\n .get(r.lane)\n ?.filter((s) => !s.subagent_status)\n .forEach((c, ci) => displayNumber.set(c.index, `${i + 1}.${ci + 1}`))\n return\n }\n displayNumber.set(r.step!.index, String(i + 1))\n childrenByParent\n .get(r.step!.index)\n ?.forEach((c, ci) => displayNumber.set(c.index, `${i + 1}.${ci + 1}`))\n })\n\n const lastStepIndex = mergedSteps[mergedSteps.length - 1].index\n\n const renderRow = (step: AgentStepEvent, depth: number, isLastInList: boolean) => {\n const i = posByIndex.get(step.index)!\n const presentation = getAgentStepPresentation(step, docInfo)\n const { tool, Icon } = presentation\n const { label, summary, isMultiLine, details } = getStepDisplay(step, docInfo)\n const accent = stepAccent(step, tool)\n const duration = stepDurations[i]\n const isLastStep = step.index === lastStepIndex\n const isActive = step.index === currentStepIndex\n\n // Goal-step model tier icon (auto mode) \u2014 the tier the router picked. It\n // stands in for the goal step's raw outcome (\"fast, all 0 docs\"), so it\n // carries a tooltip: an unlabelled glyph would just be cryptic noise.\n const tier = step.step === 'goal' ? step.model_recommendation : null\n const TierIcon = tier ? MODEL_TIER_ICON_MAP[tier] : null\n\n // The last step during streaming renders its duration through a leaf that\n // subscribes to the message timer directly, keeping the 10 Hz tick\n // contained so AgentSteps and its parent stay stable across timer updates.\n const useLiveDuration = isLastStep && liveTimer != null && step.t != null\n const durationNode: React.ReactNode = useLiveDuration ? (\n <MessageLiveSeconds\n {...liveTimer!}\n offsetSeconds={step.t!}\n fallbackSeconds={totalElapsedTime ?? null}\n minDisplaySeconds={0.05}\n />\n ) : duration != null ? (\n `${duration.toFixed(1)}s`\n ) : null\n\n // The goal step's outcome is internal routing (\"fast, all 0 docs\") \u2014 cryptic\n // to a reader and redundant with the model-tier icon beside the label. Tool\n // outcomes (\"15 passages retrieved\") are real feedback, so those stay.\n const showOutcome = step.outcome && step.step !== 'goal'\n // A green tick on \"exit 1\" claims the step succeeded when it didn't \u2014 the\n // code agent's first attempt failing then retrying is exactly the story the\n // trace should tell honestly.\n const outcomeFailed = !!step.outcome && isFailureOutcome(step.outcome)\n\n // Raw tool params are a developer affordance, and only when the backend\n // gave us no summary to show instead.\n const hasSummary = step.detail?.some((d) => (d as { summary?: string }).summary)\n const toolParams =\n isDeveloper && step.detail && !step.step && !hasSummary\n ? step.detail.flatMap((d) => getToolParams(d as Record<string, unknown>))\n : []\n\n const criteria =\n step.step === 'goal_progress' && step.detail && step.detail.length > 0\n ? (step.detail as Array<{\n criterion?: string\n text?: string\n status?: string\n note?: string\n }>)\n : null\n\n const criteriaView: GoalCriterionView[] | null = criteria\n ? criteria.map((c, idx) => ({\n key: c.criterion ?? String(idx),\n text: c.text || c.criterion || '',\n note: c.note,\n met: isCriterionMet(c.status),\n }))\n : null\n const folded = childrenByParent.get(step.index)\n\n return (\n <StepRow\n key={step.index}\n index={step.index}\n number={displayNumber.get(step.index) ?? String(i + 1)}\n depth={depth}\n isLast={isLastInList}\n isActive={isActive}\n accent={accent}\n icon={<Icon size={12} strokeWidth={2.25} />}\n kind={step.narration ? 'narration' : (step.step ?? 'tool')}\n title={isActive ? presentation.description : label}\n titleTestId={isActive ? 'agent-expanded-current-step-description' : undefined}\n badge={\n TierIcon ? (\n <Tooltip>\n <TooltipTrigger asChild>\n <span className=\"flex shrink-0 items-center self-center\">\n <TierIcon size={12} className={accent.fg} aria-hidden />\n </span>\n </TooltipTrigger>\n <TooltipContent side=\"top\">{MODEL_TIER_LABELS[tier!] ?? tier}</TooltipContent>\n </Tooltip>\n ) : undefined\n }\n meta={\n <>\n {isDeveloper && (\n <StepModelIcon modelName={step.usage?.model} tag={getModelTag(step.usage?.model)} />\n )}\n {isDeveloper && stepTokens[i] != null && (\n <span>{formatTokens(stepTokens[i]!)} tok</span>\n )}\n {/* Not on the active row: this step's cost is a frozen snapshot of the ONE LLM call\n that produced it; next to a spinner it would read as \"still counting\". */}\n {!isActive && stepGbp[i] != null && <span>{formatGbp(stepGbp[i]!)}</span>}\n {durationNode != null && <span>{durationNode}</span>}\n </>\n }\n >\n {summary &&\n !isActive &&\n (step.narration ? (\n /* Narration is PROSE (headings, bold, lists): render markdown, not raw asterisks.\n Tool summaries stay plain text: one-line headlines where a clamp matters. */\n <StepNarration index={step.index}>\n <ConnectedMarkdown isStreaming={false}>{summary}</ConnectedMarkdown>\n </StepNarration>\n ) : (\n <StepSummary index={step.index} multiLine={isMultiLine}>\n {summary}\n </StepSummary>\n ))}\n\n {/* What the narrative displaced: the tool's target or a plan's checklist. Dimmer than\n the summary: it answers \"on what?\", not \"doing what?\". */}\n {details.map((d, di) => (\n <StepDetail key={di} index={step.index}>\n {d}\n </StepDetail>\n ))}\n\n {showOutcome && (\n <StepOutcome index={step.index} failed={outcomeFailed}>\n {step.outcome}\n </StepOutcome>\n )}\n\n {toolParams.length > 0 && (\n <StepParams>{toolParams.map((p) => `${p.key}=${p.value}`).join(' ')}</StepParams>\n )}\n\n {step.routing && (\n <details className=\"mt-1 text-xs text-muted-foreground\" data-testid=\"routing-details\">\n <summary className=\"cursor-pointer\">Routing details</summary>\n <dl className=\"mt-2 space-y-2\">\n <div>\n <dt className=\"font-medium\">Answer model</dt>\n <dd>\n {step.routing.selected_model}\n {step.routing.model_recommendation\n ? ` (${step.routing.model_recommendation})`\n : ''}\n </dd>\n </div>\n <div>\n <dt className=\"font-medium\">Default document search</dt>\n <dd>\n {step.routing.selected_doc_ext_ids.length\n ? step.routing.selected_doc_ext_ids\n .map((id) => docInfo[id]?.name ?? step.routing!.document_titles[id] ?? id)\n .join(', ')\n : 'No documents selected'}\n </dd>\n <dd>The complete document catalogue remains available for direct reading.</dd>\n </div>\n <div>\n <dt className=\"font-medium\">Always available tools</dt>\n <dd>\n {step.routing.always_available_tool_names\n .map((name) => name.replaceAll('_', ' '))\n .join(', ') || 'None'}\n </dd>\n </div>\n <div>\n <dt className=\"font-medium\">Additional tools</dt>\n <dd>\n {step.routing.selected_tool_names == null\n ? 'All enabled tools retained'\n : step.routing.selected_tool_names\n .filter((name) => !step.routing!.always_available_tool_names.includes(name))\n .map((name) => name.replaceAll('_', ' '))\n .join(', ') || 'None'}\n </dd>\n </div>\n <div>\n <dt className=\"font-medium\">History</dt>\n <dd>\n {step.routing.retained_message_ext_ids.length} messages retained\n {step.routing.history_retained_by_policy\n ? '; full history preserved by policy'\n : ''}\n </dd>\n </div>\n <div>\n <dt className=\"font-medium\">Router</dt>\n <dd>\n {step.routing.router_model} \u00B7 {step.routing.elapsed_seconds.toFixed(3)}s\n {step.routing.input_tokens != null\n ? ` \u00B7 ${step.routing.input_tokens.toLocaleString()} input tokens`\n : ''}\n </dd>\n </div>\n {step.routing.status === 'fallback' && (\n <div>\n <dt className=\"font-medium\">Fallback</dt>\n <dd>\n Context and authorized tools retained (\n {step.routing.fallback_reason ?? 'router unavailable'}).\n </dd>\n </div>\n )}\n </dl>\n </details>\n )}\n\n {criteriaView && <GoalCriteria criteria={criteriaView} />}\n\n {/* Sub-agent steps nest under the tool step that spawned them, COLLAPSED: a\n deep_research run emits a dozen inner rows that buried the parent trace. The parent\n keeps the count so the work is never hidden, just folded. */}\n {folded && folded.length > 0 && (\n <SubStepGroup\n parentIndex={step.index}\n summary={summariseSubSteps(folded)}\n openClassName={accent.fg}\n renderSteps={() =>\n folded.map((c, ci, arr) => renderRow(c, depth + 1, ci === arr.length - 1))\n }\n />\n )}\n </StepRow>\n )\n }\n\n let summaryNode: React.ReactNode = null\n if (contextUsage?.spent_gbp != null) {\n const runStats = computeRunStats(steps)\n // Prefer the run's true cumulative totals (summed across every LLM call this turn made) over\n // total_input/total_output, which mirror only the last call's context.\n const totalInputTokens = contextUsage.all_llm_calls?.input_tokens ?? contextUsage.total_input\n const totalOutputTokens = contextUsage.all_llm_calls?.output_tokens ?? contextUsage.total_output\n const leftParts = [\n `${displayRows.length} step${displayRows.length !== 1 ? 's' : ''}`,\n `${runStats.toolCalls} tool call${runStats.toolCalls !== 1 ? 's' : ''}`,\n ]\n if (totalElapsedTime != null) leftParts.push(`${totalElapsedTime.toFixed(1)}s`)\n leftParts.push(`${formatTokens(totalInputTokens)} in`)\n if (totalOutputTokens > 0) leftParts.push(`${formatTokens(totalOutputTokens)} out`)\n summaryNode = (\n <StepTraceSummary\n left={leftParts.join(' \u00B7 ')}\n isNearBudget={isNearAiUsageBudget(contextUsage)}\n total={`Total: ${formatGbp(contextUsage.spent_gbp)}`}\n />\n )\n }\n\n return (\n <StepTrace className={className} summary={summaryNode}>\n {displayRows.map((row, i) => {\n if (row.lane) {\n return (\n <LaneBinding\n key={`lane-${row.lane}`}\n handle={row.lane}\n steps={laneStepsByHandle.get(row.lane)!}\n number={i + 1}\n renderRow={renderRow}\n isStreaming={isStreaming}\n />\n )\n }\n const parent = row.step!\n return renderRow(\n parent,\n 0,\n i === displayRows.length - 1 && !childrenByParent.has(parent.index)\n )\n })}\n </StepTrace>\n )\n}\n\n/** Binds a sub-agent's lifecycle steps to the `SubAgentLane` block. */\nfunction LaneBinding({\n handle,\n steps,\n number,\n renderRow,\n isStreaming,\n}: {\n handle: string\n steps: AgentStepEvent[]\n number: number\n renderRow: (step: AgentStepEvent, depth: number, isLastInList: boolean) => React.ReactNode\n isStreaming: boolean\n}) {\n // The spawn marker (`subagent_status: \"running\"`) carries the child's task; a `done`/`failed`\n // marker closes it; in between are the child's own steps.\n const spawn = steps.find((s) => s.subagent_status === 'running')\n const closed = steps.find((s) => s.subagent_status === 'done' || s.subagent_status === 'failed')\n const failed = steps.some((s) => s.subagent_status === 'failed')\n const inner = steps.filter((s) => !s.subagent_status)\n const task = (spawn?.content || spawn?.focus || '').trim()\n const running = !closed && isStreaming\n // What the child is doing RIGHT NOW: its latest step's focus/label.\n const latest = inner[inner.length - 1]\n return (\n <SubAgentLane\n handle={handle}\n number={number}\n // Name the lane by its JOB, never \"sub-1\": the handle is only a stable key.\n job={subagentJobLabel(task) || `Sub-agent ${handle}`}\n task={task}\n status={running ? 'running' : failed ? 'failed' : 'done'}\n innerCount={inner.length}\n liveFocus={latest ? latest.focus?.trim() || getAgentStepLabel(latest) : ''}\n renderSteps={() => inner.map((s, i) => renderRow(s, 1, i === inner.length - 1))}\n />\n )\n}\n\n/** Summarise folded sub-steps by what they did, e.g. \"3 searches, 2 reads\". */\nfunction summariseSubSteps(steps: AgentStepEvent[]): string {\n const counts = new Map<string, number>()\n for (const s of steps) {\n const noun = subStepNoun(getStepTool(s))\n counts.set(noun, (counts.get(noun) ?? 0) + 1)\n }\n return [...counts.entries()]\n .map(([noun, n]) => `${n} ${n === 1 ? noun : pluralise(noun)}`)\n .join(', ')\n}\n\n/** `met` (and `absent_from_corpus`, which the gate accepts) tick; anything else stays open. */\nfunction isCriterionMet(status?: string): boolean {\n return status === 'met' || status === 'absent_from_corpus'\n}\n\n/**\n * Does this outcome describe a failure?\n *\n * Outcomes are free text from the backend (\"exit 0 \u00B7 1.2s\", \"15 passages\n * retrieved\", \"timed out \u00B7 30.0s\"), so this reads the few shapes that carry a\n * verdict and defaults to \"not a failure\" for the rest \u2014 a false alarm on a\n * successful step is worse than a neutral chip.\n */\nfunction isFailureOutcome(outcome: string): boolean {\n const o = outcome.toLowerCase()\n if (/\\bexit\\s+0\\b/.test(o)) return false\n return /\\bexit\\s+[1-9]/.test(o) || /timed out|timeout|failed|error\\b/.test(o)\n}\n\n/** What one inner step *is*, for the collapsed summary line. */\nfunction subStepNoun(tool: string | undefined): string {\n switch (tool) {\n case 'search_inside_documents':\n case 'search_conversations':\n case 'web_search':\n return 'search'\n case 'read_document':\n case 'read_url':\n case 'view_document_pages':\n case 'get_table_of_contents':\n return 'read'\n case 'execute_code':\n case 'spawn_coding_agent':\n return 'run'\n case 'create_plan':\n return 'plan'\n default:\n return 'step'\n }\n}\n\nfunction pluralise(noun: string): string {\n return noun.endsWith('h') ? `${noun}es` : `${noun}s`\n}\n\nexport const AgentSteps = React.memo(AgentStepsComponent, (prev, next) => {\n return (\n prev.isStreaming === next.isStreaming &&\n prev.className === next.className &&\n prev.totalElapsedTime === next.totalElapsedTime &&\n prev.steps === next.steps &&\n prev.liveTimer === next.liveTimer &&\n prev.hideLive === next.hideLive\n )\n})\n"],
|
|
5
|
-
"mappings": ";AA+EI,SAgUM,UA5TE,KAJR;AAzEJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,WAAW,oBAAoB,cAAc,uBAAuB;AAC7E,OAAO,SAAS,eAAe;AAC/B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAAyD;AAClE,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAMP,MAAM,iBAAiB,oBAAI,IAAI,CAAC,QAAQ,SAAS,QAAQ,SAAS,CAAC;AAMnE,SAAS,cAAc,QAAwE;AAC7F,QAAM,SAAgD,CAAC;AACvD,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,QAAI,eAAe,IAAI,GAAG,KAAK,SAAS,KAAM;AAC9C,UAAM,WAAW,OAAO,UAAU,WAAW,QAAQ,KAAK,UAAU,KAAK;AACzE,WAAO,KAAK,EAAE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ACF;AAEA,SAAS,UAAU,MAAsB;AACvC,SAAO,KAAK,SAAS,GAAG,IAAI,GAAG,IAAI,OAAO,GAAG,IAAI;AACnD;AAEO,MAAM,aAAa,MAAM,KAAK,qBAAqB,CAAC,MAAM,SAAS;AACxE,SACE,KAAK,gBAAgB,KAAK,eAC1B,KAAK,cAAc,KAAK,aACxB,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,UAAU,KAAK,SACpB,KAAK,cAAc,KAAK,aACxB,KAAK,aAAa,KAAK;AAE3B,CAAC;",
|
|
4
|
+
"sourcesContent": ["/**\n * A turn's agent steps, bound to the session: the step trace (`StepTrace` and its rows) filled\n * from the step stream, with the workspace's document names, the model tiers, the developer\n * details and the live duration of the running step.\n */\n\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n getDocumentTitle,\n ProviderIcon,\n} from '@arbidocs/react/ui'\nimport {\n formatGbp,\n useAvailableModels,\n useDocuments,\n useInvalidateWorkflows,\n useInvalidateAssistant,\n useUserSettings,\n} from '@arbidocs/react'\nimport React, { useEffect, useMemo } from 'react'\nimport {\n GoalCriteria,\n StepDetail,\n StepNarration,\n StepOutcome,\n StepParams,\n StepRow,\n StepSummary,\n StepTrace,\n StepTraceSummary,\n SubAgentLane,\n SubStepGroup,\n type GoalCriterionView,\n} from '../../agents/runs/AgentSteps'\nimport {\n getAgentStepPresentation,\n getModelIcon,\n MODEL_TIER_ICON_MAP,\n MODEL_TIER_LABELS,\n stepAccent,\n} from '../../agents/runs/step-presentation'\nimport { MessageLiveSeconds, type MessageTimerSubscription } from './MessageLiveSeconds'\nimport { ConnectedMarkdown } from './ConnectedMarkdown'\nimport {\n computeRunStats,\n extractSubagentLanes,\n formatTokens,\n getAgentStepLabel,\n getCurrentStep,\n getStepDisplay,\n getStepTool,\n isNearAiUsageBudget,\n mergeAgentSteps,\n subagentJobLabel,\n type AgentStepEvent,\n type ContextUsage,\n type DocInfoMap,\n} from '@arbidocs/sdk/browser'\n\n/** A workspace document, as the step trace names it. */\ntype StepDocument = { external_id: string; file_name?: string | null; n_pages?: number | null }\n\n/** Fields injected by the backend for display \u2014 excluded from param rendering */\nconst DISPLAY_FIELDS = new Set(['tool', 'label', 'icon', 'summary'])\n\n/**\n * Extract tool parameters from a detail entry, excluding display fields.\n * Returns key-value pairs for inline rendering.\n */\nfunction getToolParams(detail: Record<string, unknown>): Array<{ key: string; value: string }> {\n const params: Array<{ key: string; value: string }> = []\n for (const [key, value] of Object.entries(detail)) {\n if (DISPLAY_FIELDS.has(key) || value == null) continue\n const strValue = typeof value === 'string' ? value : JSON.stringify(value)\n params.push({ key, value: strValue })\n }\n return params\n}\n\nfunction StepModelIcon({ modelName, tag }: { modelName?: string | null; tag: string | null }) {\n // Premium \u2192 brand mark; Fast/Wise \u2192 their name icon; otherwise the tag icon.\n const cfg = tag === 'Premium' ? null : getModelIcon(modelName, tag)\n if (tag !== 'Premium' && !cfg) return null\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <span className=\"flex-shrink-0\">\n {tag === 'Premium' ? (\n <ProviderIcon modelName={modelName ?? undefined} size={11} />\n ) : (\n cfg && <cfg.icon className={cfg.className} style={{ width: 11, height: 11 }} />\n )}\n </span>\n </TooltipTrigger>\n <TooltipContent>{modelName}</TooltipContent>\n </Tooltip>\n )\n}\n\ninterface AgentStepsProps {\n steps: AgentStepEvent[]\n isStreaming: boolean\n className?: string\n /**\n * Total elapsed seconds for the message \u2014 used as a static fallback for the\n * last step's duration when `liveTimer` is not provided (e.g. messages\n * loaded from history). When `liveTimer` is provided this prop is forwarded\n * to the leaf as the post-generation fallback.\n */\n totalElapsedTime?: number\n /**\n * Optional live-timer subscription. When provided, the last step's duration\n * is rendered by a leaf component so the parent does not re-render at the\n * 100 ms timer cadence.\n */\n liveTimer?: MessageTimerSubscription\n /**\n * When true (the live bar's expander), hide what the bar already shows live \u2014\n * the agent's current step and any still-running sub-agents \u2014 so the expander\n * is purely \"what came before\", never a duplicate of the footer. Finished\n * sub-agents stay (they're history). No effect once settled.\n */\n hideLive?: boolean\n /**\n * This turn's settled context/AI usage (\u00A3) (`message.finalContextUsage`).\n * \u00A3 spent belongs here, on the turn that spent them \u2014 not on the\n * composer's forward-looking context bar, which is about future messages.\n */\n contextUsage?: ContextUsage | null\n}\n\nconst AgentStepsComponent: React.FC<AgentStepsProps> = ({\n steps,\n isStreaming,\n className,\n totalElapsedTime,\n liveTimer,\n hideLive = false,\n contextUsage,\n}) => {\n const { data: userSettings } = useUserSettings()\n const isDeveloper = userSettings?.developer === true\n\n // The agent saved a workflow (create_workflow): refresh the workflow list once the turn ends, so it\n // shows without a reload.\n const invalidateWorkflows = useInvalidateWorkflows()\n const createdWorkflow = steps.some((step) => getStepTool(step) === 'create_workflow')\n useEffect(() => {\n if (createdWorkflow && !isStreaming) void invalidateWorkflows()\n // invalidateWorkflows is a new function each render; the effect runs on the turn's state only.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [createdWorkflow, isStreaming])\n\n // The person changed the Assistant's instructions (set_assistant_brief): an Assistant page open beside\n // the chat shows the new brief once the turn ends.\n const invalidateAssistant = useInvalidateAssistant()\n const setBrief = steps.some((step) => getStepTool(step) === 'set_assistant_brief')\n useEffect(() => {\n if (setBrief && !isStreaming) void invalidateAssistant()\n // invalidateAssistant is a new function each render; the effect runs on the turn's state only.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [setBrief, isStreaming])\n\n // Build doc_ext_id \u2192 {name, pages} map from workspace documents (cached by React Query)\n const { data: documents = [] } = useDocuments()\n const docInfo = useMemo(() => {\n const map: DocInfoMap = {}\n const docArray = Array.isArray(documents) ? documents : []\n for (const doc of docArray) {\n if (doc && 'external_id' in doc) {\n const d = doc as StepDocument\n // Use the canonical document entity label (doc_metadata.title ?? file\n // name), not the raw file name, so references resolve to the same name\n // the rest of the app shows.\n map[d.external_id] = {\n name: getDocumentTitle(d, d.file_name ?? d.external_id),\n pages: d.n_pages ?? null,\n }\n }\n }\n return map\n }, [documents])\n\n // Resolve model name \u2192 tag for looking up tier icons\n const { data: availableModels } = useAvailableModels()\n const getModelTag = useMemo(() => {\n return (modelName?: string | null): string | null => {\n if (!modelName || !availableModels?.models) return null\n return availableModels.models.find((m) => m.model_name === modelName)?.tags?.[0] || null\n }\n }, [availableModels])\n\n // Raw SSE events \u2192 the logical steps a reader sees. Shared with the `Step N`\n // counter so the count always matches the rows rendered below.\n //\n // When `hideLive` (the live bar's expander), the current step STAYS \u2014 the\n // drawer is a complete, correctly-numbered list with the active step\n // highlighted as the last row, matching the \"Step N\" position on the bar.\n // (Dropping it made the drawer show N-1 rows while the bar said N, and marked\n // the *previous* step active.) Still-running sub-agents are the one thing\n // dropped: they have their own live lanes in the roster beneath the bar, so\n // showing them here too would double-render them.\n const mergedSteps = useMemo(() => {\n const merged = mergeAgentSteps(steps)\n if (!hideLive) return merged\n const runningHandles = new Set(\n extractSubagentLanes(merged)\n .filter((l) => l.status === 'running')\n .map((l) => l.handle)\n )\n return merged.filter((s) => !(s.subagent && runningHandles.has(s.subagent)))\n }, [steps, hideLive])\n\n // Compute step durations: duration = next_step.t - current_step.t\n // For the last step, use totalElapsedTime (frontend timer) if available\n const stepDurations = useMemo(() => {\n const durations: (number | null)[] = []\n for (let i = 0; i < mergedSteps.length; i++) {\n const currentT = mergedSteps[i].t\n if (currentT == null) {\n durations.push(null)\n continue\n }\n if (i + 1 < mergedSteps.length) {\n const nextT = mergedSteps[i + 1].t\n durations.push(nextT != null ? nextT - currentT : null)\n } else {\n // Last step: close it with the turn's total elapsed time.\n //\n // This is the one place two clocks meet \u2014 `totalElapsedTime` is the\n // client's wall-clock for a live turn, while `t` is the backend's\n // seconds-since-stream-start. They agree when the client watched the\n // whole stream, but a client that started late (a reconnect, or a\n // background conversation opened mid-run) measures less than the\n // backend, and the subtraction goes negative: the trace rendered\n // \"Answered \u221221.9s\". Show nothing rather than a duration we know is\n // wrong \u2014 a settled turn re-read from history uses the backend's own\n // completed `t`, so it stays consistent there.\n const remaining = totalElapsedTime != null ? totalElapsedTime - currentT : null\n durations.push(remaining != null && remaining >= 0 ? remaining : null)\n }\n }\n return durations\n }, [mergedSteps, totalElapsedTime])\n\n // Display step_tokens (per-step cost) directly from the backend.\n const stepTokens = useMemo(() => {\n return mergedSteps.map((step) => step.step_tokens ?? null)\n }, [mergedSteps])\n\n // Per-step \u00A3 cost \u2014 an estimate (cached model pricing, not the\n // authoritative LiteLLM cost), but useful to see which step is expensive\n // while the turn is still streaming. User-facing (unlike step_tokens,\n // which is raw and developer-gated) since \u00A3 is the budget unit the\n // user actually spends against.\n const stepGbp = useMemo(() => {\n return mergedSteps.map((step) => step.step_gbp ?? null)\n }, [mergedSteps])\n\n // Following the run is the HOST's job, not this list's: AgentBarShell pins\n // its drawer to the bottom while the user hasn't scrolled away. A\n // scrollIntoView here looked like it nudged \"the nearest scroll container\",\n // but it scrolls EVERY ancestor short of the viewport \u2014 each streamed tick\n // yanked the whole conversation back to this list while the user was\n // reading elsewhere on the page.\n const currentStepIndex = isStreaming ? getCurrentStep(mergedSteps)?.index : undefined\n\n if (mergedSteps.length === 0) return null\n\n // Two groupings run in one pass:\n // \u2022 Concurrent sub-agent LANES \u2014 steps carrying a `subagent` handle are pulled\n // into their own live lane (spawn marker \u2192 intermediate steps \u2192 done marker),\n // rendered as a card at the position of the lane's spawn. Multiple children\n // running at once each get their own lane, so fan-out reads as parallel work.\n // \u2022 Legacy parent_index NESTING \u2014 a handle-less sub-step (older single-child\n // relays) still indents under the parent tool step that spawned it.\n const posByIndex = new Map(mergedSteps.map((s, idx) => [s.index, idx]))\n const childrenByParent = new Map<number, AgentStepEvent[]>()\n const topLevelSteps: AgentStepEvent[] = []\n const laneStepsByHandle = new Map<string, AgentStepEvent[]>()\n const laneSpawnIndex = new Map<string, number>()\n for (const step of mergedSteps) {\n const handle = step.subagent\n if (handle) {\n const arr = laneStepsByHandle.get(handle)\n if (arr) arr.push(step)\n else {\n laneStepsByHandle.set(handle, [step])\n laneSpawnIndex.set(handle, step.index)\n }\n continue\n }\n const parent = step.parent_index\n if (parent != null && parent !== step.index && posByIndex.has(parent)) {\n const siblings = childrenByParent.get(parent) ?? []\n siblings.push(step)\n childrenByParent.set(parent, siblings)\n } else {\n topLevelSteps.push(step)\n }\n }\n\n // Interleave top-level steps and lanes by index, so a lane appears exactly where\n // its child was spawned in the parent's timeline.\n type DisplayRow = { index: number; step?: AgentStepEvent; lane?: string }\n const displayRows: DisplayRow[] = [\n ...topLevelSteps.map((s) => ({ index: s.index, step: s })),\n ...[...laneStepsByHandle.keys()].map((h) => ({ index: laneSpawnIndex.get(h) ?? 0, lane: h })),\n ].sort((a, b) => a.index - b.index)\n\n // Display numbers: top-level rows read 1..N (lanes count as a row); a fold's\n // inner rows read \"<parent>.<n>\".\n const displayNumber = new Map<number, string>()\n displayRows.forEach((r, i) => {\n if (r.lane) {\n // Lane inner steps read \"<lane>.<n>\".\n laneStepsByHandle\n .get(r.lane)\n ?.filter((s) => !s.subagent_status)\n .forEach((c, ci) => displayNumber.set(c.index, `${i + 1}.${ci + 1}`))\n return\n }\n displayNumber.set(r.step!.index, String(i + 1))\n childrenByParent\n .get(r.step!.index)\n ?.forEach((c, ci) => displayNumber.set(c.index, `${i + 1}.${ci + 1}`))\n })\n\n const lastStepIndex = mergedSteps[mergedSteps.length - 1].index\n\n const renderRow = (step: AgentStepEvent, depth: number, isLastInList: boolean) => {\n const i = posByIndex.get(step.index)!\n const presentation = getAgentStepPresentation(step, docInfo)\n const { tool, Icon } = presentation\n const { label, summary, isMultiLine, details } = getStepDisplay(step, docInfo)\n const accent = stepAccent(step, tool)\n const duration = stepDurations[i]\n const isLastStep = step.index === lastStepIndex\n const isActive = step.index === currentStepIndex\n\n // Goal-step model tier icon (auto mode) \u2014 the tier the router picked. It\n // stands in for the goal step's raw outcome (\"fast, all 0 docs\"), so it\n // carries a tooltip: an unlabelled glyph would just be cryptic noise.\n const tier = step.step === 'goal' ? step.model_recommendation : null\n const TierIcon = tier ? MODEL_TIER_ICON_MAP[tier] : null\n\n // The last step during streaming renders its duration through a leaf that\n // subscribes to the message timer directly, keeping the 10 Hz tick\n // contained so AgentSteps and its parent stay stable across timer updates.\n const useLiveDuration = isLastStep && liveTimer != null && step.t != null\n const durationNode: React.ReactNode = useLiveDuration ? (\n <MessageLiveSeconds\n {...liveTimer!}\n offsetSeconds={step.t!}\n fallbackSeconds={totalElapsedTime ?? null}\n minDisplaySeconds={0.05}\n />\n ) : duration != null ? (\n `${duration.toFixed(1)}s`\n ) : null\n\n // The goal step's outcome is internal routing (\"fast, all 0 docs\") \u2014 cryptic\n // to a reader and redundant with the model-tier icon beside the label. Tool\n // outcomes (\"15 passages retrieved\") are real feedback, so those stay.\n const showOutcome = step.outcome && step.step !== 'goal'\n // A green tick on \"exit 1\" claims the step succeeded when it didn't \u2014 the\n // code agent's first attempt failing then retrying is exactly the story the\n // trace should tell honestly.\n const outcomeFailed = !!step.outcome && isFailureOutcome(step.outcome)\n\n // Raw tool params are a developer affordance, and only when the backend\n // gave us no summary to show instead.\n const hasSummary = step.detail?.some((d) => (d as { summary?: string }).summary)\n const toolParams =\n isDeveloper && step.detail && !step.step && !hasSummary\n ? step.detail.flatMap((d) => getToolParams(d as Record<string, unknown>))\n : []\n\n const criteria =\n step.step === 'goal_progress' && step.detail && step.detail.length > 0\n ? (step.detail as Array<{\n criterion?: string\n text?: string\n status?: string\n note?: string\n }>)\n : null\n\n const criteriaView: GoalCriterionView[] | null = criteria\n ? criteria.map((c, idx) => ({\n key: c.criterion ?? String(idx),\n text: c.text || c.criterion || '',\n note: c.note,\n met: isCriterionMet(c.status),\n }))\n : null\n const folded = childrenByParent.get(step.index)\n\n return (\n <StepRow\n key={step.index}\n index={step.index}\n number={displayNumber.get(step.index) ?? String(i + 1)}\n depth={depth}\n isLast={isLastInList}\n isActive={isActive}\n accent={accent}\n icon={<Icon size={12} strokeWidth={2.25} />}\n kind={step.narration ? 'narration' : (step.step ?? 'tool')}\n title={isActive ? presentation.description : label}\n titleTestId={isActive ? 'agent-expanded-current-step-description' : undefined}\n badge={\n TierIcon ? (\n <Tooltip>\n <TooltipTrigger asChild>\n <span className=\"flex shrink-0 items-center self-center\">\n <TierIcon size={12} className={accent.fg} aria-hidden />\n </span>\n </TooltipTrigger>\n <TooltipContent side=\"top\">{MODEL_TIER_LABELS[tier!] ?? tier}</TooltipContent>\n </Tooltip>\n ) : undefined\n }\n meta={\n <>\n {isDeveloper && (\n <StepModelIcon modelName={step.usage?.model} tag={getModelTag(step.usage?.model)} />\n )}\n {isDeveloper && stepTokens[i] != null && (\n <span>{formatTokens(stepTokens[i]!)} tok</span>\n )}\n {/* Not on the active row: this step's cost is a frozen snapshot of the ONE LLM call\n that produced it; next to a spinner it would read as \"still counting\". */}\n {!isActive && stepGbp[i] != null && <span>{formatGbp(stepGbp[i]!)}</span>}\n {durationNode != null && <span>{durationNode}</span>}\n </>\n }\n >\n {summary &&\n !isActive &&\n (step.narration ? (\n /* Narration is PROSE (headings, bold, lists): render markdown, not raw asterisks.\n Tool summaries stay plain text: one-line headlines where a clamp matters. */\n <StepNarration index={step.index}>\n <ConnectedMarkdown isStreaming={false}>{summary}</ConnectedMarkdown>\n </StepNarration>\n ) : (\n <StepSummary index={step.index} multiLine={isMultiLine}>\n {summary}\n </StepSummary>\n ))}\n\n {/* What the narrative displaced: the tool's target or a plan's checklist. Dimmer than\n the summary: it answers \"on what?\", not \"doing what?\". */}\n {details.map((d, di) => (\n <StepDetail key={di} index={step.index}>\n {d}\n </StepDetail>\n ))}\n\n {showOutcome && (\n <StepOutcome index={step.index} failed={outcomeFailed}>\n {step.outcome}\n </StepOutcome>\n )}\n\n {toolParams.length > 0 && (\n <StepParams>{toolParams.map((p) => `${p.key}=${p.value}`).join(' ')}</StepParams>\n )}\n\n {step.routing && (\n <details className=\"mt-1 text-xs text-muted-foreground\" data-testid=\"routing-details\">\n <summary className=\"cursor-pointer\">Routing details</summary>\n <dl className=\"mt-2 space-y-2\">\n <div>\n <dt className=\"font-medium\">Answer model</dt>\n <dd>\n {step.routing.selected_model}\n {step.routing.model_recommendation\n ? ` (${step.routing.model_recommendation})`\n : ''}\n </dd>\n </div>\n <div>\n <dt className=\"font-medium\">Default document search</dt>\n <dd>\n {step.routing.selected_doc_ext_ids.length\n ? step.routing.selected_doc_ext_ids\n .map((id) => docInfo[id]?.name ?? step.routing!.document_titles[id] ?? id)\n .join(', ')\n : 'No documents selected'}\n </dd>\n <dd>The complete document catalogue remains available for direct reading.</dd>\n </div>\n <div>\n <dt className=\"font-medium\">Always available tools</dt>\n <dd>\n {step.routing.always_available_tool_names\n .map((name) => name.replaceAll('_', ' '))\n .join(', ') || 'None'}\n </dd>\n </div>\n <div>\n <dt className=\"font-medium\">Additional tools</dt>\n <dd>\n {step.routing.selected_tool_names == null\n ? 'All enabled tools retained'\n : step.routing.selected_tool_names\n .filter((name) => !step.routing!.always_available_tool_names.includes(name))\n .map((name) => name.replaceAll('_', ' '))\n .join(', ') || 'None'}\n </dd>\n </div>\n <div>\n <dt className=\"font-medium\">History</dt>\n <dd>\n {step.routing.retained_message_ext_ids.length} messages retained\n {step.routing.history_retained_by_policy\n ? '; full history preserved by policy'\n : ''}\n </dd>\n </div>\n <div>\n <dt className=\"font-medium\">Router</dt>\n <dd>\n {step.routing.router_model} \u00B7 {step.routing.elapsed_seconds.toFixed(3)}s\n {step.routing.input_tokens != null\n ? ` \u00B7 ${step.routing.input_tokens.toLocaleString()} input tokens`\n : ''}\n </dd>\n </div>\n {step.routing.status === 'fallback' && (\n <div>\n <dt className=\"font-medium\">Fallback</dt>\n <dd>\n Context and authorized tools retained (\n {step.routing.fallback_reason ?? 'router unavailable'}).\n </dd>\n </div>\n )}\n </dl>\n </details>\n )}\n\n {criteriaView && <GoalCriteria criteria={criteriaView} />}\n\n {/* Sub-agent steps nest under the tool step that spawned them, COLLAPSED: a\n deep_research run emits a dozen inner rows that buried the parent trace. The parent\n keeps the count so the work is never hidden, just folded. */}\n {folded && folded.length > 0 && (\n <SubStepGroup\n parentIndex={step.index}\n summary={summariseSubSteps(folded)}\n openClassName={accent.fg}\n renderSteps={() =>\n folded.map((c, ci, arr) => renderRow(c, depth + 1, ci === arr.length - 1))\n }\n />\n )}\n </StepRow>\n )\n }\n\n let summaryNode: React.ReactNode = null\n if (contextUsage?.spent_gbp != null) {\n const runStats = computeRunStats(steps)\n // Prefer the run's true cumulative totals (summed across every LLM call this turn made) over\n // total_input/total_output, which mirror only the last call's context.\n const totalInputTokens = contextUsage.all_llm_calls?.input_tokens ?? contextUsage.total_input\n const totalOutputTokens = contextUsage.all_llm_calls?.output_tokens ?? contextUsage.total_output\n const leftParts = [\n `${displayRows.length} step${displayRows.length !== 1 ? 's' : ''}`,\n `${runStats.toolCalls} tool call${runStats.toolCalls !== 1 ? 's' : ''}`,\n ]\n if (totalElapsedTime != null) leftParts.push(`${totalElapsedTime.toFixed(1)}s`)\n leftParts.push(`${formatTokens(totalInputTokens)} in`)\n if (totalOutputTokens > 0) leftParts.push(`${formatTokens(totalOutputTokens)} out`)\n summaryNode = (\n <StepTraceSummary\n left={leftParts.join(' \u00B7 ')}\n isNearBudget={isNearAiUsageBudget(contextUsage)}\n total={`Total: ${formatGbp(contextUsage.spent_gbp)}`}\n />\n )\n }\n\n return (\n <StepTrace className={className} summary={summaryNode}>\n {displayRows.map((row, i) => {\n if (row.lane) {\n return (\n <LaneBinding\n key={`lane-${row.lane}`}\n handle={row.lane}\n steps={laneStepsByHandle.get(row.lane)!}\n number={i + 1}\n renderRow={renderRow}\n isStreaming={isStreaming}\n />\n )\n }\n const parent = row.step!\n return renderRow(\n parent,\n 0,\n i === displayRows.length - 1 && !childrenByParent.has(parent.index)\n )\n })}\n </StepTrace>\n )\n}\n\n/** Binds a sub-agent's lifecycle steps to the `SubAgentLane` block. */\nfunction LaneBinding({\n handle,\n steps,\n number,\n renderRow,\n isStreaming,\n}: {\n handle: string\n steps: AgentStepEvent[]\n number: number\n renderRow: (step: AgentStepEvent, depth: number, isLastInList: boolean) => React.ReactNode\n isStreaming: boolean\n}) {\n // The spawn marker (`subagent_status: \"running\"`) carries the child's task; a `done`/`failed`\n // marker closes it; in between are the child's own steps.\n const spawn = steps.find((s) => s.subagent_status === 'running')\n const closed = steps.find((s) => s.subagent_status === 'done' || s.subagent_status === 'failed')\n const failed = steps.some((s) => s.subagent_status === 'failed')\n const inner = steps.filter((s) => !s.subagent_status)\n const task = (spawn?.content || spawn?.focus || '').trim()\n const running = !closed && isStreaming\n // What the child is doing RIGHT NOW: its latest step's focus/label.\n const latest = inner[inner.length - 1]\n return (\n <SubAgentLane\n handle={handle}\n number={number}\n // Name the lane by its JOB, never \"sub-1\": the handle is only a stable key.\n job={subagentJobLabel(task) || `Sub-agent ${handle}`}\n task={task}\n status={running ? 'running' : failed ? 'failed' : 'done'}\n innerCount={inner.length}\n liveFocus={latest ? latest.focus?.trim() || getAgentStepLabel(latest) : ''}\n renderSteps={() => inner.map((s, i) => renderRow(s, 1, i === inner.length - 1))}\n />\n )\n}\n\n/** Summarise folded sub-steps by what they did, e.g. \"3 searches, 2 reads\". */\nfunction summariseSubSteps(steps: AgentStepEvent[]): string {\n const counts = new Map<string, number>()\n for (const s of steps) {\n const noun = subStepNoun(getStepTool(s))\n counts.set(noun, (counts.get(noun) ?? 0) + 1)\n }\n return [...counts.entries()]\n .map(([noun, n]) => `${n} ${n === 1 ? noun : pluralise(noun)}`)\n .join(', ')\n}\n\n/** `met` (and `absent_from_corpus`, which the gate accepts) tick; anything else stays open. */\nfunction isCriterionMet(status?: string): boolean {\n return status === 'met' || status === 'absent_from_corpus'\n}\n\n/**\n * Does this outcome describe a failure?\n *\n * Outcomes are free text from the backend (\"exit 0 \u00B7 1.2s\", \"15 passages\n * retrieved\", \"timed out \u00B7 30.0s\"), so this reads the few shapes that carry a\n * verdict and defaults to \"not a failure\" for the rest \u2014 a false alarm on a\n * successful step is worse than a neutral chip.\n */\nfunction isFailureOutcome(outcome: string): boolean {\n const o = outcome.toLowerCase()\n if (/\\bexit\\s+0\\b/.test(o)) return false\n return /\\bexit\\s+[1-9]/.test(o) || /timed out|timeout|failed|error\\b/.test(o)\n}\n\n/** What one inner step *is*, for the collapsed summary line. */\nfunction subStepNoun(tool: string | undefined): string {\n switch (tool) {\n case 'search_inside_documents':\n case 'search_conversations':\n case 'web_search':\n return 'search'\n case 'read_document':\n case 'read_url':\n case 'view_document_pages':\n case 'get_table_of_contents':\n return 'read'\n case 'execute_code':\n case 'spawn_coding_agent':\n return 'run'\n case 'create_plan':\n return 'plan'\n default:\n return 'step'\n }\n}\n\nfunction pluralise(noun: string): string {\n return noun.endsWith('h') ? `${noun}es` : `${noun}s`\n}\n\nexport const AgentSteps = React.memo(AgentStepsComponent, (prev, next) => {\n return (\n prev.isStreaming === next.isStreaming &&\n prev.className === next.className &&\n prev.totalElapsedTime === next.totalElapsedTime &&\n prev.steps === next.steps &&\n prev.liveTimer === next.liveTimer &&\n prev.hideLive === next.hideLive\n )\n})\n"],
|
|
5
|
+
"mappings": ";AAsFI,SAoVM,UAhVE,KAJR;AAhFJ;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,OAAO,SAAS,WAAW,eAAe;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAAyD;AAClE,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAMP,MAAM,iBAAiB,oBAAI,IAAI,CAAC,QAAQ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ACA,SAAO,CAAC,GAAG,OAAO,QAAQ,CAAC,EACxB,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,IAAI,OAAO,UAAU,IAAI,CAAC,EAAE,EAC7D,KAAK,IAAI;AACd;AAGA,SAAS,eAAe,QAA0B;AAChD,SAAO,WAAW,SAAS,WAAW;AACxC;AAUA,SAAS,iBAAiB,SAA0B;AAClD,QAAM,IAAI,QAAQ,YAAY;AAC9B,MAAI,eAAe,KAAK,CAAC,EAAG,QAAO;AACnC,SAAO,iBAAiB,KAAK,CAAC,KAAK,mCAAmC,KAAK,CAAC;AAC9E;AAGA,SAAS,YAAY,MAAkC;AACrD,UAAQ,MAAM;AAAA,IACZ,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,UAAU,MAAsB;AACvC,SAAO,KAAK,SAAS,GAAG,IAAI,GAAG,IAAI,OAAO,GAAG,IAAI;AACnD;AAEO,MAAM,aAAa,MAAM,KAAK,qBAAqB,CAAC,MAAM,SAAS;AACxE,SACE,KAAK,gBAAgB,KAAK,eAC1B,KAAK,cAAc,KAAK,aACxB,KAAK,qBAAqB,KAAK,oBAC/B,KAAK,UAAU,KAAK,SACpB,KAAK,cAAc,KAAK,aACxB,KAAK,aAAa,KAAK;AAE3B,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -94,6 +94,7 @@ import { useViewerBlobs } from "./useViewerBlobs.js";
|
|
|
94
94
|
import { useViewerTabs } from "./useViewerTabs.js";
|
|
95
95
|
import { useViewerVersions } from "./useViewerVersions.js";
|
|
96
96
|
import { VersionDropdown } from "./VersionDropdown.js";
|
|
97
|
+
import { useDocumentVersionRestore } from "./useDocumentVersionRestore.js";
|
|
97
98
|
import { ParsedTextView } from "./parsed/ParsedTextView.js";
|
|
98
99
|
import { ViewerPdfPane } from "./ViewerPdfPane.js";
|
|
99
100
|
import { ConnectedNativeDocxEditor as NativeDocxEditor } from "../docx/ConnectedNativeDocxEditor.js";
|
|
@@ -229,7 +230,7 @@ function DocumentViewerContent({
|
|
|
229
230
|
activeTab,
|
|
230
231
|
handleTabChange: changeTab,
|
|
231
232
|
viewerTabs
|
|
232
|
-
} = useViewerTabs(doc, isCompact, hasHistory);
|
|
233
|
+
} = useViewerTabs(doc, isCompact, hasHistory, !!snapshotDocumentId);
|
|
233
234
|
const saveWordRef = useRef(null);
|
|
234
235
|
const transitionPending = useRef(false);
|
|
235
236
|
const transitionKey = JSON.stringify([openedId, doc.workspaceId]);
|
|
@@ -455,6 +456,21 @@ function DocumentViewerContent({
|
|
|
455
456
|
}
|
|
456
457
|
void arbi.documents.update([{ external_id: documentId, shared: !documentData?.shared }]).then(() => tools.onDocumentsChanged?.([documentId], "markup")).catch(() => notify("Couldn't change who can see this document", "error"));
|
|
457
458
|
};
|
|
459
|
+
const {
|
|
460
|
+
canRestore,
|
|
461
|
+
restoring: restoringVersion,
|
|
462
|
+
restoreVersion: restoreSnapshot
|
|
463
|
+
} = useDocumentVersionRestore({
|
|
464
|
+
documentId,
|
|
465
|
+
document: documentData,
|
|
466
|
+
currentUserId,
|
|
467
|
+
onDocumentsChanged: tools.onDocumentsChanged,
|
|
468
|
+
onRestored: () => {
|
|
469
|
+
if (parseVersionRef(session.getState().viewingDocument?.id).docId !== documentId) return;
|
|
470
|
+
setSnapshotDocumentId(null);
|
|
471
|
+
setActiveTab(isPresentation ? "slides" : isDocx ? "docx" : isArtifact ? "edit" : "pdf");
|
|
472
|
+
}
|
|
473
|
+
});
|
|
458
474
|
const shownRef = snapshotDocumentId || documentId;
|
|
459
475
|
const rightContent = /* @__PURE__ */ jsxs(ViewerHeaderEnd, { isCompact, children: [
|
|
460
476
|
annotatable && /* @__PURE__ */ jsx(
|
|
@@ -714,6 +730,8 @@ function DocumentViewerContent({
|
|
|
714
730
|
versionNumber: snapshotNumber,
|
|
715
731
|
live: isDocx || isArtifact,
|
|
716
732
|
onAsk: support.askAboutVersion ? () => support.askAboutVersion(snapshotDocumentId) : void 0,
|
|
733
|
+
onRestore: canRestore ? () => void restoreSnapshot(snapshotDocumentId) : void 0,
|
|
734
|
+
restoring: restoringVersion,
|
|
717
735
|
onReturn: () => setSnapshotDocumentId(null)
|
|
718
736
|
}
|
|
719
737
|
)
|
|
@@ -827,12 +845,14 @@ function DocumentViewerContent({
|
|
|
827
845
|
setActiveTab(isArtifact ? "edit" : isDocx ? "docx" : "pdf");
|
|
828
846
|
},
|
|
829
847
|
onCompare: (id) => session.setDocumentViewer({ compareId: id, tab: "html" }),
|
|
848
|
+
restoring: restoringVersion,
|
|
849
|
+
onRestore: canRestore ? (id) => void restoreSnapshot(id) : void 0,
|
|
830
850
|
translations,
|
|
831
851
|
onOpenTranslation: (id) => setViewingDocumentId(id)
|
|
832
852
|
}
|
|
833
853
|
),
|
|
834
854
|
activeTab === "xlsx" && isXlsx && (xlsxBlob ? /* @__PURE__ */ jsx(XlsxViewer, { blob: xlsxBlob }) : /* @__PURE__ */ jsx(ViewerMessage, { children: xlsxError ? "Failed to load spreadsheet" : "Loading spreadsheet..." })),
|
|
835
|
-
activeTab === "slides" && isPresentation && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(ViewerMessage, { children: "Loading slides\u2026" }), children: /* @__PURE__ */ jsx(
|
|
855
|
+
activeTab === "slides" && !snapshotDocumentId && isPresentation && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(ViewerMessage, { children: "Loading slides\u2026" }), children: /* @__PURE__ */ jsx(
|
|
836
856
|
SlidesTab,
|
|
837
857
|
{
|
|
838
858
|
documentId,
|