@kabmo-labs/kabmo 0.13.0 → 0.14.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.
Files changed (133) 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-vzb1qz51.js → index-nfsg1jpt.js} +779 -779
  4. package/dist/client/static/js/index-tsgy3gd1.css +1 -0
  5. package/package.json +1 -1
  6. package/src/client/components/common/batch-selection/BatchActionBar.test.ts +42 -5
  7. package/src/client/components/common/batch-selection/BatchActionBar.tsx +57 -14
  8. package/src/client/components/common/code-surface/extensions.ts +7 -1
  9. package/src/client/components/common/code-surface/fold-placeholder.ts +43 -0
  10. package/src/client/components/common/session-row/StatusSlot.tsx +133 -0
  11. package/src/client/components/common/session-row/TrailingSlot.tsx +84 -0
  12. package/src/client/components/common/session-row/index.tsx +205 -0
  13. package/src/client/components/common/session-row/session-row.test.tsx +144 -0
  14. package/src/client/components/layout/session-sidebar/ClassicView.tsx +121 -0
  15. package/src/client/components/layout/session-sidebar/SessionsView.tsx +99 -112
  16. package/src/client/components/layout/session-sidebar/Toolbar.tsx +2 -2
  17. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +149 -0
  18. package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +150 -0
  19. package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +75 -0
  20. package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +55 -0
  21. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +184 -0
  22. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +333 -0
  23. package/src/client/components/layout/session-sidebar/modern/index.tsx +147 -0
  24. package/src/client/components/layout/session-sidebar/variant-props.ts +73 -0
  25. package/src/client/components/mobile/SessionSidebar.tsx +137 -146
  26. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +140 -0
  27. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +3 -3
  28. package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +104 -0
  29. package/src/client/components/settings/Modal.tsx +5 -27
  30. package/src/client/components/settings/Sidebar.tsx +1 -1
  31. package/src/client/components/settings/apply-side-effects.test.ts +102 -0
  32. package/src/client/components/settings/apply-side-effects.ts +90 -0
  33. package/src/client/components/settings/categories/AppearanceSettings.tsx +11 -1
  34. package/src/client/components/settings/categories/ChatSettings.test.tsx +121 -0
  35. package/src/client/components/settings/categories/ChatSettings.tsx +80 -15
  36. package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +157 -0
  37. package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +177 -0
  38. package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +1 -1
  39. package/src/client/components/settings/categories/chat-settings/SidebarList.tsx +73 -0
  40. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +144 -0
  41. package/src/client/components/settings/categories/chat-settings/groups.test.ts +42 -0
  42. package/src/client/components/settings/categories/chat-settings/groups.ts +81 -0
  43. package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +1 -68
  44. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +7 -0
  45. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
  46. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -5
  47. package/src/client/components/workspace/chat-timeline/MessageList.tsx +90 -41
  48. package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +13 -6
  49. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +108 -67
  50. package/src/client/components/workspace/chat-timeline/ToolCallingSection.test.ts +28 -8
  51. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +48 -4
  52. package/src/client/components/workspace/chat-timeline/TurnRail.tsx +64 -0
  53. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +158 -0
  54. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -1
  55. package/src/client/components/workspace/chat-timeline/chat-input/ComposerNotice.tsx +50 -0
  56. package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +178 -0
  57. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +1 -1
  58. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +102 -122
  59. package/src/client/components/workspace/chat-timeline/chat-input/props.ts +7 -0
  60. package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +111 -0
  61. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +181 -0
  62. package/src/client/components/workspace/chat-timeline/index.tsx +3 -0
  63. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -0
  64. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/approval-gate.test.tsx +31 -0
  65. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +1 -1
  66. package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -2
  67. package/src/client/components/workspace/chat-timeline/tool-renderers/plugin-renderers.ts +6 -1
  68. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +98 -0
  69. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell.tsx +3 -1
  70. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph.tsx +56 -0
  71. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +19 -0
  72. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +132 -0
  73. package/src/client/components/workspace/chat-timeline/{ToolCallCard.plugin.test.ts → tool-renderers/styles/Card.plugin.test.ts} +3 -3
  74. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +60 -0
  75. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +89 -0
  76. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +72 -0
  77. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +84 -0
  78. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +22 -0
  79. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +153 -0
  80. package/src/client/components/workspace/diff-panel/folding.ts +6 -1
  81. package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +86 -12
  82. package/src/client/components/workspace/model-dropdown/Item.tsx +56 -19
  83. package/src/client/components/workspace/model-dropdown/Panel.tsx +21 -13
  84. package/src/client/components/workspace/model-dropdown/Section.test.tsx +114 -4
  85. package/src/client/components/workspace/model-dropdown/Section.tsx +21 -9
  86. package/src/client/components/workspace/model-dropdown/groups.test.ts +164 -1
  87. package/src/client/components/workspace/model-dropdown/groups.ts +94 -17
  88. package/src/client/components/workspace/model-dropdown/index.tsx +27 -19
  89. package/src/client/data/settings/omp-schema.json +151 -6
  90. package/src/client/hooks/chat/composer/style.ts +66 -0
  91. package/src/client/hooks/chat/timeline/tool-render-mode.ts +65 -0
  92. package/src/client/hooks/settings/providers/login.ts +11 -2
  93. package/src/client/hooks/ui/window-event.ts +20 -4
  94. package/src/client/hooks/workspace/batch-archive-run.ts +47 -0
  95. package/src/client/hooks/workspace/batch-archive.test.ts +59 -0
  96. package/src/client/hooks/workspace/batch-archive.ts +78 -0
  97. package/src/client/hooks/workspace/sidebar-batch.ts +95 -0
  98. package/src/client/hooks/workspace/sidebar-style.ts +66 -0
  99. package/src/client/tailwind.css +111 -0
  100. package/src/server/index.ts +10 -134
  101. package/src/server/lib/lifecycle/after-listen.ts +178 -0
  102. package/src/server/lib/lifecycle/rejection-guard.test.ts +79 -0
  103. package/src/server/lib/lifecycle/rejection-guard.ts +74 -0
  104. package/src/server/lib/lifecycle/tls.test.ts +7 -7
  105. package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +131 -0
  106. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +46 -0
  107. package/src/server/lib/omp/rpc/frame-fold.test.ts +1 -100
  108. package/src/server/lib/omp/rpc/frame-fold.ts +13 -0
  109. package/src/server/lib/plugins/background.server.ts +17 -1
  110. package/src/server/lib/plugins/background.test.ts +33 -0
  111. package/src/server/routes/sessions/batch-archive.test.ts +113 -0
  112. package/src/server/routes/sessions/batch-archive.ts +80 -0
  113. package/src/server/routes/sessions/index.ts +4 -0
  114. package/src/shared/lib/chat/composer/style.test.ts +126 -0
  115. package/src/shared/lib/chat/composer/style.ts +171 -0
  116. package/src/shared/lib/chat/composer/tui-only.test.ts +3 -0
  117. package/src/shared/lib/chat/composer/tui-only.ts +5 -0
  118. package/src/shared/lib/chat/timeline/block-chrome.ts +129 -0
  119. package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +51 -0
  120. package/src/shared/lib/chat/timeline/tool-render-mode.ts +74 -0
  121. package/src/shared/lib/chat/timeline/trace-groups.test.ts +120 -0
  122. package/src/shared/lib/chat/timeline/trace-groups.ts +68 -0
  123. package/src/shared/lib/settings/defaults.ts +6 -0
  124. package/src/shared/lib/workspace/session-focus.test.ts +93 -0
  125. package/src/shared/lib/workspace/session-focus.ts +71 -0
  126. package/src/shared/lib/workspace/sidebar-filter-row.test.ts +73 -0
  127. package/src/shared/lib/workspace/sidebar-filter-row.ts +86 -0
  128. package/src/shared/lib/workspace/sidebar-style.test.ts +58 -0
  129. package/src/shared/lib/workspace/sidebar-style.ts +86 -0
  130. package/src/shared/types/omp/agent.ts +6 -0
  131. package/src/shared/types/settings/state.ts +31 -0
  132. package/dist/client/static/js/index-68w8h33q.css +0 -1
  133. package/src/client/components/workspace/chat-timeline/ToolCallCard.tsx +0 -194
