@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,121 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The `classic` sidebar style: the toolbar of boxed icons over compact rows.
8
+ *
9
+ * This is the chrome Kabmo shipped before the style setting existed, moved out
10
+ * of `SessionsView` VERBATIM — same components, same props, same order — so the
11
+ * default style renders the DOM it always did. `SessionsView` is the dispatcher
12
+ * that owns the controller, the dialogs and the batch confirmation; this file
13
+ * only decides how the toolbar and the list look.
14
+ *
15
+ * The batch bar is NOT here: it is the same bar in both styles, so the
16
+ * dispatcher draws it once, below whichever style is on screen.
17
+ */
18
+
19
+ import { useState } from 'preact/hooks';
20
+ import { SessionSidebarToolbar } from '@/client/components/layout/session-sidebar/Toolbar';
21
+ import { SessionSidebarSessionList } from '@/client/components/layout/session-sidebar/SessionList';
22
+ import { SessionListSkeleton } from '@/client/components/layout/session-sidebar/Skeleton';
23
+ import type { SessionSidebarVariantProps } from '@/client/components/layout/session-sidebar/variant-props';
24
+
25
+ export function ClassicSidebarView({
26
+ className = '',
27
+ folders,
28
+ initializing,
29
+ activeSessionId,
30
+ sessionStatus,
31
+ searchQuery,
32
+ onSearchChange,
33
+ showArchived,
34
+ onToggleArchived,
35
+ sortOption,
36
+ optionsOpen,
37
+ onToggleOptions,
38
+ onCloseOptions,
39
+ onSortChange,
40
+ onRefresh,
41
+ refreshing,
42
+ scheduledCount,
43
+ onNewSession,
44
+ onNewWorkspace,
45
+ onScheduler,
46
+ onSelectSession,
47
+ onNewSessionForFolder,
48
+ onNewWorktreeSession,
49
+ onToast,
50
+ onCancelWait,
51
+ batch,
52
+ onSelectWorkspaces,
53
+ onStartSessionSelection,
54
+ }: SessionSidebarVariantProps) {
55
+ // Search is a MODE in this style — a toggle in the toolbar opens the field —
56
+ // so the visibility is local to the chrome. The query itself is the
57
+ // dispatcher's: switching styles must not drop what the user typed.
58
+ const [searchOpen, setSearchOpen] = useState(false);
59
+ // A query that survived a style switch (or a reload of the classic toolbar's
60
+ // own toggle) keeps the field OPEN: the list behind it is filtered, and a
61
+ // hidden field would leave a short list with nothing on screen explaining why.
62
+ const searchVisible = searchOpen || searchQuery.length > 0;
63
+ const batchActive = Boolean(batch);
64
+
65
+ return (
66
+ <div className={`flex flex-col ${className}`}>
67
+ <SessionSidebarToolbar
68
+ isSearchVisible={searchVisible}
69
+ searchQuery={searchQuery}
70
+ showArchived={showArchived}
71
+ optionsOpen={optionsOpen}
72
+ sortOption={sortOption}
73
+ onToggleSearch={() => {
74
+ if (searchVisible) {
75
+ // Hiding the field cannot leave the list filtered: the query is the
76
+ // only explanation for a short list, so closing search restores the
77
+ // full list with it. (A query that arrived from the other style is
78
+ // therefore dropped on the same click.)
79
+ setSearchOpen(false);
80
+ onSearchChange('');
81
+ } else {
82
+ setSearchOpen(true);
83
+ }
84
+ }}
85
+ onSearchChange={onSearchChange}
86
+ onToggleArchived={onToggleArchived}
87
+ onHideArchived={onToggleArchived}
88
+ onToggleOptions={onToggleOptions}
89
+ onCloseOptions={onCloseOptions}
90
+ onSortChange={onSortChange}
91
+ onNewSession={onNewSession}
92
+ onNewWorkspace={onNewWorkspace}
93
+ onScheduler={onScheduler}
94
+ scheduledCount={scheduledCount}
95
+ onRefresh={onRefresh}
96
+ refreshing={refreshing}
97
+ onSelectWorkspaces={onSelectWorkspaces}
98
+ selecting={batchActive}
99
+ />
100
+
101
+ {initializing ? (
102
+ <SessionListSkeleton />
103
+ ) : (
104
+ <SessionSidebarSessionList
105
+ folders={folders}
106
+ activeSessionId={activeSessionId}
107
+ searchQuery={searchQuery}
108
+ showArchived={showArchived}
109
+ sessionStatus={sessionStatus}
110
+ onSelectSession={onSelectSession}
111
+ onNewSessionForFolder={onNewSessionForFolder}
112
+ onNewWorktreeSession={onNewWorktreeSession}
113
+ onToast={onToast}
114
+ batch={batch}
115
+ onStartSessionSelection={onStartSessionSelection}
116
+ onCancelWait={onCancelWait}
117
+ />
118
+ )}
119
+ </div>
120
+ );
121
+ }
@@ -2,48 +2,49 @@ import { useState } from 'preact/hooks';
2
2
  import { useSearchParams } from '@/client/lib/router/search-params';
