@kabmo-labs/kabmo 0.15.0 → 0.17.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/README.md +3 -2
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +412 -394
- package/dist/client/static/js/index-3ve31rzx.css +1 -0
- package/dist/client/static/js/{index-mx658m43.js → index-rerjq5th.js} +846 -844
- package/marketplace/plugins/stats/README.md +27 -8
- package/marketplace/plugins/stats/package.json +2 -2
- package/marketplace/plugins/stats/src/HeaderReadout.test.tsx +2 -1
- package/marketplace/plugins/stats/src/HeaderReadout.tsx +6 -2
- package/marketplace/plugins/stats/src/KillConfirm.test.tsx +159 -0
- package/marketplace/plugins/stats/src/KillConfirm.tsx +145 -0
- package/marketplace/plugins/stats/src/ProcessTable.tsx +54 -8
- package/marketplace/plugins/stats/src/TotalsBar.test.tsx +5 -2
- package/marketplace/plugins/stats/src/TotalsBar.tsx +13 -3
- package/marketplace/plugins/stats/src/app.test.tsx +100 -4
- package/marketplace/plugins/stats/src/app.tsx +51 -4
- package/marketplace/plugins/stats/src/groups.test.ts +1 -1
- package/marketplace/plugins/stats/src/kill.test.ts +131 -0
- package/marketplace/plugins/stats/src/kill.ts +74 -0
- package/marketplace/plugins/stats/src/labels.test.ts +1 -0
- package/marketplace/plugins/stats/src/machine.test.ts +77 -0
- package/marketplace/plugins/stats/src/machine.ts +115 -0
- package/marketplace/plugins/stats/src/proc/darwin.ts +38 -0
- package/marketplace/plugins/stats/src/proc/linux.ts +4 -0
- package/marketplace/plugins/stats/src/proc/ps.ts +1 -0
- package/marketplace/plugins/stats/src/proc/types.ts +11 -0
- package/marketplace/plugins/stats/src/sampler.test.ts +42 -4
- package/marketplace/plugins/stats/src/sampler.ts +32 -18
- package/marketplace/plugins/stats/src/server.ts +29 -2
- package/marketplace/plugins/stats/src/snapshot.ts +31 -3
- package/package.json +3 -2
- package/src/client/components/common/Modal.tsx +7 -0
- package/src/client/components/common/code-surface/bracket-guide.test.ts +2 -2
- package/src/client/components/common/code-surface/bracket-guide.ts +2 -2
- package/src/client/components/common/code-surface/conflict-markers.ts +5 -5
- package/src/client/components/common/code-surface/extensions.ts +7 -4
- package/src/client/components/common/code-surface/theme.ts +34 -9
- package/src/client/components/common/code-surface/whitespace.test.ts +223 -0
- package/src/client/components/common/code-surface/whitespace.ts +140 -0
- package/src/client/components/common/{server-switcher/index.tsx → server-control/Panel.tsx} +73 -35
- package/src/client/components/common/{server-switcher → server-control}/index.test.tsx +98 -37
- package/src/client/components/common/server-control/index.tsx +118 -0
- package/src/client/components/layout/LeftDock.tsx +1 -0
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +8 -50
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +1 -0
- package/src/client/components/mobile/RightSidebar.tsx +1 -0
- package/src/client/components/mobile/mobile-main-view/Header.tsx +6 -12
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +41 -13
- package/src/client/components/mobile/mobile-session-sidebar/use-dock.ts +1 -0
- package/src/client/components/settings/Modal.tsx +9 -3
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +19 -9
- package/src/client/components/settings/categories/AgentSettings.tsx +27 -6
- package/src/client/components/settings/categories/ProjectSettings.tsx +122 -156
- package/src/client/components/settings/categories/SkillCatalogSettings.tsx +220 -260
- package/src/client/components/settings/categories/SkillSettings.tsx +6 -3
- package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +5 -0
- package/src/client/components/settings/categories/project-settings/AccentPalette.test.tsx +189 -0
- package/src/client/components/settings/categories/project-settings/AccentPalette.tsx +156 -24
- package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +175 -0
- package/src/client/components/settings/categories/project-settings/DeleteProjectModal.tsx +107 -0
- package/src/client/components/settings/categories/project-settings/DetailsForm.tsx +40 -24
- package/src/client/components/settings/categories/project-settings/DetailsHeader.tsx +17 -7
- package/src/client/components/settings/categories/project-settings/IconGrid.tsx +164 -69
- package/src/client/components/settings/categories/project-settings/ModelDropdown.test.tsx +122 -0
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +124 -53
- package/src/client/components/settings/categories/project-settings/NameInput.tsx +57 -11
- package/src/client/components/settings/categories/project-settings/PathField.tsx +122 -0
- package/src/client/components/settings/categories/project-settings/SidebarList.tsx +100 -59
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +253 -0
- package/src/client/components/settings/categories/skill-catalog/SkillCard.tsx +89 -0
- package/src/client/components/settings/categories/skill-catalog/SourceRail.tsx +122 -0
- package/src/client/components/settings/categories/skill-catalog/catalog-ui.test.tsx +179 -0
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +208 -0
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +137 -232
- package/src/client/components/settings/categories/skill-settings/InstructionsEditor.tsx +84 -0
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +123 -87
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +179 -0
- package/src/client/components/settings/categories/skill-settings/row-meta.ts +58 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +6 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.test.ts +46 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +29 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +11 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +6 -2
- package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +18 -2
- package/src/client/components/workspace/editor/viewers/viewers.test.ts +39 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +18 -5
- package/src/client/components/workspace/file-explorer/Modals.tsx +15 -1
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +68 -0
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +47 -57
- package/src/client/components/workspace/file-explorer/collapsed-chain.test.ts +167 -0
- package/src/client/components/workspace/file-explorer/drag-props.ts +42 -0
- package/src/client/components/workspace/file-explorer/drag.test.ts +43 -0
- package/src/client/components/workspace/file-explorer/index.tsx +21 -20
- package/src/client/components/workspace/model-dropdown/Panel.tsx +7 -2
- package/src/client/components/workspace/model-dropdown/Section.test.tsx +13 -0
- package/src/client/components/workspace/model-dropdown/Section.tsx +5 -1
- package/src/client/components/workspace/panels/builtin.tsx +7 -0
- package/src/client/components/workspace/wiki-panel/NavModal.test.tsx +136 -0
- package/src/client/components/workspace/wiki-panel/NavModal.tsx +94 -0
- package/src/client/components/workspace/wiki-panel/PageView.tsx +16 -10
- package/src/client/components/workspace/wiki-panel/index.tsx +44 -9
- package/src/client/data/settings/omp-schema.json +91 -4
- package/src/client/data/settings/project.ts +9 -28
- package/src/client/data/settings/skill.ts +6 -32
- package/src/client/hooks/chat/timeline/pending-model.ts +28 -0
- package/src/client/hooks/settings/projects/index.ts +294 -0
- package/src/client/hooks/settings/projects.test.ts +237 -0
- package/src/client/hooks/settings/skill-catalog.ts +101 -9
- package/src/client/hooks/settings/skill-git-import.ts +153 -0
- package/src/client/hooks/shell/servers.test.ts +166 -0
- package/src/client/hooks/{desktop → shell}/servers.ts +17 -14
- package/src/client/hooks/ui/updates/shell-download.ts +1 -1
- package/src/client/hooks/ui/updates/shell-update.ts +2 -6
- package/src/client/hooks/workspace/file-row-drag.ts +41 -0
- package/src/client/hooks/workspace/file-tree-actions.ts +25 -1
- package/src/client/hooks/workspace/file-tree-edits.ts +23 -6
- package/src/client/hooks/workspace/root-drop-target.ts +77 -0
- package/src/client/hooks/workspace/unfolded-chains.ts +165 -0
- package/src/client/lib/desktop/dropped-paths.ts +1 -1
- package/src/client/lib/desktop/titlebar.test.ts +12 -3
- package/src/client/lib/desktop/titlebar.ts +1 -1
- package/src/client/lib/shell/desktop.ts +117 -0
- package/src/client/lib/shell/servers.ts +75 -0
- package/src/client/lib/shell/transport.ts +216 -0
- package/src/client/main.tsx +9 -0
- package/src/server/lib/db/schema.ts +11 -0
- package/src/server/lib/fs/git-merge-conflict.test.ts +14 -1
- package/src/server/lib/lifecycle/memory.test.ts +41 -1
- package/src/server/lib/lifecycle/memory.ts +131 -14
- package/src/server/lib/omp/config/skill-sources.ts +49 -0
- package/src/server/lib/omp/config/skills-git-install.ts +155 -0
- package/src/server/lib/omp/config/skills-git-repo.ts +288 -0
- package/src/server/lib/omp/config/skills-git.test.ts +220 -0
- package/src/server/lib/omp/session/subagent-presence-scan.test.ts +137 -0
- package/src/server/lib/omp/session/subagent-presence-scan.ts +120 -0
- package/src/server/lib/omp/session/subagent-presence-store.test.ts +120 -0
- package/src/server/lib/omp/session/subagent-presence-store.ts +65 -0
- package/src/server/lib/omp/session/subagent-presence.ts +52 -15
- package/src/server/lib/workspace/project-model.server.test.ts +102 -0
- package/src/server/lib/workspace/project-model.server.ts +47 -0
- package/src/server/lib/workspace/project-patch.server.ts +156 -0
- package/src/server/routes/agent/new.ts +8 -1
- package/src/server/routes/settings/agents.ts +19 -7
- package/src/server/routes/settings/projects.ts +53 -19
- package/src/server/routes/settings/settings-projects-routes.test.ts +214 -0
- package/src/server/routes/settings/settings-store-routes.test.ts +5 -2
- package/src/server/routes/settings/skills-catalog-actions.ts +195 -0
- package/src/server/routes/settings/skills.test.ts +225 -0
- package/src/server/routes/settings/skills.ts +18 -15
- package/src/shared/lib/fs/folder-chain.test.ts +81 -1
- package/src/shared/lib/fs/folder-chain.ts +84 -0
- package/src/shared/lib/omp/config/schema.test.ts +35 -0
- package/src/shared/lib/omp/session/job-progress.test.ts +37 -1
- package/src/shared/lib/omp/session/job-progress.ts +31 -0
- package/src/shared/lib/omp/session/proc.ts +5 -0
- package/src/shared/lib/omp/session/wait.ts +5 -0
- package/src/shared/lib/ui/mobile-overlay.ts +61 -0
- package/src/shared/lib/ui/svg-scope.test.ts +97 -0
- package/src/shared/lib/ui/svg-scope.ts +134 -0
- package/src/shared/lib/workspace/project-accent.test.ts +69 -0
- package/src/shared/lib/workspace/project-accent.ts +63 -0
- package/src/shared/lib/workspace/project-icon.ts +40 -0
- package/src/shared/lib/workspace/project-model.test.ts +79 -0
- package/src/shared/lib/workspace/project-model.ts +64 -0
- package/src/shared/types/settings/skill.ts +53 -3
- package/src/test-support/file-explorer-disk.test-util.ts +25 -1
- package/src/test-support/file-explorer-drag.test-util.ts +88 -0
- package/src/test-support/file-explorer.test-util.ts +47 -47
- package/dist/client/static/js/index-28pwtt69.css +0 -1
- package/src/client/components/common/code-surface/indent-guide.ts +0 -104
- package/src/client/components/settings/categories/skill-catalog/AddSourceModal.tsx +0 -133
- package/src/client/hooks/desktop/servers.test.ts +0 -73
- package/src/client/lib/desktop/bridge.ts +0 -203
- package/src/shared/lib/code/editor/indent-guide-rule.test.ts +0 -65
- package/src/shared/lib/code/editor/indent-guide-rule.ts +0 -47
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A collapsed folder chain is ONE row standing for several directories, and
|
|
8
|
+
* that is where both reported bugs came from.
|
|
9
|
+
*
|
|
10
|
+
* `dev/src/main/code` is drawn as a single row whose `path` is the DEEPEST
|
|
11
|
+
* directory, so the levels inside its label are not rows at all:
|
|
12
|
+
*
|
|
13
|
+
* - **A drop** on the row landed in `code`, because that was the only path the
|
|
14
|
+
* row could name — dragging something onto `main` was impossible.
|
|
15
|
+
* - **A rename** could only address `code`, so typing `dev2/src/main` moved it
|
|
16
|
+
* out and left `dev/src/main` behind, and renaming `main` was unexpressible.
|
|
17
|
+
*
|
|
18
|
+
* The fix is one mechanism on both paths: the chain is UNFOLDED into a row per
|
|
19
|
+
* directory — on a hovering drag, or from the row's menu — after which every
|
|
20
|
+
* level is an ordinary folder that can be dropped on, renamed and created
|
|
21
|
+
* inside. These specs assert the two reported cases through a real DOM, plus
|
|
22
|
+
* the two halves that keep the unfold honest: Fold puts the chain back, and a
|
|
23
|
+
* rename that PRESERVES the chain keeps it unfolded.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
27
|
+
import { createFileExplorerHarness } from '@/test-support/file-explorer.test-util';
|
|
28
|
+
|
|
29
|
+
const panel = createFileExplorerHarness();
|
|
30
|
+
|
|
31
|
+
beforeAll(() => {
|
|
32
|
+
panel.install();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
panel.unmount();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterAll(() => {
|
|
40
|
+
panel.restore();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/** `dev/src/main/code/a.ts`: four directories, three of them folded away. */
|
|
44
|
+
const CHAIN = {
|
|
45
|
+
'.': { dev: null },
|
|
46
|
+
dev: { src: null },
|
|
47
|
+
'dev/src': { main: null },
|
|
48
|
+
'dev/src/main': { code: null },
|
|
49
|
+
'dev/src/main/code': { 'a.ts': 'file' },
|
|
50
|
+
} as const;
|
|
51
|
+
|
|
52
|
+
describe('Files panel collapsed chains', () => {
|
|
53
|
+
test('dragging onto a level inside the chain drops there, not in the deepest folder', async () => {
|
|
54
|
+
panel.disk = { ...structuredClone(CHAIN), '.': { dev: null, 'moved.ts': 'file' } } as never;
|
|
55
|
+
await panel.mount();
|
|
56
|
+
// One row, naming the whole chain — the levels are not rows yet.
|
|
57
|
+
expect(panel.visibleNames()).toContain('dev/src/main/code');
|
|
58
|
+
|
|
59
|
+
// Hovering the row unfolds it, which is what puts `main` on screen; the
|
|
60
|
+
// drop then lands on the row that names it.
|
|
61
|
+
await panel.hoverRow('moved.ts', 'dev/src/main/code');
|
|
62
|
+
expect(panel.visibleNames()).toContain('main');
|
|
63
|
+
|
|
64
|
+
await panel.dragRow('moved.ts', 'main');
|
|
65
|
+
|
|
66
|
+
expect(panel.transferRequests).toEqual([
|
|
67
|
+
{
|
|
68
|
+
actionType: 'paste',
|
|
69
|
+
sourcePath: 'moved.ts',
|
|
70
|
+
mode: 'cut',
|
|
71
|
+
targetPath: 'dev/src/main',
|
|
72
|
+
targetKind: 'folder',
|
|
73
|
+
root: '/ws',
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('the row menu unfolds the chain, so every level becomes a row', async () => {
|
|
79
|
+
panel.disk = structuredClone(CHAIN) as never;
|
|
80
|
+
await panel.mount();
|
|
81
|
+
|
|
82
|
+
await panel.rightClickRow('dev/src/main/code');
|
|
83
|
+
expect(panel.buttonLabels()).toContain('Unfold Folders');
|
|
84
|
+
await panel.clickMenuRow('Unfold Folders');
|
|
85
|
+
|
|
86
|
+
// Outermost first: each level is its own row, and the levels above the
|
|
87
|
+
// deepest are drawn open (a hidden row would hide the level below it).
|
|
88
|
+
const names = panel.visibleNames();
|
|
89
|
+
for (const name of ['dev', 'src', 'main', 'code']) expect(names).toContain(name);
|
|
90
|
+
expect(names).not.toContain('dev/src/main/code');
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('renaming a folder inside the chain renames THAT folder', async () => {
|
|
94
|
+
panel.disk = structuredClone(CHAIN) as never;
|
|
95
|
+
await panel.mount();
|
|
96
|
+
|
|
97
|
+
await panel.rightClickRow('dev/src/main/code');
|
|
98
|
+
await panel.clickMenuRow('Unfold Folders');
|
|
99
|
+
|
|
100
|
+
await panel.rightClickRow('main');
|
|
101
|
+
await panel.clickMenuRow('Rename');
|
|
102
|
+
// The field names the row's own path, which is what makes `dev2/src/main`
|
|
103
|
+
// mean "move `main`" rather than "move the deepest directory".
|
|
104
|
+
expect(panel.renameInput()?.value).toBe('dev/src/main');
|
|
105
|
+
await panel.submitRename('dev2/src/main');
|
|
106
|
+
|
|
107
|
+
expect(panel.renameRequests.at(-1)).toEqual({
|
|
108
|
+
actionType: 'rename',
|
|
109
|
+
path: 'dev/src/main',
|
|
110
|
+
newPath: 'dev2/src/main',
|
|
111
|
+
root: '/ws',
|
|
112
|
+
});
|
|
113
|
+
// `main` moved with everything under it; `dev` and `dev2` are now separate
|
|
114
|
+
// trees, which is what the paths say.
|
|
115
|
+
expect(panel.disk['dev2/src']).toEqual({ main: null });
|
|
116
|
+
expect(panel.disk['dev2/src/main']).toEqual({ code: null });
|
|
117
|
+
expect(panel.disk['dev2/src/main/code']).toEqual({ 'a.ts': 'file' });
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('renaming the chain’s start keeps it unfolded, at its new paths', async () => {
|
|
121
|
+
panel.disk = structuredClone(CHAIN) as never;
|
|
122
|
+
await panel.mount();
|
|
123
|
+
|
|
124
|
+
await panel.rightClickRow('dev/src/main/code');
|
|
125
|
+
await panel.clickMenuRow('Unfold Folders');
|
|
126
|
+
await panel.rightClickRow('dev');
|
|
127
|
+
await panel.clickMenuRow('Rename');
|
|
128
|
+
await panel.submitRename('dev2');
|
|
129
|
+
|
|
130
|
+
const names = panel.visibleNames();
|
|
131
|
+
expect(names).toContain('dev2');
|
|
132
|
+
expect(names).toContain('src');
|
|
133
|
+
expect(names).toContain('main');
|
|
134
|
+
expect(names).toContain('code');
|
|
135
|
+
expect(names).not.toContain('dev');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test('Fold Folders puts the chain back into the one row it is listed as', async () => {
|
|
139
|
+
panel.disk = structuredClone(CHAIN) as never;
|
|
140
|
+
await panel.mount();
|
|
141
|
+
|
|
142
|
+
await panel.rightClickRow('dev/src/main/code');
|
|
143
|
+
await panel.clickMenuRow('Unfold Folders');
|
|
144
|
+
await panel.rightClickRow('dev');
|
|
145
|
+
expect(panel.buttonLabels()).toContain('Fold Folders');
|
|
146
|
+
await panel.clickMenuRow('Fold Folders');
|
|
147
|
+
|
|
148
|
+
expect(panel.visibleNames()).toContain('dev/src/main/code');
|
|
149
|
+
expect(panel.visibleNames()).not.toContain('main');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('the rename dialog says which of the two it renames', async () => {
|
|
153
|
+
panel.disk = structuredClone(CHAIN) as never;
|
|
154
|
+
await panel.mount();
|
|
155
|
+
|
|
156
|
+
await panel.rightClickRow('dev/src/main/code');
|
|
157
|
+
await panel.clickMenuRow('Rename');
|
|
158
|
+
|
|
159
|
+
// The row reads as four directories while the rename moves one, and only
|
|
160
|
+
// the dialog can say so — otherwise a path typed from the label leaves the
|
|
161
|
+
// rest of the chain behind.
|
|
162
|
+
const text = panel.documentText();
|
|
163
|
+
expect(text).toContain('this renames');
|
|
164
|
+
expect(text).toContain('dev/src/main/code');
|
|
165
|
+
expect(text).toContain('Unfold Folders');
|
|
166
|
+
});
|
|
167
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Files panel's drag-and-drop contract, shared by the panel and the row.
|
|
8
|
+
*
|
|
9
|
+
* Split from `TreeItem.tsx` because the panel owns every one of these and each
|
|
10
|
+
* row only forwards them: declaring them once is what stops the two from
|
|
11
|
+
* drifting on which of them a nested row must be handed. The behaviour lives in
|
|
12
|
+
* `useFileRowDrag`; this file names what is handed down.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { ClipboardTarget } from '@/client/hooks/workspace/file-clipboard';
|
|
16
|
+
|
|
17
|
+
export interface FileTreeDragProps {
|
|
18
|
+
/** The row currently being dragged, or null. Panel state — see `useFileRowDrag`. */
|
|
19
|
+
dragging: ClipboardTarget | null;
|
|
20
|
+
/** A drag of this row started / ended / was dropped on `target`. */
|
|
21
|
+
onDragStart: (target: ClipboardTarget) => void;
|
|
22
|
+
onDragEnd: () => void;
|
|
23
|
+
onDropOn: (target: ClipboardTarget) => void;
|
|
24
|
+
/**
|
|
25
|
+
* Split a collapsed chain row into one row per directory.
|
|
26
|
+
*
|
|
27
|
+
* A chain row's label names directories that are not rows at all, so they
|
|
28
|
+
* cannot be dropped on or renamed. The panel calls this when a drag hovers an
|
|
29
|
+
* accepting row and when the row's own menu asks for it.
|
|
30
|
+
*/
|
|
31
|
+
onUnfold?: (target: ClipboardTarget) => void;
|
|
32
|
+
/** Fold an unfolded chain back into the one row it is listed as. */
|
|
33
|
+
onFold?: (deepestPath: string) => void;
|
|
34
|
+
/**
|
|
35
|
+
* Outermost level of each unfolded chain → the chain's deepest path.
|
|
36
|
+
*
|
|
37
|
+
* Only the outermost level offers Fold: it is the row the listing folds, and
|
|
38
|
+
* the one that still reads as the chain's beginning once the levels inside it
|
|
39
|
+
* are drawn separately.
|
|
40
|
+
*/
|
|
41
|
+
foldRoots?: ReadonlyMap<string, string>;
|
|
42
|
+
}
|
|
@@ -25,6 +25,12 @@
|
|
|
25
25
|
* already lives in, or a folder into its own subtree, must not reach the
|
|
26
26
|
* server: a request would be a move the user did not ask for.
|
|
27
27
|
*
|
|
28
|
+
* 5. **The blue block belongs to the row under the POINTER, not to every legal
|
|
29
|
+
* target.** It was drawn from `acceptsDrop` — the capability — so a drag
|
|
30
|
+
* painted every folder and file on screen at once and read as "everything is
|
|
31
|
+
* selected" (measured: dragging `a.ts` over `b` and `c` highlighted both).
|
|
32
|
+
* The background's tint had the same bug, over the whole tree.
|
|
33
|
+
*
|
|
28
34
|
* Driven through the shared harness, so this file and the listing specs exercise
|
|
29
35
|
* one mount and one HTTP stub.
|
|
30
36
|
*/
|
|
@@ -145,4 +151,41 @@ describe('Files panel drag and drop', () => {
|
|
|
145
151
|
|
|
146
152
|
expect(panel.dirReads).toContain('.');
|
|
147
153
|
});
|
|
154
|
+
|
|
155
|
+
test('only the row under the pointer is highlighted during a drag', async () => {
|
|
156
|
+
panel.disk = { '.': { 'a.ts': 'file', first: null, second: null }, first: { 'x.ts': 'file' }, second: { 'y.ts': 'file' } };
|
|
157
|
+
await panel.mount();
|
|
158
|
+
|
|
159
|
+
await panel.hoverRow('a.ts', 'first');
|
|
160
|
+
|
|
161
|
+
// `second` would accept the drop just as well, and used to be painted.
|
|
162
|
+
const highlighted = [...panel.container.querySelectorAll('[class*="bg-info"]')]
|
|
163
|
+
.map((el) => el.textContent?.trim() ?? '');
|
|
164
|
+
expect(highlighted).toEqual(['first']);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('the highlight leaves the row when the pointer does, and the drop still lands', async () => {
|
|
168
|
+
// `a.ts` lives INSIDE `dest`, so dropping it on the background is a real
|
|
169
|
+
// move to the root rather than the no-op the rule refuses.
|
|
170
|
+
panel.disk = { '.': { dest: null, other: null }, dest: { 'a.ts': 'file' }, other: {} };
|
|
171
|
+
await panel.mount();
|
|
172
|
+
await panel.clickRow('dest');
|
|
173
|
+
|
|
174
|
+
await panel.hoverRow('a.ts', 'other');
|
|
175
|
+
expect(panel.container.querySelectorAll('[class*="bg-info"]')).toHaveLength(1);
|
|
176
|
+
|
|
177
|
+
// Leaving the row for the background: the row's block goes out and the
|
|
178
|
+
// drop lands at the root, which is where the pointer is.
|
|
179
|
+
await panel.dropOnBackground();
|
|
180
|
+
expect(panel.transferRequests[0]?.targetPath).toBe('.');
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test('the background is not tinted for the whole gesture', async () => {
|
|
184
|
+
panel.disk = { '.': { 'a.ts': 'file', dest: null }, dest: {} };
|
|
185
|
+
await panel.mount();
|
|
186
|
+
|
|
187
|
+
// The drag is in flight and no row is hovered: nothing to promise yet.
|
|
188
|
+
await panel.startDrag('a.ts');
|
|
189
|
+
expect(panel.container.querySelectorAll('[class*="bg-info"]')).toHaveLength(0);
|
|
190
|
+
});
|
|
148
191
|
});
|
|
@@ -11,6 +11,7 @@ import { useFileListing } from '@/client/hooks/workspace/file-listing';
|
|
|
11
11
|
import { useFileCreate } from '@/client/hooks/workspace/file-create';
|
|
12
12
|
import { useFileClipboard, type ClipboardTarget } from '@/client/hooks/workspace/file-clipboard';
|
|
13
13
|
import { useFileTreeEdits } from '@/client/hooks/workspace/file-tree-edits';
|
|
14
|
+
import { useUnfoldedChains } from '@/client/hooks/workspace/unfolded-chains';
|
|
14
15
|
import { filterFileTree } from '@/client/components/workspace/file-explorer/filter';
|
|
15
16
|
import { useRepoList, useRepoScope } from '@/client/hooks/workspace/repo-scope';
|
|
16
17
|
import { useRealtimeTopic } from '@/client/hooks/ui/realtime';
|
|
@@ -18,6 +19,8 @@ import { useToasts } from '@/client/hooks/ui/toasts';
|
|
|
18
19
|
import { useTouchDevice } from '@/client/hooks/ui/touch-device';
|
|
19
20
|
import { ToastStack } from '@/client/components/common/ToastStack';
|
|
20
21
|
import { fsTopic } from '@/shared/lib/realtime/protocol';
|
|
22
|
+
import { unfoldChains } from '@/shared/lib/fs/folder-chain';
|
|
23
|
+
import { useRootDropTarget } from '@/client/hooks/workspace/root-drop-target';
|
|
21
24
|
|
|
22
25
|
export function FileExplorer({ className = '', enabled = true, rootPath, onOpenFile, refreshKey = 0, onRefresh }: { className?: string, enabled?: boolean, rootPath?: string, onOpenFile?: (file: any) => void, refreshKey?: number, onRefresh?: () => void }) {
|
|
23
26
|
const [searchQuery, setSearchQuery] = useSessionState<string>('files.searchQuery', '');
|
|
@@ -117,8 +120,15 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
117
120
|
setExpandedPaths,
|
|
118
121
|
setStoredExpandedPaths,
|
|
119
122
|
reload: refresh,
|
|
123
|
+
onMoved: (fromPath, toPath) => rekeyUnfold(fromPath, toPath),
|
|
120
124
|
});
|
|
121
125
|
|
|
126
|
+
// A collapsed chain row is ONE row standing for several directories, so the
|
|
127
|
+
// levels inside its label have no row to drop on (a drop lands in the deepest
|
|
128
|
+
// directory) and no row to rename. Unfolding — on a hovering drag, or from the
|
|
129
|
+
// row's own menu — turns each level back into a row.
|
|
130
|
+
const { unfolded, unfold, fold, rekey: rekeyUnfold } = useUnfoldedChains({ scope: listing.scope, setExpandedPaths, setStoredExpandedPaths });
|
|
131
|
+
|
|
122
132
|
// One clipboard for the whole tree, owned here and passed down: a
|
|
123
133
|
// subscription per row would be hundreds of listeners for a value that
|
|
124
134
|
// changes on a right-click.
|
|
@@ -156,11 +166,7 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
156
166
|
*/
|
|
157
167
|
const [dragging, setDragging] = useState<ClipboardTarget | null>(null);
|
|
158
168
|
|
|
159
|
-
|
|
160
|
-
* Whether the listing root may accept the drag in flight — the background is
|
|
161
|
-
* a drop target like any other, and the rule is the same one a row uses.
|
|
162
|
-
*/
|
|
163
|
-
const rootAcceptsDrop = Boolean(dragging) && clipboard.moveRefusalFor(dragging!, rootTarget) === null;
|
|
169
|
+
const root = useRootDropTarget({ dragging, clipboard, target: rootTarget });
|
|
164
170
|
|
|
165
171
|
// The root's own "New File": the panel background is the one target whose
|
|
166
172
|
// create belongs at the tree's top, and it is the only action the root menu
|
|
@@ -186,7 +192,8 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
186
192
|
|
|
187
193
|
const tree = listing.files;
|
|
188
194
|
|
|
189
|
-
const
|
|
195
|
+
const projected = unfoldChains(tree, unfolded);
|
|
196
|
+
const files = filterFileTree(projected.nodes, searchQuery);
|
|
190
197
|
// The button spins for this panel's own read OR a topic push: the server
|
|
191
198
|
// republishes `fs:` on every tool call, so the tree moved with nothing on
|
|
192
199
|
// screen saying so otherwise.
|
|
@@ -210,7 +217,7 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
210
217
|
<div
|
|
211
218
|
className={`flex-1 scrollbar-overlay-container p-2 font-mono text-[11px] text-ink/80 ${
|
|
212
219
|
touch ? 'file-tree-touch' : ''
|
|
213
|
-
} ${
|
|
220
|
+
} ${root.highlighted ? 'bg-info/[0.06]' : ''}`}
|
|
214
221
|
onContextMenu={(e) => {
|
|
215
222
|
// The panel's own background. A row stops propagation before this
|
|
216
223
|
// runs, so this handler only ever sees a right-click that named NO
|
|
@@ -218,19 +225,10 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
218
225
|
e.preventDefault();
|
|
219
226
|
setRootMenu({ x: e.clientX, y: e.clientY });
|
|
220
227
|
}}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
if (!rootAcceptsDrop) return;
|
|
226
|
-
e.preventDefault();
|
|
227
|
-
if (e.dataTransfer) e.dataTransfer.dropEffect = 'move';
|
|
228
|
-
}}
|
|
229
|
-
onDrop={(e) => {
|
|
230
|
-
if (!rootAcceptsDrop) return;
|
|
231
|
-
e.preventDefault();
|
|
232
|
-
clipboard.move(dragging!, rootTarget);
|
|
233
|
-
}}
|
|
228
|
+
onDragEnter={root.onDragEnter}
|
|
229
|
+
onDragLeave={root.onDragLeave}
|
|
230
|
+
onDragOver={root.onDragOver}
|
|
231
|
+
onDrop={root.onDrop}
|
|
234
232
|
>
|
|
235
233
|
{listing.isLoading && files.length === 0 ? (
|
|
236
234
|
<div className="p-4 text-center text-ink/40">
|
|
@@ -265,6 +263,9 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
|
|
|
265
263
|
if (!dragging) return;
|
|
266
264
|
clipboard.move(dragging, target);
|
|
267
265
|
}}
|
|
266
|
+
onUnfold={unfold}
|
|
267
|
+
onFold={fold}
|
|
268
|
+
foldRoots={projected.roots}
|
|
268
269
|
touch={touch}
|
|
269
270
|
/>
|
|
270
271
|
))
|
|
@@ -93,9 +93,14 @@ export function ModelDropdownPanel({
|
|
|
93
93
|
onAddProvider={onAddProvider}
|
|
94
94
|
/>
|
|
95
95
|
|
|
96
|
-
{/* Scrollable Model Lists
|
|
96
|
+
{/* Scrollable Model Lists. Deliberately no top padding: Chrome's
|
|
97
|
+
sticky view rectangle is the scrollport's CONTENT box, so a
|
|
98
|
+
`sticky top-0` heading inside a padded list pins below the padding
|
|
99
|
+
and leaves that strip showing rows sliding above it (measured: a
|
|
100
|
+
`p-1.5` list pinned its heading 6px down and `elementFromPoint` at
|
|
101
|
+
2px returned a row). The first heading sits flush instead. */}
|
|
97
102
|
<div
|
|
98
|
-
className="flex-1 scrollbar-overlay-container
|
|
103
|
+
className="flex-1 scrollbar-overlay-container px-1.5 pb-1.5 space-y-2 max-h-80"
|
|
99
104
|
onMouseLeave={onMouseLeave}
|
|
100
105
|
// The row under a resting pointer moves when the list scrolls; the
|
|
101
106
|
// card follows it instead of staying where the hover started.
|
|
@@ -123,6 +123,19 @@ describe('model picker section header columns', () => {
|
|
|
123
123
|
expect(chevronSlot.querySelector('svg')).not.toBeNull();
|
|
124
124
|
});
|
|
125
125
|
|
|
126
|
+
test('the header pins to the top of the scrolling list', () => {
|
|
127
|
+
mountSection();
|
|
128
|
+
|
|
129
|
+
// The list is capped (`max-h-80`), so a provider heading that scrolled
|
|
130
|
+
// away left its rows unnamed. `sticky top-0` keeps it in view; the opaque
|
|
131
|
+
// paper background is what hides the rows passing underneath, and z-10
|
|
132
|
+
// keeps the heading above them.
|
|
133
|
+
expect(header().className).toContain('sticky');
|
|
134
|
+
expect(header().className).toContain('top-0');
|
|
135
|
+
expect(header().className).toContain('bg-paper');
|
|
136
|
+
expect(header().className).toContain('z-10');
|
|
137
|
+
});
|
|
138
|
+
|
|
126
139
|
test('a row carries its row id, which the specs card anchors to', () => {
|
|
127
140
|
mountSection();
|
|
128
141
|
|
|
@@ -56,7 +56,11 @@ export function ModelDropdownSection({
|
|
|
56
56
|
<button
|
|
57
57
|
type="button"
|
|
58
58
|
onClick={() => onToggleCollapse(id)}
|
|
59
|
-
|
|
59
|
+
// Sticky: the list is capped at `max-h-80`, and a section heading that
|
|
60
|
+
// scrolled away left the rows below it with no provider to name them.
|
|
61
|
+
// The opaque paper background is what hides those rows as they pass
|
|
62
|
+
// under the pinned heading; `z-10` keeps the heading above the rows.
|
|
63
|
+
className="sticky top-0 z-10 w-full flex items-center justify-between gap-2 pl-1 pr-2 py-1 text-[11px] font-semibold text-ink/60 uppercase tracking-wider hover:text-ink cursor-pointer select-none bg-paper"
|
|
60
64
|
>
|
|
61
65
|
<div className="flex items-center gap-2 min-w-0">
|
|
62
66
|
{iconType === 'star' && (
|
|
@@ -52,6 +52,13 @@ export interface PanelBodyProps {
|
|
|
52
52
|
onClose?: () => void;
|
|
53
53
|
/** The phone's drawer hides a view's own header; the desktop stack does not. */
|
|
54
54
|
showHeader?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Which shell is drawing this body. A view with its own small-screen form
|
|
57
|
+
* (the wiki's floating page-list button) must know the PHONE from a merely
|
|
58
|
+
* narrow desktop column; no container or media query can tell the two apart.
|
|
59
|
+
* Omitted means desktop.
|
|
60
|
+
*/
|
|
61
|
+
layout?: 'desktop' | 'phone';
|
|
55
62
|
/**
|
|
56
63
|
* The boot settings snapshot, for the views that read it (the session list
|
|
57
64
|
* passes it to its own Settings modal and to the prewarm's access mode).
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The narrow wiki nav: an outlined floating trigger opens the page list as a
|
|
8
|
+
* modal, and reaching a page closes it.
|
|
9
|
+
*
|
|
10
|
+
* Three properties are pinned because each is invisible to a markup screenshot:
|
|
11
|
+
* the trigger reports its open state (`aria-expanded`), Escape closes the modal
|
|
12
|
+
* the reader opened (no other UI unmounts it), and a page click closes it too —
|
|
13
|
+
* a modal left covering the page the reader just chose is the bug this pair
|
|
14
|
+
* exists to avoid.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
18
|
+
import { Window } from 'happy-dom';
|
|
19
|
+
import { render, type ComponentChild } from 'preact';
|
|
20
|
+
import { act } from 'preact/test-utils';
|
|
21
|
+
import { WikiNavModal, WikiNavTrigger } from '@/client/components/workspace/wiki-panel/NavModal';
|
|
22
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
23
|
+
import type { WikiNavSection } from '@/shared/types/wiki';
|
|
24
|
+
|
|
25
|
+
const SECTIONS: WikiNavSection[] = [
|
|
26
|
+
{
|
|
27
|
+
title: 'Navigation',
|
|
28
|
+
links: [
|
|
29
|
+
{ label: 'Home', target: 'Home', path: 'Home.md', url: null },
|
|
30
|
+
{ label: 'Deploying', target: 'Deploying', path: 'Deploying.md', url: null },
|
|
31
|
+
],
|
|
32
|
+
notes: ['**Version**: 1.6.0'],
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
let container: HTMLElement | null = null;
|
|
37
|
+
|
|
38
|
+
function mount(node: ComponentChild): HTMLElement {
|
|
39
|
+
container = document.createElement('div');
|
|
40
|
+
document.body.appendChild(container);
|
|
41
|
+
act(() => render(node, container as HTMLElement));
|
|
42
|
+
return container;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
beforeAll(() => {
|
|
46
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
afterEach(() => {
|
|
50
|
+
if (container) {
|
|
51
|
+
render(null, container);
|
|
52
|
+
container.remove();
|
|
53
|
+
container = null;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
afterAll(() => {
|
|
58
|
+
restoreDomGlobals();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('WikiNavTrigger', () => {
|
|
62
|
+
test('is an outlined button that reports the state it opens', () => {
|
|
63
|
+
let clicks = 0;
|
|
64
|
+
const root = mount(<WikiNavTrigger open={false} onClick={() => { clicks += 1; }} />);
|
|
65
|
+
const button = root.querySelector('button');
|
|
66
|
+
|
|
67
|
+
expect(button).not.toBeNull();
|
|
68
|
+
expect(button?.getAttribute('aria-expanded')).toBe('false');
|
|
69
|
+
// Outline, not fill: the trigger floats over the document it belongs to.
|
|
70
|
+
expect(button?.getAttribute('class')).toContain('border');
|
|
71
|
+
|
|
72
|
+
act(() => button?.click());
|
|
73
|
+
expect(clicks).toBe(1);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('reports the modal as expanded while it is open', () => {
|
|
77
|
+
const root = mount(<WikiNavTrigger open onClick={() => {}} />);
|
|
78
|
+
expect(root.querySelector('button')?.getAttribute('aria-expanded')).toBe('true');
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('WikiNavModal', () => {
|
|
83
|
+
test('renders nothing while closed', () => {
|
|
84
|
+
const root = mount(
|
|
85
|
+
<WikiNavModal open={false} sections={SECTIONS} selected={null} onSelect={() => {}} onClose={() => {}} />,
|
|
86
|
+
);
|
|
87
|
+
expect(root.querySelector('[role="dialog"]')).toBeNull();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('shows the wiki sections and closes when a page is chosen', () => {
|
|
91
|
+
const selected: string[] = [];
|
|
92
|
+
let closed = 0;
|
|
93
|
+
const root = mount(
|
|
94
|
+
<WikiNavModal
|
|
95
|
+
open
|
|
96
|
+
sections={SECTIONS}
|
|
97
|
+
selected="Home.md"
|
|
98
|
+
onSelect={(path) => selected.push(path)}
|
|
99
|
+
onClose={() => { closed += 1; }}
|
|
100
|
+
/>,
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const dialog = root.querySelector('[role="dialog"]');
|
|
104
|
+
expect(dialog).not.toBeNull();
|
|
105
|
+
expect(dialog?.getAttribute('aria-label')).toBe('Wiki pages');
|
|
106
|
+
expect(dialog?.textContent).toContain('Navigation');
|
|
107
|
+
expect(dialog?.textContent).toContain('1.6.0');
|
|
108
|
+
|
|
109
|
+
const page = Array.from(dialog?.querySelectorAll<HTMLButtonElement>('button') ?? []).find(
|
|
110
|
+
(button) => button.textContent === 'Deploying',
|
|
111
|
+
);
|
|
112
|
+
expect(page).not.toBeNull();
|
|
113
|
+
act(() => page?.click());
|
|
114
|
+
|
|
115
|
+
expect(selected).toEqual(['Deploying.md']);
|
|
116
|
+
expect(closed).toBe(1);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('Escape closes the modal', () => {
|
|
120
|
+
let closed = 0;
|
|
121
|
+
mount(
|
|
122
|
+
<WikiNavModal
|
|
123
|
+
open
|
|
124
|
+
sections={SECTIONS}
|
|
125
|
+
selected={null}
|
|
126
|
+
onSelect={() => {}}
|
|
127
|
+
onClose={() => { closed += 1; }}
|
|
128
|
+
/>,
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
act(() => {
|
|
132
|
+
document.dispatchEvent(new window.KeyboardEvent('keydown', { key: 'Escape' }));
|
|
133
|
+
});
|
|
134
|
+
expect(closed).toBe(1);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The wiki's navigation on the phone: the floating outline-style button in the
|
|
8
|
+
* page, and the page list as a modal.
|
|
9
|
+
*
|
|
10
|
+
* This is the same pattern the phone's markdown editor already uses for its
|
|
11
|
+
* outline (`MobileOutlineButton`): a tap-sized round button outlined rather
|
|
12
|
+
* than filled, floating over the document it belongs to, with the list in the
|
|
13
|
+
* shared `Modal` shell. The desktop panel keeps its nav column and its
|
|
14
|
+
* drill-down when the column is narrow; `WikiPanel` decides which one renders
|
|
15
|
+
* from the `layout` it was handed, never from a container query.
|
|
16
|
+
*
|
|
17
|
+
* Selecting a page closes the modal, because the point of opening it was to
|
|
18
|
+
* reach that page.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useEffect } from 'preact/hooks';
|
|
22
|
+
import { ListTree } from 'lucide-preact';
|
|
23
|
+
import { Modal } from '@/client/components/common/Modal';
|
|
24
|
+
import { WikiNav } from '@/client/components/workspace/wiki-panel/Nav';
|
|
25
|
+
import type { WikiNavSection } from '@/shared/types/wiki';
|
|
26
|
+
|
|
27
|
+
interface WikiNavTriggerProps {
|
|
28
|
+
open: boolean;
|
|
29
|
+
onClick: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function WikiNavTrigger({ open, onClick }: WikiNavTriggerProps) {
|
|
33
|
+
return (
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
onClick={onClick}
|
|
37
|
+
title="Browse wiki pages"
|
|
38
|
+
aria-label="Browse wiki pages"
|
|
39
|
+
aria-expanded={open}
|
|
40
|
+
className="absolute bottom-3 right-3 z-20 flex h-9 w-9 items-center justify-center rounded-full border border-ink/20 bg-paper text-ink/60 shadow-sm transition-all hover:bg-ink/5 hover:text-ink active:scale-95"
|
|
41
|
+
>
|
|
42
|
+
<ListTree size={16} />
|
|
43
|
+
</button>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface WikiNavModalProps {
|
|
48
|
+
open: boolean;
|
|
49
|
+
sections: readonly WikiNavSection[];
|
|
50
|
+
selected: string | null;
|
|
51
|
+
onSelect: (path: string) => void;
|
|
52
|
+
onClose: () => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function WikiNavModal({ open, sections, selected, onSelect, onClose }: WikiNavModalProps) {
|
|
56
|
+
// A dialog this small is dismissed with Escape in every other surface; the
|
|
57
|
+
// shared `Modal` shell does not bind it, so the owner of the open flag does.
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (!open) return;
|
|
60
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
61
|
+
if (event.key === 'Escape') onClose();
|
|
62
|
+
};
|
|
63
|
+
document.addEventListener('keydown', onKeyDown);
|
|
64
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
65
|
+
}, [open, onClose]);
|
|
66
|
+
|
|
67
|
+
if (!open) return null;
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Modal
|
|
71
|
+
onClose={onClose}
|
|
72
|
+
maxWidthClass="max-w-sm"
|
|
73
|
+
zClass="z-[70]"
|
|
74
|
+
ariaLabel="Wiki pages"
|
|
75
|
+
header={
|
|
76
|
+
<div className="flex min-w-0 items-center gap-2">
|
|
77
|
+
<ListTree size={15} className="flex-shrink-0 text-ink/50" />
|
|
78
|
+
<span className="text-sm font-medium">Wiki pages</span>
|
|
79
|
+
</div>
|
|
80
|
+
}
|
|
81
|
+
>
|
|
82
|
+
<div className="flex h-[60vh] min-h-0 flex-col">
|
|
83
|
+
<WikiNav
|
|
84
|
+
sections={sections}
|
|
85
|
+
selected={selected}
|
|
86
|
+
onSelect={(path) => {
|
|
87
|
+
onSelect(path);
|
|
88
|
+
onClose();
|
|
89
|
+
}}
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
</Modal>
|
|
93
|
+
);
|
|
94
|
+
}
|