@@ -1,30 +1,45 @@
1
- import { useEffect, useRef, useState } from 'preact/hooks';
1
+ import { useState } from 'preact/hooks';
2
2
  import { MobileSessionHeader } from '@/client/components/mobile/mobile-session-sidebar/Header';
3
- import { MobileSessionToolbar } from '@/client/components/mobile/mobile-session-sidebar/Toolbar';
4
- import { MobileSessionList } from '@/client/components/mobile/mobile-session-sidebar/List';
3
+ import { ClassicDrawer } from '@/client/components/mobile/mobile-session-sidebar/ClassicDrawer';
4
+ import { ModernSidebarView } from '@/client/components/layout/session-sidebar/modern';
5
5
  import { MobileSessionFooter } from '@/client/components/mobile/mobile-session-sidebar/Footer';
6
6
  import { useShellOffer } from '@/client/hooks/ui/updates/shell-download';
7
- import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
8
7
  import { useKabmoEvent } from '@/client/hooks/ui/window-event';
9
8
  import { useToasts } from '@/client/hooks/ui/toasts';
10
9
  import { useCancelWait } from '@/client/hooks/chat/waiting/cancel';
11
10
  import { useWaitingDispatch } from '@/client/hooks/chat/waiting/dispatch';
12
11
  import { useUpdates } from '@/client/hooks/ui/updates';
12
+ import { useSidebarStyle } from '@/client/hooks/workspace/sidebar-style';
13
13
  import { UPDATE_REQUEST_EVENT } from '@/shared/lib/updates/popup-state';
14
- import { useSessionSidebarController } from '@/client/hooks/chat/omp/session-sidebar-controller';
15
14
  import { useScheduledTaskCount } from '@/client/hooks/workspace/scheduled-tasks';
