@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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +319 -319
- package/dist/client/static/js/{index-vzb1qz51.js → index-nfsg1jpt.js} +779 -779
- package/dist/client/static/js/index-tsgy3gd1.css +1 -0
- package/package.json +1 -1
- package/src/client/components/common/batch-selection/BatchActionBar.test.ts +42 -5
- package/src/client/components/common/batch-selection/BatchActionBar.tsx +57 -14
- package/src/client/components/common/code-surface/extensions.ts +7 -1
- package/src/client/components/common/code-surface/fold-placeholder.ts +43 -0
- package/src/client/components/common/session-row/StatusSlot.tsx +133 -0
- package/src/client/components/common/session-row/TrailingSlot.tsx +84 -0
- package/src/client/components/common/session-row/index.tsx +205 -0
- package/src/client/components/common/session-row/session-row.test.tsx +144 -0
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +121 -0
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +99 -112
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +2 -2
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +149 -0
- package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +150 -0
- package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +75 -0
- package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +55 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +184 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +333 -0
- package/src/client/components/layout/session-sidebar/modern/index.tsx +147 -0
- package/src/client/components/layout/session-sidebar/variant-props.ts +73 -0
- package/src/client/components/mobile/SessionSidebar.tsx +137 -146
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +140 -0
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +3 -3
- package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +104 -0
- package/src/client/components/settings/Modal.tsx +5 -27
- package/src/client/components/settings/Sidebar.tsx +1 -1
- package/src/client/components/settings/apply-side-effects.test.ts +102 -0
- package/src/client/components/settings/apply-side-effects.ts +90 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +11 -1
- package/src/client/components/settings/categories/ChatSettings.test.tsx +121 -0
- package/src/client/components/settings/categories/ChatSettings.tsx +80 -15
- package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +157 -0
- package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +177 -0
- package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +1 -1
- package/src/client/components/settings/categories/chat-settings/SidebarList.tsx +73 -0
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +144 -0
- package/src/client/components/settings/categories/chat-settings/groups.test.ts +42 -0
- package/src/client/components/settings/categories/chat-settings/groups.ts +81 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +1 -68
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +7 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -5
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +90 -41
- package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +13 -6
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +108 -67
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.test.ts +28 -8
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +48 -4
- package/src/client/components/workspace/chat-timeline/TurnRail.tsx +64 -0
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +158 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerNotice.tsx +50 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +178 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +102 -122
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +7 -0
- package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +111 -0
- package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +181 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/approval-gate.test.tsx +31 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/plugin-renderers.ts +6 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +98 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph.tsx +56 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +19 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +132 -0
- package/src/client/components/workspace/chat-timeline/{ToolCallCard.plugin.test.ts → tool-renderers/styles/Card.plugin.test.ts} +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +60 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +89 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +72 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +84 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +22 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +153 -0
- package/src/client/components/workspace/diff-panel/folding.ts +6 -1
- package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +86 -12
- package/src/client/components/workspace/model-dropdown/Item.tsx +56 -19
- package/src/client/components/workspace/model-dropdown/Panel.tsx +21 -13
- package/src/client/components/workspace/model-dropdown/Section.test.tsx +114 -4
- package/src/client/components/workspace/model-dropdown/Section.tsx +21 -9
- package/src/client/components/workspace/model-dropdown/groups.test.ts +164 -1
- package/src/client/components/workspace/model-dropdown/groups.ts +94 -17
- package/src/client/components/workspace/model-dropdown/index.tsx +27 -19
- package/src/client/data/settings/omp-schema.json +151 -6
- package/src/client/hooks/chat/composer/style.ts +66 -0
- package/src/client/hooks/chat/timeline/tool-render-mode.ts +65 -0
- package/src/client/hooks/settings/providers/login.ts +11 -2
- package/src/client/hooks/ui/window-event.ts +20 -4
- package/src/client/hooks/workspace/batch-archive-run.ts +47 -0
- package/src/client/hooks/workspace/batch-archive.test.ts +59 -0
- package/src/client/hooks/workspace/batch-archive.ts +78 -0
- package/src/client/hooks/workspace/sidebar-batch.ts +95 -0
- package/src/client/hooks/workspace/sidebar-style.ts +66 -0
- package/src/client/tailwind.css +111 -0
- package/src/server/index.ts +10 -134
- package/src/server/lib/lifecycle/after-listen.ts +178 -0
- package/src/server/lib/lifecycle/rejection-guard.test.ts +79 -0
- package/src/server/lib/lifecycle/rejection-guard.ts +74 -0
- package/src/server/lib/lifecycle/tls.test.ts +7 -7
- package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +131 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +46 -0
- package/src/server/lib/omp/rpc/frame-fold.test.ts +1 -100
- package/src/server/lib/omp/rpc/frame-fold.ts +13 -0
- package/src/server/lib/plugins/background.server.ts +17 -1
- package/src/server/lib/plugins/background.test.ts +33 -0
- package/src/server/routes/sessions/batch-archive.test.ts +113 -0
- package/src/server/routes/sessions/batch-archive.ts +80 -0
- package/src/server/routes/sessions/index.ts +4 -0
- package/src/shared/lib/chat/composer/style.test.ts +126 -0
- package/src/shared/lib/chat/composer/style.ts +171 -0
- package/src/shared/lib/chat/composer/tui-only.test.ts +3 -0
- package/src/shared/lib/chat/composer/tui-only.ts +5 -0
- package/src/shared/lib/chat/timeline/block-chrome.ts +129 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +51 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +74 -0
- package/src/shared/lib/chat/timeline/trace-groups.test.ts +120 -0
- package/src/shared/lib/chat/timeline/trace-groups.ts +68 -0
- package/src/shared/lib/settings/defaults.ts +6 -0
- package/src/shared/lib/workspace/session-focus.test.ts +93 -0
- package/src/shared/lib/workspace/session-focus.ts +71 -0
- package/src/shared/lib/workspace/sidebar-filter-row.test.ts +73 -0
- package/src/shared/lib/workspace/sidebar-filter-row.ts +86 -0
- package/src/shared/lib/workspace/sidebar-style.test.ts +58 -0
- package/src/shared/lib/workspace/sidebar-style.ts +86 -0
- package/src/shared/types/omp/agent.ts +6 -0
- package/src/shared/types/settings/state.ts +31 -0
- package/dist/client/static/js/index-68w8h33q.css +0 -1
- package/src/client/components/workspace/chat-timeline/ToolCallCard.tsx +0 -194
|
@@ -8,7 +8,7 @@ import { ModelDropdownPanel } from '@/client/components/workspace/model-dropdown
|
|
|
8
8
|
import { ProviderIconPlate } from '@/client/components/common/provider-icon/Plate';
|
|
9
9
|
import { useModelCatalog } from '@/client/components/workspace/model-dropdown/use-catalog';
|
|
10
10
|
import { useCollapsedSections } from '@/client/components/workspace/model-dropdown/collapsed';
|
|
11
|
-
import { buildPickerGroups } from '@/client/components/workspace/model-dropdown/groups';
|
|
11
|
+
import { buildPickerGroups, type PickerRow } from '@/client/components/workspace/model-dropdown/groups';
|
|
12
12
|
import { modelKey } from '@/shared/lib/models/identity';
|
|
13
13
|
import { RECENT_MODELS_LIMIT, filterKnownKeys, readModelPreferences, recordRecentKey, toggleFavoriteKey } from '@/shared/lib/models/preferences';
|
|
14
14
|
|
|
@@ -30,7 +30,10 @@ export function ModelDropdown({
|
|
|
30
30
|
const [isOpen, setIsOpen] = useState(false);
|
|
31
31
|
const [search, setSearch] = useState('');
|
|
32
32
|
const [focusedIndex, setFocusedIndex] = useState<number>(-1);
|
|
33
|
-
|
|
33
|
+
// Hover is a ROW, not a model: one model can be drawn twice (its rail and its
|
|
34
|
+
// provider section), and both the specs card and the keyboard focus have to
|
|
35
|
+
// address the row the pointer is actually on.
|
|
36
|
+
const [hoveredRow, setHoveredRow] = useState<PickerRow | null>(null);
|
|
34
37
|
const [collapsedSections, toggleSection] = useCollapsedSections();
|
|
35
38
|
const {
|
|
36
39
|
models,
|
|
@@ -71,7 +74,7 @@ export function ModelDropdown({
|
|
|
71
74
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
72
75
|
useOnClickOutside(containerRef, () => {
|
|
73
76
|
setIsOpen(false);
|
|
74
|
-
|
|
77
|
+
setHoveredRow(null);
|
|
75
78
|
setFocusedIndex(-1);
|
|
76
79
|
});
|
|
77
80
|
|
|
@@ -80,6 +83,7 @@ export function ModelDropdown({
|
|
|
80
83
|
favorites: favoriteModels,
|
|
81
84
|
recent: recentModels,
|
|
82
85
|
byProvider: providerGroups,
|
|
86
|
+
ambiguousNames,
|
|
83
87
|
visibleFlatList,
|
|
84
88
|
index: modelIndex,
|
|
85
89
|
} = useMemo(
|
|
@@ -91,7 +95,7 @@ export function ModelDropdown({
|
|
|
91
95
|
|
|
92
96
|
const handleAddProviderClick = () => {
|
|
93
97
|
setIsOpen(false);
|
|
94
|
-
|
|
98
|
+
setHoveredRow(null);
|
|
95
99
|
if (onOpenAddProvider) {
|
|
96
100
|
onOpenAddProvider();
|
|
97
101
|
} else {
|
|
@@ -180,7 +184,7 @@ export function ModelDropdown({
|
|
|
180
184
|
setSelectedModel(model);
|
|
181
185
|
onSelectModel?.(model);
|
|
182
186
|
setIsOpen(false);
|
|
183
|
-
|
|
187
|
+
setHoveredRow(null);
|
|
184
188
|
// Move the pick to the top of RECENT straight away — the server records it
|
|
185
189
|
// alongside the selection, and waiting for the round trip would leave the
|
|
186
190
|
// rail stale until the next full reload. Same rules as the server's write:
|
|
@@ -200,38 +204,38 @@ export function ModelDropdown({
|
|
|
200
204
|
} catch {}
|
|
201
205
|
};
|
|
202
206
|
|
|
207
|
+
/** The focused row, or the one under the pointer when no row is focused. */
|
|
208
|
+
const activeRow = (focusedIndex >= 0 ? visibleFlatList[focusedIndex] : null) || hoveredRow;
|
|
209
|
+
|
|
203
210
|
const handleKeyDown = (e: globalThis.KeyboardEvent) => {
|
|
204
211
|
if (!isOpen) return;
|
|
205
212
|
if (e.key === 'ArrowDown') {
|
|
206
213
|
e.preventDefault();
|
|
207
214
|
setFocusedIndex(prev => {
|
|
208
215
|
const next = (prev + 1) % Math.max(1, visibleFlatList.length);
|
|
209
|
-
|
|
216
|
+
setHoveredRow(visibleFlatList[next] || null);
|
|
210
217
|
return next;
|
|
211
218
|
});
|
|
212
219
|
} else if (e.key === 'ArrowUp') {
|
|
213
220
|
e.preventDefault();
|
|
214
221
|
setFocusedIndex(prev => {
|
|
215
222
|
const prevIdx = (prev - 1 + visibleFlatList.length) % Math.max(1, visibleFlatList.length);
|
|
216
|
-
|
|
223
|
+
setHoveredRow(visibleFlatList[prevIdx] || null);
|
|
217
224
|
return prevIdx;
|
|
218
225
|
});
|
|
219
226
|
} else if (e.key === 'Enter') {
|
|
220
227
|
e.preventDefault();
|
|
221
|
-
|
|
222
|
-
if (target) handleSelect(target);
|
|
228
|
+
if (activeRow) handleSelect(activeRow.model);
|
|
223
229
|
} else if (e.key === 'Escape') {
|
|
224
230
|
e.preventDefault();
|
|
225
231
|
setIsOpen(false);
|
|
226
|
-
|
|
232
|
+
setHoveredRow(null);
|
|
227
233
|
} else if (e.key === 'Tab') {
|
|
228
234
|
e.preventDefault();
|
|
229
|
-
|
|
230
|
-
if (target) toggleAgentCmd(target);
|
|
235
|
+
if (activeRow) toggleAgentCmd(activeRow.model);
|
|
231
236
|
} else if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
|
|
232
237
|
e.preventDefault();
|
|
233
|
-
|
|
234
|
-
if (target) cycleThinkingLevel(target);
|
|
238
|
+
if (activeRow) cycleThinkingLevel(activeRow.model);
|
|
235
239
|
}
|
|
236
240
|
};
|
|
237
241
|
|
|
@@ -242,7 +246,7 @@ export function ModelDropdown({
|
|
|
242
246
|
type="button"
|
|
243
247
|
onClick={() => {
|
|
244
248
|
setIsOpen(prev => !prev);
|
|
245
|
-
|
|
249
|
+
setHoveredRow(null);
|
|
246
250
|
setFocusedIndex(-1);
|
|
247
251
|
}}
|
|
248
252
|
className="flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 font-medium cursor-pointer min-w-0 max-w-full"
|
|
@@ -292,20 +296,24 @@ export function ModelDropdown({
|
|
|
292
296
|
favoriteModels={favoriteModels}
|
|
293
297
|
recentModels={recentModels}
|
|
294
298
|
providerGroups={providerGroups}
|
|
299
|
+
ambiguousNames={ambiguousNames}
|
|
295
300
|
collapsedSections={collapsedSections}
|
|
296
301
|
onToggleCollapse={toggleSection}
|
|
297
302
|
selectedModelKey={selectedModelKey}
|
|
298
303
|
modelIndex={modelIndex}
|
|
299
304
|
focusedIndex={focusedIndex}
|
|
300
|
-
|
|
305
|
+
hoveredRow={hoveredRow}
|
|
301
306
|
onSelect={handleSelect}
|
|
302
307
|
onToggleFavorite={handleToggleFavorite}
|
|
303
308
|
onCycleThinking={cycleThinkingLevel}
|
|
304
|
-
onHoverItem={(idx
|
|
309
|
+
onHoverItem={(idx) => {
|
|
305
310
|
setFocusedIndex(idx);
|
|
306
|
-
|
|
311
|
+
// The flat list is the one order the panel renders, so an index is
|
|
312
|
+
// enough to name the exact row — including which of a model's two
|
|
313
|
+
// rows the pointer is on.
|
|
314
|
+
setHoveredRow(visibleFlatList[idx] ?? null);
|
|
307
315
|
}}
|
|
308
|
-
onMouseLeave={() =>
|
|
316
|
+
onMouseLeave={() => setHoveredRow(null)}
|
|
309
317
|
/>
|
|
310
318
|
)}
|
|
311
319
|
</div>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"source": "@oh-my-pi/pi-coding-agent 10 tabs /
|
|
2
|
+
"source": "@oh-my-pi/pi-coding-agent 10 tabs / 574 settings",
|
|
3
3
|
"tabs": [
|
|
4
4
|
{
|
|
5
5
|
"id": "appearance",
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"tab": "interaction",
|
|
157
157
|
"group": "Startup & Updates",
|
|
158
158
|
"label": "Auto Resume",
|
|
159
|
-
"description": "Automatically resume the most recent session in the current directory"
|
|
159
|
+
"description": "Automatically resume the most recent session in the current directory. If its model cannot be restored and model fallback is disabled, interactive startup warns and starts a new session without the saved history"
|
|
160
160
|
}
|
|
161
161
|
},
|
|
162
162
|
"git.enabled": {
|
|
@@ -569,8 +569,9 @@
|
|
|
569
569
|
},
|
|
570
570
|
"tui.autoGraph": {
|
|
571
571
|
"type": "enum",
|
|
572
|
-
"default": "
|
|
572
|
+
"default": "auto",
|
|
573
573
|
"values": [
|
|
574
|
+
"auto",
|
|
574
575
|
"smart",
|
|
575
576
|
"always",
|
|
576
577
|
"off"
|
|
@@ -581,6 +582,11 @@
|
|
|
581
582
|
"label": "Auto-Graph Tables",
|
|
582
583
|
"description": "Draw a chart under numeric tables in the agent's answers, in your theme's colors, on terminals that show graphics",
|
|
583
584
|
"options": [
|
|
585
|
+
{
|
|
586
|
+
"value": "auto",
|
|
587
|
+
"label": "Auto",
|
|
588
|
+
"description": "Smart when the judge role resolves to a native TypeSafe jev model, else Always"
|
|
589
|
+
},
|
|
584
590
|
{
|
|
585
591
|
"value": "smart",
|
|
586
592
|
"label": "Smart",
|
|
@@ -689,7 +695,7 @@
|
|
|
689
695
|
"tab": "appearance",
|
|
690
696
|
"group": "Display",
|
|
691
697
|
"label": "Mouse Click-to-Focus",
|
|
692
|
-
"description": "Capture mouse clicks in the main session so live subagent cards and HUD rows focus on click, with a hover highlight on the target. Native text selection becomes Shift+drag and wheel scroll becomes Shift+wheel while on"
|
|
698
|
+
"description": "Capture mouse clicks in the main session so live subagent cards and HUD rows focus on click, with a hover highlight on the target, and clicks on extension-owned links reach their extension (the link-hint key picks them without the mouse). Native text selection becomes Shift+drag and wheel scroll becomes Shift+wheel while on"
|
|
693
699
|
}
|
|
694
700
|
},
|
|
695
701
|
"tui.tight": {
|
|
@@ -826,6 +832,39 @@
|
|
|
826
832
|
"description": "Show a divider after an assistant turn whose request lost (missed) the prompt cache"
|
|
827
833
|
}
|
|
828
834
|
},
|
|
835
|
+
"display.advisorCollapsedLines": {
|
|
836
|
+
"type": "number",
|
|
837
|
+
"default": 0,
|
|
838
|
+
"ui": {
|
|
839
|
+
"tab": "appearance",
|
|
840
|
+
"group": "Display",
|
|
841
|
+
"label": "Advisor Collapsed Lines",
|
|
842
|
+
"description": "Maximum note lines a collapsed advisor card shows below its header (0 keeps the full preview; expand with the tool-output toggle)",
|
|
843
|
+
"options": [
|
|
844
|
+
{
|
|
845
|
+
"value": "0",
|
|
846
|
+
"label": "No limit",
|
|
847
|
+
"description": "Default."
|
|
848
|
+
},
|
|
849
|
+
{
|
|
850
|
+
"value": "1",
|
|
851
|
+
"label": "1 line"
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
"value": "2",
|
|
855
|
+
"label": "2 lines"
|
|
856
|
+
},
|
|
857
|
+
{
|
|
858
|
+
"value": "3",
|
|
859
|
+
"label": "3 lines"
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
"value": "5",
|
|
863
|
+
"label": "5 lines"
|
|
864
|
+
}
|
|
865
|
+
]
|
|
866
|
+
}
|
|
867
|
+
},
|
|
829
868
|
"display.collapseCompacted": {
|
|
830
869
|
"type": "boolean",
|
|
831
870
|
"default": true,
|
|
@@ -1511,6 +1550,32 @@
|
|
|
1511
1550
|
]
|
|
1512
1551
|
}
|
|
1513
1552
|
},
|
|
1553
|
+
"session.worktreeScope": {
|
|
1554
|
+
"type": "enum",
|
|
1555
|
+
"default": "repo",
|
|
1556
|
+
"values": [
|
|
1557
|
+
"directory",
|
|
1558
|
+
"repo"
|
|
1559
|
+
],
|
|
1560
|
+
"ui": {
|
|
1561
|
+
"tab": "interaction",
|
|
1562
|
+
"group": "Startup & Updates",
|
|
1563
|
+
"label": "Resume Worktree Scope",
|
|
1564
|
+
"description": "Choose whether the resume picker's current folder includes sessions from other repository worktrees",
|
|
1565
|
+
"options": [
|
|
1566
|
+
{
|
|
1567
|
+
"value": "directory",
|
|
1568
|
+
"label": "This Directory",
|
|
1569
|
+
"description": "Only sessions saved for this directory"
|
|
1570
|
+
},
|
|
1571
|
+
{
|
|
1572
|
+
"value": "repo",
|
|
1573
|
+
"label": "Repository Worktrees",
|
|
1574
|
+
"description": "Also include sessions from sibling worktrees"
|
|
1575
|
+
}
|
|
1576
|
+
]
|
|
1577
|
+
}
|
|
1578
|
+
},
|
|
1514
1579
|
"power.sleepPrevention": {
|
|
1515
1580
|
"type": "enum",
|
|
1516
1581
|
"default": "idle",
|
|
@@ -1559,6 +1624,26 @@
|
|
|
1559
1624
|
"description": "Start on the active model, then switch to a fast/cheap model (default the 'smol' role) at the first edit/write after the plan nudge's todo list exists — the strong model plans, commits the todos, and starts the implementation before handing off. Overridable per session with --prewalk / --no-prewalk."
|
|
1560
1625
|
}
|
|
1561
1626
|
},
|
|
1627
|
+
"prewalk.from": {
|
|
1628
|
+
"type": "string",
|
|
1629
|
+
"default": "@default",
|
|
1630
|
+
"ui": {
|
|
1631
|
+
"tab": "model",
|
|
1632
|
+
"group": "Prewalk",
|
|
1633
|
+
"label": "Prewalk planning model",
|
|
1634
|
+
"description": "Model or role (default '@default') that /prewalk restart returns to for planning."
|
|
1635
|
+
}
|
|
1636
|
+
},
|
|
1637
|
+
"prewalk.into": {
|
|
1638
|
+
"type": "string",
|
|
1639
|
+
"default": "@smol",
|
|
1640
|
+
"ui": {
|
|
1641
|
+
"tab": "model",
|
|
1642
|
+
"group": "Prewalk",
|
|
1643
|
+
"label": "Prewalk target",
|
|
1644
|
+
"description": "Model or role (default '@smol') that prewalk hands off to at the first edit/write: /prewalk, /prewalk restart, Enable Prewalk, and --prewalk. Auto-prewalk uses its own target."
|
|
1645
|
+
}
|
|
1646
|
+
},
|
|
1562
1647
|
"prewalk.auto": {
|
|
1563
1648
|
"type": "enum",
|
|
1564
1649
|
"default": "off",
|
|
@@ -2488,6 +2573,16 @@
|
|
|
2488
2573
|
]
|
|
2489
2574
|
}
|
|
2490
2575
|
},
|
|
2576
|
+
"retry.rateLimitWalksChain": {
|
|
2577
|
+
"type": "boolean",
|
|
2578
|
+
"default": false,
|
|
2579
|
+
"ui": {
|
|
2580
|
+
"tab": "model",
|
|
2581
|
+
"group": "Retry & Fallback",
|
|
2582
|
+
"label": "Rate Limit Walks Chain",
|
|
2583
|
+
"description": "On a rate limit, do not hold the retry.fallbackChains walk for a turn whose thinking is signed by the failing model. Off (the default), such a turn keeps retrying the rate-limited model until retry.maxRetries is spent before the chain is reached."
|
|
2584
|
+
}
|
|
2585
|
+
},
|
|
2491
2586
|
"retry.usageAwareFallback": {
|
|
2492
2587
|
"type": "boolean",
|
|
2493
2588
|
"default": false,
|
|
@@ -3042,7 +3137,7 @@
|
|
|
3042
3137
|
},
|
|
3043
3138
|
"providers.openaiLiveSteering": {
|
|
3044
3139
|
"type": "boolean",
|
|
3045
|
-
"default":
|
|
3140
|
+
"default": false,
|
|
3046
3141
|
"ui": {
|
|
3047
3142
|
"tab": "providers",
|
|
3048
3143
|
"group": "Protocol",
|
|
@@ -6418,6 +6513,16 @@
|
|
|
6418
6513
|
"description": "Enable the ask tool for interactive user questions"
|
|
6419
6514
|
}
|
|
6420
6515
|
},
|
|
6516
|
+
"out.enabled": {
|
|
6517
|
+
"type": "boolean",
|
|
6518
|
+
"default": true,
|
|
6519
|
+
"ui": {
|
|
6520
|
+
"tab": "tools",
|
|
6521
|
+
"group": "Available Tools",
|
|
6522
|
+
"label": "Out",
|
|
6523
|
+
"description": "Let the agent reply mid-task by writing to out://, shown like a response without ending its turn. Unset: on in the interactive TUI, off in print, RPC, and ACP"
|
|
6524
|
+
}
|
|
6525
|
+
},
|
|
6421
6526
|
"tools.intentTracing": {
|
|
6422
6527
|
"type": "boolean",
|
|
6423
6528
|
"default": true,
|
|
@@ -6594,6 +6699,16 @@
|
|
|
6594
6699
|
"description": "When xd:// Prompt Docs is Built-ins Only, inline dynamic devices whose names match these glob patterns (for example mcp__context_mode_*). Catalog Only ignores this setting."
|
|
6595
6700
|
}
|
|
6596
6701
|
},
|
|
6702
|
+
"tools.xdevNotices": {
|
|
6703
|
+
"type": "boolean",
|
|
6704
|
+
"default": true,
|
|
6705
|
+
"ui": {
|
|
6706
|
+
"tab": "tools",
|
|
6707
|
+
"group": "Discovery & MCP",
|
|
6708
|
+
"label": "xd:// Mount Notices",
|
|
6709
|
+
"description": "Show an `xd://: mounted …` notice when MCP or extension tools are mounted or unmounted. The model still learns of the change with its next prompt."
|
|
6710
|
+
}
|
|
6711
|
+
},
|
|
6597
6712
|
"dev.autoqa": {
|
|
6598
6713
|
"type": "boolean",
|
|
6599
6714
|
"default": true,
|
|
@@ -6758,7 +6873,7 @@
|
|
|
6758
6873
|
"tab": "shell",
|
|
6759
6874
|
"group": "Bash",
|
|
6760
6875
|
"label": "Git Guard",
|
|
6761
|
-
"description": "Refuse git commands that discard or move shared work in
|
|
6876
|
+
"description": "Refuse git commands that discard or move shared work in a repository's main checkout: stash, reset --hard or to another commit, and checkout/switch/restore outside a merge or rebase conflict. In a linked worktree they run, saving uncommitted changes they discard first"
|
|
6762
6877
|
}
|
|
6763
6878
|
},
|
|
6764
6879
|
"bash.patterns": {
|
|
@@ -7188,6 +7303,16 @@
|
|
|
7188
7303
|
"description": "Switch the task tool to its batch shape: one call carries { context, tasks[] } — one subagent per item, with an optional per-item agent (defaulting to the session spawn-policy agent), per-item isolation, and a required shared context prepended to every assignment. With async.enabled=true, each spawn runs as an independent background agent with the normal idle/parked lifecycle; otherwise the call blocks for merged results. Disable to restore the flat single-spawn schema."
|
|
7189
7304
|
}
|
|
7190
7305
|
},
|
|
7306
|
+
"task.file": {
|
|
7307
|
+
"type": "boolean",
|
|
7308
|
+
"default": false,
|
|
7309
|
+
"ui": {
|
|
7310
|
+
"tab": "tasks",
|
|
7311
|
+
"group": "Subagents",
|
|
7312
|
+
"label": "Task Instructions from Files",
|
|
7313
|
+
"description": "Let the task tool read subagent instructions from a file (taskFile), recording its path and SHA-256."
|
|
7314
|
+
}
|
|
7315
|
+
},
|
|
7191
7316
|
"task.structured": {
|
|
7192
7317
|
"type": "boolean",
|
|
7193
7318
|
"default": false,
|
|
@@ -7678,6 +7803,26 @@
|
|
|
7678
7803
|
"description": "Positive finite active-work timeout for extension tool_call handlers; invalid values use 30000ms, and time awaiting OMP-owned dialogs does not count"
|
|
7679
7804
|
}
|
|
7680
7805
|
},
|
|
7806
|
+
"extensionHandlers.modeControl": {
|
|
7807
|
+
"type": "boolean",
|
|
7808
|
+
"default": true,
|
|
7809
|
+
"ui": {
|
|
7810
|
+
"tab": "tools",
|
|
7811
|
+
"group": "Extensions",
|
|
7812
|
+
"label": "Extension Mode Control",
|
|
7813
|
+
"description": "Let extensions enter and exit plan, vibe, goal, and loop modes via ctx.sessionModes.set(); reading mode state stays available"
|
|
7814
|
+
}
|
|
7815
|
+
},
|
|
7816
|
+
"extensionRenderers.assistantText": {
|
|
7817
|
+
"type": "boolean",
|
|
7818
|
+
"default": false,
|
|
7819
|
+
"ui": {
|
|
7820
|
+
"tab": "tools",
|
|
7821
|
+
"group": "Extensions",
|
|
7822
|
+
"label": "Extension Reply Renderers",
|
|
7823
|
+
"description": "Let extensions change how assistant replies are drawn, redraw a reply in place, and receive clicks on their own links; the session, exports and model context keep the reply as written"
|
|
7824
|
+
}
|
|
7825
|
+
},
|
|
7681
7826
|
"exa.enabled": {
|
|
7682
7827
|
"type": "boolean",
|
|
7683
7828
|
"default": true,
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The one reader/writer of the composer's style.
|
|
8
|
+
*
|
|
9
|
+
* A style picks a ROW ORDER and a frame, so something in JavaScript must
|
|
10
|
+
* re-render when it changes — `appSettings` is a boot-time prop and would only
|
|
11
|
+
* show a new style after a reload. The settings modal calls `applyComposerStyle`
|
|
12
|
+
* when the value moves, which announces `omp:composer-style-changed`;
|
|
13
|
+
* `useComposerStyle` is the single subscriber and the composer is its only
|
|
14
|
+
* consumer.
|
|
15
|
+
*
|
|
16
|
+
* The initial value comes from the primed settings snapshot
|
|
17
|
+
* (`primeKabmoSettings` in `main.tsx`), so a mounted composer draws the stored
|
|
18
|
+
* style on its first render — no flash of the other order.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useState } from 'preact/hooks';
|
|
22
|
+
import { readKabmoSetting } from '@/shared/lib/settings/client';
|
|
23
|
+
import { useKabmoEvent } from '@/client/hooks/ui/window-event';
|
|
24
|
+
import type { SettingsState } from '@/shared/types';
|
|
25
|
+
import {
|
|
26
|
+
resolveComposerStyle,
|
|
27
|
+
type ComposerStyle,
|
|
28
|
+
} from '@/shared/lib/chat/composer/style';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* `app_settings` key holding the style (in the `kabmo_settings` blob).
|
|
32
|
+
*
|
|
33
|
+
* `satisfies keyof SettingsState` because the key and the field name must be
|
|
34
|
+
* the same string for persistence to work at all — renaming the field without
|
|
35
|
+
* this line would leave the setting silently unsaved.
|
|
36
|
+
*/
|
|
37
|
+
export const COMPOSER_STYLE_SETTING_KEY = 'composerStyle' satisfies keyof SettingsState;
|
|
38
|
+
|
|
39
|
+
/** Window event carrying the resolved style as `detail`. */
|
|
40
|
+
export const COMPOSER_STYLE_CHANGED_EVENT = 'omp:composer-style-changed';
|
|
41
|
+
|
|
42
|
+
/** The stored style, resolved against what this build can draw. */
|
|
43
|
+
export function currentComposerStyle(appSettings?: Record<string, any>): ComposerStyle {
|
|
44
|
+
return resolveComposerStyle(readKabmoSetting<unknown>(COMPOSER_STYLE_SETTING_KEY, appSettings));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Announce a new style. Called by the settings modal when the value changes —
|
|
49
|
+
* the persisted copy is written by the modal's own `writeKabmoSettings`, so
|
|
50
|
+
* this function only has to make the mounted composer re-render.
|
|
51
|
+
*/
|
|
52
|
+
export function applyComposerStyle(style: unknown): void {
|
|
53
|
+
if (typeof window === 'undefined') return;
|
|
54
|
+
window.dispatchEvent(
|
|
55
|
+
new CustomEvent(COMPOSER_STYLE_CHANGED_EVENT, { detail: resolveComposerStyle(style) }),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The style the composer should draw, kept live across settings edits. */
|
|
60
|
+
export function useComposerStyle(): ComposerStyle {
|
|
61
|
+
const [style, setStyle] = useState<ComposerStyle>(() => currentComposerStyle());
|
|
62
|
+
useKabmoEvent(COMPOSER_STYLE_CHANGED_EVENT, (event) => {
|
|
63
|
+
setStyle(resolveComposerStyle((event as CustomEvent<unknown>).detail));
|
|
64
|
+
});
|
|
65
|
+
return style;
|
|
66
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The one reader/writer of the transcript's tool-render style.
|
|
8
|
+
*
|
|
9
|
+
* Unlike the chat column's width (an attribute CSS reads), the style picks a
|
|
10
|
+
* Preact renderer, so something in JavaScript must re-render when it changes.
|
|
11
|
+
* The settings modal therefore calls `applyToolRenderMode` when the value
|
|
12
|
+
* moves, which announces `omp:tool-render-changed`; `useToolRenderMode` is the
|
|
13
|
+
* single subscriber, and `ToolCallingSection` is the only consumer.
|
|
14
|
+
*
|
|
15
|
+
* The initial value comes from the primed settings snapshot
|
|
16
|
+
* (`primeKabmoSettings` in `main.tsx`), so a mounted timeline draws the stored
|
|
17
|
+
* style on its first render — no flash of the default.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { useState } from 'preact/hooks';
|
|
21
|
+
import { readKabmoSetting } from '@/shared/lib/settings/client';
|
|
22
|
+
import { useKabmoEvent } from '@/client/hooks/ui/window-event';
|
|
23
|
+
import type { SettingsState } from '@/shared/types';
|
|
24
|
+
import {
|
|
25
|
+
resolveToolRenderMode,
|
|
26
|
+
type ToolRenderMode,
|
|
27
|
+
} from '@/shared/lib/chat/timeline/tool-render-mode';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* `app_settings` key holding the style (in the `kabmo_settings` blob).
|
|
31
|
+
*
|
|
32
|
+
* `satisfies keyof SettingsState` because the key and the field name must be
|
|
33
|
+
* the same string for persistence to work at all — renaming the field without
|
|
34
|
+
* this line would leave the setting silently unsaved.
|
|
35
|
+
*/
|
|
36
|
+
export const TOOL_RENDER_SETTING_KEY = 'toolRenderStyle' satisfies keyof SettingsState;
|
|
37
|
+
|
|
38
|
+
/** Window event carrying the resolved mode as `detail`. */
|
|
39
|
+
export const TOOL_RENDER_CHANGED_EVENT = 'omp:tool-render-changed';
|
|
40
|
+
|
|
41
|
+
/** The stored style, resolved against what this build can draw. */
|
|
42
|
+
export function currentToolRenderMode(appSettings?: Record<string, any>): ToolRenderMode {
|
|
43
|
+
return resolveToolRenderMode(readKabmoSetting<unknown>(TOOL_RENDER_SETTING_KEY, appSettings));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Announce a new style. Called by the settings modal when the value changes —
|
|
48
|
+
* the persisted copy is written by the modal's own `writeKabmoSettings`, so
|
|
49
|
+
* this function only has to make the open timeline re-render.
|
|
50
|
+
*/
|
|
51
|
+
export function applyToolRenderMode(mode: unknown): void {
|
|
52
|
+
if (typeof window === 'undefined') return;
|
|
53
|
+
window.dispatchEvent(
|
|
54
|
+
new CustomEvent(TOOL_RENDER_CHANGED_EVENT, { detail: resolveToolRenderMode(mode) }),
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The style the transcript should draw, kept live across settings edits. */
|
|
59
|
+
export function useToolRenderMode(): ToolRenderMode {
|
|
60
|
+
const [mode, setMode] = useState<ToolRenderMode>(() => currentToolRenderMode());
|
|
61
|
+
useKabmoEvent(TOOL_RENDER_CHANGED_EVENT, (event) => {
|
|
62
|
+
setMode(resolveToolRenderMode((event as CustomEvent<unknown>).detail));
|
|
63
|
+
});
|
|
64
|
+
return mode;
|
|
65
|
+
}
|
|
@@ -32,6 +32,10 @@ export interface LoginUiFrame {
|
|
|
32
32
|
launchUrl?: string;
|
|
33
33
|
instructions?: string;
|
|
34
34
|
placeholder?: string;
|
|
35
|
+
/** omp 18.14.0: `ctx.ui.input({ secret: true })`. Provider login rejects
|
|
36
|
+
* secret prompts server-side, so a secret frame here is an unrelated
|
|
37
|
+
* extension dialog and must not be taken for the OAuth code field. */
|
|
38
|
+
secret?: boolean;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
export type LoginStatus = 'connecting' | 'waiting' | 'success' | 'failed';
|
|
@@ -184,6 +188,7 @@ export function useProviderLogin({ isOpen, providerId, onAuthenticated }: UsePro
|
|
|
184
188
|
...(typeof frame.launchUrl === 'string' ? { launchUrl: frame.launchUrl } : {}),
|
|
185
189
|
...(typeof frame.instructions === 'string' ? { instructions: frame.instructions } : {}),
|
|
186
190
|
...(typeof frame.placeholder === 'string' ? { placeholder: frame.placeholder } : {}),
|
|
191
|
+
...(typeof frame.secret === 'boolean' ? { secret: frame.secret } : {}),
|
|
187
192
|
};
|
|
188
193
|
const method = ui.method;
|
|
189
194
|
if (method === 'open_url') {
|
|
@@ -206,7 +211,7 @@ export function useProviderLogin({ isOpen, providerId, onAuthenticated }: UsePro
|
|
|
206
211
|
}
|
|
207
212
|
continue;
|
|
208
213
|
}
|
|
209
|
-
if (method === 'input') {
|
|
214
|
+
if (method === 'input' && ui.secret !== true) {
|
|
210
215
|
setState((prev) => ({ ...prev, status: 'waiting', prompt: ui }));
|
|
211
216
|
continue;
|
|
212
217
|
}
|
|
@@ -222,7 +227,11 @@ export function useProviderLogin({ isOpen, providerId, onAuthenticated }: UsePro
|
|
|
222
227
|
respond({ id: ui.id, accepted: true });
|
|
223
228
|
continue;
|
|
224
229
|
}
|
|
225
|
-
// Any other dialog method has no answer this dialog can give.
|
|
230
|
+
// Any other dialog method has no answer this dialog can give. A
|
|
231
|
+
// `secret` input lands here on purpose: omp's provider login
|
|
232
|
+
// refuses secret prompts server-side, so one arriving on this
|
|
233
|
+
// stream belongs to an unrelated extension and reading it as the
|
|
234
|
+
// OAuth code would post a password to the wrong dialog.
|
|
226
235
|
respond({ id: ui.id, cancelled: true });
|
|
227
236
|
continue;
|
|
228
237
|
}
|
|
@@ -8,8 +8,21 @@ import { useEffect, useRef } from 'preact/hooks';
|
|
|
8
8
|
|
|
9
9
|
type EventTargetLike = Window | Document;
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* The global to subscribe on, or null when this environment has none.
|
|
13
|
+
*
|
|
14
|
+
* Read through `globalThis` rather than as a bare identifier: `window` is a
|
|
15
|
+
* ReferenceError where it does not exist, and a component that subscribes during
|
|
16
|
+
* render would then throw instead of rendering. That is not hypothetical — a
|
|
17
|
+
* suite that unmounts its DOM globals between files made `useToolRenderMode`
|
|
18
|
+
* fail with `window is not defined` inside an unrelated render.
|
|
19
|
+
*/
|
|
20
|
+
function globalTarget(name: 'window' | 'document'): EventTargetLike | null {
|
|
21
|
+
return (globalThis as unknown as Record<string, EventTargetLike | undefined>)[name] ?? null;
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
function useEventListener<E extends Event>(
|
|
12
|
-
target: EventTargetLike,
|
|
25
|
+
target: EventTargetLike | null,
|
|
13
26
|
type: string,
|
|
14
27
|
handler: (event: E) => void,
|
|
15
28
|
options?: AddEventListenerOptions | boolean,
|
|
@@ -18,6 +31,9 @@ function useEventListener<E extends Event>(
|
|
|
18
31
|
handlerRef.current = handler;
|
|
19
32
|
|
|
20
33
|
useEffect(() => {
|
|
34
|
+
// Nothing to subscribe on: an effect without a target is a no-op rather
|
|
35
|
+
// than a crash, so a render in a DOM-less environment still mounts.
|
|
36
|
+
if (!target) return;
|
|
21
37
|
const listener = (event: Event) => handlerRef.current(event as E);
|
|
22
38
|
target.addEventListener(type, listener, options);
|
|
23
39
|
return () => target.removeEventListener(type, listener, options);
|
|
@@ -30,7 +46,7 @@ export function useWindowEvent<K extends keyof WindowEventMap>(
|
|
|
30
46
|
handler: (event: WindowEventMap[K]) => void,
|
|
31
47
|
options?: AddEventListenerOptions | boolean,
|
|
32
48
|
) {
|
|
33
|
-
useEventListener<WindowEventMap[K]>(window, type, handler, options);
|
|
49
|
+
useEventListener<WindowEventMap[K]>(globalTarget('window'), type, handler, options);
|
|
34
50
|
}
|
|
35
51
|
|
|
36
52
|
/** Subscribe a `document` listener; the latest handler is always invoked. */
|
|
@@ -39,7 +55,7 @@ export function useDocumentEvent<K extends keyof DocumentEventMap>(
|
|
|
39
55
|
handler: (event: DocumentEventMap[K]) => void,
|
|
40
56
|
options?: AddEventListenerOptions | boolean,
|
|
41
57
|
) {
|
|
42
|
-
useEventListener<DocumentEventMap[K]>(document, type, handler, options);
|
|
58
|
+
useEventListener<DocumentEventMap[K]>(globalTarget('document'), type, handler, options);
|
|
43
59
|
}
|
|
44
60
|
|
|
45
61
|
/** Subscribe to a custom `omp:*` window event. */
|
|
@@ -48,7 +64,7 @@ export function useKabmoEvent(
|
|
|
48
64
|
handler: (event: Event) => void,
|
|
49
65
|
options?: AddEventListenerOptions | boolean,
|
|
50
66
|
) {
|
|
51
|
-
useEventListener<Event>(window, name, handler, options);
|
|
67
|
+
useEventListener<Event>(globalTarget('window'), name, handler, options);
|
|
52
68
|
}
|
|
53
69
|
|
|
54
70
|
/** @deprecated Use `useKabmoEvent`. */
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The state behind a batch archive, shared by both sidebars.
|
|
8
|
+
*
|
|
9
|
+
* Archive is reversible, so there is no confirmation dialog and no pending set
|
|
10
|
+
* to hold: the bar's Archive acts on the live selection and the run only has to
|
|
11
|
+
* report in-flight state (the button spins) and republish the sidebar ONCE,
|
|
12
|
+
* from the server's own signal, after any row actually moved. The caller
|
|
13
|
+
* decides what to say about the settled outcome, because the toast stack is
|
|
14
|
+
* per-layout.
|
|
15
|
+
*
|
|
16
|
+
* Workspaces have no archive state — archive is a session noun — so this is
|
|
17
|
+
* session-mode only.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { useCallback, useState } from 'preact/hooks';
|
|
21
|
+
import {
|
|
22
|
+
archiveSessionsBatch,
|
|
23
|
+
type BatchArchiveOutcome,
|
|
24
|
+
} from '@/client/hooks/workspace/batch-archive';
|
|
25
|
+
|
|
26
|
+
export interface BatchArchiveRun {
|
|
27
|
+
isArchiving: boolean;
|
|
28
|
+
/** Archive these ids. Resolves with the settled outcome (null when nothing ran). */
|
|
29
|
+
archive: (ids: readonly string[]) => Promise<BatchArchiveOutcome | null>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function useBatchArchiveRun(refresh: () => void): BatchArchiveRun {
|
|
33
|
+
const [isArchiving, setIsArchiving] = useState(false);
|
|
34
|
+
|
|
35
|
+
const archive = useCallback(async (ids: readonly string[]): Promise<BatchArchiveOutcome | null> => {
|
|
36
|
+
if (ids.length === 0 || isArchiving) return null;
|
|
37
|
+
setIsArchiving(true);
|
|
38
|
+
const result = await archiveSessionsBatch(ids);
|
|
39
|
+
// One refresh for the whole batch: the server emits `sidebar-structure`
|
|
40
|
+
// once, and only when something actually archived.
|
|
41
|
+
if (result.archived.length > 0) refresh();
|
|
42
|
+
setIsArchiving(false);
|
|
43
|
+
return result;
|
|
44
|
+
}, [isArchiving, refresh]);
|
|
45
|
+
|
|
46
|
+
return { isArchiving, archive };
|
|
47
|
+
}
|