@kabmo-labs/kabmo 0.13.0 → 0.14.1

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.
Files changed (148) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +319 -319
  3. package/dist/client/static/js/index-bnrrw242.css +1 -0
  4. package/dist/client/static/js/{index-vzb1qz51.js → index-w6jx0h0p.js} +780 -780
  5. package/marketplace/plugins/command-runner/package.json +2 -2
  6. package/marketplace/plugins/command-runner/src/server/ring.test.ts +41 -0
  7. package/marketplace/plugins/command-runner/src/server/run-types.ts +6 -0
  8. package/marketplace/plugins/command-runner/src/server/runner-harness.ts +69 -0
  9. package/marketplace/plugins/command-runner/src/server/runner-path.test.ts +127 -0
  10. package/marketplace/plugins/command-runner/src/server/runner.test.ts +2 -72
  11. package/marketplace/plugins/command-runner/src/server/runner.ts +31 -3
  12. package/package.json +2 -2
  13. package/src/client/components/common/batch-selection/BatchActionBar.test.ts +42 -5
  14. package/src/client/components/common/batch-selection/BatchActionBar.tsx +57 -14
  15. package/src/client/components/common/code-surface/extensions.ts +7 -1
  16. package/src/client/components/common/code-surface/fold-placeholder.ts +43 -0
  17. package/src/client/components/common/session-row/StatusSlot.tsx +133 -0
  18. package/src/client/components/common/session-row/TrailingSlot.tsx +84 -0
  19. package/src/client/components/common/session-row/index.tsx +215 -0
  20. package/src/client/components/common/session-row/session-row.test.tsx +154 -0
  21. package/src/client/components/layout/session-sidebar/ClassicView.tsx +121 -0
  22. package/src/client/components/layout/session-sidebar/SessionsView.tsx +99 -112
  23. package/src/client/components/layout/session-sidebar/Toolbar.tsx +2 -2
  24. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +149 -0
  25. package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +150 -0
  26. package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +75 -0
  27. package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +56 -0
  28. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +193 -0
  29. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +333 -0
  30. package/src/client/components/layout/session-sidebar/modern/index.tsx +147 -0
  31. package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +111 -0
  32. package/src/client/components/layout/session-sidebar/variant-props.ts +73 -0
  33. package/src/client/components/mobile/SessionSidebar.tsx +137 -146
  34. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +140 -0
  35. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +3 -3
  36. package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +104 -0
  37. package/src/client/components/settings/Modal.tsx +5 -27
  38. package/src/client/components/settings/Sidebar.tsx +1 -1
  39. package/src/client/components/settings/apply-side-effects.test.ts +102 -0
  40. package/src/client/components/settings/apply-side-effects.ts +90 -0
  41. package/src/client/components/settings/categories/AppearanceSettings.tsx +11 -1
  42. package/src/client/components/settings/categories/ChatSettings.test.tsx +121 -0
  43. package/src/client/components/settings/categories/ChatSettings.tsx +80 -15
  44. package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +157 -0
  45. package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +177 -0
  46. package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +1 -1
  47. package/src/client/components/settings/categories/chat-settings/SidebarList.tsx +73 -0
  48. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +144 -0
  49. package/src/client/components/settings/categories/chat-settings/groups.test.ts +42 -0
  50. package/src/client/components/settings/categories/chat-settings/groups.ts +81 -0
  51. package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +1 -68
  52. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +7 -0
  53. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
  54. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +15 -5
  55. package/src/client/components/workspace/chat-timeline/MessageList.tsx +90 -41
  56. package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +13 -6
  57. package/src/client/components/workspace/chat-timeline/ThinkingSection.test.tsx +117 -0
  58. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +117 -75
  59. package/src/client/components/workspace/chat-timeline/ToolCallingSection.test.ts +28 -8
  60. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +48 -4
  61. package/src/client/components/workspace/chat-timeline/TurnRail.tsx +64 -0
  62. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +178 -0
  63. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -1
  64. package/src/client/components/workspace/chat-timeline/chat-input/ComposerNotice.tsx +50 -0
  65. package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +178 -0
  66. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +1 -1
  67. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +102 -122
  68. package/src/client/components/workspace/chat-timeline/chat-input/props.ts +7 -0
  69. package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +111 -0
  70. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +181 -0
  71. package/src/client/components/workspace/chat-timeline/index.tsx +3 -0
  72. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -0
  73. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/approval-gate.test.tsx +31 -0
  74. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +1 -1
  75. package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -2
  76. package/src/client/components/workspace/chat-timeline/tool-renderers/plugin-renderers.ts +6 -1
  77. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +98 -0
  78. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell.tsx +3 -1
  79. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph.tsx +56 -0
  80. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +19 -0
  81. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +132 -0
  82. package/src/client/components/workspace/chat-timeline/{ToolCallCard.plugin.test.ts → tool-renderers/styles/Card.plugin.test.ts} +3 -3
  83. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +60 -0
  84. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +89 -0
  85. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +72 -0
  86. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +84 -0
  87. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +22 -0
  88. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +153 -0
  89. package/src/client/components/workspace/diff-panel/folding.ts +6 -1
  90. package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +16 -2
  91. package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +86 -12
  92. package/src/client/components/workspace/model-dropdown/Item.tsx +56 -19
  93. package/src/client/components/workspace/model-dropdown/Panel.tsx +21 -13
  94. package/src/client/components/workspace/model-dropdown/Section.test.tsx +114 -4
  95. package/src/client/components/workspace/model-dropdown/Section.tsx +21 -9
  96. package/src/client/components/workspace/model-dropdown/groups.test.ts +164 -1
  97. package/src/client/components/workspace/model-dropdown/groups.ts +94 -17
  98. package/src/client/components/workspace/model-dropdown/index.tsx +27 -19
  99. package/src/client/data/settings/omp-schema.json +151 -6
  100. package/src/client/hooks/chat/composer/style.ts +66 -0
  101. package/src/client/hooks/chat/timeline/row-window-reveal.ts +130 -0
  102. package/src/client/hooks/chat/timeline/row-window.test.ts +35 -0
  103. package/src/client/hooks/chat/timeline/row-window.ts +59 -133
  104. package/src/client/hooks/chat/timeline/thinking-open.ts +67 -0
  105. package/src/client/hooks/chat/timeline/tool-render-mode.ts +65 -0
  106. package/src/client/hooks/settings/providers/login.ts +11 -2
  107. package/src/client/hooks/ui/window-event.ts +20 -4
  108. package/src/client/hooks/workspace/batch-archive-run.ts +47 -0
  109. package/src/client/hooks/workspace/batch-archive.test.ts +59 -0
  110. package/src/client/hooks/workspace/batch-archive.ts +78 -0
  111. package/src/client/hooks/workspace/sidebar-batch.ts +95 -0
  112. package/src/client/hooks/workspace/sidebar-style.ts +66 -0
  113. package/src/client/tailwind.css +111 -0
  114. package/src/server/index.ts +10 -134
  115. package/src/server/lib/lifecycle/after-listen.ts +178 -0
  116. package/src/server/lib/lifecycle/rejection-guard.test.ts +79 -0
  117. package/src/server/lib/lifecycle/rejection-guard.ts +74 -0
  118. package/src/server/lib/lifecycle/tls.test.ts +7 -7
  119. package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +131 -0
  120. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +46 -0
  121. package/src/server/lib/omp/rpc/frame-fold.test.ts +1 -100
  122. package/src/server/lib/omp/rpc/frame-fold.ts +13 -0
  123. package/src/server/lib/plugins/background.server.ts +17 -1
  124. package/src/server/lib/plugins/background.test.ts +33 -0
  125. package/src/server/routes/sessions/batch-archive.test.ts +113 -0
  126. package/src/server/routes/sessions/batch-archive.ts +80 -0
  127. package/src/server/routes/sessions/index.ts +4 -0
  128. package/src/shared/lib/chat/composer/style.test.ts +126 -0
  129. package/src/shared/lib/chat/composer/style.ts +171 -0
  130. package/src/shared/lib/chat/composer/tui-only.test.ts +3 -0
  131. package/src/shared/lib/chat/composer/tui-only.ts +5 -0
  132. package/src/shared/lib/chat/timeline/block-chrome.ts +129 -0
  133. package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +51 -0
  134. package/src/shared/lib/chat/timeline/tool-render-mode.ts +74 -0
  135. package/src/shared/lib/chat/timeline/trace-groups.test.ts +132 -0
  136. package/src/shared/lib/chat/timeline/trace-groups.ts +95 -0
  137. package/src/shared/lib/settings/defaults.ts +6 -0
  138. package/src/shared/lib/workspace/session-focus.test.ts +93 -0
  139. package/src/shared/lib/workspace/session-focus.ts +71 -0
  140. package/src/shared/lib/workspace/session-state/store.ts +5 -0
  141. package/src/shared/lib/workspace/sidebar-filter-row.test.ts +73 -0
  142. package/src/shared/lib/workspace/sidebar-filter-row.ts +86 -0
  143. package/src/shared/lib/workspace/sidebar-style.test.ts +58 -0
  144. package/src/shared/lib/workspace/sidebar-style.ts +86 -0
  145. package/src/shared/types/omp/agent.ts +6 -0
  146. package/src/shared/types/settings/state.ts +31 -0
  147. package/dist/client/static/js/index-68w8h33q.css +0 -1
  148. package/src/client/components/workspace/chat-timeline/ToolCallCard.tsx +0 -194