16
- import { MobileSessionListSkeleton } from '@/client/components/mobile/mobile-session-sidebar/Skeleton';
17
- import { useBatchSelection } from '@/client/hooks/workspace/batch-selection';
18
- import { useBatchDeleteRun } from '@/client/hooks/workspace/batch-delete-run';
19
- import { setFolderExpanded } from '@/client/hooks/workspace/folder-expansion';
20
15
  import { phoneLeftStripVisible } from '@/shared/lib/workspace/mobile-dock';
21
- import { dockBodyProps, useMobileDock } from '@/client/components/mobile/mobile-session-sidebar/use-dock';
22
16
  import { MobileDockBody, MobileDockStrip } from '@/client/components/mobile/mobile-session-sidebar/Dock';
23
17
  import { MobileDrawerDialogs } from '@/client/components/mobile/mobile-session-sidebar/Dialogs';
18
+ import { useDrawerState } from '@/client/components/mobile/mobile-session-sidebar/use-drawer';
19
+ import { archiveOutcomeMessage } from '@/client/hooks/workspace/batch-archive';
24
20
  import { BatchActionBar } from '@/client/components/common/batch-selection/BatchActionBar';
25
- import type { BatchBinding } from '@/client/components/common/batch-selection/types';
26
- import { liveSelection, selectableSessionIds } from '@/shared/lib/workspace/batch-select';
21
+ import type { SessionSidebarVariantProps } from '@/client/components/layout/session-sidebar/variant-props';
27
22
 