3
3
  import { NewWorkspaceModal } from '@/client/components/layout/session-sidebar/Modals';
4
4
  import { SchedulerModal } from '@/client/components/layout/session-sidebar/scheduler-modal';
5
- import { SessionSidebarToolbar } from '@/client/components/layout/session-sidebar/Toolbar';
6
- import { SessionSidebarSessionList } from '@/client/components/layout/session-sidebar/SessionList';
7
- import { SessionListSkeleton } from '@/client/components/layout/session-sidebar/Skeleton';
5
+ import { ClassicSidebarView } from '@/client/components/layout/session-sidebar/ClassicView';
6
+ import { ModernSidebarView } from '@/client/components/layout/session-sidebar/modern';
8
7
  import { ToastStack } from '@/client/components/common/ToastStack';
9
8
  import { spawnCwdForNewSession, triggerSessionPrewarm } from '@/shared/lib/omp/session/prewarm';
10
9
  import { useToasts } from '@/client/hooks/ui/toasts';
11
10
  import { useSessionSidebarController } from '@/client/hooks/chat/omp/session-sidebar-controller';
11
+ import { useSidebarStyle } from '@/client/hooks/workspace/sidebar-style';
12
12
  import { useCancelWait } from '@/client/hooks/chat/waiting/cancel';
13
13
  import { useWaitingDispatch } from '@/client/hooks/chat/waiting/dispatch';
14
14
  import { startPendingSession } from '@/client/hooks/chat/omp/pending-sessions';
15
15
  import { setSessionKey } from '@/shared/lib/workspace/session-state/store';
16
16
  import { useScheduledTaskCount } from '@/client/hooks/workspace/scheduled-tasks';
17
17
  import { cloneWorkspaceFolder, createWorkspaceFolder } from '@/client/hooks/workspace/new-workspace';
18
- import { useBatchSelection } from '@/client/hooks/workspace/batch-selection';
19
- import { useBatchDeleteRun } from '@/client/hooks/workspace/batch-delete-run';
18
+ import { useSidebarBatch } from '@/client/hooks/workspace/sidebar-batch';
19
+ import { archiveOutcomeMessage } from '@/client/hooks/workspace/batch-archive';
20
20
  import { BatchActionBar } from '@/client/components/common/batch-selection/BatchActionBar';
21
21
  import { BatchDeleteModal } from '@/client/components/common/batch-selection/BatchDeleteModal';
22
- import type { BatchBinding } from '@/client/components/common/batch-selection/types';
23
- import { liveSelection, selectableSessionIds } from '@/shared/lib/workspace/batch-select';
22
+ import type { SessionSidebarVariantProps } from '@/client/components/layout/session-sidebar/variant-props';
24
23
 
