@kabmo-labs/kabmo 0.17.0 → 0.19.0
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/README.md +10 -7
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +523 -441
- package/dist/client/static/js/{index-rerjq5th.js → index-fcee4c13.js} +828 -818
- package/dist/client/static/js/index-sxdw908m.css +1 -0
- package/marketplace/plugins/command-runner/package.json +3 -2
- package/marketplace/plugins/git-forge/package.json +3 -2
- package/marketplace/plugins/session-info/package.json +3 -2
- package/marketplace/plugins/stats/package.json +3 -2
- package/package.json +3 -1
- package/src/client/components/auth/login-screen/index.tsx +2 -1
- package/src/client/components/common/ComposerPicker.tsx +1 -1
- package/src/client/components/common/FolderPicker.tsx +2 -2
- package/src/client/components/common/MarkdownRenderer.tsx +136 -89
- package/src/client/components/common/Modal.tsx +2 -2
- package/src/client/components/common/PWAInstallButton.tsx +2 -2
- package/src/client/components/common/ViewportSelector.tsx +1 -1
- package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
- package/src/client/components/common/anchored-menu/index.tsx +147 -0
- package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
- package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
- package/src/client/components/common/brand-wordmark/index.tsx +13 -2
- package/src/client/components/common/checkbox/style.test.ts +139 -0
- package/src/client/components/common/checkbox/style.ts +51 -0
- package/src/client/components/common/context-usage-button/index.tsx +2 -2
- package/src/client/components/common/file-icon/index.tsx +23 -9
- package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
- package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
- package/src/client/components/common/markdown-review/index.tsx +129 -0
- package/src/client/components/common/panel-mark/index.tsx +97 -0
- package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
- package/src/client/components/common/provider-icon/index.test.ts +14 -0
- package/src/client/components/common/provider-icon/index.tsx +4 -0
- package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
- package/src/client/components/common/provider-icon/resolve.ts +16 -3
- package/src/client/components/common/server-control/Panel.tsx +33 -23
- package/src/client/components/common/server-control/index.test.tsx +11 -5
- package/src/client/components/common/server-control/index.tsx +10 -8
- package/src/client/components/common/session-actions-menu/index.tsx +1 -1
- package/src/client/components/common/toolbar-row/index.tsx +1 -1
- package/src/client/components/layout/ActivityBar.tsx +22 -3
- package/src/client/components/layout/LeftDock.tsx +9 -2
- package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
- package/src/client/components/layout/WindowAura.tsx +27 -0
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
- package/src/client/components/layout/desktop-layout/index.tsx +3 -1
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +44 -23
- package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
- package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
- package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +40 -14
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
- package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
- package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
- package/src/client/components/layout/update-popup/index.tsx +5 -1
- package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
- package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
- package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
- package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
- package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
- package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/mobile/panel-chips.tsx +10 -2
- package/src/client/components/settings/Modal.tsx +4 -4
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
- package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
- package/src/client/components/settings/apply-side-effects.test.ts +30 -0
- package/src/client/components/settings/apply-side-effects.ts +14 -0
- package/src/client/components/settings/categories/AgentSettings.tsx +23 -50
- package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
- package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
- package/src/client/components/settings/categories/McpSettings.tsx +4 -21
- package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
- package/src/client/components/settings/categories/SkillSettings.tsx +2 -2
- package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
- package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
- package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
- package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +9 -2
- package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
- package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
- package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
- package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +93 -77
- package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +28 -15
- package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
- package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
- package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
- package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
- package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
- package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
- package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
- package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
- package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
- package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
- package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
- package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +37 -8
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +34 -14
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +21 -0
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +15 -6
- package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
- package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
- package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
- package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
- package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
- package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
- package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
- package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
- package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
- package/src/client/components/workspace/browser-panel/index.tsx +50 -4
- package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
- package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
- package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
- package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
- package/src/client/components/workspace/diff-panel/changes.ts +28 -12
- package/src/client/components/workspace/diff-panel/index.tsx +2 -2
- package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
- package/src/client/components/workspace/diff-panel/merge.ts +21 -1
- package/src/client/components/workspace/editor/Body.tsx +7 -0
- package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
- package/src/client/components/workspace/editor/FilePane.tsx +12 -0
- package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
- package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
- package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
- package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
- package/src/client/components/workspace/editor/Tabs.tsx +1 -1
- package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
- package/src/client/components/workspace/editor/index.tsx +25 -22
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
- package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
- package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
- package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
- package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
- package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
- package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
- package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
- package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
- package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
- package/src/client/components/workspace/git-panel/index.tsx +7 -0
- package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
- package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
- package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
- package/src/client/components/workspace/search-panel/Body.tsx +1 -1
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
- package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
- package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
- package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
- package/src/client/data/agent-data/builtin.ts +0 -10
- package/src/client/data/agent-data/orchestrator.ts +0 -45
- package/src/client/data/agent-data/specialist.ts +0 -100
- package/src/client/data/mock/token-usage.ts +170 -120
- package/src/client/data/settings/omp-schema.json +33 -1
- package/src/client/glass.css +785 -0
- package/src/client/glass.test.ts +346 -0
- package/src/client/hooks/browser/use-annotate.test.ts +143 -0
- package/src/client/hooks/browser/use-annotate.ts +98 -0
- package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
- package/src/client/hooks/browser/use-close-tab.ts +67 -0
- package/src/client/hooks/browser/use-screencast.ts +13 -1
- package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
- package/src/client/hooks/chat/composer/browser-context.ts +40 -16
- package/src/client/hooks/chat/composer/items.test.ts +1 -1
- package/src/client/hooks/chat/composer/review-context.ts +38 -0
- package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
- package/src/client/hooks/chat/composer/use-draft.ts +31 -2
- package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
- package/src/client/hooks/editor/use-document-annotations.ts +124 -0
- package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
- package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
- package/src/client/hooks/editor/use-preview-review.ts +148 -0
- package/src/client/hooks/settings/agents.ts +149 -0
- package/src/client/hooks/settings/crud-list.test.ts +28 -6
- package/src/client/hooks/settings/crud-list.ts +96 -57
- package/src/client/hooks/settings/omp-config.ts +164 -0
- package/src/client/hooks/settings/useTokenUsage.ts +125 -0
- package/src/client/hooks/settings/write-feedback.test.ts +104 -0
- package/src/client/hooks/settings/write-feedback.ts +63 -0
- package/src/client/hooks/ui/glass-support.ts +57 -0
- package/src/client/hooks/ui/icon-style.ts +59 -0
- package/src/client/hooks/ui/markdown-hydration.ts +125 -0
- package/src/client/hooks/ui/stuck-header.test.ts +188 -0
- package/src/client/hooks/ui/stuck-header.ts +91 -0
- package/src/client/hooks/ui/style-attributes.test.ts +120 -0
- package/src/client/hooks/ui/surface-style.ts +56 -0
- package/src/client/hooks/ui/updates/index.test.ts +100 -1
- package/src/client/hooks/ui/updates/index.ts +50 -0
- package/src/client/hooks/ui/updates/notes.test.ts +138 -0
- package/src/client/hooks/ui/updates/notes.ts +57 -0
- package/src/client/hooks/workspace/panel-hues.ts +23 -0
- package/src/client/lib/browser/element-at.test.ts +229 -0
- package/src/client/lib/browser/element-at.ts +139 -0
- package/src/client/lib/review/client.ts +73 -0
- package/src/client/lib/router/search-params.ts +42 -20
- package/src/client/main.tsx +10 -0
- package/src/client/tailwind.css +329 -11
- package/src/server/lib/assets/shell-attributes.server.ts +80 -0
- package/src/server/lib/assets/shell-attributes.test.ts +86 -0
- package/src/server/lib/btw/lifecycle.server.ts +2 -2
- package/src/server/lib/db/schema.ts +7 -0
- package/src/server/lib/db/seed-terminal.test.ts +4 -0
- package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
- package/src/server/lib/omp/config/agents.ts +231 -61
- package/src/server/lib/omp/config/definitions.test.ts +9 -105
- package/src/server/lib/omp/config/extensions.ts +16 -7
- package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
- package/src/server/lib/omp/rpc/constants.test.ts +11 -0
- package/src/server/lib/omp/rpc/constants.ts +15 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
- package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
- package/src/server/lib/omp/rpc/manager.ts +2 -2
- package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
- package/src/server/lib/omp/rpc/process.test.ts +106 -0
- package/src/server/lib/omp/rpc/process.ts +39 -18
- package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
- package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
- package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
- package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
- package/src/server/lib/omp/rpc/session-commands.ts +17 -3
- package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
- package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
- package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
- package/src/server/lib/omp/rpc/utility.ts +12 -0
- package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
- package/src/server/lib/panels/manifest.test.ts +20 -0
- package/src/server/lib/panels/manifest.ts +12 -0
- package/src/server/lib/panels/scan.server.ts +4 -0
- package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
- package/src/server/lib/queue/delivery-harness.ts +8 -4
- package/src/server/lib/queue/delivery.server.test.ts +29 -0
- package/src/server/lib/queue/delivery.server.ts +39 -0
- package/src/server/lib/queue/store.server.test.ts +22 -2
- package/src/server/lib/queue/store.server.ts +33 -11
- package/src/server/lib/review/schema.server.ts +45 -0
- package/src/server/lib/review/store.server.ts +138 -0
- package/src/server/lib/terminal/attach-replay.test.ts +132 -0
- package/src/server/lib/terminal/output.test.ts +166 -0
- package/src/server/lib/terminal/output.ts +104 -0
- package/src/server/lib/terminal/runtime.server.ts +5 -0
- package/src/server/lib/terminal/send-result.test.ts +33 -0
- package/src/server/lib/terminal/send-result.ts +32 -0
- package/src/server/lib/terminal/session.server.ts +45 -11
- package/src/server/lib/terminal/store-liveness.test.ts +4 -0
- package/src/server/lib/updates/active-notes.test.ts +149 -0
- package/src/server/lib/updates/active-notes.ts +75 -0
- package/src/server/lib/updates/changelog-file.ts +42 -11
- package/src/server/lib/updates/changelog.test.ts +15 -1
- package/src/server/lib/updates/omp.ts +42 -15
- package/src/server/lib/updates/release-url.ts +27 -1
- package/src/server/lib/usage/index-parse.test.ts +200 -0
- package/src/server/lib/usage/index-parse.ts +178 -0
- package/src/server/lib/usage/index-query.server.ts +248 -0
- package/src/server/lib/usage/index-scan.server.ts +343 -0
- package/src/server/lib/usage/index-schema.server.ts +82 -0
- package/src/server/lib/usage/index.test.ts +234 -0
- package/src/server/lib/usage/providers.server.ts +4 -53
- package/src/server/plugins/ssr.ts +22 -5
- package/src/server/routes/browser/index.ts +3 -0
- package/src/server/routes/browser/stream.ts +31 -2
- package/src/server/routes/browser/tabs.test.ts +94 -0
- package/src/server/routes/browser/tabs.ts +85 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/review/bindings.ts +11 -0
- package/src/server/routes/review/index.ts +127 -0
- package/src/server/routes/review/routes.test.ts +191 -0
- package/src/server/routes/settings/agents.test.ts +180 -0
- package/src/server/routes/settings/agents.ts +95 -102
- package/src/server/routes/settings/mcp.test.ts +135 -0
- package/src/server/routes/settings/mcp.ts +14 -6
- package/src/server/routes/settings/settings-store-routes.test.ts +6 -113
- package/src/server/routes/telemetry/tokens.test.ts +145 -0
- package/src/server/routes/telemetry/tokens.ts +70 -149
- package/src/server/routes/terminal/ws.ts +6 -5
- package/src/server/routes/updates/index.ts +2 -0
- package/src/server/routes/updates/notes.ts +34 -0
- package/src/server/routes/updates/routes.test.ts +49 -0
- package/src/shared/lib/browser/annotate.test.ts +283 -0
- package/src/shared/lib/browser/annotate.ts +231 -0
- package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
- package/src/shared/lib/browser/frame-gate.test.ts +91 -0
- package/src/shared/lib/browser/frame-gate.ts +69 -0
- package/src/shared/lib/browser/frame-params.test.ts +43 -0
- package/src/shared/lib/browser/frame-params.ts +60 -0
- package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
- package/src/shared/lib/browser/frame-pipeline.ts +80 -0
- package/src/shared/lib/browser/page-context.ts +60 -4
- package/src/shared/lib/browser/snapshot.test.ts +115 -0
- package/src/shared/lib/browser/snapshot.ts +112 -0
- package/src/shared/lib/browser/tab-close.test.ts +74 -0
- package/src/shared/lib/browser/tab-close.ts +77 -0
- package/src/shared/lib/browser/viewer.ts +45 -26
- package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
- package/src/shared/lib/chat/tool/artifact.ts +55 -20
- package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
- package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
- package/src/shared/lib/chat/tool/minimized.ts +64 -0
- package/src/shared/lib/chat/tool/summary.test.ts +28 -8
- package/src/shared/lib/chat/tool/summary.ts +3 -32
- package/src/shared/lib/icons/file-brand-color.ts +38 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
- package/src/shared/lib/icons/icon-paint-css.ts +284 -0
- package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
- package/src/shared/lib/icons/tint.test.ts +273 -0
- package/src/shared/lib/icons/tint.ts +219 -0
- package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
- package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
- package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
- package/src/shared/lib/markdown/blocks/scan.ts +100 -0
- package/src/shared/lib/markdown/blocks/types.ts +62 -0
- package/src/shared/lib/markdown/marked.ts +58 -147
- package/src/shared/lib/markdown/math-extensions.ts +168 -0
- package/src/shared/lib/markdown/review/prompt.ts +77 -0
- package/src/shared/lib/markdown/review/reconcile.ts +55 -0
- package/src/shared/lib/markdown/review/review.test.ts +96 -0
- package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
- package/src/shared/lib/markdown/xml-sections.ts +139 -0
- package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
- package/src/shared/lib/models/provider/brand-color.ts +103 -0
- package/src/shared/lib/models/provider/label.ts +57 -0
- package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
- package/src/shared/lib/omp/config/agent-file.ts +43 -0
- package/src/shared/lib/omp/config/row-value.test.ts +95 -0
- package/src/shared/lib/omp/config/row-value.ts +97 -0
- package/src/shared/lib/omp/config/schema.test.ts +31 -0
- package/src/shared/lib/omp/config/schema.ts +6 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +113 -47
- package/src/shared/lib/omp/rpc/frame.ts +107 -43
- package/src/shared/lib/settings/defaults.ts +4 -0
- package/src/shared/lib/theme/catalog.test.ts +5 -4
- package/src/shared/lib/theme/catalog.ts +18 -3
- package/src/shared/lib/theme/glass-support.test.ts +38 -0
- package/src/shared/lib/theme/glass-support.ts +73 -0
- package/src/shared/lib/theme/icon-style.test.ts +74 -0
- package/src/shared/lib/theme/icon-style.ts +90 -0
- package/src/shared/lib/theme/legibility.ts +91 -0
- package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
- package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
- package/src/shared/lib/theme/surface-style.test.ts +68 -0
- package/src/shared/lib/theme/surface-style.ts +91 -0
- package/src/shared/lib/theme/theme.test.ts +11 -7
- package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
- package/src/shared/lib/ui/menu-anchor.ts +89 -0
- package/src/shared/lib/usage/breakdown.test.ts +197 -0
- package/src/shared/lib/usage/breakdown.ts +241 -0
- package/src/shared/lib/usage/range.test.ts +204 -0
- package/src/shared/lib/usage/range.ts +240 -0
- package/src/shared/lib/usage/view.test.ts +85 -0
- package/src/shared/lib/usage/view.ts +74 -0
- package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
- package/src/shared/lib/workspace/panel-hues.ts +57 -0
- package/src/shared/types/browser.ts +78 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/panels-registry.ts +6 -0
- package/src/shared/types/panels.ts +14 -0
- package/src/shared/types/settings/agent.ts +28 -6
- package/src/shared/types/settings/state.ts +30 -3
- package/src/shared/types/settings/write.ts +6 -0
- package/src/shared/types/tokenUsage.ts +128 -21
- package/src/shared/types/updates.ts +20 -0
- package/src/test-support/fake-omp-frames.ts +163 -0
- package/dist/client/static/js/index-3ve31rzx.css +0 -1
- package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
- package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
- package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
- package/src/server/lib/omp/session/usage/shaping.ts +0 -130
- /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
|
@@ -1,125 +1,265 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo, useState } from 'preact/hooks';
|
|
2
|
+
import { ChevronDown, ChevronRight } from 'lucide-preact';
|
|
3
|
+
import type { BreakdownTab, BucketGranularity, UsageTotals } from '@/shared/types';
|
|
4
|
+
import type { BreakdownViewRow } from '@/shared/lib/usage/breakdown';
|
|
5
|
+
import { cacheHitLabel, costLabel, costPerMillionLabel, tokenLabel } from '@/shared/lib/usage/view';
|
|
6
|
+
import { ProviderIconPlate } from '@/client/components/common/provider-icon/Plate';
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The time tab is named for the bucket width the PERIOD implies. A month of
|
|
10
|
+
* usage is a list of days; a quarter is a list of weeks; all time is months.
|
|
11
|
+
*/
|
|
12
|
+
function tabsFor(granularity: BucketGranularity): Array<{ id: BreakdownTab; label: string }> {
|
|
13
|
+
return [
|
|
14
|
+
{ id: 'provider', label: 'PROVIDER' },
|
|
15
|
+
{ id: 'model', label: 'MODEL' },
|
|
16
|
+
{ id: 'day', label: granularity === 'week' ? 'WEEK' : granularity === 'month' ? 'MONTH' : 'DAY' },
|
|
17
|
+
{ id: 'project', label: 'PROJECT' },
|
|
18
|
+
];
|
|
9
19
|
}
|
|
10
20
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
/** Provider rows shown before "Show all" — twelve was the old silent ceiling. */
|
|
22
|
+
const COLLAPSED_ROWS = 8;
|
|
23
|
+
/**
|
|
24
|
+
* Time rows shown at once. A period is fully enumerated (every day of the
|
|
25
|
+
* month), so this is a scroll region, not a truncation: the table body scrolls
|
|
26
|
+
* and the count above it says how many rows the period has.
|
|
27
|
+
*/
|
|
28
|
+
const TIME_ROWS_VISIBLE = 14;
|
|
29
|
+
|
|
30
|
+
interface TokenUsageBreakdownProps {
|
|
31
|
+
tab: BreakdownTab;
|
|
32
|
+
onTab: (tab: BreakdownTab) => void;
|
|
33
|
+
rows: BreakdownViewRow[];
|
|
34
|
+
totals: UsageTotals;
|
|
35
|
+
granularity: BucketGranularity;
|
|
36
|
+
/** Provider slugs to display names, for the icon plate. */
|
|
37
|
+
providerNames: Record<string, string>;
|
|
38
|
+
}
|
|
16
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The provider → model tree, the time table and the project table.
|
|
42
|
+
*
|
|
43
|
+
* The Model tab is deliberately two-level: `message.provider` was on every usage
|
|
44
|
+
* record, but the breakdown keyed on model alone, so two accounts serving
|
|
45
|
+
* `deepseek-v4-1-flash` showed up as one $1 673.86 row instead of $1 619.43 and
|
|
46
|
+
* $54.43 — the one number a multi-account user needs to see.
|
|
47
|
+
*
|
|
48
|
+
* Every cell is the selected PERIOD's total — there is no per-day/per-week
|
|
49
|
+
* number, because a period is a single span. Only the time tab's bucket width
|
|
50
|
+
* varies, and it follows the period's length (see `tabsFor`).
|
|
51
|
+
*/
|
|
17
52
|
export function TokenUsageBreakdown({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
53
|
+
tab,
|
|
54
|
+
onTab,
|
|
55
|
+
rows,
|
|
56
|
+
totals,
|
|
57
|
+
granularity,
|
|
58
|
+
providerNames,
|
|
23
59
|
}: TokenUsageBreakdownProps) {
|
|
60
|
+
// `null` means "the default": the top three providers open, the rest closed
|
|
61
|
+
// so the rows carrying the answer need no click. The first explicit toggle
|
|
62
|
+
// materialises a concrete set, and from then on the user's choice wins —
|
|
63
|
+
// including collapsing one of those three (a chevron that cannot close its
|
|
64
|
+
// own row is worse than no chevron).
|
|
65
|
+
const [expanded, setExpanded] = useState<Set<string> | null>(null);
|
|
66
|
+
const [showAll, setShowAll] = useState(false);
|
|
67
|
+
|
|
68
|
+
const isTree = tab === 'provider' || tab === 'model';
|
|
69
|
+
const defaultOpen = useMemo(
|
|
70
|
+
() => new Set(rows.filter((row) => row.kind === 'group').slice(0, 3).map((row) => row.provider ?? '')),
|
|
71
|
+
[rows],
|
|
72
|
+
);
|
|
73
|
+
const openSet = expanded ?? defaultOpen;
|
|
74
|
+
|
|
75
|
+
// A time tab lists the PERIOD, so it is never sliced: the body scrolls
|
|
76
|
+
// instead. Slicing it to eight rows is what made a month look like it had
|
|
77
|
+
// only eight days.
|
|
78
|
+
const visibleRows = useMemo(() => {
|
|
79
|
+
if (!isTree) return rows;
|
|
80
|
+
const shown: BreakdownViewRow[] = [];
|
|
81
|
+
for (const row of rows) {
|
|
82
|
+
if (row.kind === 'group' || showAll || openSet.has(row.provider ?? '')) shown.push(row);
|
|
83
|
+
}
|
|
84
|
+
return shown;
|
|
85
|
+
}, [rows, isTree, showAll, openSet]);
|
|
86
|
+
|
|
87
|
+
const toggle = (provider: string) => {
|
|
88
|
+
const next = new Set(openSet);
|
|
89
|
+
if (next.has(provider)) next.delete(provider);
|
|
90
|
+
else next.add(provider);
|
|
91
|
+
setExpanded(next);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const firstColumn = tab === 'day' ? granularity : tab === 'model' ? 'Provider / Model' : tab;
|
|
95
|
+
|
|
24
96
|
return (
|
|
25
|
-
<div className="grid grid-cols-1 xl:grid-cols-3
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
>
|
|
53
|
-
PROJECT
|
|
54
|
-
</button>
|
|
97
|
+
<div className="grid grid-cols-1 gap-3 xl:grid-cols-3">
|
|
98
|
+
<div className="rounded-lg border border-ink/15 bg-paper p-3.5 shadow-xs xl:col-span-2">
|
|
99
|
+
{/* Wraps rather than overflowing: at phone widths the four tabs were
|
|
100
|
+
14–84 px wider than the card, so PROJECT sat outside it and looked
|
|
101
|
+
like a missing tab. */}
|
|
102
|
+
<div className="mb-3 flex flex-wrap items-center justify-between gap-x-2 gap-y-1.5">
|
|
103
|
+
<span className="flex items-baseline gap-2 text-xs font-semibold text-ink">
|
|
104
|
+
Breakdown
|
|
105
|
+
<span className="font-mono text-[9px] font-normal uppercase tracking-wider text-ink/35">
|
|
106
|
+
{isTree ? 'period total' : `${rows.length} ${rows.length === 1 ? 'row' : 'rows'} · ${granularity}`}
|
|
107
|
+
</span>
|
|
108
|
+
</span>
|
|
109
|
+
<div role="tablist" aria-label="Breakdown" className="flex shrink-0 rounded bg-ink/5 p-0.5">
|
|
110
|
+
{tabsFor(granularity).map((entry) => (
|
|
111
|
+
<button
|
|
112
|
+
key={entry.id}
|
|
113
|
+
type="button"
|
|
114
|
+
role="tab"
|
|
115
|
+
aria-selected={tab === entry.id}
|
|
116
|
+
onClick={() => onTab(entry.id)}
|
|
117
|
+
className={`rounded px-2 py-0.5 text-[9px] font-bold tracking-wider transition-colors ${
|
|
118
|
+
tab === entry.id ? 'bg-paper text-ink shadow-xs' : 'text-ink/50 hover:text-ink'
|
|
119
|
+
}`}
|
|
120
|
+
>
|
|
121
|
+
{entry.label}
|
|
122
|
+
</button>
|
|
123
|
+
))}
|
|
55
124
|
</div>
|
|
56
125
|
</div>
|
|
57
126
|
|
|
58
|
-
|
|
59
|
-
<
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
</
|
|
77
|
-
<td className="py-2.5 text-right font-bold text-ink">{row.cost}</td>
|
|
78
|
-
<td className="py-2.5 text-right text-ink/60">{row.share}</td>
|
|
79
|
-
<td className="py-2.5 text-right text-ink/60">{row.tokens}</td>
|
|
127
|
+
{rows.length === 0 ? (
|
|
128
|
+
<p className="py-6 text-center text-[11px] text-ink/40">No usage recorded in this period.</p>
|
|
129
|
+
) : (
|
|
130
|
+
<div className="overflow-x-auto">
|
|
131
|
+
<div
|
|
132
|
+
// A time tab's rows scroll; the provider tree is short enough to
|
|
133
|
+
// render whole and must not nest two scroll regions.
|
|
134
|
+
className={isTree ? undefined : 'overflow-y-auto'}
|
|
135
|
+
style={isTree ? undefined : { maxHeight: `${TIME_ROWS_VISIBLE * 1.6}rem` }}
|
|
136
|
+
>
|
|
137
|
+
<table className="w-full text-[11px]">
|
|
138
|
+
<thead>
|
|
139
|
+
<tr className="border-b border-ink/10 text-ink/40">
|
|
140
|
+
<th className="pb-2 text-left font-medium capitalize">{firstColumn}</th>
|
|
141
|
+
<th className="pb-2 text-right font-medium">Cost</th>
|
|
142
|
+
<th className="pb-2 text-right font-medium">Share</th>
|
|
143
|
+
<th className="pb-2 text-right font-medium">Tokens</th>
|
|
144
|
+
<th className="hidden pb-2 text-right font-medium sm:table-cell">Cache</th>
|
|
145
|
+
<th className="hidden pb-2 text-right font-medium sm:table-cell">Turns</th>
|
|
80
146
|
</tr>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
147
|
+
</thead>
|
|
148
|
+
<tbody className="divide-y divide-ink/5">
|
|
149
|
+
{visibleRows.map((row) => {
|
|
150
|
+
const isGroup = row.kind === 'group';
|
|
151
|
+
const providerId = row.provider ?? '';
|
|
152
|
+
const open = !isGroup || showAll || openSet.has(providerId);
|
|
153
|
+
return (
|
|
154
|
+
<tr key={row.key} className={isGroup ? 'bg-ink/[0.02]' : undefined}>
|
|
155
|
+
<td className="py-2">
|
|
156
|
+
<div className="flex items-center gap-2" style={{ paddingLeft: `${row.depth * 14}px` }}>
|
|
157
|
+
{isGroup ? (
|
|
158
|
+
<button
|
|
159
|
+
type="button"
|
|
160
|
+
aria-expanded={open}
|
|
161
|
+
aria-label={`${row.label} models`}
|
|
162
|
+
onClick={() => toggle(providerId)}
|
|
163
|
+
className="-ml-0.5 text-ink/50 transition-colors hover:text-ink"
|
|
164
|
+
>
|
|
165
|
+
{open ? <ChevronDown size={12} /> : <ChevronRight size={12} />}
|
|
166
|
+
</button>
|
|
167
|
+
) : null}
|
|
168
|
+
{row.provider && (
|
|
169
|
+
<ProviderIconPlate
|
|
170
|
+
provider={{
|
|
171
|
+
slug: row.provider,
|
|
172
|
+
name: providerNames[row.provider] ?? row.provider,
|
|
173
|
+
}}
|
|
174
|
+
size={isGroup ? 16 : 14}
|
|
175
|
+
radius={4}
|
|
176
|
+
/>
|
|
177
|
+
)}
|
|
178
|
+
<span
|
|
179
|
+
className={`whitespace-nowrap ${
|
|
180
|
+
isGroup ? 'font-semibold text-ink' : 'font-medium text-ink/85'
|
|
181
|
+
}`}
|
|
182
|
+
>
|
|
183
|
+
{row.label}
|
|
184
|
+
</span>
|
|
185
|
+
</div>
|
|
186
|
+
</td>
|
|
187
|
+
<td className={`py-2 text-right tabular-nums ${isGroup ? 'font-bold text-ink' : 'text-ink/80'}`}>
|
|
188
|
+
{costLabel(row.cost)}
|
|
189
|
+
</td>
|
|
190
|
+
<td className="py-2 text-right tabular-nums text-ink/60">{row.sharePercent.toFixed(1)}%</td>
|
|
191
|
+
<td className="py-2 text-right tabular-nums text-ink/60">{tokenLabel(row.tokens)}</td>
|
|
192
|
+
<td className="hidden py-2 text-right tabular-nums text-ink/60 sm:table-cell">{row.cacheHit}</td>
|
|
193
|
+
<td className="hidden py-2 text-right tabular-nums text-ink/60 sm:table-cell">
|
|
194
|
+
{row.records.toLocaleString('en-US')}
|
|
195
|
+
</td>
|
|
196
|
+
</tr>
|
|
197
|
+
);
|
|
198
|
+
})}
|
|
199
|
+
</tbody>
|
|
200
|
+
</table>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
)}
|
|
85
204
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
205
|
+
<div className="mt-3 flex h-1.5 w-full overflow-hidden rounded-full bg-ink/5">
|
|
206
|
+
{rows
|
|
207
|
+
.filter((row) => row.kind === 'group' || !isTree)
|
|
208
|
+
.slice(0, COLLAPSED_ROWS)
|
|
209
|
+
.map((row, index) => (
|
|
210
|
+
<div
|
|
211
|
+
key={row.key}
|
|
212
|
+
className={index === 0 ? 'bg-ink/80' : index === 1 ? 'border-l border-paper bg-ink/45' : 'border-l border-paper bg-ink/25'}
|
|
213
|
+
style={{ width: `${row.sharePercent}%` }}
|
|
214
|
+
/>
|
|
215
|
+
))}
|
|
97
216
|
</div>
|
|
217
|
+
|
|
218
|
+
{isTree && !showAll && visibleRows.length < rows.length && (
|
|
219
|
+
<button
|
|
220
|
+
type="button"
|
|
221
|
+
onClick={() => setShowAll(true)}
|
|
222
|
+
className="mt-2 text-[10px] font-semibold text-ink/50 transition-colors hover:text-ink"
|
|
223
|
+
>
|
|
224
|
+
Show all {rows.length} rows
|
|
225
|
+
</button>
|
|
226
|
+
)}
|
|
98
227
|
</div>
|
|
99
228
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
229
|
+
<div className="rounded-lg border border-ink/15 bg-paper p-3.5 shadow-xs">
|
|
230
|
+
<div className="mb-3 flex items-baseline justify-between gap-2">
|
|
231
|
+
<span className="text-xs font-semibold text-ink">Cost quality</span>
|
|
232
|
+
<span className="font-mono text-[9px] uppercase tracking-wider text-ink/35">period total</span>
|
|
233
|
+
</div>
|
|
234
|
+
<dl className="space-y-2 text-[11px]">
|
|
235
|
+
<div className="flex items-center justify-between">
|
|
236
|
+
<dt className="text-ink/60">Cost per 1M tokens</dt>
|
|
237
|
+
<dd className="tabular-nums font-semibold text-ink">{costPerMillionLabel(totals)}</dd>
|
|
107
238
|
</div>
|
|
108
|
-
<div className="flex justify-between
|
|
109
|
-
<
|
|
110
|
-
<
|
|
239
|
+
<div className="flex items-center justify-between">
|
|
240
|
+
<dt className="text-ink/60">Cache hit rate</dt>
|
|
241
|
+
<dd className="tabular-nums font-semibold text-ink">{cacheHitLabel(totals)}</dd>
|
|
111
242
|
</div>
|
|
112
|
-
<div className="flex justify-between
|
|
113
|
-
<
|
|
114
|
-
<
|
|
243
|
+
<div className="flex items-center justify-between">
|
|
244
|
+
<dt className="text-ink/60">Unpriced turns</dt>
|
|
245
|
+
<dd className="tabular-nums font-semibold text-ink">
|
|
246
|
+
{totals.records > 0 ? `${((totals.unpriced / totals.records) * 100).toFixed(1)}%` : '—'}
|
|
247
|
+
</dd>
|
|
115
248
|
</div>
|
|
116
|
-
|
|
249
|
+
<div className="flex items-center justify-between">
|
|
250
|
+
<dt className="text-ink/60">Turns</dt>
|
|
251
|
+
<dd className="tabular-nums font-semibold text-ink">{totals.records.toLocaleString('en-US')}</dd>
|
|
252
|
+
</div>
|
|
253
|
+
</dl>
|
|
117
254
|
|
|
118
|
-
<div className="border-t border-ink/10
|
|
119
|
-
<div className="flex justify-between
|
|
120
|
-
<span className="text-ink/60">
|
|
121
|
-
<span className="font-semibold text-ink">{
|
|
255
|
+
<div className="mt-3 border-t border-ink/10 pt-2.5">
|
|
256
|
+
<div className="flex items-center justify-between text-[11px]">
|
|
257
|
+
<span className="text-ink/60">Paid for cache reads</span>
|
|
258
|
+
<span className="tabular-nums font-semibold text-ink">{costLabel(totals.cacheReadCost)}</span>
|
|
122
259
|
</div>
|
|
260
|
+
<p className="mt-1 text-[10px] leading-tight text-ink/40">
|
|
261
|
+
Provider-reported cost only. A turn with no reported rate counts as unpriced rather than free.
|
|
262
|
+
</p>
|
|
123
263
|
</div>
|
|
124
264
|
</div>
|
|
125
265
|
</div>
|
|
@@ -1,74 +1,148 @@
|
|
|
1
|
-
import type { ChartMetric
|
|
2
|
-
import {
|
|
1
|
+
import type { ChartMetric } from '@/shared/types';
|
|
2
|
+
import type { CadenceBucket } from '@/shared/lib/usage/breakdown';
|
|
3
|
+
import { costLabel, tokenLabel } from '@/shared/lib/usage/view';
|
|
4
|
+
|
|
5
|
+
/** Ink ramp, strongest first. Chroma stays reserved for the error state. */
|
|
6
|
+
const SERIES_FILL = [
|
|
7
|
+
'var(--theme-ink)',
|
|
8
|
+
'color-mix(in oklab, var(--theme-ink) 72%, transparent)',
|
|
9
|
+
'color-mix(in oklab, var(--theme-ink) 54%, transparent)',
|
|
10
|
+
'color-mix(in oklab, var(--theme-ink) 38%, transparent)',
|
|
11
|
+
'color-mix(in oklab, var(--theme-ink) 26%, transparent)',
|
|
12
|
+
'color-mix(in oklab, var(--theme-ink) 16%, transparent)',
|
|
13
|
+
] as const;
|
|
14
|
+
|
|
15
|
+
export interface ChartProvider {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
3
19
|
|
|
4
20
|
interface UsageChartProps {
|
|
5
|
-
|
|
21
|
+
buckets: CadenceBucket[];
|
|
6
22
|
metric: ChartMetric;
|
|
7
|
-
|
|
23
|
+
providers: ChartProvider[];
|
|
24
|
+
/** Providers currently drawn; a legend click toggles one. */
|
|
25
|
+
visible: ReadonlySet<string>;
|
|
26
|
+
onToggle: (id: string) => void;
|
|
27
|
+
/** `day`/`week`/`month` — the period's own bucket width, for the aria label. */
|
|
28
|
+
granularity: string;
|
|
8
29
|
}
|
|
9
30
|
|
|
10
|
-
function
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
return series
|
|
15
|
-
.map((_, index) => {
|
|
16
|
-
const x = (index / (series.length - 1)) * 100;
|
|
17
|
-
const y = 98 - (values[index] / span) * 94;
|
|
18
|
-
return `${index === 0 ? 'M' : 'L'}${x.toFixed(2)},${y.toFixed(2)}`;
|
|
19
|
-
})
|
|
20
|
-
.join(' ');
|
|
31
|
+
function valueOf(bucket: CadenceBucket, metric: ChartMetric, provider: string): number {
|
|
32
|
+
const split = bucket.byProvider[provider];
|
|
33
|
+
if (!split) return 0;
|
|
34
|
+
return metric === 'cost' ? split.cost : split.tokens;
|
|
21
35
|
}
|
|
22
36
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (
|
|
37
|
+
/**
|
|
38
|
+
* Stacked area, one band per provider.
|
|
39
|
+
*
|
|
40
|
+
* The bands are the point: a single line of the total cannot show that two
|
|
41
|
+
* accounts serving the same model id are 95% / 4% of the bill. Bars would need
|
|
42
|
+
* the same vertical budget and read worse at 30+ buckets, so bands reuse the
|
|
43
|
+
* existing axis layout.
|
|
44
|
+
*/
|
|
45
|
+
export function UsageChart({ buckets, metric, providers, visible, onToggle, granularity }: UsageChartProps) {
|
|
46
|
+
const drawn = providers.filter((provider) => visible.has(provider.id));
|
|
47
|
+
if (buckets.length === 0) {
|
|
34
48
|
return (
|
|
35
|
-
<div className="h-
|
|
36
|
-
No usage
|
|
49
|
+
<div className="flex h-32 items-center justify-center text-[11px] text-ink/40">
|
|
50
|
+
No usage recorded in this period.
|
|
37
51
|
</div>
|
|
38
52
|
);
|
|
39
53
|
}
|
|
40
54
|
|
|
55
|
+
// Cumulative totals per bucket, in legend order, so a band's top edge is the
|
|
56
|
+
// sum of every band below it.
|
|
57
|
+
const cumulative: number[][] = [];
|
|
58
|
+
let running = new Array(buckets.length).fill(0) as number[];
|
|
59
|
+
for (const provider of drawn) {
|
|
60
|
+
running = running.map((value, index) => value + valueOf(buckets[index], metric, provider.id));
|
|
61
|
+
cumulative.push(running);
|
|
62
|
+
}
|
|
63
|
+
const max = Math.max(...running, 0);
|
|
64
|
+
const span = max > 0 ? max : 1;
|
|
65
|
+
const x = (index: number) => (buckets.length === 1 ? 0 : (index / (buckets.length - 1)) * 100);
|
|
66
|
+
const y = (value: number) => 98 - (value / span) * 94;
|
|
67
|
+
const format = (value: number) => (metric === 'cost' ? costLabel(value) : tokenLabel(value));
|
|
68
|
+
|
|
69
|
+
/** A provider's total for the whole period — the only figure it has. */
|
|
70
|
+
const providerTotal = (providerId: string): number =>
|
|
71
|
+
buckets.reduce((sum, bucket) => sum + valueOf(bucket, metric, providerId), 0);
|
|
72
|
+
|
|
73
|
+
const bandPath = (band: number): string => {
|
|
74
|
+
const top = cumulative[band];
|
|
75
|
+
const base = band === 0 ? (new Array(buckets.length).fill(0) as number[]) : cumulative[band - 1];
|
|
76
|
+
const up = top.map((value, index) => `${index === 0 ? 'M' : 'L'}${x(index).toFixed(2)},${y(value).toFixed(2)}`);
|
|
77
|
+
const down = [...base].reverse().map((value, index) => `L${x(buckets.length - 1 - index).toFixed(2)},${y(value).toFixed(2)}`);
|
|
78
|
+
return `${up.join(' ')} ${down.join(' ')} Z`;
|
|
79
|
+
};
|
|
80
|
+
|
|
41
81
|
return (
|
|
42
|
-
<div className="
|
|
43
|
-
<div className="
|
|
44
|
-
<div className="
|
|
45
|
-
|
|
46
|
-
|
|
82
|
+
<div className="flex flex-col gap-2">
|
|
83
|
+
<div className="relative h-32">
|
|
84
|
+
<div className="absolute inset-0 flex flex-col justify-between pb-4 pt-1">
|
|
85
|
+
<div className="w-full border-t border-dashed border-ink/5" />
|
|
86
|
+
<div className="w-full border-t border-dashed border-ink/5" />
|
|
87
|
+
<div className="w-full border-t border-ink/15" />
|
|
88
|
+
</div>
|
|
89
|
+
<div className="absolute bottom-4 left-0 top-0 flex w-10 flex-col justify-between font-mono text-[9px] text-ink/40">
|
|
90
|
+
<span>{format(max)}</span>
|
|
91
|
+
<span>{format(max / 2)}</span>
|
|
92
|
+
<span>0</span>
|
|
93
|
+
</div>
|
|
94
|
+
<div className="absolute bottom-4 left-10 right-0 top-0">
|
|
95
|
+
<svg
|
|
96
|
+
className="h-full w-full"
|
|
97
|
+
preserveAspectRatio="none"
|
|
98
|
+
viewBox="0 0 100 100"
|
|
99
|
+
role="img"
|
|
100
|
+
aria-label={`${metric} by provider, bucketed by ${granularity}`}
|
|
101
|
+
>
|
|
102
|
+
{drawn.map((provider, band) => (
|
|
103
|
+
<path
|
|
104
|
+
key={provider.id}
|
|
105
|
+
d={bandPath(band)}
|
|
106
|
+
fill={SERIES_FILL[providers.indexOf(provider) % SERIES_FILL.length]}
|
|
107
|
+
stroke="none"
|
|
108
|
+
/>
|
|
109
|
+
))}
|
|
110
|
+
</svg>
|
|
111
|
+
</div>
|
|
112
|
+
<div className="absolute bottom-0 left-10 right-0 flex h-4 items-end justify-between text-[9px] text-ink/40">
|
|
113
|
+
<span>{buckets[0]?.label}</span>
|
|
114
|
+
{buckets.length > 2 && <span>{buckets[Math.floor(buckets.length / 2)]?.label}</span>}
|
|
115
|
+
{/* One bucket would otherwise print the same label twice. */}
|
|
116
|
+
{buckets.length > 1 && <span>{buckets[buckets.length - 1]?.label}</span>}
|
|
117
|
+
</div>
|
|
47
118
|
</div>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
119
|
+
|
|
120
|
+
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
|
|
121
|
+
{providers.map((provider) => {
|
|
122
|
+
const active = visible.has(provider.id);
|
|
123
|
+
const figure = providerTotal(provider.id);
|
|
124
|
+
return (
|
|
125
|
+
<button
|
|
126
|
+
key={provider.id}
|
|
127
|
+
type="button"
|
|
128
|
+
aria-pressed={active}
|
|
129
|
+
onClick={() => onToggle(provider.id)}
|
|
130
|
+
className={`flex items-center gap-1.5 text-[10px] transition-opacity ${
|
|
131
|
+
active ? 'text-ink/70' : 'line-through text-ink/35'
|
|
132
|
+
} hover:text-ink`}
|
|
133
|
+
title={`${provider.name}: ${format(figure)} in this period`}
|
|
134
|
+
>
|
|
135
|
+
<span
|
|
136
|
+
aria-hidden="true"
|
|
137
|
+
className="h-1.5 w-1.5 rounded-full"
|
|
138
|
+
style={{ background: SERIES_FILL[providers.indexOf(provider) % SERIES_FILL.length] }}
|
|
139
|
+
/>
|
|
140
|
+
<span className="font-medium">{provider.name}</span>
|
|
141
|
+
<span className="font-mono tabular-nums text-ink/45">{format(figure)}</span>
|
|
142
|
+
</button>
|
|
143
|
+
);
|
|
144
|
+
})}
|
|
70
145
|
</div>
|
|
71
|
-
<span className="sr-only">{`${cadence} ${metric} trend`}</span>
|
|
72
146
|
</div>
|
|
73
147
|
);
|
|
74
148
|
}
|