@kabmo-labs/kabmo 0.25.0 → 0.27.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/dist/client/index.html +1 -1
- package/dist/client/index.js +448 -444
- package/dist/client/static/js/index-32rpkj6b.css +1 -0
- package/dist/client/static/js/{index-ga8cbpt4.js → index-e3qh2yps.js} +950 -950
- package/package.json +1 -1
- package/src/client/components/common/Toast.test.tsx +28 -2
- package/src/client/components/common/Toast.tsx +21 -9
- package/src/client/components/common/session-actions-menu/index.tsx +38 -12
- package/src/client/components/common/session-branch/BranchGuides.tsx +93 -0
- package/src/client/components/common/session-branch/SubagentRow.tsx +77 -0
- package/src/client/components/common/session-branch/index.tsx +169 -0
- package/src/client/components/common/session-branch/session-branch.test.tsx +240 -0
- package/src/client/components/common/session-branch/style.ts +29 -0
- package/src/client/components/common/session-row/StatusSlot.tsx +15 -3
- package/src/client/components/common/session-row/index.tsx +24 -25
- package/src/client/components/common/session-row/session-row.test.tsx +11 -0
- package/src/client/components/common/session-state-provider/index.tsx +1 -1
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +2 -1
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +66 -69
- package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -3
- package/src/client/components/layout/session-sidebar/SessionItem.test.ts +25 -2
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +33 -30
- package/src/client/components/layout/session-sidebar/SessionList.tsx +2 -1
- package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +35 -225
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +36 -16
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +11 -3
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +13 -4
- package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +3 -2
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +30 -14
- package/src/client/components/layout/session-sidebar/modern/RevealRow.tsx +56 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +69 -85
- package/src/client/components/layout/session-sidebar/modern/reveal-row.test.tsx +104 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -1
- package/src/client/components/layout/session-sidebar/variant-props.ts +2 -1
- package/src/client/components/mobile/SessionSidebar.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +59 -62
- package/src/client/components/mobile/mobile-session-sidebar/List.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +33 -30
- package/src/client/components/settings/Modal.tsx +1 -1
- package/src/client/components/settings/Sidebar.tsx +1 -1
- package/src/client/components/settings/categories/NotificationSettings.test.tsx +92 -0
- package/src/client/components/settings/categories/NotificationSettings.tsx +112 -2
- package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +39 -19
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +1 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.test.ts +94 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.ts +118 -0
- package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +118 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +94 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +31 -5
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +86 -93
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +7 -5
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +21 -1
- package/src/client/components/workspace/chat-timeline/PendingTranscript.tsx +130 -0
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +15 -1
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +85 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +84 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
- package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +141 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +16 -22
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +116 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +5 -4
- package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
- package/src/client/components/workspace/git-panel/index.tsx +2 -2
- package/src/client/components/workspace/terminal-panel/RealtimeTerminalView.tsx +8 -5
- package/src/client/components/workspace/terminal-panel/index.tsx +3 -0
- package/src/client/hooks/chat/composer/items.test.ts +19 -0
- package/src/client/hooks/chat/omp/folder-auto-expand.ts +1 -1
- package/src/client/hooks/chat/omp/pending-adoption.ts +51 -0
- package/src/client/hooks/chat/omp/pending-child.test.ts +73 -0
- package/src/client/hooks/chat/omp/pending-entry.ts +59 -0
- package/src/client/hooks/chat/omp/pending-rows.ts +6 -2
- package/src/client/hooks/chat/omp/pending-sessions.test.ts +1 -2
- package/src/client/hooks/chat/omp/pending-sessions.ts +45 -69
- package/src/client/hooks/chat/omp/pending-waiting.ts +1 -1
- package/src/client/hooks/chat/omp/run-switch.ts +1 -1
- package/src/client/hooks/chat/omp/session-list.tsx +9 -0
- package/src/client/hooks/chat/omp/sidebar-reload.test.ts +85 -0
- package/src/client/hooks/chat/omp/sidebar-reload.ts +30 -0
- package/src/client/hooks/chat/subagents/roster.ts +122 -0
- package/src/client/hooks/chat/timeline/child-spawn.test.ts +55 -0
- package/src/client/hooks/chat/timeline/child-spawn.ts +45 -0
- package/src/client/hooks/chat/timeline/fork-preview.test.ts +148 -0
- package/src/client/hooks/chat/timeline/fork-preview.ts +104 -0
- package/src/client/hooks/chat/timeline/fork-request.test.ts +54 -0
- package/src/client/hooks/chat/timeline/fork-request.ts +43 -0
- package/src/client/hooks/chat/timeline/fork-send.test.ts +139 -0
- package/src/client/hooks/chat/timeline/mode-availability.test.ts +1 -1
- package/src/client/hooks/chat/timeline/mode-availability.ts +33 -0
- package/src/client/hooks/chat/timeline/mode-markers.ts +7 -1
- package/src/client/hooks/chat/timeline/mode-post.ts +15 -3
- package/src/client/hooks/chat/timeline/modes-contract.ts +9 -4
- package/src/client/hooks/chat/timeline/modes.test.ts +56 -18
- package/src/client/hooks/chat/timeline/modes.ts +42 -29
- package/src/client/hooks/chat/timeline/pending-branch.ts +214 -0
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +302 -0
- package/src/client/hooks/chat/timeline/send.ts +17 -103
- package/src/client/hooks/chat/timeline/session-harness.ts +6 -0
- package/src/client/hooks/chat/timeline/stop-with-queue.ts +42 -0
- package/src/client/hooks/chat/timeline/use-fork-session.ts +40 -31
- package/src/client/hooks/chat/waiting/cancel.ts +2 -1
- package/src/client/hooks/chat/waiting/dispatch.ts +5 -4
- package/src/client/hooks/chat/waiting/held.ts +2 -1
- package/src/client/hooks/models/use-harness-update.test.ts +137 -44
- package/src/client/hooks/models/use-harness-update.ts +133 -85
- package/src/client/hooks/settings/providers/actions.ts +3 -2
- package/src/client/hooks/settings/providers/messages.ts +9 -7
- package/src/client/hooks/settings/providers/model-actions.ts +2 -1
- package/src/client/hooks/ui/editor-error-toast.ts +2 -1
- package/src/client/hooks/ui/input-required-alert.ts +12 -5
- package/src/client/hooks/ui/notifications.ts +45 -0
- package/src/client/hooks/ui/run-outcome-alert.ts +48 -0
- package/src/client/hooks/workspace/batch-archive.test.ts +2 -2
- package/src/client/hooks/workspace/batch-archive.ts +4 -2
- package/src/client/hooks/workspace/expanded-sessions.ts +36 -7
- package/src/client/hooks/workspace/git-action-outcome.ts +4 -3
- package/src/client/hooks/workspace/navbar-session-actions.ts +2 -1
- package/src/client/hooks/workspace/session-actions.test.ts +2 -1
- package/src/client/hooks/workspace/session-actions.ts +2 -1
- package/src/client/hooks/workspace/terminal/connection.test.ts +63 -0
- package/src/client/hooks/workspace/terminal/connection.ts +47 -0
- package/src/client/hooks/workspace/terminal/index.ts +35 -4
- package/src/client/hooks/workspace/workspace-folder-actions.ts +2 -1
- package/src/client/lib/native/open-session.ts +33 -0
- package/src/client/lib/notifications/os.test.ts +125 -0
- package/src/client/lib/notifications/os.ts +130 -0
- package/src/client/lib/plugins/sidebar-bridge.ts +2 -20
- package/src/client/lib/router/open-session.test.ts +75 -0
- package/src/client/lib/router/open-session.ts +34 -0
- package/src/client/lib/signals.ts +5 -1
- package/src/client/main.tsx +6 -0
- package/src/server/lib/db/schema.ts +1 -0
- package/src/server/lib/harness/acp/calls.ts +15 -1
- package/src/server/lib/harness/acp/client-capabilities.test.ts +55 -0
- package/src/server/lib/harness/acp/client-capabilities.ts +61 -0
- package/src/server/lib/harness/acp/client-fs.test.ts +135 -0
- package/src/server/lib/harness/acp/client-fs.ts +131 -0
- package/src/server/lib/harness/acp/client-initialize.test.ts +70 -0
- package/src/server/lib/harness/acp/client-initialize.ts +84 -0
- package/src/server/lib/harness/acp/client.ts +31 -21
- package/src/server/lib/harness/acp/commands.test.ts +5 -5
- package/src/server/lib/harness/acp/commands.ts +14 -2
- package/src/server/lib/harness/acp/frames-timing.test.ts +68 -0
- package/src/server/lib/harness/acp/frames-v2.test.ts +85 -0
- package/src/server/lib/harness/acp/frames.ts +71 -158
- package/src/server/lib/harness/acp/mapper.test.ts +40 -0
- package/src/server/lib/harness/acp/mapper.ts +12 -0
- package/src/server/lib/harness/acp/permissions.ts +6 -0
- package/src/server/lib/harness/acp/protocol.ts +41 -2
- package/src/server/lib/harness/acp/session-facts.ts +1 -1
- package/src/server/lib/harness/acp/session-handshake.test.ts +90 -1
- package/src/server/lib/harness/acp/session-handshake.ts +83 -6
- package/src/server/lib/harness/acp/session-idle.ts +7 -6
- package/src/server/lib/harness/acp/session-notifications.ts +41 -2
- package/src/server/lib/harness/acp/session-observers.test.ts +63 -0
- package/src/server/lib/harness/acp/session-permissions.test.ts +29 -0
- package/src/server/lib/harness/acp/session-permissions.ts +36 -0
- package/src/server/lib/harness/acp/session-requests.test.ts +92 -0
- package/src/server/lib/harness/acp/session-requests.ts +48 -6
- package/src/server/lib/harness/acp/session-turns.ts +8 -3
- package/src/server/lib/harness/acp/session-usage.ts +4 -0
- package/src/server/lib/harness/acp/session-web-state.ts +30 -2
- package/src/server/lib/harness/acp/session.test-util.ts +19 -1
- package/src/server/lib/harness/acp/session.ts +60 -60
- package/src/server/lib/harness/acp/tool-calls.ts +223 -0
- package/src/server/lib/harness/acp/turn.test.ts +102 -0
- package/src/server/lib/harness/acp/turn.ts +81 -6
- package/src/server/lib/harness/acp/v2.test.ts +144 -0
- package/src/server/lib/harness/acp/v2.ts +220 -0
- package/src/server/lib/harness/acp/verbs.ts +46 -6
- package/src/server/lib/harness/launch.test.ts +25 -0
- package/src/server/lib/harness/launch.ts +21 -9
- package/src/server/lib/harness/session.ts +3 -0
- package/src/server/lib/harness/update-job-store.test.ts +37 -12
- package/src/server/lib/harness/update-job-store.ts +22 -16
- package/src/server/lib/harness/update-job.server.ts +66 -175
- package/src/server/lib/harness/update-queue.server.ts +292 -0
- package/src/server/lib/harness/update-queue.test.ts +265 -0
- package/src/server/lib/harness/update-spawn.server.ts +96 -0
- package/src/server/lib/harness/update-worker.ts +8 -3
- package/src/server/lib/lifecycle/after-listen.ts +9 -0
- package/src/server/lib/lifecycle/paths.ts +14 -9
- package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
- package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
- package/src/server/lib/omp/rpc/terminal-settle.ts +5 -1
- package/src/server/lib/omp/session/delete-flow.server.ts +1 -0
- package/src/server/lib/omp/session/sidebar-data.server.ts +10 -12
- package/src/server/lib/sessions/fork.server.test.ts +68 -0
- package/src/server/lib/sessions/fork.server.ts +31 -6
- package/src/server/lib/sessions/spawn.server.test.ts +41 -0
- package/src/server/lib/sessions/spawn.server.ts +27 -2
- package/src/server/lib/usage/report.server.ts +57 -0
- package/src/server/routes/agent/harness-command.ts +6 -5
- package/src/server/routes/chat/stream.ts +7 -2
- package/src/server/routes/harness/update-status.ts +18 -12
- package/src/server/routes/harness/update.test.ts +53 -16
- package/src/server/routes/harness/update.ts +13 -8
- package/src/server/routes/sessions/body-readers.ts +43 -0
- package/src/server/routes/sessions/fork.ts +19 -4
- package/src/server/routes/sessions/routes.test.ts +1 -2
- package/src/server/routes/sessions/session.ts +19 -0
- package/src/server/routes/sessions/spawn.ts +16 -13
- package/src/shared/lib/chat/omp/agent-events.ts +11 -0
- package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
- package/src/shared/lib/chat/timeline/fork-preview.test.ts +62 -0
- package/src/shared/lib/chat/timeline/fork-preview.ts +36 -0
- package/src/shared/lib/harness/mode-signal.ts +20 -0
- package/src/shared/lib/harness/session-modes.ts +24 -0
- package/src/shared/lib/harness/update-job.ts +53 -6
- package/src/shared/lib/icons/tint-hues.generated.ts +34 -34
- package/src/shared/lib/notifications/outcomes.test.ts +96 -0
- package/src/shared/lib/notifications/outcomes.ts +64 -0
- package/src/shared/lib/notifications/settings.test.ts +49 -0
- package/src/shared/lib/notifications/settings.ts +34 -0
- package/src/shared/lib/omp/session/default-title.ts +5 -4
- package/src/shared/lib/omp/session/prewarm-misc.test.ts +3 -2
- package/src/shared/lib/omp/session/schema-migrations.ts +4 -0
- package/src/shared/lib/omp/session/stream-state.server.test.ts +19 -0
- package/src/shared/lib/omp/session/stream-state.server.ts +24 -4
- package/src/shared/lib/settings/defaults.ts +3 -0
- package/src/shared/lib/ui/toast-duration.test.ts +25 -1
- package/src/shared/lib/ui/toast-duration.ts +22 -4
- package/src/shared/lib/workspace/session-state/store.ts +4 -0
- package/src/shared/types/harness-update.ts +24 -0
- package/src/shared/types/realtime.ts +2 -0
- package/src/shared/types/settings/state.ts +10 -0
- package/src/shared/types/workspace.ts +4 -0
- package/src/test-support/harness-table.test-util.ts +25 -9
- package/dist/client/static/js/index-bc9aa4mx.css +0 -1
- package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +0 -113
- package/src/client/components/common/subagent-list/index.tsx +0 -165
- package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +0 -66
- package/src/client/hooks/workspace/child-expansion.ts +0 -33
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Check, ChevronDown, ChevronRight, CircleQuestionMark, GitBranch, Hourglass, Loader2, MoreHorizontal } from 'lucide-preact';
|
|
2
2
|
import type { SessionItemData } from '@/shared/types';
|
|
3
3
|
import { useInlineRename } from '@/client/hooks/ui/inline-rename';
|
|
4
4
|
import { useSessionRenaming } from '@/client/hooks/workspace/renaming-sessions';
|
|
5
5
|
import { SessionActionsMenu, useRowMenu } from '@/client/components/common/session-actions-menu';
|
|
6
6
|
import { SelectionCheckbox } from '@/client/components/common/batch-selection/SelectionCheckbox';
|
|
7
7
|
import { HarnessGlyph, HARNESS_GLYPH_SIZE } from '@/client/components/common/harness-glyph';
|
|
8
|
+
import type { BranchRowStyle } from '@/client/components/common/session-branch/style';
|
|
8
9
|
import { WorktreeBadge } from '@/client/components/layout/session-sidebar/WorktreeBadge';
|
|
9
10
|
|
|
11
|
+
/** What a subagent row under this chrome's rows borrows from it. */
|
|
12
|
+
export const MOBILE_BRANCH_STYLE: BranchRowStyle = {
|
|
13
|
+
inset: '',
|
|
14
|
+
insetPx: 0,
|
|
15
|
+
slotWidth: 16,
|
|
16
|
+
markGap: 8,
|
|
17
|
+
padding: 'py-2',
|
|
18
|
+
glyph: HARNESS_GLYPH_SIZE.touch,
|
|
19
|
+
};
|
|
20
|
+
|
|
10
21
|
export interface MobileSessionRowProps {
|
|
11
22
|
session: SessionItemData;
|
|
12
23
|
/** Harness that ran this session (`omp-rpc`, `claude`, …). Absent draws no
|
|
@@ -18,14 +29,15 @@ export interface MobileSessionRowProps {
|
|
|
18
29
|
awaitingInput?: boolean;
|
|
19
30
|
/** Relative age of the session, or null when no usable timestamp exists. */
|
|
20
31
|
timeAgo: string | null;
|
|
21
|
-
/** The session has a
|
|
22
|
-
hasSubagents?: boolean;
|
|
23
|
-
subagentsExpanded?: boolean;
|
|
24
|
-
onToggleSubagents?: () => void;
|
|
25
|
-
/** The session has child sessions, so it can be expanded as a tree. */
|
|
32
|
+
/** The session has a branch (child sessions and/or a subagent roster). */
|
|
26
33
|
expandable?: boolean;
|
|
27
34
|
isExpanded?: boolean;
|
|
28
35
|
onToggleExpand?: () => void;
|
|
36
|
+
/** Drawn inside a parent's branch; a leaf child gets a child mark in its slot. */
|
|
37
|
+
isChild?: boolean;
|
|
38
|
+
/** The folder the row belongs to, so a child spawned from its menu lands in
|
|
39
|
+
* the right list before the server answers. */
|
|
40
|
+
folderId?: number | string;
|
|
29
41
|
onSelect: () => void;
|
|
30
42
|
onArchive: () => void;
|
|
31
43
|
/** Omitted for a session that cannot be deleted yet (a pending `new-…` chat,
|
|
@@ -54,12 +66,11 @@ export function MobileSessionRow({
|
|
|
54
66
|
status,
|
|
55
67
|
awaitingInput = false,
|
|
56
68
|
timeAgo,
|
|
57
|
-
hasSubagents = false,
|
|
58
|
-
subagentsExpanded = false,
|
|
59
|
-
onToggleSubagents,
|
|
60
69
|
expandable = false,
|
|
61
70
|
isExpanded = false,
|
|
62
71
|
onToggleExpand,
|
|
72
|
+
isChild = false,
|
|
73
|
+
folderId,
|
|
63
74
|
onSelect,
|
|
64
75
|
onArchive,
|
|
65
76
|
onDelete,
|
|
@@ -88,15 +99,15 @@ export function MobileSessionRow({
|
|
|
88
99
|
const hasActions = Boolean(onRename || onArchive || onDelete || onCancelWait);
|
|
89
100
|
const waiting = Boolean(waitingFor);
|
|
90
101
|
|
|
91
|
-
// The
|
|
92
|
-
// column as the folder header's expand chevron — one vertical line of
|
|
93
|
-
// disclosure controls down the drawer. The
|
|
102
|
+
// The branch chevron is the row's LAST element, so its glyph lands in the
|
|
103
|
+
// same column as the folder header's expand chevron — one vertical line of
|
|
104
|
+
// disclosure controls down the drawer. The chevron is a SIBLING of the select
|
|
94
105
|
// button, never a child: a button inside a button is invalid and the browser
|
|
95
106
|
// reparents it.
|
|
96
107
|
//
|
|
97
108
|
// Touch has no hover to reveal a hidden toggle the way desktop does, so it is
|
|
98
|
-
// pinned whenever the row has a
|
|
99
|
-
// unreachable on a phone.
|
|
109
|
+
// pinned whenever the row has a branch; a hidden one would leave child
|
|
110
|
+
// sessions and subagents unreachable on a phone.
|
|
100
111
|
const showChevron = expandable && Boolean(onToggleExpand);
|
|
101
112
|
const title = session.title.charAt(0).toUpperCase() + session.title.slice(1);
|
|
102
113
|
|
|
@@ -178,6 +189,10 @@ export function MobileSessionRow({
|
|
|
178
189
|
</span>
|
|
179
190
|
) : status ? (
|
|
180
191
|
<Check size={13} className="text-ink/50" />
|
|
192
|
+
) : isChild ? (
|
|
193
|
+
<span data-testid="child-indicator" className="text-ink/35" aria-hidden="true">
|
|
194
|
+
<GitBranch size={13} />
|
|
195
|
+
</span>
|
|
181
196
|
) : null}
|
|
182
197
|
</span>
|
|
183
198
|
)}
|
|
@@ -230,29 +245,15 @@ export function MobileSessionRow({
|
|
|
230
245
|
</button>
|
|
231
246
|
)}
|
|
232
247
|
|
|
233
|
-
{/* The roster badge is a separate control from the tree chevron. */}
|
|
234
|
-
{hasSubagents && onToggleSubagents && !selectable && (
|
|
235
|
-
<button
|
|
236
|
-
type="button"
|
|
237
|
-
onClick={onToggleSubagents}
|
|
238
|
-
title="Subagents (tool calls)"
|
|
239
|
-
aria-label="Subagents"
|
|
240
|
-
aria-expanded={subagentsExpanded}
|
|
241
|
-
className="flex-shrink-0 py-1.5 pl-1.5 pr-1 flex items-center justify-center text-ink/40 hover:text-ink rounded-lg cursor-pointer"
|
|
242
|
-
>
|
|
243
|
-
<Boxes size={15} />
|
|
244
|
-
</button>
|
|
245
|
-
)}
|
|
246
|
-
|
|
247
248
|
{/* Last element, so its glyph shares the trigger's column — the same
|
|
248
249
|
inset pair and the same 4px ink margin. */}
|
|
249
250
|
{showChevron && !selectable && (
|
|
250
251
|
<button
|
|
251
252
|
type="button"
|
|
252
253
|
onClick={onToggleExpand}
|
|
253
|
-
title={isExpanded ? 'Collapse
|
|
254
|
+
title={isExpanded ? 'Collapse sessions and subagents' : 'Expand sessions and subagents'}
|
|
254
255
|
aria-expanded={isExpanded}
|
|
255
|
-
aria-label={isExpanded ? 'Collapse
|
|
256
|
+
aria-label={isExpanded ? 'Collapse sessions and subagents' : 'Expand sessions and subagents'}
|
|
256
257
|
className="flex-shrink-0 py-1.5 pl-1.5 pr-1 flex items-center justify-center text-ink/50 hover:text-ink rounded-lg cursor-pointer"
|
|
257
258
|
>
|
|
258
259
|
{isExpanded ? <ChevronDown size={14} /> : <ChevronRight size={14} />}
|
|
@@ -264,6 +265,8 @@ export function MobileSessionRow({
|
|
|
264
265
|
<SessionActionsMenu
|
|
265
266
|
anchor={menu.anchor}
|
|
266
267
|
sessionId={session.id}
|
|
268
|
+
{...(harness ? { harness } : {})}
|
|
269
|
+
{...(folderId !== undefined ? { folderId } : {})}
|
|
267
270
|
isArchived={session.is_archived === 1}
|
|
268
271
|
onRename={onRename ? startRename : undefined}
|
|
269
272
|
onRenameWithAi={onRenameWithAi}
|
|
@@ -23,7 +23,7 @@ export const SETTINGS_CATEGORIES: CategoryDef[] = [
|
|
|
23
23
|
// KABMO
|
|
24
24
|
{ id: 'appearance', label: 'Appearance', icon: Palette, section: 'KABMO', description: 'Custom themes, typography scale, and layout density.' },
|
|
25
25
|
{ id: 'chats', label: 'Chats', icon: MessageSquare, section: 'KABMO', description: 'Chat width, composer style, tool call rendering, session titles, goal mode, and keybindings.' },
|
|
26
|
-
{ id: 'notifications', label: 'Notifications', icon: Bell, section: 'KABMO', description: '
|
|
26
|
+
{ id: 'notifications', label: 'Notifications', icon: Bell, section: 'KABMO', description: 'Completion sound, plus system notifications for finished, waiting-for-you and failed runs.' },
|
|
27
27
|
{ id: 'usage', label: 'Usage', icon: BarChart3, section: 'KABMO', description: 'Build minutes quota, storage, and general usage.' },
|
|
28
28
|
{ id: 'token-usage', label: 'Token Usage', icon: Coins, section: 'KABMO', description: 'Token telemetry, cache, and cost breakdown.' },
|
|
29
29
|
{ id: 'panel-plugins', label: 'Panel Plugins', icon: Puzzle, section: 'KABMO', description: 'Panels a plugin adds to Kabmo: right-panel views, navbar readouts and editor tabs.' },
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The three system-notification preferences.
|
|
8
|
+
*
|
|
9
|
+
* They ship FALSE, and the UI is where that promise becomes a user-visible
|
|
10
|
+
* fact: a default of `true` would show three switches already on, and the first
|
|
11
|
+
* agent run would ask the OS for permission nobody chose. The toggle must also
|
|
12
|
+
* write ONE key — the settings modal persists the diff, so a handler that
|
|
13
|
+
* touched the others would republish values the user never changed.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
17
|
+
import { Window } from 'happy-dom';
|
|
18
|
+
import { h, render } from 'preact';
|
|
19
|
+
import { act } from 'preact/test-utils';
|
|
20
|
+
|
|
21
|
+
import { NotificationSettings } from '@/client/components/settings/categories/NotificationSettings';
|
|
22
|
+
import { DEFAULT_SETTINGS } from '@/shared/lib/settings/defaults';
|
|
23
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
24
|
+
import type { SettingsState } from '@/shared/types';
|
|
25
|
+
|
|
26
|
+
let container: HTMLElement | undefined;
|
|
27
|
+
|
|
28
|
+
beforeAll(() => {
|
|
29
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
afterEach(() => {
|
|
33
|
+
if (container) {
|
|
34
|
+
render(null, container);
|
|
35
|
+
container.remove();
|
|
36
|
+
container = undefined;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
afterAll(() => {
|
|
41
|
+
restoreDomGlobals();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
type Updater = Partial<SettingsState> | ((prev: SettingsState) => SettingsState);
|
|
45
|
+
|
|
46
|
+
function mount(onUpdate: (updater: Updater) => void): HTMLElement {
|
|
47
|
+
const host = document.createElement('div');
|
|
48
|
+
container = host;
|
|
49
|
+
document.body.append(host);
|
|
50
|
+
act(() => {
|
|
51
|
+
render(h(NotificationSettings, { settings: { ...DEFAULT_SETTINGS }, onUpdate }), host);
|
|
52
|
+
});
|
|
53
|
+
return host;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function switches(): HTMLElement[] {
|
|
57
|
+
return [...document.querySelectorAll('[role="switch"]')] as HTMLElement[];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
describe('NotificationSettings', () => {
|
|
61
|
+
test('the three system toggles are off on a fresh install', () => {
|
|
62
|
+
mount(() => {});
|
|
63
|
+
// The sound switch is first and keeps its shipped-on default; the three
|
|
64
|
+
// system preferences follow it.
|
|
65
|
+
const system = switches().slice(1);
|
|
66
|
+
expect(system).toHaveLength(3);
|
|
67
|
+
for (const toggle of system) expect(toggle.getAttribute('aria-checked')).toBe('false');
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
test('turning Run finished on writes only that key', () => {
|
|
71
|
+
const updates: Updater[] = [];
|
|
72
|
+
mount((update) => updates.push(update));
|
|
73
|
+
const finish = switches().find((toggle) => toggle.getAttribute('aria-label')?.includes('Run finished'));
|
|
74
|
+
expect(finish).toBeDefined();
|
|
75
|
+
|
|
76
|
+
act(() => {
|
|
77
|
+
finish?.click();
|
|
78
|
+
});
|
|
79
|
+
expect(updates).toEqual([{ notifyOnFinish: true }]);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('turning Waiting for you on writes its own key', () => {
|
|
83
|
+
const updates: Updater[] = [];
|
|
84
|
+
mount((update) => updates.push(update));
|
|
85
|
+
const ask = switches().find((toggle) => toggle.getAttribute('aria-label')?.includes('Waiting for you'));
|
|
86
|
+
|
|
87
|
+
act(() => {
|
|
88
|
+
ask?.click();
|
|
89
|
+
});
|
|
90
|
+
expect(updates).toEqual([{ notifyOnAsk: true }]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -1,13 +1,64 @@
|
|
|
1
|
-
import { useState } from 'preact/hooks';
|
|
2
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
2
|
+
import {
|
|
3
|
+
BellRing,
|
|
4
|
+
CircleCheck,
|
|
5
|
+
CircleQuestionMark,
|
|
6
|
+
Sparkles,
|
|
7
|
+
TriangleAlert,
|
|
8
|
+
Volume2,
|
|
9
|
+
VolumeX,
|
|
10
|
+
} from 'lucide-preact';
|
|
3
11
|
import type { SettingsState } from '@/shared/types';
|
|
4
12
|
import { playNotificationSound } from '@/client/hooks/ui/notification-sound';
|
|
13
|
+
import { requestNotificationPermission } from '@/client/lib/notifications/os';
|
|
5
14
|
|
|
6
15
|
interface NotificationSettingsProps {
|
|
7
16
|
settings: SettingsState;
|
|
8
17
|
onUpdate: (updater: Partial<SettingsState> | ((prev: SettingsState) => SettingsState)) => void;
|
|
9
18
|
}
|
|
10
19
|
|
|
20
|
+
interface SystemToggleProps {
|
|
21
|
+
icon: typeof BellRing;
|
|
22
|
+
title: string;
|
|
23
|
+
description: string;
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
onToggle: () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function SystemToggle({ icon: Icon, title, description, enabled, onToggle }: SystemToggleProps) {
|
|
29
|
+
return (
|
|
30
|
+
<div className="flex items-start justify-between gap-4 py-3">
|
|
31
|
+
<div className="flex items-start gap-3">
|
|
32
|
+
<div className="w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5">
|
|
33
|
+
<Icon size={16} className={enabled ? 'text-ink' : 'text-ink/40'} />
|
|
34
|
+
</div>
|
|
35
|
+
<div>
|
|
36
|
+
<div className="text-sm font-semibold text-ink">{title}</div>
|
|
37
|
+
<p className="text-ink/65 text-[11px] mt-1 leading-relaxed">{description}</p>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<button
|
|
42
|
+
type="button"
|
|
43
|
+
role="switch"
|
|
44
|
+
aria-checked={enabled}
|
|
45
|
+
aria-label={`${enabled ? 'Disable' : 'Enable'} ${title}`}
|
|
46
|
+
onClick={onToggle}
|
|
47
|
+
className={`relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${
|
|
48
|
+
enabled ? 'bg-ink' : 'bg-ink/20'
|
|
49
|
+
}`}
|
|
50
|
+
>
|
|
51
|
+
<span
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
className={`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-paper shadow ring-0 transition duration-200 ease-in-out ${
|
|
54
|
+
enabled ? 'translate-x-5' : 'translate-x-0'
|
|
55
|
+
}`}
|
|
56
|
+
/>
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
11
62
|
export function NotificationSettings({ settings, onUpdate }: NotificationSettingsProps) {
|
|
12
63
|
const [isPlayingTest, setIsPlayingTest] = useState(false);
|
|
13
64
|
|
|
@@ -18,6 +69,24 @@ export function NotificationSettings({ settings, onUpdate }: NotificationSetting
|
|
|
18
69
|
};
|
|
19
70
|
|
|
20
71
|
const isSoundEnabled = settings.chatCompletionSound ?? settings.soundAlerts ?? true;
|
|
72
|
+
const anySystemNotification = settings.notifyOnFinish === true
|
|
73
|
+
|| settings.notifyOnAsk === true
|
|
74
|
+
|| settings.notifyOnError === true;
|
|
75
|
+
|
|
76
|
+
// A preference can be turned on in another tab, a browser, or before this
|
|
77
|
+
// shell was installed — and the OS permission belongs to THIS shell. Opening
|
|
78
|
+
// the page that owns the preference is the honest moment to ask, and the
|
|
79
|
+
// shell answers immediately when permission is already granted.
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (anySystemNotification) void requestNotificationPermission();
|
|
82
|
+
}, [anySystemNotification]);
|
|
83
|
+
|
|
84
|
+
// Turning one of these on asks for permission immediately, so the toggle can
|
|
85
|
+
// never read "on" without the shell having had its chance to prompt.
|
|
86
|
+
const setSystemNotification = (key: 'notifyOnFinish' | 'notifyOnAsk' | 'notifyOnError', next: boolean) => {
|
|
87
|
+
onUpdate({ [key]: next });
|
|
88
|
+
if (next) void requestNotificationPermission();
|
|
89
|
+
};
|
|
21
90
|
|
|
22
91
|
return (
|
|
23
92
|
<div className="w-full space-y-6 text-xs text-ink">
|
|
@@ -92,6 +161,47 @@ export function NotificationSettings({ settings, onUpdate }: NotificationSetting
|
|
|
92
161
|
</button>
|
|
93
162
|
</div>
|
|
94
163
|
</div>
|
|
164
|
+
|
|
165
|
+
{/* System Notifications */}
|
|
166
|
+
<div className="bg-paper border border-ink/15 rounded-lg p-4 shadow-xs">
|
|
167
|
+
<div className="flex items-start gap-3 pb-3 border-b border-ink/10">
|
|
168
|
+
<div className="w-8 h-8 rounded-md bg-ink/5 border border-ink/10 flex items-center justify-center flex-shrink-0 mt-0.5">
|
|
169
|
+
<BellRing size={16} className="text-ink" />
|
|
170
|
+
</div>
|
|
171
|
+
<div>
|
|
172
|
+
<div className="text-sm font-semibold text-ink">System Notifications</div>
|
|
173
|
+
<p className="text-ink/65 text-[11px] mt-1 leading-relaxed">
|
|
174
|
+
Shown by Android, iOS and the desktop shell — and by the browser outside a shell — only
|
|
175
|
+
while Kabmo is not the window you are looking at. Clicking one opens that session.
|
|
176
|
+
The sidebar badge stays the in-app record either way.
|
|
177
|
+
</p>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div className="divide-y divide-ink/10">
|
|
182
|
+
<SystemToggle
|
|
183
|
+
icon={CircleCheck}
|
|
184
|
+
title="Run finished"
|
|
185
|
+
description="A session's agent finished its turn."
|
|
186
|
+
enabled={settings.notifyOnFinish === true}
|
|
187
|
+
onToggle={() => setSystemNotification('notifyOnFinish', settings.notifyOnFinish !== true)}
|
|
188
|
+
/>
|
|
189
|
+
<SystemToggle
|
|
190
|
+
icon={CircleQuestionMark}
|
|
191
|
+
title="Waiting for you"
|
|
192
|
+
description="An agent is blocked on a question or an approval."
|
|
193
|
+
enabled={settings.notifyOnAsk === true}
|
|
194
|
+
onToggle={() => setSystemNotification('notifyOnAsk', settings.notifyOnAsk !== true)}
|
|
195
|
+
/>
|
|
196
|
+
<SystemToggle
|
|
197
|
+
icon={TriangleAlert}
|
|
198
|
+
title="Run failed"
|
|
199
|
+
description="A run ended in failure, with the reason when the agent reported one."
|
|
200
|
+
enabled={settings.notifyOnError === true}
|
|
201
|
+
onToggle={() => setSystemNotification('notifyOnError', settings.notifyOnError !== true)}
|
|
202
|
+
/>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
95
205
|
</div>
|
|
96
206
|
);
|
|
97
207
|
}
|
|
@@ -193,7 +193,7 @@ export function HarnessCard({
|
|
|
193
193
|
<div className="grid gap-x-6 sm:grid-cols-2">
|
|
194
194
|
<div>
|
|
195
195
|
<div className="mb-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40">Session</div>
|
|
196
|
-
<Capability label="Load / resume history" value={caps ? caps.loadSession : null} />
|
|
196
|
+
<Capability label="Load / resume history" value={caps ? caps.loadSession || caps.resumeSession : null} />
|
|
197
197
|
<Capability label="List sessions" value={caps ? caps.listSessions : null} />
|
|
198
198
|
<Capability label="Fork" value={caps ? caps.forkSession : null} />
|
|
199
199
|
<Capability label="Delete" value={caps ? caps.deleteSession : null} />
|
|
@@ -25,13 +25,14 @@ import { useWorktrees } from '@/client/hooks/workspace/worktree/index';
|
|
|
25
25
|
import { removeWorktree } from '@/client/hooks/workspace/worktree/index';
|
|
26
26
|
import { WORKTREE_CARRY_SETTING, WORKTREE_DIRECTORY_SETTING } from '@/shared/lib/fs/worktree/settings-keys';
|
|
27
27
|
import { branchDeletable, removalRefusal, worktreeRowDetail } from '@/client/components/settings/categories/project-settings/worktree-row';
|
|
28
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
28
29
|
|
|
29
30
|
export interface WorktreeSettingsProps {
|
|
30
31
|
/** The selected project's `project_path`; the section is inert without one. */
|
|
31
32
|
root: string | null;
|
|
32
33
|
folderId: number | null;
|
|
33
34
|
/** Report a refusal — the section never claims a removal it did not get. */
|
|
34
|
-
onReport: (message: string, tone?:
|
|
35
|
+
onReport: (message: string, tone?: ToastTone) => void;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export function WorktreeSettings({ root, folderId, onReport }: WorktreeSettingsProps) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { UsageLimitWindow } from '@/shared/types';
|
|
2
2
|
import { formatDateTime, formatFractionPercent, formatUsageAmount } from '@/client/components/settings/categories/usage-settings/format';
|
|
3
|
+
import { groupProviderLimits } from '@/client/components/settings/categories/usage-settings/limit-groups';
|
|
3
4
|
|
|
4
5
|
interface LimitRowProps {
|
|
5
6
|
limit: UsageLimitWindow;
|
|
@@ -19,7 +20,14 @@ function LimitRow({ limit }: LimitRowProps) {
|
|
|
19
20
|
<div className="bg-paper border border-ink/15 rounded-lg p-3 shadow-xs space-y-2">
|
|
20
21
|
<div className="flex items-start justify-between gap-2">
|
|
21
22
|
<div className="min-w-0">
|
|
22
|
-
<div className="text-[11px] font-semibold text-ink truncate">
|
|
23
|
+
<div className="text-[11px] font-semibold text-ink truncate">
|
|
24
|
+
{limit.label}
|
|
25
|
+
{limit.windowLabel && (
|
|
26
|
+
<span className="ml-1.5 rounded border border-ink/15 px-1 py-px font-mono text-[9px] font-normal text-ink/50">
|
|
27
|
+
{limit.windowLabel}
|
|
28
|
+
</span>
|
|
29
|
+
)}
|
|
30
|
+
</div>
|
|
23
31
|
{scope && <div className="text-[10px] text-ink/50 truncate">{scope}</div>}
|
|
24
32
|
</div>
|
|
25
33
|
<span className="text-[10px] text-ink/50 flex-shrink-0 whitespace-nowrap">
|
|
@@ -70,6 +78,8 @@ function LimitRow({ limit }: LimitRowProps) {
|
|
|
70
78
|
}
|
|
71
79
|
|
|
72
80
|
interface LimitsSectionProps {
|
|
81
|
+
/** Provider slug, used to group Claude's balance and Antigravity's families. */
|
|
82
|
+
providerId: string;
|
|
73
83
|
limits: UsageLimitWindow[];
|
|
74
84
|
/** Whether omp ships a usage adapter for this provider. */
|
|
75
85
|
tracked: boolean;
|
|
@@ -80,13 +90,11 @@ interface LimitsSectionProps {
|
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
/** Generic quota windows for any provider omp reports usage for. */
|
|
83
|
-
export function LimitsSection({ limits, tracked, unavailable, notes }: LimitsSectionProps) {
|
|
93
|
+
export function LimitsSection({ providerId, limits, tracked, unavailable, notes }: LimitsSectionProps) {
|
|
94
|
+
const groups = groupProviderLimits(providerId, limits);
|
|
95
|
+
|
|
84
96
|
return (
|
|
85
97
|
<div className="space-y-2">
|
|
86
|
-
<h4 className="text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40">
|
|
87
|
-
Quota windows
|
|
88
|
-
</h4>
|
|
89
|
-
|
|
90
98
|
{notes && notes.length > 0 && (
|
|
91
99
|
<ul className="text-[10px] text-ink/50 leading-relaxed space-y-0.5">
|
|
92
100
|
{notes.map((note) => (
|
|
@@ -95,20 +103,32 @@ export function LimitsSection({ limits, tracked, unavailable, notes }: LimitsSec
|
|
|
95
103
|
</ul>
|
|
96
104
|
)}
|
|
97
105
|
|
|
98
|
-
{
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
{groups.length === 0 ? (
|
|
107
|
+
<>
|
|
108
|
+
<h4 className="text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40">
|
|
109
|
+
Quota windows
|
|
110
|
+
</h4>
|
|
111
|
+
<p className="text-[11px] text-ink/50">
|
|
112
|
+
{!tracked
|
|
113
|
+
? 'No quota source for this provider: omp ships no usage adapter for it and it exposes no balance endpoint Kabmo knows.'
|
|
114
|
+
: unavailable
|
|
115
|
+
? 'omp tracks this provider but its usage endpoint returned no data — an invalid or expired credential, an unreachable endpoint, or a plan without quota windows.'
|
|
116
|
+
: 'No quota windows were reported for this provider.'}
|
|
117
|
+
</p>
|
|
118
|
+
</>
|
|
106
119
|
) : (
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
groups.map((group) => (
|
|
121
|
+
<div key={group.id} className="@container space-y-2">
|
|
122
|
+
<h4 className="text-[10px] font-mono font-semibold uppercase tracking-wider text-ink/40">
|
|
123
|
+
{group.title}
|
|
124
|
+
</h4>
|
|
125
|
+
<div className="grid grid-cols-1 @[520px]:grid-cols-2 gap-2.5">
|
|
126
|
+
{group.limits.map((limit) => (
|
|
127
|
+
<LimitRow key={limit.id} limit={limit} />
|
|
128
|
+
))}
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
))
|
|
112
132
|
)}
|
|
113
133
|
</div>
|
|
114
134
|
);
|
|
@@ -37,6 +37,7 @@ export function ProviderDetail({ summary }: ProviderDetailProps) {
|
|
|
37
37
|
says so — a second "no quota source" note would contradict it. */}
|
|
38
38
|
{!hasRichReport && (summary.limits.length > 0 || !summary.error) && (
|
|
39
39
|
<LimitsSection
|
|
40
|
+
providerId={summary.id}
|
|
40
41
|
limits={summary.limits}
|
|
41
42
|
tracked={summary.tracked}
|
|
42
43
|
unavailable={summary.limitsUnavailable}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The grouping rule the quota section renders.
|
|
8
|
+
*
|
|
9
|
+
* Three shapes, three bugs prevented:
|
|
10
|
+
* - Claude's USD spend limit (`anthropic:extra`) must NOT sit in the same grid
|
|
11
|
+
* as its 5h/7d windows; it is a balance after the windows, not a window.
|
|
12
|
+
* - Antigravity's `anthropic:` and `openai:` rows are ONE upstream bucket
|
|
13
|
+
* ("Claude & GPT (shared)"), so they must land in one group rather than two
|
|
14
|
+
* headings repeating the same sentence.
|
|
15
|
+
* - Every other provider is a single group, and a row's order inside it is
|
|
16
|
+
* omp's own (sorted by remaining fraction) — regrouping must not reshuffle.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { describe, expect, test } from 'bun:test';
|
|
20
|
+
import { groupProviderLimits } from '@/client/components/settings/categories/usage-settings/limit-groups';
|
|
21
|
+
import type { UsageLimitWindow } from '@/shared/types';
|
|
22
|
+
|
|
23
|
+
const limit = (id: string, overrides: Partial<UsageLimitWindow> = {}): UsageLimitWindow => ({
|
|
24
|
+
id,
|
|
25
|
+
label: id,
|
|
26
|
+
unit: 'percent',
|
|
27
|
+
status: 'ok',
|
|
28
|
+
...overrides,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('groupProviderLimits', () => {
|
|
32
|
+
test('an ordinary provider is one group, in source order', () => {
|
|
33
|
+
const limits = [limit('openrouter:credits'), limit('openrouter:daily')];
|
|
34
|
+
const groups = groupProviderLimits('openrouter', limits);
|
|
35
|
+
expect(groups).toHaveLength(1);
|
|
36
|
+
expect(groups[0]?.title).toBe('Quota windows');
|
|
37
|
+
expect(groups[0]?.limits.map((row) => row.id)).toEqual(['openrouter:credits', 'openrouter:daily']);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('Claude keeps its plan windows together and puts the spend limit under Balance', () => {
|
|
41
|
+
const limits = [
|
|
42
|
+
limit('anthropic:5h'),
|
|
43
|
+
limit('anthropic:7d'),
|
|
44
|
+
limit('anthropic:7d:opus'),
|
|
45
|
+
limit('anthropic:extra', { unit: 'usd', label: 'Claude Extra Usage' }),
|
|
46
|
+
];
|
|
47
|
+
const groups = groupProviderLimits('anthropic', limits);
|
|
48
|
+
expect(groups.map((group) => group.title)).toEqual(['Quota windows', 'Balance']);
|
|
49
|
+
expect(groups[0]?.limits.map((row) => row.id)).toEqual(['anthropic:5h', 'anthropic:7d', 'anthropic:7d:opus']);
|
|
50
|
+
expect(groups[1]?.limits.map((row) => row.id)).toEqual(['anthropic:extra']);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('Claude without a spend limit renders one section, not an empty Balance', () => {
|
|
54
|
+
const groups = groupProviderLimits('anthropic', [limit('anthropic:5h')]);
|
|
55
|
+
expect(groups).toHaveLength(1);
|
|
56
|
+
expect(groups[0]?.title).toBe('Quota windows');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('Antigravity merges the shared Anthropic/OpenAI bucket and keeps Google apart', () => {
|
|
60
|
+
const limits = [
|
|
61
|
+
limit('google-antigravity:google:default:weekly'),
|
|
62
|
+
limit('google-antigravity:anthropic:default:5h'),
|
|
63
|
+
limit('google-antigravity:openai:default:5h'),
|
|
64
|
+
limit('google-antigravity:default:default:daily'),
|
|
65
|
+
];
|
|
66
|
+
const groups = groupProviderLimits('google-antigravity', limits);
|
|
67
|
+
expect(groups.map((group) => group.title)).toEqual(['Google', 'Claude & GPT (shared)', 'Usage']);
|
|
68
|
+
expect(groups[1]?.limits.map((row) => row.id)).toEqual([
|
|
69
|
+
'google-antigravity:anthropic:default:5h',
|
|
70
|
+
'google-antigravity:openai:default:5h',
|
|
71
|
+
]);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test('Antigravity emits one row for the shared bucket even though omp names two families', () => {
|
|
75
|
+
const shared = { label: 'Claude & GPT (shared)', usedFraction: 0.71, remaining: 29, resetsAt: 1_800 };
|
|
76
|
+
const groups = groupProviderLimits('google-antigravity', [
|
|
77
|
+
limit('google-antigravity:anthropic:default:5h', shared),
|
|
78
|
+
limit('google-antigravity:openai:default:5h', shared),
|
|
79
|
+
]);
|
|
80
|
+
expect(groups).toHaveLength(1);
|
|
81
|
+
expect(groups[0]?.limits).toHaveLength(1);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('an unknown Antigravity counter is shown under its own name, never dropped', () => {
|
|
85
|
+
const groups = groupProviderLimits('google-antigravity', [limit('google-antigravity:mistral:default:weekly')]);
|
|
86
|
+
expect(groups).toHaveLength(1);
|
|
87
|
+
expect(groups[0]?.title).toBe('mistral');
|
|
88
|
+
expect(groups[0]?.limits).toHaveLength(1);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('no limits means no groups, so the caller draws its empty state', () => {
|
|
92
|
+
expect(groupProviderLimits('anthropic', [])).toEqual([]);
|
|
93
|
+
});
|
|
94
|
+
});
|