23
+ /**
24
+ * The phone's session drawer — the dispatcher, exactly like the desktop
25
+ * `SessionsView`.
26
+ *
27
+ * It owns the controller, the folder expansion, the batch machine and the
28
+ * dialogs; two chromes draw the list. `classic` is the drawer that shipped
29
+ * before the style setting (`ClassicDrawer`), `modern` is the same
30
+ * `ModernSidebarView` the desktop dock uses with `touch` density — NOT a second
31
+ * phone implementation, so a row drawn here and a row drawn on a desktop are
32
+ * the same component at two sizes.
33
+ *
34
+ * Two rules the drawer carries into both styles:
35
+ *
36
+ * - **The list is hidden, never unmounted, while a placed panel is on screen**
37
+ * (the same rule the desktop dock follows): its folder expansion, scroll
38
+ * position and batch selection must survive a look at another view, and a
39
+ * re-mount would re-seed every expansion from the server's flags.
40
+ * - **New Session closes the drawer.** The pending chat is opened behind it, so
41
+ * the user lands on the chat rather than on the list they just acted on.
42
+ */
28
43
  interface MobileSessionSidebarProps {
29
44
  activeSessionId: number | string | null;
30
45
  onSelectSession: (id: number | string) => void;
@@ -57,8 +72,16 @@ export function MobileSessionSidebar({
57
72
  onRefresh,
58
73
  onOpenFile,
59
74
  }: MobileSessionSidebarProps) {
75
+ const { controller, batch, expandedFolders, toggleFolder, optionsRef, dock, dockBody } = useDrawerState({
76
+ appSettings,
77
+ onSelectSession,
78
+ onClose,
79
+ rootPath,
80
+ refreshKey,
81
+ onRefresh,
82
+ onOpenFile,
83
+ });
60
84
  const {
61
- folders,
62
85
  initializing,
63
86
  refreshNow,
64
87
  isRefreshing,
@@ -73,13 +96,9 @@ export function MobileSessionSidebar({
73
96
  processedFolders,
74
97
  sessionStatus,
75
98
  handleSelectSession,
76
- } = useSessionSidebarController(appSettings, { onSelectSession, onAfterSelect: onClose });
77
-
78
- const [expandedFolders, setExpandedFolders] = useState<Record<number, boolean>>({
79
- 1: true,
80
- 2: true,
81
- 3: true
82
- });
99
+ } = controller;
100
+ const { selection, deleteRun, archiveRun, binding: batchBinding, scopeFolder, available, selected } = batch;
101
+ const sidebarStyle = useSidebarStyle();
83
102
 
84
103
  // Modals state (matching desktop)
85
104
  const [newWorkspaceOpen, setNewWorkspaceOpen] = useState(false);
@@ -107,40 +126,23 @@ export function MobileSessionSidebar({
107
126
  });
108
127
  });
109
128
 
110
- const optionsRef = useRef<HTMLDivElement>(null);
111
- useOnClickOutside(optionsRef, () => setOptionsOpen(false));
112
-
113
- const toggleFolder = (folderId: number) => {
114
- setExpandedFolders(prev => ({
115
- ...prev,
116
- [folderId]: !prev[folderId]
117
- }));
118
- const folder = folders.find(item => item.id === folderId);
119
- const nextExpanded = !(expandedFolders[folderId] ?? folder?.isExpanded ?? true);
120
- void setFolderExpanded(folderId, nextExpanded);
121
- };
122
-
123
- // Seeded from the list the drawer RENDERS, not from the raw server payload:
124
- // the controller force-opens a folder that hosts a pending row (a chat whose
125
- // transcript omp has not written yet), and a seed taken from the raw folders
126
- // would collapse it again — hiding the one row the user cannot get back by
127
- // expanding, because nothing else knows it exists.
128
- //
129
- // Keyed on the flags themselves rather than the array: `processedFolders` is
130
- // a new array on every sidebar push (a tool call republishes the structure),
131
- // and re-seeding on identity would discard every expansion the user just
132
- // made, several times a minute.
133
- const expansionSeed = processedFolders.map(folder => `${folder.id}:${folder.isExpanded}`).join('|');
134
- useEffect(() => {
135
- setExpandedFolders(Object.fromEntries(processedFolders.map(folder => [folder.id, folder.isExpanded])));
136
- // eslint-disable-next-line react-hooks/exhaustive-deps
137
- }, [expansionSeed]);
138
-
139
129
  const handleNewSessionAndClose = () => {
140
130
  onNewSession();
141
131
  onClose();
142
132
  };
143
133
 
134
+ // Archive the selection — the same reversible flow the desktop dispatcher
135
+ // runs: no confirmation, one toast, leave the mode once the rows have moved
136
+ // to the archive view. A request-level error keeps the selection to retry.
137
+ const handleArchiveSelected = () => {
138
+ void archiveRun.archive(selected).then((result) => {
139
+ if (!result) return;
140
+ const report = archiveOutcomeMessage(result);
141
+ if (report) pushToast(report.message, report.tone);
142
+ if (!result.error) selection.end();
143
+ });
144
+ };
145
+
144
146
  // Same dismissal as the toolbar's New Session: the pending session is opened
145
147
  // behind the drawer, so the user must land on the chat, not on the list.
146
148
  const handleNewSessionForFolderAndClose = (folderId: number) => {
@@ -148,66 +150,62 @@ export function MobileSessionSidebar({
148
150
  onClose();
149
151
  };
150
152
 
151
- // The Archive button is a sibling of the sort dropdown, not a row inside it,
153
+ // The Archive control is a sibling of the sort dropdown, not a row inside it,
152
154
  // so this no longer has to dismiss the dropdown itself — clicking anywhere
153
- // outside the menu does that already (`useOnClickOutside` below), and doing
154
- // it here as well would be a second answer to the same question.
155
+ // outside the menu does that already, and doing it here as well would be a
156
+ // second answer to the same question.
155
157
  const handleToggleArchived = () => {
156
158
  setShowArchived(!showArchived);
157
159
  };
158
160
 
159
- // Batch selection — same two modes and the same rules as the desktop sidebar
160
- // (the state machine and the confirmation are shared hooks/components).
161
- const batch = useBatchSelection();
162
- const batchDelete = useBatchDeleteRun(refreshNow);
163
-
164
- const scopeFolder = batch.scopeFolderId === null
165
- ? null
166
- : processedFolders.find((folder) => folder.id === batch.scopeFolderId) ?? null;
167
- const batchAvailable = batch.mode === 'workspace'
168
- ? processedFolders.map((folder) => String(folder.id))
169
- : batch.mode === 'session'
170
- ? selectableSessionIds(scopeFolder?.sessions ?? [], showArchived)
171
- : [];
172
- // Same rule as the desktop sidebar: the count and the payload are the LIVE
173
- // selection, so a row removed elsewhere cannot be counted or sent.
174
- const batchSelected = liveSelection(batch.selected, batchAvailable);
175
-
176
- const batchBinding: BatchBinding | undefined = batch.mode
177
- ? {
178
- mode: batch.mode,
179
- scopeFolderId: batch.scopeFolderId,
180
- selected: batch.selected,
181
- toggle: batch.toggle,
182
- selectAllOf: batch.selectAllOf,
183
- unselectAllOf: batch.unselectAllOf,
184
- summaryOf: batch.summaryOf,
161
+ const closeAfterWorktree = onNewWorktreeSession
162
+ ? (id: number, path: string) => {
163
+ onNewWorktreeSession(id, path);
164
+ onClose();
185
165
  }
186
166
  : undefined;
187
167
 
188
- const startWorkspaceSelection = () => {
189
- if (batch.mode === 'workspace') batch.end();
190
- else batch.begin('workspace');
168
+ // The same contract the desktop dispatcher hands its two styles, so the phone
169
+ // and the desktop cannot describe a folder, a row or an action differently.
170
+ const modernProps: SessionSidebarVariantProps = {
171
+ // Fills the drawer between the header and the batch bar, the same way the
172
+ // desktop dispatcher sizes its chrome.
173
+ className: 'flex-1 min-h-0 w-full',
174
+ folders: processedFolders,
175
+ initializing,
176
+ activeSessionId,
177
+ sessionStatus,
178
+ searchQuery,
179
+ onSearchChange: setSearchQuery,
180
+ showArchived,
181
+ onToggleArchived: handleToggleArchived,
182
+ sortOption,
183
+ optionsOpen,
184
+ onToggleOptions: () => setOptionsOpen(!optionsOpen),
185
+ onCloseOptions: () => setOptionsOpen(false),
186
+ onSortChange: handleSortChange,
187
+ onRefresh: refreshNow,
188
+ refreshing: isRefreshing,
189
+ scheduledCount,
190
+ onNewSession: handleNewSessionAndClose,
191
+ onNewWorkspace: () => setNewWorkspaceOpen(true),
192
+ onScheduler: () => setSchedulerOpen(true),
193
+ onSelectSession: handleSelectSession,
194
+ onNewSessionForFolder: handleNewSessionForFolderAndClose,
195
+ onNewWorktreeSession: closeAfterWorktree,
196
+ onToast: pushToast,
197
+ onCancelWait: cancelWait,
198
+ batch: batchBinding,
199
+ onSelectWorkspaces: batch.toggleWorkspaceSelection,
200
+ onStartSessionSelection: (folderId) => selection.begin('session', folderId),
191
201
  };
192
202
 
193
- const dock = useMobileDock();
194
- const showingSessions = dock.showingSessions;
195
- const activeView = dock.activeView;
196
- const dockBody = dockBodyProps({
197
- sessionId: activeSessionId,
198
- refreshKey,
199
- rootPath,
200
- onRefresh,
201
- onOpenFile,
202
- onClose,
203
- });
204
-
205
203
  return (
206
204
  <div className="flex flex-col h-full w-full bg-canvas text-ink relative select-none">
207
205
 
208
206
  <MobileSessionHeader
209
207
  onClose={onClose}
210
- viewLabel={showingSessions ? 'Sessions' : dock.activePanel?.label ?? 'Panel'}
208
+ viewLabel={dock.showingSessions ? 'Sessions' : dock.activePanel?.label ?? 'Panel'}
211
209
  />
212
210
 
213
211
  {/* The strip is the phone's RAIL, so it follows the switch: with the rail
@@ -215,7 +213,7 @@ export function MobileSessionSidebar({
215
213
  always holds Sessions). Requiring a second destination made the
216
214
  Settings switch a no-op on a phone with nothing placed. */}
217
215
  {phoneLeftStripVisible(dock.enabled) ? (
218
- <MobileDockStrip panels={dock.catalog} activeId={activeView} onSelect={dock.setActiveView} />
216
+ <MobileDockStrip panels={dock.catalog} activeId={dock.activeView} onSelect={dock.setActiveView} />
219
217
  ) : null}
220
218
 
221
219
  {/* The list is HIDDEN, never unmounted, while a panel is on screen — the
@@ -223,20 +221,29 @@ export function MobileSessionSidebar({
223
221
  expansion, scroll position and batch selection must survive a look at
224
222
  another view, and a re-mount would also re-seed every expansion from
225
223
  the server's flags. */}
226
- <div className={showingSessions ? 'contents' : 'hidden'}>
227
- <>
228
- <MobileSessionToolbar
224
+ <div className={dock.showingSessions ? 'contents' : 'hidden'}>
225
+ {sidebarStyle === 'modern' ? (
226
+ <ModernSidebarView {...modernProps} touch />
227
+ ) : (
228
+ <ClassicDrawer
229
+ folders={processedFolders}
230
+ initializing={initializing}
231
+ activeSessionId={activeSessionId}
232
+ expandedFolders={expandedFolders}
233
+ sessionStatus={sessionStatus}
229
234
  searchQuery={searchQuery}
230
235
  sortOption={sortOption}
231
236
  optionsOpen={optionsOpen}
232
237
  showArchived={showArchived}
233
238
  optionsRef={optionsRef}
239
+ scheduledCount={scheduledCount}
240
+ refreshing={isRefreshing}
241
+ selecting={selection.mode !== null}
242
+ batch={batchBinding}
234
243
  onNewSession={handleNewSessionAndClose}
235
244
  onNewWorkspace={() => setNewWorkspaceOpen(true)}
236
245
  onScheduler={() => setSchedulerOpen(true)}
237
- scheduledCount={scheduledCount}
238
246
  onRefresh={refreshNow}
239
- refreshing={isRefreshing}
240
247
  onToggleOptions={() => setOptionsOpen(!optionsOpen)}
241
248
  onSortChange={handleSortChange}
242
249
  onResetSort={() => handleSortChange('A-Z')}
@@ -244,52 +251,36 @@ export function MobileSessionSidebar({
244
251
  onHideArchived={() => setShowArchived(false)}
245
252
  onSearchChange={setSearchQuery}
246
253
  onClearSearch={() => setSearchQuery('')}
247
- onSelectWorkspaces={startWorkspaceSelection}
248
- selecting={batch.mode !== null}
254
+ onSelectWorkspaces={batch.toggleWorkspaceSelection}
255
+ onSelectSession={handleSelectSession}
256
+ onNewSessionForFolder={handleNewSessionForFolderAndClose}
257
+ onNewWorktreeSession={closeAfterWorktree}
258
+ onToggleFolder={toggleFolder}
259
+ onToast={pushToast}
260
+ onStartSessionSelection={(folderId) => selection.begin('session', folderId)}
261
+ onCancelWait={cancelWait}
249
262
  />
263
+ )}
250
264
 
251
- {initializing ? (
252
- <MobileSessionListSkeleton />
253
- ) : (
254
- <MobileSessionList
255
- folders={processedFolders}
256
- activeSessionId={activeSessionId}
257
- expandedFolders={expandedFolders}
258
- showArchived={showArchived}
259
- sessionStatus={sessionStatus}
260
- onSelectSession={handleSelectSession}
261
- onNewSessionForFolder={handleNewSessionForFolderAndClose}
262
- onNewWorktreeSession={
263
- onNewWorktreeSession
264
- ? (id, path) => { onNewWorktreeSession(id, path); onClose(); }
265
- : undefined
266
- }
267
- onToggleFolder={toggleFolder}
268
- onToast={pushToast}
269
- batch={batchBinding}
270
- onStartSessionSelection={(folderId) => batch.begin('session', folderId)}
271
- onCancelWait={cancelWait}
272
- />
273
- )}
274
-
275
- {batch.mode && (
276
- <BatchActionBar
277
- drawer
278
- mode={batch.mode}
279
- count={batchSelected.length}
280
- total={batchAvailable.length}
281
- busy={batchDelete.isDeleting}
282
- scopeLabel={scopeFolder?.name}
283
- onSelectAll={() => batch.selectAllOf(batchAvailable)}
284
- onUnselectAll={() => batch.unselectAllOf(batchAvailable)}
285
- onDelete={() => batchDelete.request(batchSelected)}
286
- onCancel={batch.end}
287
- />
288
- )}
289
- </>
265
+ {selection.mode && (
266
+ <BatchActionBar
267
+ drawer
268
+ mode={selection.mode}
269
+ count={selected.length}
270
+ total={available.length}
271
+ busy={deleteRun.isDeleting}
272
+ archiving={archiveRun.isArchiving}
273
+ scopeLabel={scopeFolder?.name}
274
+ onSelectAll={() => selection.selectAllOf(available)}
275
+ onUnselectAll={() => selection.unselectAllOf(available)}
276
+ onDelete={() => deleteRun.request(selected)}
277
+ onArchive={handleArchiveSelected}
278
+ onCancel={selection.end}
279
+ />
280
+ )}
290
281
  </div>
291
- {showingSessions ? null : (
292
- <MobileDockBody panelKey={activeView} panel={dock.activePanel} body={dockBody} />
282
+ {dock.showingSessions ? null : (
283
+ <MobileDockBody panelKey={dock.activeView} panel={dock.activePanel} body={dockBody} />
293
284
  )}
294
285
 
295
286
  <MobileSessionFooter
@@ -314,9 +305,9 @@ export function MobileSessionSidebar({
314
305
  onCloseAbout={() => setAboutOpen(false)}
315
306
  updates={updates}
316
307
  pushToast={pushToast}
317
- batchDelete={batchDelete}
318
- batchMode={batch.mode}
319
- onEndBatch={batch.end}
308
+ batchDelete={deleteRun}
309
+ batchMode={selection.mode}
310
+ onEndBatch={selection.end}
320
311
  scopeLabel={scopeFolder?.name}
321
312
  toasts={toasts}
322
313
  dismissToast={dismissToast}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The phone drawer's `classic` chrome: the toolbar of boxed controls over the
8
+ * drawer's compact rows.
9
+ *
10
+ * Extracted from `SessionSidebar` VERBATIM so the style setting can switch it
11
+ * for the modern chrome without moving any state. The drawer's controller, its
12
+ * folder expansion, its batch machine and its dialogs stay in the dispatcher —
13
+ * this file draws the two rows above the list and nothing else.
14
+ */
15
+
16
+ import type { RefObject } from 'preact/compat';
17
+ import { MobileSessionToolbar } from '@/client/components/mobile/mobile-session-sidebar/Toolbar';
18
+ import { MobileSessionList } from '@/client/components/mobile/mobile-session-sidebar/List';
19
+ import { MobileSessionListSkeleton } from '@/client/components/mobile/mobile-session-sidebar/Skeleton';
20
+ import type { BatchBinding } from '@/client/components/common/batch-selection/types';
21
+ import type { SessionSortOption, WorkspaceFolderData } from '@/shared/types';
22
+
23
+ export interface ClassicDrawerProps {
24
+ folders: WorkspaceFolderData[];
25
+ initializing: boolean;
26
+ activeSessionId: number | string | null;
27
+ expandedFolders: Record<number, boolean>;
28
+ sessionStatus: Record<string, 'stream' | 'finish' | 'abort'>;
29
+ searchQuery: string;
30
+ sortOption: SessionSortOption;
31
+ optionsOpen: boolean;
32
+ showArchived: boolean;
33
+ optionsRef: RefObject<HTMLDivElement>;
34
+ scheduledCount: number;
35
+ refreshing: boolean;
36
+ selecting: boolean;
37
+ batch?: BatchBinding;
38
+ onNewSession: () => void;
39
+ onNewWorkspace: () => void;
40
+ onScheduler: () => void;
41
+ onRefresh: () => void;
42
+ onToggleOptions: () => void;
43
+ onSortChange: (option: SessionSortOption) => void;
44
+ onResetSort: () => void;
45
+ onToggleArchived: () => void;
46
+ onHideArchived: () => void;
47
+ onSearchChange: (value: string) => void;
48
+ onClearSearch: () => void;
49
+ onSelectWorkspaces: () => void;
50
+ onSelectSession: (id: number | string) => void;
51
+ onNewSessionForFolder: (folderId: number) => void;
52
+ onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
53
+ onToggleFolder: (folderId: number) => void;
54
+ onToast: (message: string, type?: 'success' | 'error') => void;
55
+ onStartSessionSelection: (folderId: number) => void;
56
+ onCancelWait?: (waitId: string) => void;
57
+ }
58
+
59
+ export function ClassicDrawer({
60
+ folders,
61
+ initializing,
62
+ activeSessionId,
63
+ expandedFolders,
64
+ sessionStatus,
65
+ searchQuery,
66
+ sortOption,
67
+ optionsOpen,
68
+ showArchived,
69
+ optionsRef,
70
+ scheduledCount,
71
+ refreshing,
72
+ selecting,
73
+ batch,
74
+ onNewSession,
75
+ onNewWorkspace,
76
+ onScheduler,
77
+ onRefresh,
78
+ onToggleOptions,
79
+ onSortChange,
80
+ onResetSort,
81
+ onToggleArchived,
82
+ onHideArchived,
83
+ onSearchChange,
84
+ onClearSearch,
85
+ onSelectWorkspaces,
86
+ onSelectSession,
87
+ onNewSessionForFolder,
88
+ onNewWorktreeSession,
89
+ onToggleFolder,
90
+ onToast,
91
+ onStartSessionSelection,
92
+ onCancelWait,
93
+ }: ClassicDrawerProps) {
94
+ return (
95
+ <>
96
+ <MobileSessionToolbar
97
+ searchQuery={searchQuery}
98
+ sortOption={sortOption}
99
+ optionsOpen={optionsOpen}
100
+ showArchived={showArchived}
101
+ optionsRef={optionsRef}
102
+ onNewSession={onNewSession}
103
+ onNewWorkspace={onNewWorkspace}
104
+ onScheduler={onScheduler}
105
+ scheduledCount={scheduledCount}
106
+ onRefresh={onRefresh}
107
+ refreshing={refreshing}
108
+ onToggleOptions={onToggleOptions}
109
+ onSortChange={onSortChange}
110
+ onResetSort={onResetSort}
111
+ onToggleArchived={onToggleArchived}
112
+ onHideArchived={onHideArchived}
113
+ onSearchChange={onSearchChange}
114
+ onClearSearch={onClearSearch}
115
+ onSelectWorkspaces={onSelectWorkspaces}
116
+ selecting={selecting}
117
+ />
118
+
119
+ {initializing ? (
120
+ <MobileSessionListSkeleton />
121
+ ) : (
122
+ <MobileSessionList
123
+ folders={folders}
124
+ activeSessionId={activeSessionId}
125
+ expandedFolders={expandedFolders}
126
+ showArchived={showArchived}
127
+ sessionStatus={sessionStatus}
128
+ onSelectSession={onSelectSession}
129
+ onNewSessionForFolder={onNewSessionForFolder}
130
+ onNewWorktreeSession={onNewWorktreeSession}
131
+ onToggleFolder={onToggleFolder}
132
+ onToast={onToast}
133
+ batch={batch}
134
+ onStartSessionSelection={onStartSessionSelection}
135
+ onCancelWait={onCancelWait}
136
+ />
137
+ )}
138
+ </>
139
+ );
140
+ }
@@ -171,7 +171,7 @@ export function MobileSessionToolbar({
171
171
  type="button"
172
172
  onClick={onToggleArchived}
173
173
  aria-pressed={showArchived}
174
- className={`${CONTROL_CLASS} ${showArchived ? 'bg-amber-500/15 border-amber-500/40 text-amber-900' : CONTROL_IDLE}`}
174
+ className={`${CONTROL_CLASS} ${showArchived ? 'bg-warning/15 border-warning/40 text-warning' : CONTROL_IDLE}`}
175
175
  title={archiveLabel}
176
176
  aria-label={archiveLabel}
177
177
  >
@@ -288,13 +288,13 @@ export function MobileSessionToolbar({
288
288
  </span>
289
289
  )}
290
290
  {showArchived && (
291
- <span className="inline-flex items-center space-x-1 bg-amber-500/15 border border-amber-500/25 text-amber-900 rounded-lg px-2 py-0.5 text-[10px] font-mono">
291
+ <span className="inline-flex items-center space-x-1 bg-warning/15 border border-warning/25 text-warning rounded-lg px-2 py-0.5 text-[10px] font-mono">
292
292
  <Archive size={10} />
293
293
  <span>Archived</span>
294
294
  <button
295
295
  type="button"
296
296
  onClick={onHideArchived}
297
- className="hover:text-amber-950 ml-0.5"
297
+ className="hover:text-warning-hover ml-0.5"
298
298
  title="Hide archived"
299
299
  >
300
300
  <X size={10} />
@@ -0,0 +1,104 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The phone drawer's state, gathered in one hook so the component stays under
8
+ * the repo's per-file ceiling.
9
+ *
10
+ * Everything here is the drawer's own wiring, not a second implementation of
11
+ * anything: the controller, the folder-expansion seed, the batch machine and
12
+ * the dock are the same hooks the desktop column uses. The split is by
13
+ * responsibility — this file answers "what does the drawer know", the component
14
+ * answers "what does it draw" — and it is the seam that lets the drawer hand the
15
+ * SAME `SessionSidebarVariantProps` to either chrome.
16
+ */
17
+
18
+ import { useEffect, useRef, useState } from 'preact/hooks';
19
+ import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
20
+ import { useSessionSidebarController } from '@/client/hooks/chat/omp/session-sidebar-controller';
21
+ import { useSidebarBatch } from '@/client/hooks/workspace/sidebar-batch';
22
+ import { setFolderExpanded } from '@/client/hooks/workspace/folder-expansion';
23
+ import { dockBodyProps, useMobileDock } from '@/client/components/mobile/mobile-session-sidebar/use-dock';
24
+ import type { SessionSidebarController } from '@/client/hooks/chat/omp/session-sidebar-controller';
25
+ import type { SidebarBatch } from '@/client/hooks/workspace/sidebar-batch';
26
+
27
+ export interface DrawerState {
28
+ controller: SessionSidebarController;
29
+ batch: SidebarBatch;
30
+ /** Folder expansion, seeded from the list the drawer actually renders. */
31
+ expandedFolders: Record<number, boolean>;
32
+ toggleFolder: (folderId: number) => void;
33
+ optionsRef: { current: HTMLDivElement | null };
34
+ dock: ReturnType<typeof useMobileDock>;
35
+ dockBody: ReturnType<typeof dockBodyProps>;
36
+ }
37
+
38
+ export interface DrawerOptions {
39
+ appSettings: Record<string, any>;
40
+ onSelectSession: (id: number | string) => void;
41
+ onClose: () => void;
42
+ rootPath?: string;
43
+ refreshKey: number;
44
+ onRefresh?: () => void;
45
+ onOpenFile?: (file: unknown) => void;
46
+ }
47
+
48
+ export function useDrawerState({
49
+ appSettings,
50
+ onSelectSession,
51
+ onClose,
52
+ rootPath,
53
+ refreshKey,
54
+ onRefresh,
55
+ onOpenFile,
56
+ }: DrawerOptions): DrawerState {
57
+ const controller = useSessionSidebarController(appSettings, { onSelectSession, onAfterSelect: onClose });
58
+ const { folders, processedFolders, refreshNow, showArchived, activeSessionId } = controller;
59
+ const batch = useSidebarBatch(processedFolders, showArchived, refreshNow);
60
+
61
+ const [expandedFolders, setExpandedFolders] = useState<Record<number, boolean>>({
62
+ 1: true,
63
+ 2: true,
64
+ 3: true,
65
+ });
66
+
67
+ const optionsRef = useRef<HTMLDivElement>(null);
68
+ useOnClickOutside(optionsRef, () => controller.setOptionsOpen(false));
69
+
70
+ const toggleFolder = (folderId: number) => {
71
+ setExpandedFolders(prev => ({ ...prev, [folderId]: !prev[folderId] }));
72
+ const folder = folders.find(item => item.id === folderId);
73
+ const nextExpanded = !(expandedFolders[folderId] ?? folder?.isExpanded ?? true);
74
+ void setFolderExpanded(folderId, nextExpanded);
75
+ };
76
+
77
+ // Seeded from the list the drawer RENDERS, not from the raw server payload:
78
+ // the controller force-opens a folder that hosts a pending row (a chat whose
79
+ // transcript omp has not written yet), and a seed taken from the raw folders
80
+ // would collapse it again — hiding the one row the user cannot get back by
81
+ // expanding, because nothing else knows it exists.
82
+ //
83
+ // Keyed on the flags themselves rather than the array: `processedFolders` is
84
+ // a new array on every sidebar push (a tool call republishes the structure),
85
+ // and re-seeding on identity would discard every expansion the user just
86
+ // made, several times a minute.
87
+ const expansionSeed = processedFolders.map(folder => `${folder.id}:${folder.isExpanded}`).join('|');
88
+ useEffect(() => {
89
+ setExpandedFolders(Object.fromEntries(processedFolders.map(folder => [folder.id, folder.isExpanded])));
90
+ // eslint-disable-next-line react-hooks/exhaustive-deps
91
+ }, [expansionSeed]);
92
+
93
+ const dock = useMobileDock();
94
+ const dockBody = dockBodyProps({
95
+ sessionId: activeSessionId,
96
+ refreshKey,
97
+ rootPath,
98
+ onRefresh,
99
+ onOpenFile,
100
+ onClose,
101
+ });
102
+
103
+ return { controller, batch, expandedFolders, toggleFolder, optionsRef, dock, dockBody };
104
+ }