@kabmo-labs/kabmo 0.25.0 → 0.26.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 +440 -436
- package/dist/client/static/js/{index-ga8cbpt4.js → index-95b3n20k.js} +945 -945
- package/dist/client/static/js/index-p2yw9ywf.css +1 -0
- package/package.json +1 -1
- 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/session-sidebar/CategoryItem.tsx +64 -68
- 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/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/index.tsx +28 -13
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +59 -57
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +57 -61
- 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/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/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 +28 -39
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +7 -5
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +10 -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/index.tsx +10 -21
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +115 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
- package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -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 +4 -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-request.test.ts +54 -0
- package/src/client/hooks/chat/timeline/fork-request.ts +43 -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 +205 -0
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +253 -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/models/use-harness-update.test.ts +137 -44
- package/src/client/hooks/models/use-harness-update.ts +133 -85
- 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/expanded-sessions.ts +36 -7
- 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/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/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/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
|
@@ -32,11 +32,10 @@ import { useShowMore } from '@/client/hooks/ui/show-more';
|
|
|
32
32
|
import { useWorkspaceFolderActions } from '@/client/hooks/workspace/workspace-folder-actions';
|
|
33
33
|
import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
|
|
34
34
|
import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
|
|
35
|
-
import { useChildExpansion } from '@/client/hooks/workspace/child-expansion';
|
|
36
35
|
import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
|
|
37
|
-
import { SessionRow, type SessionRowDensity } from '@/client/components/common/session-row';
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
36
|
+
import { SessionRow, sessionRowBranchStyle, type SessionRowDensity } from '@/client/components/common/session-row';
|
|
37
|
+
import { SessionBranch, branchControlFor } from '@/client/components/common/session-branch';
|
|
38
|
+
import type { BranchControl } from '@/client/components/common/session-branch';
|
|
40
39
|
import { buildSessionTree } from '@/client/lib/session-tree';
|
|
41
40
|
import { SessionDeleteModal } from '@/client/components/common/session-delete-modal';
|
|
42
41
|
import { WorkspaceOptionsMenu } from '@/client/components/common/workspace-options-menu';
|
|
@@ -44,9 +43,10 @@ import { NewWorktreeModal } from '@/client/components/workspace/worktree-modal/i
|
|
|
44
43
|
import { WorkspaceHeader } from '@/client/components/layout/session-sidebar/modern/WorkspaceHeader';
|
|
45
44
|
import { folderBatchState } from '@/client/components/common/batch-selection/folder-state';
|
|
46
45
|
import { relativeTimeAgo } from '@/shared/lib/workspace/relative-time';
|
|
46
|
+
import { isPendingSessionId } from '@/shared/lib/omp/session/default-title';
|
|
47
47
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
48
48
|
import type { SessionStatusMap } from '@/client/components/layout/session-sidebar/variant-props';
|
|
49
|
-
import type { WorkspaceFolderData } from '@/shared/types';
|
|
49
|
+
import type { SessionItemData, WorkspaceFolderData } from '@/shared/types';
|
|
50
50
|
|
|
51
51
|
export interface WorkspaceSectionProps {
|
|
52
52
|
folder: WorkspaceFolderData;
|
|
@@ -89,7 +89,6 @@ export function WorkspaceSection({
|
|
|
89
89
|
const urlSubagentId = searchParams.get('subagent');
|
|
90
90
|
const urlSessionId = searchParams.get('sessionId');
|
|
91
91
|
const { expandedSessionIds, toggleSession } = useExpandedSessions();
|
|
92
|
-
const { expandedChildIds, toggleChild } = useChildExpansion();
|
|
93
92
|
const { refresh } = useSidebarData();
|
|
94
93
|
const toggleFetcher = useFetcher<{ success?: boolean }>();
|
|
95
94
|
const {
|
|
@@ -155,6 +154,48 @@ export function WorkspaceSection({
|
|
|
155
154
|
// A session selection opens every workspace: a checkbox on a collapsed folder
|
|
156
155
|
// would let the user select rows they cannot see or unselect.
|
|
157
156
|
const listOpen = forceExpanded || isOpen || sessionCheckboxes;
|
|
157
|
+
|
|
158
|
+
// Roots and descendants share this renderer: a child session is the same row as a root.
|
|
159
|
+
const renderSessionRow = (session: SessionItemData, control: BranchControl) => {
|
|
160
|
+
const key = String(session.id);
|
|
161
|
+
const isActive = activeSessionId === null ? session.is_active === 1 : String(activeSessionId) === key;
|
|
162
|
+
// While one of its subagents is viewed, the row dims so the leaf reads as the active one.
|
|
163
|
+
const viewingSubagent = isActive && urlSessionId === key && Boolean(urlSubagentId);
|
|
164
|
+
const pending = isPendingSessionId(key);
|
|
165
|
+
return (
|
|
166
|
+
<SessionRow
|
|
167
|
+
sessionId={session.id}
|
|
168
|
+
title={session.title}
|
|
169
|
+
harness={session.harness}
|
|
170
|
+
folderId={session.folder_id}
|
|
171
|
+
density={density}
|
|
172
|
+
isActive={isActive && !viewingSubagent}
|
|
173
|
+
isArchived={session.is_archived === 1}
|
|
174
|
+
status={sessionStatus[key]}
|
|
175
|
+
awaitingInput={Boolean(session.awaitingInput)}
|
|
176
|
+
timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
|
|
177
|
+
worktree={session.worktree}
|
|
178
|
+
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
179
|
+
expandable={control.expandable} isChild={control.isChild}
|
|
180
|
+
isExpanded={control.isExpanded}
|
|
181
|
+
onToggleExpand={control.onToggleExpand}
|
|
182
|
+
onClick={() => onSelectSession(session.id)}
|
|
183
|
+
onArchive={() => handleArchive(session)}
|
|
184
|
+
// A pending `new-…` chat has no transcript anywhere yet, so there is
|
|
185
|
+
// nothing to delete and nothing to rename from.
|
|
186
|
+
onDelete={pending ? undefined : () => sessionDelete.requestDelete(session)}
|
|
187
|
+
onRename={pending ? undefined : (name) => void handleRename(session, name)}
|
|
188
|
+
onRenameWithAi={pending ? undefined : () => void handleRenameWithAi(session)}
|
|
189
|
+
onCancelWait={session.waitingFor ? () => onCancelWait?.(session.waitingFor!.waitId) : undefined}
|
|
190
|
+
selectable={sessionCheckboxes}
|
|
191
|
+
selected={Boolean(batch?.selected.includes(key))}
|
|
192
|
+
onToggleSelect={batch ? () => batch.toggle(key) : undefined}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const controlFor = (session: SessionItemData): BranchControl =>
|
|
198
|
+
branchControlFor(session, tree.childrenOf, expandedSessionIds, toggleSession);
|
|
158
199
|
const canCreateWorktree = Boolean(onNewWorktreeSession && folder.project_path);
|
|
159
200
|
|
|
160
201
|
return (
|
|
@@ -227,59 +268,20 @@ export function WorkspaceSection({
|
|
|
227
268
|
<div className="space-y-0.5">
|
|
228
269
|
{tree.roots.map((session) => {
|
|
229
270
|
const key = String(session.id);
|
|
230
|
-
const
|
|
231
|
-
? String(activeSessionId) === key
|
|
232
|
-
: session.is_active === 1;
|
|
233
|
-
// While one of its subagents is being viewed, the parent row dims so
|
|
234
|
-
// the highlighted roster entry reads as the active one.
|
|
235
|
-
const viewingSubagent = isActive && urlSessionId === key && Boolean(urlSubagentId);
|
|
236
|
-
const hasChildren = (tree.childrenOf.get(key)?.length ?? 0) > 0;
|
|
237
|
-
const hasSubagents = Boolean(session.hasSubagents);
|
|
238
|
-
const childrenExpanded = hasChildren && expandedChildIds.has(key);
|
|
239
|
-
const rosterExpanded = hasSubagents && expandedSessionIds.has(key);
|
|
240
|
-
const pending = key.startsWith('new-');
|
|
241
|
-
|
|
271
|
+
const control = controlFor(session);
|
|
242
272
|
return (
|
|
243
273
|
<div key={session.id} className="space-y-0.5">
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
256
|
-
expandable={hasChildren}
|
|
257
|
-
isExpanded={childrenExpanded}
|
|
258
|
-
onToggleExpand={() => toggleChild(key)}
|
|
259
|
-
hasSubagents={hasSubagents}
|
|
260
|
-
subagentsExpanded={rosterExpanded}
|
|
261
|
-
onToggleSubagents={() => toggleSession(key)}
|
|
262
|
-
onClick={() => onSelectSession(session.id)}
|
|
263
|
-
onArchive={() => handleArchive(session)}
|
|
264
|
-
// A pending `new-…` chat has no transcript anywhere yet, so
|
|
265
|
-
// there is nothing to delete and nothing to rename from.
|
|
266
|
-
onDelete={pending ? undefined : () => sessionDelete.requestDelete(session)}
|
|
267
|
-
onRename={pending ? undefined : (name) => void handleRename(session, name)}
|
|
268
|
-
onRenameWithAi={pending ? undefined : () => void handleRenameWithAi(session)}
|
|
269
|
-
onCancelWait={
|
|
270
|
-
session.waitingFor ? () => onCancelWait?.(session.waitingFor!.waitId) : undefined
|
|
271
|
-
}
|
|
272
|
-
selectable={sessionCheckboxes}
|
|
273
|
-
selected={Boolean(batch?.selected.includes(key))}
|
|
274
|
-
onToggleSelect={batch ? () => batch.toggle(key) : undefined}
|
|
275
|
-
/>
|
|
276
|
-
{childrenExpanded && (
|
|
277
|
-
<ChildSessionList parentId={key} childrenOf={tree.childrenOf} onSelect={onSelectSession} />
|
|
278
|
-
)}
|
|
279
|
-
{rosterExpanded && (
|
|
280
|
-
<SubagentList
|
|
281
|
-
sessionId={session.id}
|
|
282
|
-
isActiveSession={activeSessionId !== null && key === String(activeSessionId)}
|
|
274
|
+
{renderSessionRow(session, control)}
|
|
275
|
+
{control.isExpanded && (
|
|
276
|
+
<SessionBranch
|
|
277
|
+
parentId={key}
|
|
278
|
+
hasSubagents={Boolean(session.hasSubagents)}
|
|
279
|
+
childrenOf={tree.childrenOf}
|
|
280
|
+
expandedIds={expandedSessionIds}
|
|
281
|
+
onToggle={toggleSession}
|
|
282
|
+
activeSessionId={activeSessionId === null ? null : String(activeSessionId)}
|
|
283
|
+
renderSession={renderSessionRow}
|
|
284
|
+
style={sessionRowBranchStyle(density === 'touch')}
|
|
283
285
|
/>
|
|
284
286
|
)}
|
|
285
287
|
</div>
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { ChevronDown, ChevronRight, GitBranch, MessageSquare, Plus } from 'lucide-preact';
|
|
2
2
|
import { FolderItemMenu } from '@/client/components/mobile/mobile-session-sidebar/ItemMenu';
|
|
3
3
|
import { useSearchParams } from '@/client/lib/router/search-params';
|
|
4
|
-
import { MobileSessionRow } from '@/client/components/mobile/mobile-session-sidebar/SessionRow';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { MobileSessionRow, MOBILE_BRANCH_STYLE } from '@/client/components/mobile/mobile-session-sidebar/SessionRow';
|
|
5
|
+
import { SessionBranch, branchControlFor } from '@/client/components/common/session-branch';
|
|
6
|
+
import type { BranchControl } from '@/client/components/common/session-branch';
|
|
7
7
|
import { buildSessionTree } from '@/client/lib/session-tree';
|
|
8
8
|
import { useWorktreeDialog } from '@/client/components/mobile/mobile-session-sidebar/WorktreeDialog';
|
|
9
9
|
import { useShowMore } from '@/client/hooks/ui/show-more';
|
|
10
10
|
import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
|
|
11
|
-
import { useChildExpansion } from '@/client/hooks/workspace/child-expansion';
|
|
12
11
|
import { useWorkspaceFolderActions } from '@/client/hooks/workspace/workspace-folder-actions';
|
|
13
12
|
import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
|
|
14
13
|
import { SessionDeleteModal } from '@/client/components/common/session-delete-modal';
|
|
15
14
|
import { getProjectIcon } from '@/shared/lib/workspace/project-icon';
|
|
16
15
|
import { relativeTimeAgo } from '@/shared/lib/workspace/relative-time';
|
|
16
|
+
import { isPendingSessionId } from '@/shared/lib/omp/session/default-title';
|
|
17
17
|
import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
|
|
18
|
-
import type { WorkspaceFolderData } from '@/shared/types';
|
|
18
|
+
import type { SessionItemData, WorkspaceFolderData } from '@/shared/types';
|
|
19
19
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
20
20
|
import { folderBatchState } from '@/client/components/common/batch-selection/folder-state';
|
|
21
21
|
import { SelectionCheckbox } from '@/client/components/common/batch-selection/SelectionCheckbox';
|
|
@@ -65,7 +65,6 @@ export function MobileSessionCategory({
|
|
|
65
65
|
);
|
|
66
66
|
const { refresh } = useSidebarData();
|
|
67
67
|
const { expandedSessionIds, toggleSession } = useExpandedSessions();
|
|
68
|
-
const { expandedChildIds, toggleChild } = useChildExpansion();
|
|
69
68
|
// The viewed transcript, so its session row dims while a roster entry is
|
|
70
69
|
// open (desktop parity — same params, same rule).
|
|
71
70
|
const [searchParams] = useSearchParams();
|
|
@@ -119,6 +118,48 @@ export function MobileSessionCategory({
|
|
|
119
118
|
const tree = buildSessionTree(visibleSessions);
|
|
120
119
|
const listOpen = isExpanded || sessionCheckboxes;
|
|
121
120
|
|
|
121
|
+
// Roots and descendants share this renderer, so the phone cannot draw a
|
|
122
|
+
// child session differently from the row it hangs under.
|
|
123
|
+
const renderSessionRow = (session: SessionItemData, control: BranchControl) => {
|
|
124
|
+
const sessionKey = String(session.id);
|
|
125
|
+
const isSessionActive = String(activeSessionId) === sessionKey;
|
|
126
|
+
// While one of its subagents is being viewed, the row dims so the
|
|
127
|
+
// highlighted leaf reads as the active one (desktop parity).
|
|
128
|
+
const isViewingSubagent = isSessionActive && urlSessionId === sessionKey && Boolean(urlSubagentId);
|
|
129
|
+
const pending = isPendingSessionId(sessionKey);
|
|
130
|
+
return (
|
|
131
|
+
<MobileSessionRow
|
|
132
|
+
session={session}
|
|
133
|
+
harness={session.harness}
|
|
134
|
+
folderId={session.folder_id}
|
|
135
|
+
isActive={isSessionActive && !isViewingSubagent}
|
|
136
|
+
status={sessionStatus[sessionKey]}
|
|
137
|
+
awaitingInput={Boolean(session.awaitingInput)}
|
|
138
|
+
timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
|
|
139
|
+
expandable={control.expandable} isChild={control.isChild}
|
|
140
|
+
isExpanded={control.isExpanded}
|
|
141
|
+
onToggleExpand={control.onToggleExpand}
|
|
142
|
+
onSelect={() => onSelectSession(session.id)}
|
|
143
|
+
onArchive={() => handleArchive(session)}
|
|
144
|
+
// A pending `new-…` chat has no transcript anywhere yet, so there is
|
|
145
|
+
// nothing to delete and nothing to rename from.
|
|
146
|
+
onDelete={pending ? undefined : () => sessionDelete.requestDelete(session)}
|
|
147
|
+
onRename={pending ? undefined : (name) => void handleRename(session, name)}
|
|
148
|
+
onRenameWithAi={pending ? undefined : () => void handleRenameWithAi(session)}
|
|
149
|
+
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
150
|
+
onCancelWait={
|
|
151
|
+
session.waitingFor ? () => onCancelWait?.(session.waitingFor!.waitId) : undefined
|
|
152
|
+
}
|
|
153
|
+
selectable={sessionCheckboxes}
|
|
154
|
+
selected={Boolean(batch?.selected.includes(sessionKey))}
|
|
155
|
+
onToggleSelect={batch ? () => batch.toggle(sessionKey) : undefined}
|
|
156
|
+
/>
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const controlFor = (session: SessionItemData): BranchControl =>
|
|
161
|
+
branchControlFor(session, tree.childrenOf, expandedSessionIds, toggleSession);
|
|
162
|
+
|
|
122
163
|
return (
|
|
123
164
|
<div className={folderGroupGap(listOpen)} data-testid="session-folder">
|
|
124
165
|
<div
|
|
@@ -231,67 +272,22 @@ export function MobileSessionCategory({
|
|
|
231
272
|
<div className="mt-0.5 space-y-0.5">
|
|
232
273
|
{tree.roots.map((session) => {
|
|
233
274
|
const sessionKey = String(session.id);
|
|
234
|
-
const
|
|
235
|
-
// While one of its subagents is being viewed, the parent session
|
|
236
|
-
// row dims so the highlighted roster entry reads as the active one
|
|
237
|
-
// (desktop parity).
|
|
238
|
-
const isViewingSubagent = isSessionActive && urlSessionId === sessionKey && Boolean(urlSubagentId);
|
|
239
|
-
// Same gate as desktop: the omp-side loader flag is authoritative,
|
|
240
|
-
// so a session whose roster exists on disk can be opened without a
|
|
241
|
-
// live process. Children are a separate, tree-level disclosure.
|
|
242
|
-
const hasSubagents = Boolean(session.hasSubagents);
|
|
243
|
-
const hasChildren = (tree.childrenOf.get(sessionKey)?.length ?? 0) > 0;
|
|
244
|
-
const isRosterOpen = hasSubagents && expandedSessionIds.has(sessionKey);
|
|
245
|
-
const childrenOpen = hasChildren && expandedChildIds.has(sessionKey);
|
|
246
|
-
|
|
275
|
+
const control = controlFor(session);
|
|
247
276
|
return (
|
|
248
277
|
<div key={session.id} className="space-y-0.5">
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
isActive={isSessionActive && !isViewingSubagent}
|
|
253
|
-
status={sessionStatus[sessionKey]}
|
|
254
|
-
awaitingInput={Boolean(session.awaitingInput)}
|
|
255
|
-
timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
|
|
256
|
-
hasSubagents={hasSubagents}
|
|
257
|
-
subagentsExpanded={isRosterOpen}
|
|
258
|
-
onToggleSubagents={() => toggleSession(sessionKey)}
|
|
259
|
-
expandable={hasChildren}
|
|
260
|
-
isExpanded={childrenOpen}
|
|
261
|
-
onToggleExpand={() => toggleChild(sessionKey)}
|
|
262
|
-
onSelect={() => onSelectSession(session.id)}
|
|
263
|
-
onArchive={() => handleArchive(session)}
|
|
264
|
-
onDelete={
|
|
265
|
-
// A pending `new-…` chat has no transcript anywhere yet —
|
|
266
|
-
// there is nothing to delete, and the server refuses it.
|
|
267
|
-
sessionKey.startsWith('new-')
|
|
268
|
-
? undefined
|
|
269
|
-
: () => sessionDelete.requestDelete(session)
|
|
270
|
-
}
|
|
271
|
-
onRename={sessionKey.startsWith('new-') ? undefined : (name) => void handleRename(session, name)}
|
|
272
|
-
onRenameWithAi={
|
|
273
|
-
sessionKey.startsWith('new-') ? undefined : () => void handleRenameWithAi(session)
|
|
274
|
-
}
|
|
275
|
-
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
276
|
-
onCancelWait={
|
|
277
|
-
session.waitingFor
|
|
278
|
-
? () => onCancelWait?.(session.waitingFor!.waitId)
|
|
279
|
-
: undefined
|
|
280
|
-
}
|
|
281
|
-
selectable={sessionCheckboxes}
|
|
282
|
-
selected={Boolean(batch?.selected.includes(sessionKey))}
|
|
283
|
-
onToggleSelect={batch ? () => batch.toggle(sessionKey) : undefined}
|
|
284
|
-
/>
|
|
285
|
-
{childrenOpen && (
|
|
286
|
-
<ChildSessionList
|
|
278
|
+
{renderSessionRow(session, control)}
|
|
279
|
+
{control.isExpanded && (
|
|
280
|
+
<SessionBranch
|
|
287
281
|
parentId={sessionKey}
|
|
282
|
+
hasSubagents={Boolean(session.hasSubagents)}
|
|
288
283
|
childrenOf={tree.childrenOf}
|
|
289
|
-
|
|
284
|
+
expandedIds={expandedSessionIds}
|
|
285
|
+
onToggle={toggleSession}
|
|
286
|
+
activeSessionId={activeSessionId === null ? null : String(activeSessionId)}
|
|
287
|
+
renderSession={renderSessionRow}
|
|
288
|
+
style={MOBILE_BRANCH_STYLE}
|
|
290
289
|
/>
|
|
291
290
|
)}
|
|
292
|
-
{isRosterOpen && (
|
|
293
|
-
<SubagentList sessionId={session.id} isActiveSession={isSessionActive} />
|
|
294
|
-
)}
|
|
295
291
|
</div>
|
|
296
292
|
);
|
|
297
293
|
})}
|
|
@@ -89,6 +89,11 @@ describe('mobile session row status slot', () => {
|
|
|
89
89
|
const slot = el.querySelector('span.w-4');
|
|
90
90
|
expect(slot?.querySelector('svg')).toBeNull();
|
|
91
91
|
});
|
|
92
|
+
|
|
93
|
+
test('a leaf child fills the empty slot with the child mark', async () => {
|
|
94
|
+
const el = await mount({ isChild: true });
|
|
95
|
+
expect(el.querySelector('[data-testid="child-indicator"] svg')).not.toBeNull();
|
|
96
|
+
});
|
|
92
97
|
});
|
|
93
98
|
|
|
94
99
|
/**
|
|
@@ -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
|
+
});
|