@@ -0,0 +1,333 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * One workspace in the `modern` sidebar: its sticky header, its rows, its
8
+ * pagination and the dialogs those rows own.
9
+ *
10
+ * It is NOT a second implementation of a workspace. Every rule that governs a
11
+ * folder — which rows the archive filter offers, what the header checkbox
12
+ * reports, which window of rows is shown, what a rename or a delete issues — is
13
+ * the same hook the classic category calls (`folderBatchState`,
14
+ * `useWorkspaceFolderActions`, `useSessionDelete`, `useShowMore`,
15
+ * `useExpandedSessions`). Only the markup differs. That is what makes the style
16
+ * setting safe: a fix to a folder action lands in one place and appears in both.
17
+ *
18
+ * Two behaviours are deliberately identical to the classic list, because each
19
+ * one was a reported bug there:
20
+ *
21
+ * - a session selection LIFTS the pagination window (`folderBatchState`), so a
22
+ * checkbox cannot be ticked on a row that has no checkbox on screen;
23
+ * - the search forces every workspace open, so a match inside a collapsed folder
24
+ * is not silently hidden.
25
+ */
26
+
27
+ import { useEffect, useRef, useState } from 'preact/hooks';
28
+ import { ChevronDown, ChevronUp } from 'lucide-preact';
29
+ import { useSearchParams } from '@/client/lib/router/search-params';
30
+ import { useFetcher } from '@/client/lib/router/fetcher';
31
+ import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
32
+ import { useShowMore } from '@/client/hooks/ui/show-more';
33
+ import { useWorkspaceFolderActions } from '@/client/hooks/workspace/workspace-folder-actions';
34
+ import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
35
+ import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
36
+ import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
37
+ import { SessionRow, type SessionRowDensity } from '@/client/components/common/session-row';
38
+ import { SubagentList } from '@/client/components/common/subagent-list';
39
+ import { SessionDeleteModal } from '@/client/components/common/session-delete-modal';
40
+ import { WorkspaceOptionsMenu } from '@/client/components/common/workspace-options-menu';
41
+ import { NewWorktreeModal } from '@/client/components/workspace/worktree-modal/index';
42
+ import { WorkspaceHeader } from '@/client/components/layout/session-sidebar/modern/WorkspaceHeader';
43
+ import { folderBatchState } from '@/client/components/common/batch-selection/folder-state';
44
+ import { relativeTimeAgo } from '@/shared/lib/workspace/relative-time';
45
+ import type { BatchBinding } from '@/client/components/common/batch-selection/types';
46
+ import type { SessionStatusMap } from '@/client/components/layout/session-sidebar/variant-props';
47
+ import type { WorkspaceFolderData } from '@/shared/types';
48
+
49
+ export interface WorkspaceSectionProps {
50
+ folder: WorkspaceFolderData;
51
+ activeSessionId: number | string | null;
52
+ sessionStatus: SessionStatusMap;
53
+ showArchived: boolean;
54
+ /** True while a search is active: every workspace opens to show its matches. */
55
+ forceExpanded?: boolean;
56
+ /** Row density: `touch` on the phone drawer, `compact` on the desktop dock. */
57
+ density?: SessionRowDensity;
58
+ batch?: BatchBinding;
59
+ onSelectSession: (id: number | string) => void;
60
+ onNewSessionForFolder: (folderId: number) => void;
61
+ onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
62
+ onToast: (message: string, type?: 'success' | 'error') => void;
63
+ onStartSessionSelection?: (folderId: number) => void;
64
+ onCancelWait?: (waitId: string) => void;
65
+ }
66
+
67
+ export function WorkspaceSection({
68
+ folder,
69
+ activeSessionId,
70
+ sessionStatus,
71
+ showArchived,
72
+ forceExpanded = false,
73
+ density = 'compact',
74
+ batch,
75
+ onSelectSession,
76
+ onNewSessionForFolder,
77
+ onNewWorktreeSession,
78
+ onToast,
79
+ onStartSessionSelection,
80
+ onCancelWait,
81
+ }: WorkspaceSectionProps) {
82
+ const [isOpen, setIsOpen] = useState(folder.isExpanded || false);
83
+ const [showMenu, setShowMenu] = useState(false);
84
+ const [worktreeOpen, setWorktreeOpen] = useState(false);
85
+ const { visibleCount, showMore, showLess, canShowLess } = useShowMore();
86
+ const [searchParams] = useSearchParams();
87
+ const urlSubagentId = searchParams.get('subagent');
88
+ const urlSessionId = searchParams.get('sessionId');
89
+ const { expandedSessionIds, toggleSession } = useExpandedSessions();
90
+ const menuRef = useRef<HTMLDivElement>(null);
91
+ const { refresh } = useSidebarData();
92
+ const toggleFetcher = useFetcher<{ success?: boolean }>();
93
+ const {
94
+ confirmDelete,
95
+ requestDelete,
96
+ cancelDelete,
97
+ handlePin,
98
+ handleDelete,
99
+ handleArchive,
100
+ handleRename,
101
+ handleRenameWithAi,
102
+ handleOpenFolder,
103
+ } = useWorkspaceFolderActions(folder, refresh, onToast);
104
+ const sessionDelete = useSessionDelete();
105
+
106
+ // The stored flag is the source of truth, so a collapse made on the phone
107
+ // arrives here too. Keyed on the flag itself, not the folder object, which is
108
+ // a new identity on every structure push.
109
+ useEffect(() => {
110
+ if (typeof folder.isExpanded === 'boolean') setIsOpen(folder.isExpanded);
111
+ }, [folder.isExpanded]);
112
+
113
+ useOnClickOutside(menuRef, () => {
114
+ setShowMenu(false);
115
+ cancelDelete();
116
+ });
117
+
118
+ const toggleFolder = () => {
119
+ const next = !isOpen;
120
+ setIsOpen(next);
121
+ if (typeof folder.id !== 'number') return;
122
+ toggleFetcher.submit(
123
+ { isExpanded: String(next) },
124
+ { method: 'POST', action: `/api/folders/${folder.id}/toggle` },
125
+ );
126
+ };
127
+
128
+ const offered = folder.sessions.filter((session) =>
129
+ showArchived ? session.is_archived === 1 : session.is_archived !== 1,
130
+ );
131
+
132
+ const {
133
+ folderCheckbox,
134
+ sessionCheckboxes,
135
+ folderSummary,
136
+ toggleFolderSelection,
137
+ rendered,
138
+ hiddenCount,
139
+ } = folderBatchState({
140
+ batch,
141
+ folder,
142
+ sessions: offered,
143
+ showArchived,
144
+ visibleCount,
145
+ activeSessionId,
146
+ sessionStatus,
147
+ });
148
+
149
+ // A session selection opens every workspace: a checkbox on a collapsed folder
150
+ // would let the user select rows they cannot see or unselect.
151
+ const listOpen = forceExpanded || isOpen || sessionCheckboxes;
152
+ const canCreateWorktree = Boolean(onNewWorktreeSession && folder.project_path);
153
+
154
+ return (
155
+ <div className="space-y-0.5">
156
+ <WorkspaceHeader
157
+ folder={folder}
158
+ isOpen={listOpen}
159
+ onToggleFolder={toggleFolder}
160
+ sessionCount={offered.length}
161
+ checkbox={
162
+ folderCheckbox && folderSummary
163
+ ? {
164
+ checked: folderSummary.all,
165
+ indeterminate: folderSummary.some,
166
+ label: `Select ${folder.name}`,
167
+ onChange: toggleFolderSelection,
168
+ }
169
+ : null
170
+ }
171
+ batchActive={Boolean(batch)}
172
+ menuRef={menuRef}
173
+ showMenu={showMenu}
174
+ onToggleMenu={() => setShowMenu((open) => !open)}
175
+ onNewSession={() => onNewSessionForFolder(folder.id)}
176
+ touch={density === 'touch'}
177
+ menu={
178
+ <WorkspaceOptionsMenu
179
+ variant="desktop"
180
+ isPinned={folder.isPinned}
181
+ onOpenFolder={
182
+ handleOpenFolder
183
+ ? () => {
184
+ handleOpenFolder();
185
+ setShowMenu(false);
186
+ }
187
+ : undefined
188
+ }
189
+ onSelectSessions={
190
+ onStartSessionSelection
191
+ ? () => {
192
+ setShowMenu(false);
193
+ onStartSessionSelection(folder.id);
194
+ }
195
+ : undefined
196
+ }
197
+ onNewWorktree={
198
+ canCreateWorktree
199
+ ? () => {
200
+ setShowMenu(false);
201
+ setWorktreeOpen(true);
202
+ }
203
+ : undefined
204
+ }
205
+ confirmDelete={confirmDelete}
206
+ onPin={() => {
207
+ handlePin();
208
+ setShowMenu(false);
209
+ }}
210
+ onDelete={() => {
211
+ handleDelete();
212
+ setShowMenu(false);
213
+ }}
214
+ onRequestDelete={requestDelete}
215
+ onCancelDelete={cancelDelete}
216
+ />
217
+ }
218
+ />
219
+
220
+ {listOpen && (
221
+ <div className="space-y-0.5">
222
+ {rendered.map((session) => {
223
+ const key = String(session.id);
224
+ const isActive = activeSessionId !== null
225
+ ? String(activeSessionId) === key
226
+ : session.is_active === 1;
227
+ // While one of its subagents is being viewed, the parent row dims so
228
+ // the highlighted roster entry reads as the active one.
229
+ const viewingSubagent = isActive && urlSessionId === key && Boolean(urlSubagentId);
230
+ const hasSubagents = Boolean(session.hasSubagents);
231
+ const isExpanded = hasSubagents && expandedSessionIds.has(key);
232
+ const pending = key.startsWith('new-');
233
+
234
+ return (
235
+ <div key={session.id} className="space-y-0.5">
236
+ <SessionRow
237
+ sessionId={session.id}
238
+ title={session.title}
239
+ density={density}
240
+ isActive={isActive && !viewingSubagent}
241
+ isArchived={session.is_archived === 1}
242
+ status={sessionStatus[key]}
243
+ awaitingInput={Boolean(session.awaitingInput)}
244
+ timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
245
+ worktree={session.worktree}
246
+ waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
247
+ hasSubagents={hasSubagents}
248
+ isExpanded={isExpanded}
249
+ onToggleExpand={() => toggleSession(key)}
250
+ onClick={() => onSelectSession(session.id)}
251
+ onArchive={() => handleArchive(session)}
252
+ // A pending `new-…` chat has no transcript anywhere yet, so
253
+ // there is nothing to delete and nothing to rename from.
254
+ onDelete={pending ? undefined : () => sessionDelete.requestDelete(session)}
255
+ onRename={pending ? undefined : (name) => void handleRename(session, name)}
256
+ onRenameWithAi={pending ? undefined : () => void handleRenameWithAi(session)}
257
+ onCancelWait={
258
+ session.waitingFor ? () => onCancelWait?.(session.waitingFor!.waitId) : undefined
259
+ }
260
+ selectable={sessionCheckboxes}
261
+ selected={Boolean(batch?.selected.includes(key))}
262
+ onToggleSelect={batch ? () => batch.toggle(key) : undefined}
263
+ />
264
+ {hasSubagents && isExpanded && (
265
+ <SubagentList
266
+ sessionId={session.id}
267
+ isActiveSession={activeSessionId !== null && key === String(activeSessionId)}
268
+ />
269
+ )}
270
+ </div>
271
+ );
272
+ })}
273
+
274
+ {/* Reveal and collapse are two controls, not a toggle: the list is
275
+ truncated for height, so after a partial reveal the user needs to
276
+ keep going AND to start over. */}
277
+ {(hiddenCount > 0 || canShowLess) && !forceExpanded && !sessionCheckboxes && (
278
+ <div className="flex items-center gap-1 pl-6">
279
+ {hiddenCount > 0 && (
280
+ <button
281
+ type="button"
282
+ onClick={showMore}
283
+ className="min-w-0 truncate rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80"
284
+ >
285
+ <ChevronDown size={11} className="mr-1 inline align-[-2px]" />
286
+ {hiddenCount} more
287
+ </button>
288
+ )}
289
+ {canShowLess && (
290
+ <button
291
+ type="button"
292
+ onClick={showLess}
293
+ className="ml-auto shrink-0 rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80"
294
+ >
295
+ <ChevronUp size={11} className="mr-1 inline align-[-2px]" />
296
+ Less
297
+ </button>
298
+ )}
299
+ </div>
300
+ )}
301
+
302
+ {offered.length === 0 && (
303
+ <div className="px-1 py-1 pl-6 text-[11px] italic text-ink/40">
304
+ {showArchived ? 'No archived sessions.' : 'No sessions.'}
305
+ </div>
306
+ )}
307
+ </div>
308
+ )}
309
+
310
+ <SessionDeleteModal
311
+ session={sessionDelete.pending}
312
+ isDeleting={sessionDelete.isDeleting}
313
+ error={sessionDelete.error}
314
+ onClose={sessionDelete.cancelDelete}
315
+ onConfirm={() => void sessionDelete.confirmDelete()}
316
+ />
317
+
318
+ {canCreateWorktree && (
319
+ <NewWorktreeModal
320
+ isOpen={worktreeOpen}
321
+ onClose={() => setWorktreeOpen(false)}
322
+ root={folder.project_path ?? null}
323
+ folderId={folder.id}
324
+ folderName={folder.name}
325
+ onCreated={(created) => {
326
+ setWorktreeOpen(false);
327
+ onNewWorktreeSession?.(folder.id, created.path);
328
+ }}
329
+ />
330
+ )}
331
+ </div>
332
+ );
333
+ }
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The `modern` sidebar style: search line, focus chips, sticky workspaces.
8
+ *
9
+ * It receives the same `SessionSidebarVariantProps` the classic style does, so
10
+ * every action in this chrome is the same server call and the same dialog —
11
+ * `SessionsView` owns those, and this file cannot diverge from it.
12
+ *
13
+ * What is local to the chrome, and therefore lost when the style is switched
14
+ * away from, is only presentation: which focus chip is on, whether the search
15
+ * field has the caret. The QUERY is not local — it lives in the dispatcher, so
16
+ * switching styles mid-search keeps the results.
17
+ *
18
+ * Two empty states, both explicit: a query with no matches and a focus with
19
+ * nothing running say which filter is responsible, rather than drawing an empty
20
+ * column the user cannot explain.
21
+ */
22
+
23
+ import { useMemo, useState } from 'preact/hooks';
24
+ import { SearchField } from '@/client/components/layout/session-sidebar/modern/SearchField';
25
+ import { FilterChips } from '@/client/components/layout/session-sidebar/modern/FilterChips';
26
+ import { SidebarActionRow } from '@/client/components/layout/session-sidebar/modern/ActionRow';
27
+ import { WorkspaceSection } from '@/client/components/layout/session-sidebar/modern/WorkspaceSection';
28
+ import { ModernSidebarSkeleton } from '@/client/components/layout/session-sidebar/modern/Skeleton';
29
+ import {
30
+ focusFolders,
31
+ runningSessionCount,
32
+ type SessionFocus,
33
+ } from '@/shared/lib/workspace/session-focus';
34
+ import type { SessionSidebarVariantProps } from '@/client/components/layout/session-sidebar/variant-props';
35
+
36
+ export function ModernSidebarView({
37
+ className = '',
38
+ folders,
39
+ initializing,
40
+ activeSessionId,
41
+ sessionStatus,
42
+ searchQuery,
43
+ onSearchChange,
44
+ showArchived,
45
+ onToggleArchived,
46
+ sortOption,
47
+ optionsOpen,
48
+ onToggleOptions,
49
+ onCloseOptions,
50
+ onSortChange,
51
+ onRefresh,
52
+ refreshing,
53
+ scheduledCount,
54
+ onNewSession,
55
+ onNewWorkspace,
56
+ onScheduler,
57
+ onSelectSession,
58
+ onNewSessionForFolder,
59
+ onNewWorktreeSession,
60
+ onToast,
61
+ onCancelWait,
62
+ batch,
63
+ onSelectWorkspaces,
64
+ onStartSessionSelection,
65
+ touch = false,
66
+ }: SessionSidebarVariantProps & { /** Phone drawer: taller targets and rows. */ touch?: boolean }) {
67
+ const [focus, setFocus] = useState<SessionFocus>('all');
68
+ const runningCount = useMemo(
69
+ () => runningSessionCount(folders, (id) => sessionStatus[id]),
70
+ [folders, sessionStatus],
71
+ );
72
+ const visible = useMemo(
73
+ () => focusFolders(folders, { focus, statusOf: (id) => sessionStatus[id] }),
74
+ [folders, focus, sessionStatus],
75
+ );
76
+ // The binding only exists while a mode is active, so its presence IS the
77
+ // "selecting" flag — the same test the classic chrome makes.
78
+ const selecting = Boolean(batch);
79
+
80
+ // `flex-1 min-h-0`: the dispatcher draws the batch bar below this chrome in
81
+ // the same column (see `ClassicView`).
82
+ return (
83
+ <div className={`flex flex-col ${className}`}>
84
+ <SearchField value={searchQuery} onChange={onSearchChange} touch={touch} />
85
+
86
+ <FilterChips
87
+ focus={focus}
88
+ onFocusChange={setFocus}
89
+ runningCount={runningCount}
90
+ showArchived={showArchived}
91
+ onToggleArchived={onToggleArchived}
92
+ selecting={selecting}
93
+ onToggleSelect={onSelectWorkspaces}
94
+ />
95
+
96
+ <SidebarActionRow
97
+ onNewSession={onNewSession}
98
+ onNewWorkspace={onNewWorkspace}
99
+ onScheduler={onScheduler}
100
+ scheduledCount={scheduledCount}
101
+ onRefresh={onRefresh}
102
+ refreshing={refreshing}
103
+ sortOption={sortOption}
104
+ optionsOpen={optionsOpen}
105
+ onToggleOptions={onToggleOptions}
106
+ onCloseOptions={onCloseOptions}
107
+ onSortChange={onSortChange}
108
+ touch={touch}
109
+ />
110
+
111
+ <div className="mt-1 flex-1 scrollbar-overlay-container px-2 pb-3">
112
+ {initializing ? (
113
+ <ModernSidebarSkeleton touch={touch} />
114
+ ) : visible.length === 0 ? (
115
+ <div className="px-1 py-8 text-center text-[11px] leading-relaxed text-ink/40">
116
+ {focus === 'running'
117
+ ? 'Nothing is running right now.'
118
+ : searchQuery
119
+ ? 'No workspace or chat matches that search.'
120
+ : 'No workspaces yet.'}
121
+ </div>
122
+ ) : (
123
+ <div className="space-y-3">
124
+ {visible.map((folder) => (
125
+ <WorkspaceSection
126
+ key={folder.id}
127
+ folder={folder}
128
+ activeSessionId={activeSessionId}
129
+ sessionStatus={sessionStatus}
130
+ showArchived={showArchived}
131
+ forceExpanded={Boolean(searchQuery)}
132
+ density={touch ? 'touch' : 'compact'}
133
+ batch={batch}
134
+ onSelectSession={onSelectSession}
135
+ onNewSessionForFolder={onNewSessionForFolder}
136
+ onNewWorktreeSession={onNewWorktreeSession}
137
+ onToast={onToast}
138
+ onStartSessionSelection={onStartSessionSelection}
139
+ onCancelWait={onCancelWait}
140
+ />
141
+ ))}
142
+ </div>
143
+ )}
144
+ </div>
145
+ </div>
146
+ );
147
+ }
@@ -0,0 +1,111 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The `modern` workspace header's sticky surface.
8
+ *
9
+ * The header is opaque because rows scroll under it, so the colour it paints is
10
+ * visible as a band behind every folder. It must be the surface the list sits
11
+ * on: `--theme-paper` in the desktop column, `--theme-canvas` in the phone
12
+ * drawer (`shared/lib/theme/chrome.ts`). Shipping one `bg-paper` put a lighter
13
+ * stripe behind each folder on the phone — the reported "belang" list.
14
+ *
15
+ * Rendered with `h()` against happy-dom, following
16
+ * `common/session-row/session-row.test.tsx`.
17
+ */
18
+
19
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
20
+ import { Window } from 'happy-dom';
21
+ import { h, render } from 'preact';
22
+
23
+ import { WorkspaceHeader } from '@/client/components/layout/session-sidebar/modern/WorkspaceHeader';
24
+ import type { WorkspaceHeaderProps } from '@/client/components/layout/session-sidebar/modern/WorkspaceHeader';
25
+ import type { WorkspaceFolderData } from '@/shared/types';
26
+
27
+ const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event', 'MouseEvent'] as const;
28
+ const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
29
+
30
+ let container: HTMLElement;
31
+
32
+ beforeAll(() => {
33
+ const win = new Window({ url: 'http://localhost' });
34
+ const target = globalThis as unknown as Record<string, unknown>;
35
+ for (const key of DOM_GLOBALS) {
36
+ if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
37
+ target[key] = (win as unknown as Record<string, unknown>)[key];
38
+ }
39
+ });
40
+
41
+ afterAll(() => {
42
+ const target = globalThis as unknown as Record<string, unknown>;
43
+ for (const key of DOM_GLOBALS) {
44
+ if (nativeGlobals[key] === undefined) delete target[key];
45
+ else target[key] = nativeGlobals[key];
46
+ }
47
+ });
48
+
49
+ afterEach(() => {
50
+ if (container) render(null, container);
51
+ container?.remove();
52
+ });
53
+
54
+ const FOLDER: WorkspaceFolderData = {
55
+ id: 1,
56
+ name: 'kabmo',
57
+ isExpanded: true,
58
+ sessions: [],
59
+ hasMore: false,
60
+ totalSessions: 0,
61
+ };
62
+
63
+ function mount(overrides: Partial<WorkspaceHeaderProps> = {}) {
64
+ if (container) {
65
+ render(null, container);
66
+ container.remove();
67
+ }
68
+ container = document.createElement('div');
69
+ document.body.appendChild(container);
70
+ render(
71
+ h(WorkspaceHeader, {
72
+ folder: FOLDER,
73
+ isOpen: true,
74
+ onToggleFolder: () => {},
75
+ sessionCount: 0,
76
+ checkbox: null,
77
+ batchActive: false,
78
+ menuRef: { current: null },
79
+ showMenu: false,
80
+ onToggleMenu: () => {},
81
+ onNewSession: () => {},
82
+ ...overrides,
83
+ }),
84
+ container,
85
+ );
86
+ return container.firstElementChild as HTMLElement;
87
+ }
88
+
89
+ describe('modern workspace header', () => {
90
+ test('the desktop header paints the column surface', () => {
91
+ const header = mount();
92
+ expect(header.className).toContain('bg-paper');
93
+ expect(header.className).not.toContain('bg-canvas');
94
+ });
95
+
96
+ test('the phone header paints the drawer surface, so no folder band appears', () => {
97
+ const header = mount({ touch: true });
98
+ expect(header.className).toContain('bg-canvas');
99
+ expect(header.className).not.toContain('bg-paper');
100
+ });
101
+
102
+ test('it stays sticky in both densities', () => {
103
+ expect(mount().className).toContain('sticky');
104
+ expect(mount({ touch: true }).className).toContain('sticky');
105
+ });
106
+
107
+ test('the phone header is 32px, the height its rows match', () => {
108
+ expect(mount({ touch: true }).className).toContain('h-8');
109
+ expect(mount().className).toContain('h-[26px]');
110
+ });
111
+ });
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The ONE data contract both sidebar styles render.
8
+ *
9
+ * The style setting exists so the list can be drawn two ways, not so it can
10
+ * behave two ways: a folder, a row, a rename, a delete, a worktree chat and a
11
+ * batch selection must all be reachable from either style, with the same
12
+ * confirmations and the same server calls. That is guaranteed structurally —
13
+ * `SessionsView` owns the controller, the dialogs and every mutation, and a
14
+ * style variant receives this object and nothing else. A variant that wants a
15
+ * new field is a variant asking to become a second sidebar; the answer is to
16
+ * add the field here, so the other style gets it too.
17
+ *
18
+ * Deliberately a type-only module: it is imported by both styles and by the
19
+ * dispatcher, and it must not pull a component into any of them.
20
+ */
21
+
22
+ import type { SessionSortOption, WorkspaceFolderData } from '@/shared/types';
23
+ import type { BatchBinding } from '@/client/components/common/batch-selection/types';
24
+
25
+ export type SessionStatusMap = Record<string, 'stream' | 'finish' | 'abort'>;
26
+
27
+ export interface SessionSidebarVariantProps {
28
+ className?: string;
29
+ /** The folders the list renders — already sorted and search-filtered. */
30
+ folders: WorkspaceFolderData[];
31
+ /** True until the first list fetch settles (drives the skeleton). */
32
+ initializing: boolean;
33
+ activeSessionId: number | string | null;
34
+ sessionStatus: SessionStatusMap;
35
+
36
+ searchQuery: string;
37
+ onSearchChange: (value: string) => void;
38
+ showArchived: boolean;
39
+ /** Flip the archive filter. Both chromes read it as a toggle. */
40
+ onToggleArchived: () => void;
41
+
42
+ sortOption: SessionSortOption;
43
+ optionsOpen: boolean;
44
+ onToggleOptions: () => void;
45
+ onCloseOptions: () => void;
46
+ onSortChange: (option: SessionSortOption) => void;
47
+
48
+ /** Reload the list; `refreshing` spins whatever the style's refresh control is. */
49
+ onRefresh: () => void;
50
+ refreshing: boolean;
51
+ /** Armed scheduled tasks, for the calendar badge. */
52
+ scheduledCount: number;
53
+
54
+ /** The toolbar's primary action, in both styles and on both layouts. */
55
+ onNewSession: () => void;
56
+ onNewWorkspace: () => void;
57
+ onScheduler: () => void;
58
+
59
+ onSelectSession: (id: number | string) => void;
60
+ onNewSessionForFolder: (folderId: number) => void;
61
+ /** Start a chat in a worktree made from this folder. */
62
+ onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
63
+ /** Reports a refused folder action (the reveal endpoint's own reason). */
64
+ onToast: (message: string, type?: 'success' | 'error') => void;
65
+ onCancelWait?: (waitId: string) => void;
66
+
67
+ /** The active batch mode, or undefined when the list is not selecting. */
68
+ batch?: BatchBinding;
69
+ /** Enter workspace selection from the style's own control. */
70
+ onSelectWorkspaces: () => void;
71
+ /** Start a session selection scoped to a workspace, from its `⋯` menu. */
72
+ onStartSessionSelection: (folderId: number) => void;
73
+ }