25
24
  /**
26
- * The session list — the left dock's own view.
25
+ * The session list — the left dock's own view, and the ONE owner of its data.
27
26
  *
28
- * It used to BE the left column. The column is a dock now, and this is the view
29
- * that fills it unless the user places a plugin panel there; the strip below it
30
- * (Settings · About · the APK offer) is the DOCK's, not this view's, because
31
- * those controls act on Kabmo rather than on the list.
27
+ * This file is a dispatcher, not a layout. It reads the controller, holds the
28
+ * search/archive/sort state, runs the batch machine, and renders the dialogs
29
+ * and toasts. Two chrome variants draw the result — `classic` (the layout Kabmo
30
+ * shipped before the style setting) and `modern` — and each receives exactly
31
+ * the same `SessionSidebarVariantProps`. That is the whole design: a style
32
+ * chooses a frame, never a behaviour, so an action added here exists in both
33
+ * and a style cannot grow a private copy of one.
32
34
  *
33
- * Three things are deliberately NOT here any more:
35
+ * Three things are deliberately NOT here:
34
36
  *
35
- * - **The header.** It is the COLUMN's title row now, and it spans the rail too
36
- * (see `LeftColumn`): a title that stopped at the dock body would leave the
37
- * rail starting above it, with a gap under the app's own titlebar.
37
+ * - **The header.** It is the COLUMN's title row (`LeftColumn`), spanning the
38
+ * rail too: a title that stopped at the dock body would leave the rail
39
+ * starting above it, with a gap under the app's own titlebar.
38
40
  * - **The footer.** It is dock furniture, and a plugin view on the same dock
39
41
  * must not take it away — moving to a plugin panel would otherwise lose the
40
42
  * only visible way into Settings.
41
43
  * - **The update popup and the About modal it hands over to.** Both are app
42
- * level: they are about the console, not about one view, and the dock renders
43
- * them so they survive a view switch.
44
+ * level, and the dock renders them so they survive a view switch.
44
45
  *
45
- * Everything else — the header's collapse control, the toolbar, the batch bar,
46
- * the workspace and scheduler dialogs — belongs to the list and stays.
46
+ * The batch bar is drawn HERE rather than inside a variant: it is the same bar
47
+ * in both styles, and a style that owned it could forget to.
47
48
  */
