@kabmo-labs/kabmo 0.28.0 → 0.30.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/bunfig.toml +6 -0
- package/dist/client/index.html +2 -2
- package/dist/client/index.js +481 -472
- package/dist/client/static/js/{index-xzvyrxya.js → index-5vjbp04s.js} +1193 -1049
- package/dist/client/static/js/index-naa91727.css +1 -0
- package/dist/client/static/{manifest-q6h8k9e0.webmanifest → manifest-vdvdqpre.webmanifest} +1 -0
- package/package.json +3 -2
- package/public/manifest.webmanifest +1 -0
- package/src/client/components/common/ComposerTextarea.test.tsx +109 -0
- package/src/client/components/common/ComposerTextarea.tsx +6 -0
- package/src/client/components/common/ReloadPageButton.test.tsx +14 -0
- package/src/client/components/common/ReloadPageButton.tsx +11 -2
- package/src/client/components/common/diagram-viewer/read-block.test.ts +71 -0
- package/src/client/components/common/diagram-viewer/read-block.ts +40 -16
- package/src/client/components/common/file-icon/index.tsx +7 -1
- package/src/client/components/common/harness-glyph/brands.ts +7 -1
- package/src/client/components/common/image-viewer/index.tsx +37 -165
- package/src/client/components/common/picker-search/index.tsx +70 -0
- package/src/client/components/common/search-select/index.tsx +2 -7
- package/src/client/components/common/zoom-pan-stage/index.tsx +258 -0
- package/src/client/components/common/zoom-pan-stage/zoom-pan-stage.test.tsx +87 -0
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +1 -1
- package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +7 -3
- package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +4 -1
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +12 -1
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.test.tsx +82 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +23 -3
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +1 -0
- package/src/client/components/layout/session-sidebar/modern/index.tsx +1 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +6 -4
- package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +8 -0
- package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +25 -0
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +1 -1
- package/src/client/components/settings/Sidebar.tsx +6 -8
- package/src/client/components/settings/categories/HarnessSettings.tsx +4 -2
- package/src/client/components/settings/categories/PanelPluginSettings.tsx +2 -2
- package/src/client/components/settings/categories/PluginSettings.tsx +1 -1
- package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +3 -6
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +36 -0
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +1 -3
- package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +18 -4
- package/src/client/components/settings/categories/plugin-settings/MarketplacePane.tsx +64 -61
- package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +15 -4
- package/src/client/components/settings/groups.test.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/IrcNotice.test.tsx +55 -0
- package/src/client/components/workspace/chat-timeline/IrcNotice.tsx +71 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +4 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +19 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +8 -3
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.search.test.tsx +72 -0
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +42 -15
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.test.tsx +28 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +28 -10
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +47 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +55 -5
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +3 -2
- package/src/client/components/workspace/editor/FilePane.tsx +32 -0
- package/src/client/components/workspace/editor/Toolbar.tsx +4 -0
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +1 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +5 -2
- package/src/client/components/workspace/editor/viewers/CsvGrid.tsx +52 -5
- package/src/client/components/workspace/editor/viewers/DataGrid.tsx +227 -41
- package/src/client/components/workspace/editor/viewers/DrawioView.tsx +93 -0
- package/src/client/components/workspace/editor/viewers/GridRow.tsx +91 -0
- package/src/client/components/workspace/editor/viewers/GridToolbar.tsx +53 -0
- package/src/client/components/workspace/editor/viewers/SheetView.tsx +152 -57
- package/src/client/components/workspace/editor/viewers/dispatch.tsx +42 -9
- package/src/client/components/workspace/editor/viewers/drawio-pages.test.ts +80 -0
- package/src/client/components/workspace/editor/viewers/drawio-pages.ts +63 -0
- package/src/client/components/workspace/editor/viewers/grid.test.ts +296 -0
- package/src/client/components/workspace/editor/viewers/use-cell-edit.ts +64 -0
- package/src/client/components/workspace/editor/viewers/use-grid-interaction.ts +216 -0
- package/src/client/components/workspace/editor/viewers/viewers.test.ts +47 -2
- package/src/client/components/workspace/editor/viewers/workbook.ts +149 -0
- package/src/client/components/workspace/file-explorer/ArchiveModals.tsx +262 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +30 -6
- package/src/client/components/workspace/file-explorer/Modals.tsx +8 -3
- package/src/client/components/workspace/file-explorer/RootOverlays.tsx +60 -0
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +6 -2
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +39 -49
- package/src/client/components/workspace/file-explorer/TreeItemModals.tsx +80 -0
- package/src/client/components/workspace/file-explorer/index.tsx +53 -29
- package/src/client/components/workspace/file-explorer/selection.test.tsx +109 -0
- package/src/client/data/settings/omp-schema.json +169 -22
- package/src/client/glass-palette.test.ts +72 -0
- package/src/client/glass.css +39 -14
- package/src/client/glass.test.ts +28 -67
- package/src/client/hooks/chat/composer/history.test.ts +267 -0
- package/src/client/hooks/chat/composer/history.ts +146 -0
- package/src/client/hooks/chat/timeline/ask-frames.test.ts +54 -0
- package/src/client/hooks/chat/timeline/ask-frames.ts +29 -1
- package/src/client/hooks/chat/timeline/timeline-rail.test.ts +34 -2
- package/src/client/hooks/chat/timeline/user-turns.ts +31 -2
- package/src/client/hooks/editor/file-editor-types.ts +15 -0
- package/src/client/hooks/editor/save-bytes.ts +79 -0
- package/src/client/hooks/editor/use-dirty-tracking.test.ts +73 -0
- package/src/client/hooks/editor/use-dirty-tracking.ts +96 -0
- package/src/client/hooks/editor/use-file-cache.ts +1 -0
- package/src/client/hooks/editor/use-file-editor.test.ts +30 -0
- package/src/client/hooks/editor/use-file-editor.ts +20 -17
- package/src/client/hooks/editor/use-file-read.ts +21 -2
- package/src/client/hooks/editor/use-grid-selection.ts +160 -0
- package/src/client/hooks/models/use-harness-update.test.ts +35 -2
- package/src/client/hooks/models/use-harness-update.ts +49 -10
- package/src/client/hooks/workspace/diff-file.test.ts +72 -0
- package/src/client/hooks/workspace/diff-file.ts +12 -6
- package/src/client/hooks/workspace/file-archive.ts +220 -0
- package/src/client/hooks/workspace/file-clipboard.test.ts +4 -4
- package/src/client/hooks/workspace/file-clipboard.ts +37 -26
- package/src/client/hooks/workspace/file-selection.test.ts +67 -0
- package/src/client/hooks/workspace/file-selection.ts +156 -0
- package/src/client/hooks/workspace/file-tree-actions-clipboard.test.ts +5 -5
- package/src/client/hooks/workspace/file-tree-actions.ts +36 -8
- package/src/client/lib/editor/workbook-drafts.ts +42 -0
- package/src/client/lib/launch/file-handlers.ts +2 -2
- package/src/client/lib/scrollbar-activity.test.ts +21 -88
- package/src/client/lib/scrollbar-activity.ts +71 -73
- package/src/client/lib/scrollbar-events.ts +143 -0
- package/src/client/lib/scrollbar-input.test.ts +126 -0
- package/src/client/lib/scrollbar-probe.test-util.ts +107 -0
- package/src/client/tailwind.css +32 -1
- package/src/server/db.server.test.ts +50 -1
- package/src/server/db.server.ts +36 -3
- package/src/server/lib/chat/prompt-history.server.test.ts +92 -0
- package/src/server/lib/chat/prompt-history.server.ts +65 -0
- package/src/server/lib/chat/schema.server.ts +35 -0
- package/src/server/lib/db/schema.ts +3 -0
- package/src/server/lib/fs/archive.test.ts +198 -0
- package/src/server/lib/fs/archive.ts +278 -0
- package/src/server/lib/fs/git-diff.test.ts +26 -1
- package/src/server/lib/fs/git-diff.ts +43 -15
- package/src/server/lib/harness/launch-table.ts +19 -0
- package/src/server/lib/harness/provider-entry.ts +1 -1
- package/src/server/lib/harness/provider-file.server.ts +1 -1
- package/src/server/lib/harness/provider-sources.server.ts +2 -1
- package/src/server/lib/harness/provider-write.server.ts +2 -1
- package/src/server/lib/harness/update-job-store.ts +12 -0
- package/src/server/lib/harness/update-queue.server.ts +15 -10
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +5 -1
- package/src/server/lib/omp/rpc/frame-fold.test.ts +5 -1
- package/src/server/lib/omp/rpc/lifecycle.test.ts +4 -0
- package/src/server/lib/omp/session/auto-title.server.test.ts +4 -0
- package/src/server/lib/omp/session/delete.server.ts +1 -0
- package/src/server/lib/omp/session/goal-driver.test.ts +5 -1
- package/src/server/lib/omp/session/goal-settings.test.ts +5 -1
- package/src/server/lib/panels/auto-update.server.test.ts +5 -2
- package/src/server/lib/panels/git-update.server.test.ts +5 -2
- package/src/server/lib/panels/install.server.test.ts +5 -2
- package/src/server/lib/panels/remove.server.test.ts +5 -2
- package/src/server/routes/agent/command.ts +11 -0
- package/src/server/routes/agent/new.ts +5 -0
- package/src/server/routes/chat/index.ts +5 -0
- package/src/server/routes/chat/prompt-history.test.ts +67 -0
- package/src/server/routes/chat/prompt-history.ts +31 -0
- package/src/server/routes/chat/stream.test.ts +21 -0
- package/src/server/routes/chat/stream.ts +5 -0
- package/src/server/routes/fs/action-archive.test.ts +128 -0
- package/src/server/routes/fs/action-bulk.ts +106 -0
- package/src/server/routes/fs/action-save-bytes.test.ts +59 -0
- package/src/server/routes/fs/action-transfer.test.ts +26 -0
- package/src/server/routes/fs/action.ts +91 -11
- package/src/server/routes/fs/archive.ts +20 -0
- package/src/server/routes/fs/grant.test.ts +5 -2
- package/src/server/routes/fs/index.ts +2 -0
- package/src/server/routes/fs/scope.test.ts +6 -2
- package/src/server/routes/harness/import-action.ts +1 -1
- package/src/server/routes/harness/root.ts +6 -1
- package/src/server/routes/harness/summary.test.ts +50 -0
- package/src/server/routes/harness/update-status.ts +41 -2
- package/src/server/routes/harness/update.test.ts +56 -2
- package/src/server/routes/sessions/delete.test.ts +4 -0
- package/src/shared/lib/chat/ask-form/index.ts +39 -31
- package/src/shared/lib/chat/ask-form/labels.ts +46 -0
- package/src/shared/lib/chat/ask-form/tokens.ts +11 -2
- package/src/shared/lib/chat/ask-form.test.ts +57 -0
- package/src/shared/lib/chat/ask-questions.ts +31 -0
- package/src/shared/lib/chat/composer/history.test.ts +67 -0
- package/src/shared/lib/chat/composer/history.ts +61 -0
- package/src/shared/lib/chat/irc-notice.ts +42 -0
- package/src/shared/lib/chat/timeline/fork-anchor.test.ts +2 -0
- package/src/shared/lib/chat/todo/parser.ts +6 -4
- package/src/shared/lib/fs/archive.test.ts +101 -0
- package/src/shared/lib/fs/archive.ts +191 -0
- package/src/shared/lib/fs/clipboard.test.ts +32 -7
- package/src/shared/lib/fs/clipboard.ts +59 -14
- package/src/shared/lib/fs/csv.test.ts +50 -0
- package/src/shared/lib/fs/csv.ts +40 -0
- package/src/shared/lib/fs/document-kind.test.ts +13 -6
- package/src/shared/lib/fs/document-kind.ts +18 -6
- package/src/shared/lib/fs/file-kind-classify.test.ts +4 -0
- package/src/shared/lib/fs/file-kind.test.ts +2 -7
- package/src/shared/lib/fs/file-kind.ts +4 -2
- package/src/shared/lib/fs/grid-edit.test.ts +24 -0
- package/src/shared/lib/fs/grid-edit.ts +29 -0
- package/src/shared/lib/fs/grid-selection.test.ts +137 -0
- package/src/shared/lib/fs/grid-selection.ts +138 -0
- package/src/shared/lib/harness/brand-color.ts +5 -0
- package/src/shared/lib/harness/catalog.test.ts +22 -0
- package/src/shared/lib/harness/catalog.ts +12 -1
- package/src/shared/lib/harness/config-fields.test.ts +25 -0
- package/src/shared/lib/harness/config-fields.ts +33 -3
- package/src/shared/lib/harness/dialects.ts +1 -1
- package/src/shared/lib/harness/mcp-facts.ts +4 -0
- package/src/shared/lib/harness/provider-contracts.ts +109 -0
- package/src/shared/lib/harness/provider-facts.test.ts +2 -1
- package/src/shared/lib/harness/provider-facts.ts +24 -115
- package/src/shared/lib/harness/provider-lookup.ts +37 -0
- package/src/shared/lib/harness/providers.ts +2 -1
- package/src/shared/lib/harness/updates.ts +10 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +14 -13
- package/src/shared/lib/omp/session/mapper.test.ts +31 -0
- package/src/shared/lib/omp/session/mapper.ts +17 -0
- package/src/shared/lib/omp/session/messages-map-notice.test.ts +68 -0
- package/src/shared/lib/omp/session/messages-map.test.ts +1 -35
- package/src/shared/lib/omp/session/messages-map.ts +17 -0
- package/src/shared/lib/omp/session/wait.ts +10 -1
- package/src/shared/lib/settings/sections.ts +8 -4
- package/src/shared/lib/ui/picker-filter.test.ts +23 -0
- package/src/shared/lib/ui/picker-filter.ts +20 -0
- package/src/shared/types/chat.ts +4 -0
- package/src/shared/types/harness.ts +5 -1
- package/src/shared/types/omp/session.ts +18 -0
- package/src/shared/types/settings/state.ts +6 -6
- package/src/shared/types/todo.ts +3 -1
- package/src/test-support/file-actions.test-util.ts +4 -0
- package/src/test-support/file-archive.test-util.ts +41 -0
- package/src/test-support/file-clipboard.test-util.ts +9 -6
- package/src/test-support/file-editor.test-util.ts +3 -2
- package/src/test-support/glass-css.ts +30 -0
- package/src/test-support/harness-table.test-util.ts +2 -0
- package/src/test-support/preload.ts +46 -0
- package/dist/client/static/js/index-81f7berm.css +0 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Files panel's MULTI-selection: which rows are marked, and what a click on
|
|
8
|
+
* one means.
|
|
9
|
+
*
|
|
10
|
+
* The panel opens files, so the click has to do two jobs at once — the first
|
|
11
|
+
* click selects AND opens, a shift-click selects a block without opening, and a
|
|
12
|
+
* meta/ctrl-click adds or removes one row. That split lives here rather than in
|
|
13
|
+
* `TreeItem` because the range needs the VISIBLE row order, which is the
|
|
14
|
+
* panel's tree, not the row's own state.
|
|
15
|
+
*
|
|
16
|
+
* The anchor is deliberately sticky: shift-clicking a third time extends from
|
|
17
|
+
* the same row the plain click started at, which is what every file manager
|
|
18
|
+
* does. A plain click moves it; a toggle moves it too, so the next shift range
|
|
19
|
+
* starts where the user last touched.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { useCallback, useMemo, useState } from 'preact/hooks';
|
|
23
|
+
|
|
24
|
+
/** What a click with the platform modifiers means. */
|
|
25
|
+
export type SelectionGesture = 'plain' | 'range' | 'toggle';
|
|
26
|
+
|
|
27
|
+
/** The gesture a click carries: shift ranges, meta/ctrl toggles, else plain. */
|
|
28
|
+
export function selectionGestureOf(event: {
|
|
29
|
+
shiftKey?: boolean;
|
|
30
|
+
metaKey?: boolean;
|
|
31
|
+
ctrlKey?: boolean;
|
|
32
|
+
}): SelectionGesture {
|
|
33
|
+
if (event.shiftKey) return 'range';
|
|
34
|
+
if (event.metaKey || event.ctrlKey) return 'toggle';
|
|
35
|
+
return 'plain';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The paths between `anchor` and `target` in visible order, inclusive.
|
|
40
|
+
*
|
|
41
|
+
* Empty when either end is not visible: the anchor can survive a folder being
|
|
42
|
+
* collapsed, and a range across rows that are no longer drawn would select
|
|
43
|
+
* entries the user cannot see.
|
|
44
|
+
*/
|
|
45
|
+
export function rangePaths(
|
|
46
|
+
order: readonly string[],
|
|
47
|
+
anchor: string | null,
|
|
48
|
+
target: string,
|
|
49
|
+
): string[] {
|
|
50
|
+
if (!anchor) return [target];
|
|
51
|
+
const from = order.indexOf(anchor);
|
|
52
|
+
const to = order.indexOf(target);
|
|
53
|
+
if (from === -1 || to === -1) return [target];
|
|
54
|
+
const start = Math.min(from, to);
|
|
55
|
+
const end = Math.max(from, to);
|
|
56
|
+
return order.slice(start, end + 1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface FileSelection {
|
|
60
|
+
/** The marked paths. Stable identity until the selection changes. */
|
|
61
|
+
selected: ReadonlySet<string>;
|
|
62
|
+
/** How many rows are marked — the menus' labels read it. */
|
|
63
|
+
count: number;
|
|
64
|
+
/** The row a shift-click ranges from. */
|
|
65
|
+
anchor: string | null;
|
|
66
|
+
gestureOf: (event: { shiftKey?: boolean; metaKey?: boolean; ctrlKey?: boolean }) => SelectionGesture;
|
|
67
|
+
/** Apply a gesture to `path`; a plain click replaces the selection. */
|
|
68
|
+
applyGesture: (gesture: SelectionGesture, path: string) => void;
|
|
69
|
+
/** Right-click: keep a selection the row belongs to, else select just it. */
|
|
70
|
+
ensureForContext: (path: string) => void;
|
|
71
|
+
/** Drop the whole selection — a repo switch, or Escape. */
|
|
72
|
+
clear: () => void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function useFileSelection(order: readonly string[]): FileSelection {
|
|
76
|
+
const [selected, setSelected] = useState<ReadonlySet<string>>(() => new Set());
|
|
77
|
+
const [anchor, setAnchor] = useState<string | null>(null);
|
|
78
|
+
|
|
79
|
+
const applyGesture = useCallback((gesture: SelectionGesture, path: string) => {
|
|
80
|
+
if (gesture === 'range') {
|
|
81
|
+
setSelected(new Set(rangePaths(order, anchor, path)));
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
setAnchor(path);
|
|
85
|
+
if (gesture === 'toggle') {
|
|
86
|
+
setSelected((previous) => {
|
|
87
|
+
const next = new Set(previous);
|
|
88
|
+
if (next.has(path)) next.delete(path);
|
|
89
|
+
else next.add(path);
|
|
90
|
+
return next;
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
setSelected(new Set([path]));
|
|
95
|
+
}, [anchor, order]);
|
|
96
|
+
|
|
97
|
+
const ensureForContext = useCallback((path: string) => {
|
|
98
|
+
setSelected((previous) => {
|
|
99
|
+
if (previous.has(path)) return previous;
|
|
100
|
+
return new Set([path]);
|
|
101
|
+
});
|
|
102
|
+
setAnchor(path);
|
|
103
|
+
}, []);
|
|
104
|
+
|
|
105
|
+
const clear = useCallback(() => {
|
|
106
|
+
setSelected(new Set());
|
|
107
|
+
setAnchor(null);
|
|
108
|
+
}, []);
|
|
109
|
+
|
|
110
|
+
const gestureOf = useCallback(selectionGestureOf, []);
|
|
111
|
+
|
|
112
|
+
return useMemo(
|
|
113
|
+
() => ({ selected, count: selected.size, anchor, gestureOf, applyGesture, ensureForContext, clear }),
|
|
114
|
+
[selected, anchor, gestureOf, applyGesture, ensureForContext, clear],
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** A path's place in the visible tree, with the facts a batch action needs. */
|
|
119
|
+
export interface SelectionEntry {
|
|
120
|
+
path: string;
|
|
121
|
+
name: string;
|
|
122
|
+
kind: 'file' | 'folder';
|
|
123
|
+
/** Nesting depth, for the flat order the range is computed against. */
|
|
124
|
+
depth: number;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The rows the panel is DRAWING, in order — the coordinate space of a
|
|
129
|
+
* shift-range.
|
|
130
|
+
*
|
|
131
|
+
* A folder contributes itself and, when open, its children immediately after
|
|
132
|
+
* it: that is the DOM order the rows are read in. `isOpen` is the panel's own
|
|
133
|
+
* expansion set plus the transient `forceExpanded` a chain row carries.
|
|
134
|
+
*/
|
|
135
|
+
export interface SelectionNode {
|
|
136
|
+
path: string;
|
|
137
|
+
name: string;
|
|
138
|
+
type: 'file' | 'folder';
|
|
139
|
+
children?: readonly SelectionNode[];
|
|
140
|
+
forceExpanded?: boolean;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function visibleEntriesOf(
|
|
144
|
+
nodes: readonly SelectionNode[],
|
|
145
|
+
isOpen: (node: SelectionNode) => boolean,
|
|
146
|
+
depth = 0,
|
|
147
|
+
out: SelectionEntry[] = [],
|
|
148
|
+
): SelectionEntry[] {
|
|
149
|
+
for (const node of nodes) {
|
|
150
|
+
out.push({ path: node.path, name: node.name, kind: node.type === 'folder' ? 'folder' : 'file', depth });
|
|
151
|
+
if (node.type === 'folder' && isOpen(node) && Array.isArray(node.children)) {
|
|
152
|
+
visibleEntriesOf(node.children, isOpen, depth + 1, out);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
@@ -32,7 +32,7 @@ describe('useFileActions clipboard', () => {
|
|
|
32
32
|
|
|
33
33
|
await harness.step(() => harness.actions()?.handleAction('cut'));
|
|
34
34
|
expect(harness.clipboard()?.calls).toEqual([
|
|
35
|
-
{ action: 'cut',
|
|
35
|
+
{ action: 'cut', targets: [{ path: 'src/a.ts', name: 'a.ts', kind: 'file' }] },
|
|
36
36
|
]);
|
|
37
37
|
|
|
38
38
|
await harness.step(() => harness.actions()?.handleAction('copy'));
|
|
@@ -53,7 +53,7 @@ describe('useFileActions clipboard', () => {
|
|
|
53
53
|
// so the two entry points — a row's menu and the background's — cannot
|
|
54
54
|
// drift on what a duplicate does.
|
|
55
55
|
expect(harness.clipboard()?.calls).toEqual([
|
|
56
|
-
{ action: 'duplicate',
|
|
56
|
+
{ action: 'duplicate', targets: [{ path: 'src/a.ts', name: 'a.ts', kind: 'file' }] },
|
|
57
57
|
]);
|
|
58
58
|
expect(srv.requests).toEqual([]);
|
|
59
59
|
});
|
|
@@ -68,7 +68,7 @@ describe('useFileActions clipboard', () => {
|
|
|
68
68
|
// The row delegates: the panel's hook is what knows the clipboard's source
|
|
69
69
|
// path, and sending the row's own path would move a file onto itself.
|
|
70
70
|
expect(harness.clipboard()?.calls).toEqual([
|
|
71
|
-
{ action: 'paste',
|
|
71
|
+
{ action: 'paste', targets: [{ path: 'dest', name: 'dest', kind: 'folder' }] },
|
|
72
72
|
]);
|
|
73
73
|
expect(srv.requests).toEqual([]);
|
|
74
74
|
});
|
|
@@ -82,7 +82,7 @@ describe('useFileActions clipboard', () => {
|
|
|
82
82
|
await harness.step(() => harness.actions()?.handleAction('copy'));
|
|
83
83
|
expect(harness.actions()?.pasteLabel).toBeNull();
|
|
84
84
|
|
|
85
|
-
const clip = { scope: '/root\u0000.', path: 'a.ts', name: 'a.ts', kind: 'file' as const, mode: 'copy' as const };
|
|
85
|
+
const clip = { scope: '/root\u0000.', entries: [{ path: 'a.ts', name: 'a.ts', kind: 'file' as const }], mode: 'copy' as const };
|
|
86
86
|
await harness.mount({ path: 'dest', name: 'dest' }, { clipboard: { clip } });
|
|
87
87
|
expect(harness.actions()?.pasteLabel).toBe('Paste a.ts');
|
|
88
88
|
|
|
@@ -100,7 +100,7 @@ describe('useFileActions clipboard', () => {
|
|
|
100
100
|
await harness.step(() => harness.actions()?.handleAction('cut'));
|
|
101
101
|
|
|
102
102
|
expect(harness.clipboard()?.calls).toEqual([
|
|
103
|
-
{ action: 'cut',
|
|
103
|
+
{ action: 'cut', targets: [{ path: 'src', name: 'src', kind: 'folder' }] },
|
|
104
104
|
]);
|
|
105
105
|
});
|
|
106
106
|
});
|
|
@@ -23,7 +23,10 @@ import { useFetcher } from '@/client/lib/router/fetcher';
|
|
|
23
23
|
import { toAbsolutePath } from '@/shared/lib/fs/paths';
|
|
24
24
|
import { copyToClipboard } from '@/client/hooks/ui/clipboard';
|
|
25
25
|
import { useFileCreate, type CreatedEntry } from '@/client/hooks/workspace/file-create';
|
|
26
|
-
import type { FileClipboard } from '@/client/hooks/workspace/file-clipboard';
|
|
26
|
+
import type { FileClipboard, ClipboardTarget } from '@/client/hooks/workspace/file-clipboard';
|
|
27
|
+
import type { FileArchive } from '@/client/hooks/workspace/file-archive';
|
|
28
|
+
import { clipboardLabel } from '@/shared/lib/fs/clipboard';
|
|
29
|
+
import { isArchiveName } from '@/shared/lib/fs/archive';
|
|
27
30
|
import type { FsActionResponse } from '@/shared/types';
|
|
28
31
|
|
|
29
32
|
export interface FileActionTarget {
|
|
@@ -65,6 +68,16 @@ export interface FileActionDeps {
|
|
|
65
68
|
clipboard: FileClipboard;
|
|
66
69
|
/** Whether this row is a folder — what Cut/Copy/Paste need to name their target. */
|
|
67
70
|
isFolder: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The rows the panel has MARKED. When this row is one of several, every batch
|
|
73
|
+
* verb acts on the whole selection; the row that was right-clicked only
|
|
74
|
+
* supplies the menu.
|
|
75
|
+
*/
|
|
76
|
+
selection: readonly ClipboardTarget[];
|
|
77
|
+
/** True when this row is part of the marked set. */
|
|
78
|
+
selected: boolean;
|
|
79
|
+
/** The panel's archive dialogs. */
|
|
80
|
+
archive: FileArchive;
|
|
68
81
|
}
|
|
69
82
|
|
|
70
83
|
export interface FileActions {
|
|
@@ -90,6 +103,10 @@ export interface FileActions {
|
|
|
90
103
|
busy: boolean;
|
|
91
104
|
/** Label of the row's Paste action, or null when a paste cannot land here. */
|
|
92
105
|
pasteLabel: string | null;
|
|
106
|
+
/** How many rows the batch verbs act on — one, or the panel's selection. */
|
|
107
|
+
selectionCount: number;
|
|
108
|
+
/** True when the row itself is an archive the Extract flow understands. */
|
|
109
|
+
isArchive: boolean;
|
|
93
110
|
/**
|
|
94
111
|
* True when the row's label names more than one directory — a collapsed
|
|
95
112
|
* chain, whose inner levels are not rows and therefore not renameable until
|
|
@@ -111,7 +128,7 @@ export interface FileActions {
|
|
|
111
128
|
closeHistory: () => void;
|
|
112
129
|
}
|
|
113
130
|
|
|
114
|
-
export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCreated, onRenamed, onUnfold, onFold, clipboard, isFolder }: FileActionDeps): FileActions {
|
|
131
|
+
export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCreated, onRenamed, onUnfold, onFold, clipboard, isFolder, selection, selected, archive }: FileActionDeps): FileActions {
|
|
115
132
|
const actionFetcher = useFetcher<FsActionResponse>();
|
|
116
133
|
const [contextMenu, setContextMenu] = useState<{ x: number; y: number } | null>(null);
|
|
117
134
|
const contextMenuRef = useRef<HTMLDivElement>(null);
|
|
@@ -183,7 +200,11 @@ export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCre
|
|
|
183
200
|
onOpenFile?.({ path: file.path, name: file.name, root: rootPath, repo: repo || '.' });
|
|
184
201
|
};
|
|
185
202
|
|
|
186
|
-
const clipboardTarget = { path: file.path, name: file.name, kind: isFolder ? 'folder'
|
|
203
|
+
const clipboardTarget: ClipboardTarget = { path: file.path, name: file.name, kind: isFolder ? 'folder' : 'file' };
|
|
204
|
+
// The menu's verbs act on the marked rows when this row is one of them; a
|
|
205
|
+
// right-click on an unmarked row never gets here — the panel selects it first.
|
|
206
|
+
const targets = selected && selection.length > 1 ? selection : [clipboardTarget];
|
|
207
|
+
const archiveTarget = isArchiveName(file.name);
|
|
187
208
|
/**
|
|
188
209
|
* The row's Paste label, or null when a paste cannot land here.
|
|
189
210
|
*
|
|
@@ -194,7 +215,7 @@ export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCre
|
|
|
194
215
|
* background menu, which cannot know which rows are illegal.
|
|
195
216
|
*/
|
|
196
217
|
const pasteLabel = clipboard.clip && !clipboard.refusalFor(clipboardTarget)
|
|
197
|
-
? `Paste ${clipboard.clip
|
|
218
|
+
? `Paste ${clipboardLabel(clipboard.clip) ?? 'item'}`
|
|
198
219
|
: null;
|
|
199
220
|
|
|
200
221
|
const handleAction = (actionType: string) => {
|
|
@@ -241,9 +262,13 @@ export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCre
|
|
|
241
262
|
} else if (actionType === 'delete') {
|
|
242
263
|
setShowDeleteModal(true);
|
|
243
264
|
} else if (actionType === 'cut') {
|
|
244
|
-
clipboard.cut(
|
|
265
|
+
clipboard.cut(targets);
|
|
245
266
|
} else if (actionType === 'copy') {
|
|
246
|
-
clipboard.copy(
|
|
267
|
+
clipboard.copy(targets);
|
|
268
|
+
} else if (actionType === 'compress') {
|
|
269
|
+
archive.openCompress(targets);
|
|
270
|
+
} else if (actionType === 'extract') {
|
|
271
|
+
archive.openExtract(clipboardTarget);
|
|
247
272
|
} else if (actionType === 'duplicate') {
|
|
248
273
|
clipboard.duplicate(clipboardTarget);
|
|
249
274
|
} else if (actionType === 'paste') {
|
|
@@ -264,7 +289,8 @@ export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCre
|
|
|
264
289
|
const submitDelete = () => {
|
|
265
290
|
const fd = new FormData();
|
|
266
291
|
fd.append('actionType', 'delete');
|
|
267
|
-
fd.append('
|
|
292
|
+
if (targets.length > 1) fd.append('paths', JSON.stringify(targets.map((target) => target.path)));
|
|
293
|
+
else fd.append('path', file.path);
|
|
268
294
|
submitAction(fd);
|
|
269
295
|
};
|
|
270
296
|
|
|
@@ -284,8 +310,10 @@ export function useFileActions({ file, diff, onOpenFile, onActionComplete, onCre
|
|
|
284
310
|
renameValue,
|
|
285
311
|
setRenameValue,
|
|
286
312
|
renameError,
|
|
287
|
-
busy: actionFetcher.state !== 'idle' || create.busy || clipboard.busy,
|
|
313
|
+
busy: actionFetcher.state !== 'idle' || create.busy || clipboard.busy || archive.busy,
|
|
288
314
|
pasteLabel,
|
|
315
|
+
selectionCount: targets.length,
|
|
316
|
+
isArchive: archiveTarget,
|
|
289
317
|
chainLabel: onUnfold !== undefined,
|
|
290
318
|
foldable: onFold !== undefined,
|
|
291
319
|
fetcherState: actionFetcher.state,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Edited workbooks that are not on disk yet, keyed by the file they belong to.
|
|
8
|
+
*
|
|
9
|
+
* The grid's edits live in the viewer, and the viewer unmounts when the user
|
|
10
|
+
* switches tabs — so a draft kept in component state would be lost by a glance
|
|
11
|
+
* at another file while the tab still said "edited". This map is the smallest
|
|
12
|
+
* thing that survives that: one entry per workbook with unsaved edits, dropped
|
|
13
|
+
* when the save lands.
|
|
14
|
+
*
|
|
15
|
+
* It is deliberately NOT a cache of every workbook ever opened: a clean
|
|
16
|
+
* workbook is re-read from disk, which is the only copy that can be trusted
|
|
17
|
+
* after an external change.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import type { LoadedWorkbook } from '@/client/components/workspace/editor/viewers/workbook';
|
|
21
|
+
|
|
22
|
+
export interface WorkbookDraft {
|
|
23
|
+
workbook: LoadedWorkbook;
|
|
24
|
+
dirty: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const drafts = new Map<string, WorkbookDraft>();
|
|
28
|
+
|
|
29
|
+
/** The draft for a file, or undefined when it has none. */
|
|
30
|
+
export function draftFor(key: string): WorkbookDraft | undefined {
|
|
31
|
+
return drafts.get(key);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Keep an edited workbook for a file. */
|
|
35
|
+
export function rememberDraft(key: string, draft: WorkbookDraft): void {
|
|
36
|
+
drafts.set(key, draft);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Drop a file's draft — the save landed, or the edits were discarded. */
|
|
40
|
+
export function forgetDraft(key: string): void {
|
|
41
|
+
drafts.delete(key);
|
|
42
|
+
}
|
|
@@ -145,7 +145,7 @@ export type HandleWriteResult = 'written' | 'needs-permission' | 'failed';
|
|
|
145
145
|
*/
|
|
146
146
|
export async function writeThroughHandle(
|
|
147
147
|
handleId: string,
|
|
148
|
-
|
|
148
|
+
data: string | Uint8Array,
|
|
149
149
|
options: { interactive: boolean },
|
|
150
150
|
): Promise<HandleWriteResult> {
|
|
151
151
|
const handle = handles.get(handleId);
|
|
@@ -162,7 +162,7 @@ export async function writeThroughHandle(
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
const writable = await handle.createWritable();
|
|
165
|
-
await writable.write(
|
|
165
|
+
await writable.write(data);
|
|
166
166
|
await writable.close();
|
|
167
167
|
return 'written';
|
|
168
168
|
} catch {
|
|
@@ -3,107 +3,40 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* The app-wide scrollbar reveal rule.
|
|
8
|
-
*
|
|
9
|
-
* What this file pins is the part that is easy to get wrong and impossible to
|
|
10
|
-
* notice by hand: `scroll` does not bubble, so a document listener only sees
|
|
11
|
-
* the reveal if it is registered in the CAPTURE phase with `event.target` read
|
|
12
|
-
* as the scroller. Get that wrong and the code still runs, still adds no error
|
|
13
|
-
* anywhere, and simply never reveals a bar on any container except the page
|
|
14
|
-
* itself — which looks exactly like a CSS problem.
|
|
15
|
-
*
|
|
16
|
-
* The other half is the gate, and it is the reason this module exists in the
|
|
17
|
-
* shape it does: a PROGRAMMATIC scroll is a real, trusted `scroll` event, so a
|
|
18
|
-
* reveal keyed on the event alone pins the bar on screen for as long as
|
|
19
|
-
* anything else moves the container — measured as a chat timeline whose bar
|
|
20
|
-
* never faded during a stream, with nobody touching the page. Every case below
|
|
21
|
-
* that asserts a reveal therefore produces INPUT first, and the cases that
|
|
22
|
-
* assert no reveal are the ones with a bare scroll.
|
|
23
|
-
*
|
|
24
|
-
* Each case gets its OWN document and its own install, because the module is
|
|
25
|
-
* idempotent per document and its input clock is per install: a shared document
|
|
26
|
-
* would make every case inherit the previous one's wheel (and would make a
|
|
27
|
-
* `useFakeTimers` clock that restarts at real time read as recent input).
|
|
28
|
-
*
|
|
29
|
-
* Mounted against happy-dom, the same way the other client tests are.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
6
|
import { afterAll, afterEach, beforeAll, describe, expect, jest, test } from 'bun:test';
|
|
33
|
-
import { Window } from 'happy-dom';
|
|
34
7
|
|
|
35
8
|
import {
|
|
36
|
-
installScrollbarActivity,
|
|
37
9
|
SCROLLBAR_ACTIVE_ATTRIBUTE,
|
|
38
10
|
SCROLLBAR_IDLE_MS,
|
|
39
|
-
|
|
11
|
+
installScrollbarActivity,
|
|
40
12
|
} from '@/client/lib/scrollbar-activity';
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
13
|
+
import {
|
|
14
|
+
ARM_MS,
|
|
15
|
+
IDLE_MS,
|
|
16
|
+
freshPage,
|
|
17
|
+
inputAt,
|
|
18
|
+
restoreNativeGlobals,
|
|
19
|
+
saveNativeGlobals,
|
|
20
|
+
scrollAt,
|
|
21
|
+
scroller,
|
|
22
|
+
} from '@/client/lib/scrollbar-probe.test-util';
|
|
23
|
+
|
|
24
|
+
beforeAll(saveNativeGlobals);
|
|
25
|
+
afterAll(restoreNativeGlobals);
|
|
58
26
|
afterEach(() => {
|
|
59
27
|
jest.useRealTimers();
|
|
60
28
|
});
|
|
61
29
|
|
|
62
|
-
afterAll(() => {
|
|
63
|
-
const target = globalThis as unknown as Record<string, unknown>;
|
|
64
|
-
for (const key of DOM_GLOBALS) {
|
|
65
|
-
if (nativeGlobals[key] === undefined) delete target[key];
|
|
66
|
-
else target[key] = nativeGlobals[key];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
|
|
70
30
|
/**
|
|
71
|
-
*
|
|
31
|
+
* The reveal gate: which scrolls may paint a bar, and for how long.
|
|
72
32
|
*
|
|
73
|
-
* A
|
|
74
|
-
*
|
|
75
|
-
*
|
|
33
|
+
* A `scroll` event alone is not proof of a user — a stream's auto-follow emits
|
|
34
|
+
* real, trusted scroll events — so the gate asks whether the user's input
|
|
35
|
+
* produced this scroll. Everything here is that question, its escape hatches
|
|
36
|
+
* (a held pointer, a delayed delivery) and the fade window.
|
|
76
37
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const target = globalThis as unknown as Record<string, unknown>;
|
|
80
|
-
for (const key of DOM_GLOBALS) target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
81
|
-
installScrollbarActivity(IDLE_MS, ARM_MS);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** A scroll container in the live document. */
|
|
85
|
-
function scroller(): HTMLElement {
|
|
86
|
-
const element = document.createElement('div');
|
|
87
|
-
document.body.appendChild(element);
|
|
88
|
-
return element;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/** The event a browser dispatches at a scroller — it does not bubble. */
|
|
92
|
-
function scrollAt(element: Element): void {
|
|
93
|
-
element.dispatchEvent(new Event('scroll'));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** The input a browser delivers before a scroll the USER caused.
|
|
97
|
-
*
|
|
98
|
-
* Dispatched ON the scroller, because that is what a wheel does: it is targeted
|
|
99
|
-
* at the element under the pointer, and the arm is bound to that subtree so a
|
|
100
|
-
* wheel that could not move its container cannot later vouch for a programmatic
|
|
101
|
-
* scroll somewhere else. */
|
|
102
|
-
function inputAt(element: Element = document.body): void {
|
|
103
|
-
element.dispatchEvent(new Event('wheel'));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
describe('installScrollbarActivity', () => {
|
|
38
|
+
|
|
39
|
+
describe('the scrollbar reveal gate', () => {
|
|
107
40
|
test('a user-driven scroll on a nested container reveals ITS bar, not the page\'s', () => {
|
|
108
41
|
jest.useFakeTimers();
|
|
109
42
|
freshPage();
|