48
49
  export function SessionsView({
49
50
  className = '',
@@ -72,6 +73,9 @@ export function SessionsView({
72
73
  handleSelectSession,
73
74
  } = useSessionSidebarController(appSettings, { expandSearchMatches: true });
74
75
  const [, setSearchParams] = useSearchParams();
76
+ // The style the user chose. Live: the settings modal announces a change and
77
+ // this subscription redraws the column behind it.
78
+ const sidebarStyle = useSidebarStyle();
75
79
 
76
80
  const [newWorkspaceOpen, setNewWorkspaceOpen] = useState(false);
77
81
  const [schedulerOpen, setSchedulerOpen] = useState(false);
@@ -81,43 +85,27 @@ export function SessionsView({
81
85
  // Follows a held prompt to its session — in whichever tab or instance sent it.
82
86
  useWaitingDispatch({ onNotice: pushToast });
83
87
 
84
- const [isSearchVisible, setIsSearchVisible] = useState(false);
85
-
86
88
  // Batch selection: two separate modes (sessions from a workspace's `⋯` menu,
87
- // workspaces from the toolbar). `batchDelete.pending` holds the ids the
88
- // confirmation dialog is about; the bar's Delete opens it and never deletes
89
- // on its own.
90
- const batch = useBatchSelection();
91
- const batchDelete = useBatchDeleteRun(refreshNow);
92
-
93
- const scopeFolder = batch.scopeFolderId === null
94
- ? null
95
- : processedFolders.find((folder) => folder.id === batch.scopeFolderId) ?? null;
96
- const batchAvailable = batch.mode === 'workspace'
97
- ? processedFolders.map((folder) => String(folder.id))
98
- : batch.mode === 'session'
99
- ? selectableSessionIds(scopeFolder?.sessions ?? [], showArchived)
100
- : [];
101
- // The count and the payload are the LIVE selection: an id that vanished from
102
- // the list (deleted in another tab, filtered away) is not something this bar
103
- // may still claim, and not something Delete may still send.
104
- const batchSelected = liveSelection(batch.selected, batchAvailable);
89
+ // workspaces from the toolbar). The machine, the live pruned payload and the
90
+ // confirmation dialog's state all come from one hook shared with the phone
91
+ // drawer, so the two layouts cannot count or send a different set.
92
+ const batch = useSidebarBatch(processedFolders, showArchived, refreshNow);
93
+ const { selection, deleteRun, archiveRun, binding: batchBinding, scopeFolder, available: batchAvailable, selected: batchSelected } = batch;
105
94
 
106
- const batchBinding: BatchBinding | undefined = batch.mode
107
- ? {
108
- mode: batch.mode,
109
- scopeFolderId: batch.scopeFolderId,
110
- selected: batch.selected,
111
- toggle: batch.toggle,
112
- selectAllOf: batch.selectAllOf,
113
- unselectAllOf: batch.unselectAllOf,
114
- summaryOf: batch.summaryOf,
115
- }
116
- : undefined;
117
-
118
- const startWorkspaceSelection = () => {
119
- if (batch.mode === 'workspace') batch.end();
120
- else batch.begin('workspace');
95
+ /**
96
+ * Archive the selection. Reversible, so there is no confirmation dialog: the
97
+ * rows move to the archive view, the sidebar refreshes once from the server's
98
+ * own signal, and the run reports itself as one toast. A request-level error
99
+ * keeps the selection so the user can retry; a completed run leaves the mode
100
+ * because the rows it named are no longer in this list.
101
+ */
102
+ const handleArchiveSelected = () => {
103
+ void archiveRun.archive(batchSelected).then((result) => {
104
+ if (!result) return;
105
+ const report = archiveOutcomeMessage(result);
106
+ if (report) pushToast(report.message, report.tone);
107
+ if (!result.error) selection.end();
108
+ });
121
109
  };
122
110
 
123
111
  /** The folder whose context a new session will inherit — same resolution
@@ -186,62 +174,61 @@ export function SessionsView({
186
174
  }, { replace: true });
187
175
  };
188
176
 
177
+ const variantProps: SessionSidebarVariantProps = {
178
+ // The chrome fills the column; the batch bar, when it exists, is a sibling
179
+ // below it. `className` from the dock is the variant's own.
180
+ className: `flex-1 min-h-0 w-full ${className}`,
181
+ folders: processedFolders,
182
+ initializing,
183
+ activeSessionId,
184
+ sessionStatus,
185
+ searchQuery,
186
+ onSearchChange: setSearchQuery,
187
+ showArchived,
188
+ onToggleArchived: () => setShowArchived(!showArchived),
189
+ sortOption,
190
+ optionsOpen,
191
+ onToggleOptions: () => setOptionsOpen(!optionsOpen),
192
+ onCloseOptions: () => setOptionsOpen(false),
193
+ onSortChange: handleSortChange,
194
+ onRefresh: refreshNow,
195
+ refreshing: isRefreshing,
196
+ scheduledCount,
197
+ onNewSession: handleNewSession,
198
+ onNewWorkspace: () => setNewWorkspaceOpen(true),
199
+ onScheduler: () => setSchedulerOpen(true),
200
+ onSelectSession: handleSelectSession,
201
+ onNewSessionForFolder: handleNewSessionForFolder,
202
+ onNewWorktreeSession: handleNewWorktreeSession,
203
+ onToast: pushToast,
204
+ onCancelWait: cancelWait,
205
+ batch: batchBinding,
206
+ onSelectWorkspaces: batch.toggleWorkspaceSelection,
207
+ onStartSessionSelection: (folderId) => selection.begin('session', folderId),
208
+ };
209
+
189
210
  return (
190
211
  <>
191
- <div className={`flex flex-col h-full ${className}`}>
192
- <SessionSidebarToolbar
193
- isSearchVisible={isSearchVisible}
194
- searchQuery={searchQuery}
195
- showArchived={showArchived}
196
- optionsOpen={optionsOpen}
197
- sortOption={sortOption}
198
- onToggleSearch={() => setIsSearchVisible(!isSearchVisible)}
199
- onSearchChange={setSearchQuery}
200
- onToggleArchived={() => setShowArchived(!showArchived)}
201
- onHideArchived={() => setShowArchived(false)}
202
- onToggleOptions={() => setOptionsOpen(!optionsOpen)}
203
- onCloseOptions={() => setOptionsOpen(false)}
204
- onSortChange={handleSortChange}
205
- onNewSession={handleNewSession}
206
- onNewWorkspace={() => setNewWorkspaceOpen(true)}
207
- onScheduler={() => setSchedulerOpen(true)}
208
- scheduledCount={scheduledCount}
209
- onRefresh={refreshNow}
210
- refreshing={isRefreshing}
211
- onSelectWorkspaces={startWorkspaceSelection}
212
- selecting={batch.mode !== null}
213
- />
214
-
215
- {initializing ? (
216
- <SessionListSkeleton />
212
+ <div className="flex flex-col h-full">
213
+ {sidebarStyle === 'modern' ? (
214
+ <ModernSidebarView {...variantProps} />
217
215
  ) : (
218
- <SessionSidebarSessionList
219
- folders={processedFolders}
220
- activeSessionId={activeSessionId}
221
- searchQuery={searchQuery}
222
- showArchived={showArchived}
223
- sessionStatus={sessionStatus}
224
- onSelectSession={handleSelectSession}
225
- onNewSessionForFolder={handleNewSessionForFolder}
226
- onNewWorktreeSession={handleNewWorktreeSession}
227
- onToast={pushToast}
228
- batch={batchBinding}
229
- onStartSessionSelection={(folderId) => batch.begin('session', folderId)}
230
- onCancelWait={cancelWait}
231
- />
216
+ <ClassicSidebarView {...variantProps} />
232
217
  )}
233
218
 
234
- {batch.mode && (
219
+ {selection.mode && (
235
220
  <BatchActionBar
236
- mode={batch.mode}
221
+ mode={selection.mode}
237
222
  count={batchSelected.length}
238
223
  total={batchAvailable.length}
239
- busy={batchDelete.isDeleting}
224
+ busy={deleteRun.isDeleting}
225
+ archiving={archiveRun.isArchiving}
240
226
  scopeLabel={scopeFolder?.name}
241
- onSelectAll={() => batch.selectAllOf(batchAvailable)}
242
- onUnselectAll={() => batch.unselectAllOf(batchAvailable)}
243
- onDelete={() => batchDelete.request(batchSelected)}
244
- onCancel={batch.end}
227
+ onSelectAll={() => selection.selectAllOf(batchAvailable)}
228
+ onUnselectAll={() => selection.unselectAllOf(batchAvailable)}
229
+ onDelete={() => deleteRun.request(batchSelected)}
230
+ onArchive={handleArchiveSelected}
231
+ onCancel={selection.end}
245
232
  />
246
233
  )}
247
234
  </div>
@@ -249,25 +236,25 @@ export function SessionsView({
249
236
  {/* Batch delete confirmation. It stays open on a refusal so the reasons
250
237
  can be read; a fully successful run closes itself and leaves the mode. */}
251
238
  <BatchDeleteModal
252
- mode={batch.mode ?? 'session'}
253
- count={batchDelete.pending.length}
239
+ mode={selection.mode ?? 'session'}
240
+ count={deleteRun.pending.length}
254
241
  scopeLabel={scopeFolder?.name}
255
- isDeleting={batchDelete.isDeleting}
256
- outcome={batchDelete.outcome}
242
+ isDeleting={deleteRun.isDeleting}
243
+ outcome={deleteRun.outcome}
257
244
  onClose={() => {
258
245
  // A run that finished cleanly also ends the mode; one that refused
259
246
  // ids keeps it, so the rows that survived are still selected for a
260
247
  // second attempt.
261
- const refusedCount = batchDelete.outcome?.refused.length ?? 0;
262
- batchDelete.cancel();
263
- if (batchDelete.outcome && refusedCount === 0) batch.end();
248
+ const refusedCount = deleteRun.outcome?.refused.length ?? 0;
249
+ deleteRun.cancel();
250
+ if (deleteRun.outcome && refusedCount === 0) selection.end();
264
251
  }}
265
252
  onConfirm={() => {
266
- const mode = batch.mode ?? 'session';
267
- void batchDelete.confirm(mode).then((result) => {
253
+ const mode = selection.mode ?? 'session';
254
+ void deleteRun.confirm(mode).then((result) => {
268
255
  // A finished run leaves the mode; a refused one keeps it so the
269
256
  // remaining rows are still selectable for a second attempt.
270
- if (result && result.refused.length === 0) batch.end();
257
+ if (result && result.refused.length === 0) selection.end();
271
258
  });
272
259
  }}
273
260
  />
@@ -254,12 +254,12 @@ export function SessionSidebarToolbar({
254
254
 
255
255
  {/* Archive Status Pill */}
256
256
  {showArchived && (
257
- <div className="flex items-center justify-between bg-amber-500/10 border border-amber-500/20 text-amber-900 rounded px-2.5 py-1.5 text-[10px] font-medium">
257
+ <div className="flex items-center justify-between bg-warning/10 border border-warning/25 text-warning rounded px-2.5 py-1.5 text-[10px] font-medium">
258
258
  <div className="flex items-center space-x-1.5">
259
259
  <Archive size={10} />
260
260
  <span>Showing Archived</span>
261
261
  </div>
262
- <button className="hover:text-amber-950" onClick={onHideArchived}>
262
+ <button className="hover:text-warning-hover" onClick={onHideArchived}>
263
263
  <X size={10} />
264
264
  </button>
265
265
  </div>
@@ -0,0 +1,149 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The `modern` sidebar's action row: the primary action, then the actions.
8
+ *
9
+ * The classic toolbar spends its width on seven boxed controls and moves
10
+ * whatever does not fit into a `⋯` menu measured against the panel's own width
11
+ * (`sidebarToolbarCapacity`). That arithmetic exists because a row of BORDERS
12
+ * cannot wrap. Here the split is by meaning instead:
13
+ *
14
+ * - **New Session** is the primary action and keeps its label at every width.
15
+ * - **New Workspace**, **Scheduled** and **Refresh** are ACTIONS: bare glyphs in
16
+ * one cluster, so they cost 28px each instead of 28 + a border, and the row
17
+ * survives 264px without a measured overflow menu.
18
+ * - **Sort** is a menu, and it says which order it is in — the classic toolbar
19
+ * can only show that through a pressed tint on an arrow glyph.
20
+ *
21
+ * Nothing here is a filter or a mode: search, focus, archive and batch selection
22
+ * all live in the search line and the filter row above (`FilterChips`, which
23
+ * picks between a trailing glyph and a fourth chip by measured width).
24
+ */
25
+
26
+ import { ArrowUpDown, Calendar, FolderPlus, Plus, RefreshCw } from 'lucide-preact';
27
+ import { SortMenu } from '@/client/components/common/sort-menu';
28
+ import type { SessionSortOption } from '@/shared/types';
29
+
30
+ export interface SidebarActionRowProps {
31
+ onNewSession: () => void;
32
+ onNewWorkspace: () => void;
33
+ onScheduler: () => void;
34
+ scheduledCount: number;
35
+ onRefresh: () => void;
36
+ refreshing: boolean;
37
+ sortOption: SessionSortOption;
38
+ optionsOpen: boolean;
39
+ onToggleOptions: () => void;
40
+ onCloseOptions: () => void;
41
+ onSortChange: (option: SessionSortOption) => void;
42
+ /** Taller controls for a touch row. */
43
+ touch?: boolean;
44
+ }
45
+
46
+ const GLYPH = 'shrink-0 inline-flex items-center justify-center rounded-md text-ink/55 transition-colors cursor-pointer hover:bg-ink/[0.06] hover:text-ink';
47
+ const GLYPH_ON = 'bg-ink/10 text-ink';
48
+
49
+ const SORT_LABEL: Record<SessionSortOption, string> = {
50
+ 'A-Z': 'A–Z',
51
+ 'Z-A': 'Z–A',
52
+ LATEST_SESSION: 'Latest chat',
53
+ LATEST_ADDED: 'Latest added',
54
+ };
55
+
56
+ export function SidebarActionRow({
57
+ onNewSession,
58
+ onNewWorkspace,
59
+ onScheduler,
60
+ scheduledCount,
61
+ onRefresh,
62
+ refreshing,
63
+ sortOption,
64
+ optionsOpen,
65
+ onToggleOptions,
66
+ onCloseOptions,
67
+ onSortChange,
68
+ touch = false,
69
+ }: SidebarActionRowProps) {
70
+ const glyph = `${GLYPH} ${touch ? 'h-9 w-9' : 'h-7 w-7'}`;
71
+ const schedulerLabel = scheduledCount > 0 ? `Scheduled tasks (${scheduledCount} armed)` : 'Scheduled tasks';
72
+
73
+ return (
74
+ <div className="flex items-center gap-1 px-3 pb-2">
75
+ <button
76
+ type="button"
77
+ onClick={onNewSession}
78
+ title="New Session"
79
+ aria-label="New Session"
80
+ className={`flex min-w-0 flex-1 items-center justify-center gap-1.5 rounded-md bg-ink px-2 font-semibold text-canvas transition-colors cursor-pointer hover:bg-ink/90 ${
81
+ touch ? 'h-9 text-[13px]' : 'h-7 text-xs'
82
+ }`}
83
+ >
84
+ <Plus size={touch ? 16 : 14} className="shrink-0" />
85
+ <span className="truncate">New Session</span>
86
+ </button>
87
+
88
+ <div className="flex shrink-0 items-center gap-0.5">
89
+ <button
90
+ type="button"
91
+ onClick={onNewWorkspace}
92
+ title="New Workspace"
93
+ aria-label="New Workspace"
94
+ className={glyph}
95
+ >
96
+ <FolderPlus size={touch ? 16 : 14} />
97
+ </button>
98
+
99
+ <button
100
+ type="button"
101
+ onClick={onScheduler}
102
+ title={schedulerLabel}
103
+ aria-label={scheduledCount > 0 ? `Scheduled tasks, ${scheduledCount} armed` : 'Scheduled tasks'}
104
+ className={`relative ${glyph}`}
105
+ >
106
+ <Calendar size={touch ? 16 : 14} />
107
+ {scheduledCount > 0 && (
108
+ <span className="absolute right-0.5 top-0.5 min-w-[10px] rounded-full bg-ink px-[2px] text-center text-[7px] font-semibold leading-[10px] text-canvas">
109
+ {scheduledCount > 9 ? '9+' : scheduledCount}
110
+ </span>
111
+ )}
112
+ </button>
113
+
114
+ <button
115
+ type="button"
116
+ onClick={onRefresh}
117
+ title="Refresh sessions"
118
+ aria-label="Refresh sessions"
119
+ aria-busy={refreshing}
120
+ className={glyph}
121
+ >
122
+ <RefreshCw size={touch ? 16 : 14} className={refreshing ? 'animate-spin' : ''} />
123
+ </button>
124
+
125
+ <div className="relative">
126
+ <button
127
+ type="button"
128
+ onClick={onToggleOptions}
129
+ title={`Sort: ${SORT_LABEL[sortOption]}`}
130
+ aria-label={`Sort workspaces, currently ${SORT_LABEL[sortOption]}`}
131
+ aria-haspopup="menu"
132
+ aria-expanded={optionsOpen}
133
+ className={`${glyph} ${optionsOpen || sortOption !== 'A-Z' ? GLYPH_ON : ''}`}
134
+ >
135
+ <ArrowUpDown size={touch ? 16 : 14} />
136
+ </button>
137
+ {optionsOpen && (
138
+ <div
139
+ className="absolute right-0 top-full z-50 mt-1 w-48 rounded-lg border border-ink/15 bg-paper py-1 shadow-lg"
140
+ onMouseLeave={onCloseOptions}
141
+ >
142
+ <SortMenu variant="desktop" sortOption={sortOption} onSortChange={onSortChange} />
143
+ </div>
144
+ )}
145
+ </div>
146
+ </div>
147
+ </div>
148
+ );
149
+ }