@gmickel/gno 2.14.0 → 2.16.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 +1 -1
- package/assets/skill/cli-reference.md +4 -2
- package/assets/spa-production.json.gz +0 -0
- package/browser-extension/artifacts/{gno-browser-clipper-v2.14.0.zip → gno-browser-clipper-v2.16.0.zip} +0 -0
- package/browser-extension/artifacts/gno-browser-clipper-v2.16.0.zip.sha256 +1 -0
- package/browser-extension/dist/manifest.json +1 -1
- package/package.json +1 -1
- package/spec/cli.md +88 -45
- package/spec/db/schema.sql +45 -0
- package/spec/output-schemas/embed-receipt.schema.json +89 -0
- package/src/cli/commands/agents/commands.ts +1 -1
- package/src/cli/commands/ask.ts +1 -1
- package/src/cli/commands/context-build.ts +1 -1
- package/src/cli/commands/embed.ts +341 -20
- package/src/cli/commands/links.ts +1 -1
- package/src/cli/commands/mcp/install.ts +2 -2
- package/src/cli/commands/mcp/status.ts +1 -1
- package/src/cli/commands/mcp/uninstall.ts +1 -1
- package/src/cli/commands/query.ts +1 -1
- package/src/cli/commands/shared.ts +4 -4
- package/src/cli/commands/skill/install.ts +1 -1
- package/src/cli/commands/skill/paths-cmd.ts +1 -1
- package/src/cli/commands/skill/uninstall.ts +1 -1
- package/src/cli/commands/status.ts +75 -58
- package/src/cli/config-cache.ts +86 -0
- package/src/cli/globals.ts +64 -0
- package/src/cli/options.ts +23 -0
- package/src/cli/program.ts +44 -37
- package/src/cli/run.ts +121 -67
- package/src/cli/runtime-health.ts +132 -122
- package/src/cli/session-binding.ts +11 -2
- package/src/config/saver.ts +8 -0
- package/src/converters/adapters/browser-export/formats.ts +25 -15
- package/src/converters/adapters/email/adapter.ts +37 -53
- package/src/converters/adapters/email/html.ts +37 -20
- package/src/converters/adapters/email/mime.ts +71 -39
- package/src/converters/adapters/ical/adapter.ts +20 -12
- package/src/converters/adapters/jsonl/adapter.ts +8 -6
- package/src/converters/adapters/shared/html-text.ts +55 -37
- package/src/converters/adapters/shared/ooxml-protection.ts +5 -13
- package/src/converters/adapters/shared/utf8-lines.ts +69 -31
- package/src/converters/adapters/transcript/adapter.ts +12 -7
- package/src/converters/adapters/xlsx/adapter.ts +10 -7
- package/src/converters/adapters/xlsx/sheet-markdown.ts +93 -50
- package/src/converters/canonicalize.ts +17 -3
- package/src/converters/native/markdown.ts +24 -17
- package/src/converters/native/plaintext.ts +5 -6
- package/src/converters/registry.ts +130 -8
- package/src/core/activation-status.ts +4 -8
- package/src/core/change-diff.ts +38 -11
- package/src/core/context-compiler.ts +17 -18
- package/src/core/context-evidence.ts +116 -25
- package/src/core/context-verifier.ts +70 -31
- package/src/core/file-lock.ts +10 -2
- package/src/core/graph-analysis.ts +3 -3
- package/src/core/link-inventory-markdown.ts +2 -2
- package/src/core/links.ts +20 -87
- package/src/core/memory-fence.ts +16 -9
- package/src/core/memory-recall.ts +168 -34
- package/src/core/path-rules.ts +143 -0
- package/src/core/section-parse.ts +16 -6
- package/src/core/typed-metadata.ts +68 -0
- package/src/core/wiki-link-syntax.ts +88 -0
- package/src/embed/backlog.ts +173 -60
- package/src/embed/batch.ts +83 -12
- package/src/embed/resume-cursor.ts +103 -0
- package/src/embed/retry.ts +41 -32
- package/src/embed/variant-backlog.ts +697 -63
- package/src/embed/variant-plan.ts +41 -45
- package/src/embed/variant-retry.ts +157 -44
- package/src/index.ts +3 -3
- package/src/ingestion/budget-error-codes.ts +13 -0
- package/src/ingestion/chunker.ts +60 -49
- package/src/ingestion/compiled-context.ts +4 -5
- package/src/ingestion/convert-file.ts +1 -1
- package/src/ingestion/document-metadata.ts +16 -9
- package/src/ingestion/excluded-ranges.ts +97 -0
- package/src/ingestion/file-processor.ts +122 -37
- package/src/ingestion/frontmatter.ts +35 -7
- package/src/ingestion/graph-reconciliation.ts +187 -51
- package/src/ingestion/language.ts +66 -61
- package/src/ingestion/position.ts +5 -5
- package/src/ingestion/prepare-file.ts +50 -29
- package/src/ingestion/record-adapter-canonical.ts +37 -26
- package/src/ingestion/record-adapter.ts +46 -26
- package/src/ingestion/record-container.ts +121 -53
- package/src/ingestion/record-path.ts +5 -2
- package/src/ingestion/source-availability/darwin-io.ts +10 -7
- package/src/ingestion/source-availability/darwin-path.ts +21 -3
- package/src/ingestion/source-availability/readers.ts +51 -0
- package/src/ingestion/strip.ts +39 -105
- package/src/ingestion/sync.ts +692 -386
- package/src/ingestion/typed-metadata.ts +10 -4
- package/src/ingestion/walker.ts +485 -158
- package/src/llm/cache.ts +128 -84
- package/src/llm/http-inference.ts +112 -35
- package/src/llm/http-policy.ts +101 -0
- package/src/llm/httpEmbedding.ts +8 -1
- package/src/llm/httpGeneration.ts +5 -1
- package/src/llm/httpRerank.ts +5 -1
- package/src/llm/inference-scope.ts +15 -2
- package/src/llm/lazy-ports.ts +33 -3
- package/src/llm/lockfile.ts +34 -7
- package/src/llm/model-cleanup.ts +24 -0
- package/src/llm/native-worker/client.ts +23 -12
- package/src/llm/native-worker/dispatcher.ts +19 -9
- package/src/llm/native-worker/embedding-identity.ts +42 -16
- package/src/llm/native-worker/entry.ts +2 -1
- package/src/llm/native-worker/owner.ts +1 -0
- package/src/llm/native-worker/ports.ts +86 -23
- package/src/llm/native-worker/protocol.ts +386 -55
- package/src/llm/nodeLlamaCpp/adapter.ts +46 -29
- package/src/llm/nodeLlamaCpp/embedding.ts +93 -40
- package/src/llm/nodeLlamaCpp/generation.ts +194 -30
- package/src/llm/nodeLlamaCpp/lifecycle.ts +2 -0
- package/src/llm/nodeLlamaCpp/rerank-capacity.ts +101 -23
- package/src/llm/nodeLlamaCpp/rerank.ts +253 -44
- package/src/llm/types.ts +14 -0
- package/src/mcp/context.ts +342 -23
- package/src/mcp/http-transport.ts +21 -3
- package/src/mcp/tool-profile-types.ts +62 -0
- package/src/mcp/tool-profile.ts +32 -56
- package/src/mcp/tools/context.ts +5 -1
- package/src/mcp/tools/index.ts +269 -191
- package/src/mcp/tools/links.ts +7 -5
- package/src/mcp/tools/query.ts +60 -37
- package/src/mcp/tools/vsearch.ts +25 -14
- package/src/pipeline/answer.ts +133 -40
- package/src/pipeline/claim-verification.ts +293 -189
- package/src/pipeline/claim-verifier.ts +6 -7
- package/src/pipeline/egress-lineage.ts +37 -26
- package/src/pipeline/exclude.ts +34 -11
- package/src/pipeline/expansion.ts +233 -19
- package/src/pipeline/filters.ts +169 -33
- package/src/pipeline/graph-retrieval.ts +117 -61
- package/src/pipeline/hybrid.ts +598 -329
- package/src/pipeline/hydration.ts +86 -24
- package/src/pipeline/intent.ts +15 -7
- package/src/pipeline/owner-fusion.ts +61 -19
- package/src/pipeline/query-language.ts +15 -2
- package/src/pipeline/rerank.ts +15 -22
- package/src/pipeline/search.ts +193 -72
- package/src/pipeline/snippet.ts +15 -2
- package/src/pipeline/temporal.ts +51 -10
- package/src/pipeline/vsearch.ts +250 -152
- package/src/publish/attachment-raster.ts +2 -16
- package/src/publish/encrypted-export.ts +15 -5
- package/src/serve/browse-tree.ts +50 -42
- package/src/serve/connectors.ts +2 -1
- package/src/serve/context.ts +13 -4
- package/src/serve/doc-events.ts +3 -0
- package/src/serve/public/app.tsx +49 -21
- package/src/serve/public/components/BrowseTreeSidebar.tsx +163 -23
- package/src/serve/public/components/CaptureModal.tsx +14 -10
- package/src/serve/public/components/ai-elements/code-block.tsx +87 -50
- package/src/serve/public/components/editor/MarkdownPreview.tsx +99 -67
- package/src/serve/public/globals.built.css +1 -1
- package/src/serve/public/globals.css +19 -0
- package/src/serve/public/hooks/useCaptureModal.tsx +23 -10
- package/src/serve/public/lib/metadata-filter.ts +234 -9
- package/src/serve/public/pages/Browse.tsx +61 -27
- package/src/serve/public/pages/DocView.tsx +44 -25
- package/src/serve/public/pages/GraphView.tsx +8 -3
- package/src/serve/resident-runtime.ts +199 -48
- package/src/serve/routes/api.ts +98 -67
- package/src/serve/routes/links.ts +18 -4
- package/src/serve/server.ts +1370 -1180
- package/src/serve/spa-bundle-source.ts +52 -27
- package/src/serve/status.ts +101 -52
- package/src/serve/watch-reconciliation-fallback.ts +11 -7
- package/src/serve/watch-reconciliation-shared.ts +42 -4
- package/src/serve/watch-reconciliation.ts +21 -8
- package/src/serve/watch-service-events.ts +7 -1
- package/src/serve/watch-service-hosts.ts +3 -1
- package/src/serve/watch-service.ts +46 -21
- package/src/serve/watch-snapshot-scan.ts +6 -15
- package/src/sessions/archive.ts +20 -8
- package/src/sessions/sanitize.ts +38 -18
- package/src/sessions/service.ts +180 -102
- package/src/store/migrations/036-vector-mirror-state.ts +83 -0
- package/src/store/migrations/037-performance-indexes.ts +56 -0
- package/src/store/migrations/index.ts +4 -0
- package/src/store/sqlite/adapter.ts +1217 -651
- package/src/store/sqlite/chunking-policy.ts +15 -1
- package/src/store/sqlite/eligibility.ts +110 -70
- package/src/store/sqlite/graph-neighbors.ts +71 -46
- package/src/store/sqlite/graph-reference-state.ts +27 -3
- package/src/store/sqlite/graph-similarity.ts +59 -12
- package/src/store/sqlite/metadata-predicate.ts +123 -28
- package/src/store/sqlite/retrieval-trace-management-store.ts +126 -33
- package/src/store/sqlite/retrieval-trace-retention.ts +88 -76
- package/src/store/sqlite/retrieval-trace-rows.ts +7 -3
- package/src/store/types.ts +32 -0
- package/src/store/vector/eligibility.ts +39 -0
- package/src/store/vector/lazy.ts +17 -0
- package/src/store/vector/partition-index.ts +49 -47
- package/src/store/vector/proof-cache.ts +103 -0
- package/src/store/vector/sqlite-vec.ts +230 -139
- package/src/store/vector/stats.ts +29 -73
- package/src/store/vector/status.ts +151 -52
- package/src/store/vector/stored-vectors.ts +131 -45
- package/src/store/vector/types.ts +10 -0
- package/src/store/vector/variant-search.ts +771 -109
- package/src/store/vector/variants.ts +785 -144
- package/browser-extension/artifacts/gno-browser-clipper-v2.14.0.zip.sha256 +0 -1
package/src/serve/browse-tree.ts
CHANGED
|
@@ -62,17 +62,22 @@ function sortNodes(nodes: BrowseTreeNode[]): void {
|
|
|
62
62
|
|
|
63
63
|
function ensureFolderNode(
|
|
64
64
|
root: BrowseTreeNode,
|
|
65
|
+
childrenByNode: Map<BrowseTreeNode, Map<string, BrowseTreeNode>>,
|
|
65
66
|
collection: string,
|
|
66
|
-
|
|
67
|
+
parts: readonly string[],
|
|
68
|
+
incrementDocumentCount: boolean
|
|
67
69
|
): BrowseTreeNode {
|
|
68
|
-
const normalizedFolderPath = normalizeBrowsePath(folderPath);
|
|
69
|
-
const parts = normalizedFolderPath.split("/").filter(Boolean);
|
|
70
70
|
let current = root;
|
|
71
71
|
let currentPath = "";
|
|
72
72
|
|
|
73
73
|
for (const part of parts) {
|
|
74
74
|
currentPath = currentPath ? `${currentPath}/${part}` : part;
|
|
75
|
-
let
|
|
75
|
+
let childMap = childrenByNode.get(current);
|
|
76
|
+
if (!childMap) {
|
|
77
|
+
childMap = new Map<string, BrowseTreeNode>();
|
|
78
|
+
childrenByNode.set(current, childMap);
|
|
79
|
+
}
|
|
80
|
+
let next = childMap.get(part);
|
|
76
81
|
if (!next) {
|
|
77
82
|
next = createNode({
|
|
78
83
|
kind: "folder",
|
|
@@ -81,8 +86,12 @@ function ensureFolderNode(
|
|
|
81
86
|
name: part,
|
|
82
87
|
depth: current.depth + 1,
|
|
83
88
|
});
|
|
89
|
+
childMap.set(part, next);
|
|
84
90
|
current.children.push(next);
|
|
85
91
|
}
|
|
92
|
+
if (incrementDocumentCount) {
|
|
93
|
+
next.documentCount += 1;
|
|
94
|
+
}
|
|
86
95
|
current = next;
|
|
87
96
|
}
|
|
88
97
|
|
|
@@ -95,6 +104,7 @@ export function buildBrowseTree(
|
|
|
95
104
|
folders: BrowseFolderLike[] = []
|
|
96
105
|
): BrowseTreeNode[] {
|
|
97
106
|
const roots = new Map<string, BrowseTreeNode>();
|
|
107
|
+
const childrenByNode = new Map<BrowseTreeNode, Map<string, BrowseTreeNode>>();
|
|
98
108
|
|
|
99
109
|
for (const collection of collections) {
|
|
100
110
|
roots.set(
|
|
@@ -139,25 +149,14 @@ export function buildBrowseTree(
|
|
|
139
149
|
continue;
|
|
140
150
|
}
|
|
141
151
|
|
|
142
|
-
const
|
|
152
|
+
const leaf = ensureFolderNode(
|
|
143
153
|
root,
|
|
154
|
+
childrenByNode,
|
|
144
155
|
doc.collection,
|
|
145
|
-
folderParts
|
|
156
|
+
folderParts,
|
|
157
|
+
true
|
|
146
158
|
);
|
|
147
|
-
|
|
148
|
-
let pointer = root;
|
|
149
|
-
let currentPath = "";
|
|
150
|
-
for (const part of folderParts) {
|
|
151
|
-
currentPath = currentPath ? `${currentPath}/${part}` : part;
|
|
152
|
-
const next = pointer.children.find((child) => child.path === currentPath);
|
|
153
|
-
if (!next) {
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
next.documentCount += 1;
|
|
157
|
-
pointer = next;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
current.directDocumentCount += 1;
|
|
159
|
+
leaf.directDocumentCount += 1;
|
|
161
160
|
}
|
|
162
161
|
|
|
163
162
|
for (const folder of folders) {
|
|
@@ -172,7 +171,10 @@ export function buildBrowseTree(
|
|
|
172
171
|
});
|
|
173
172
|
roots.set(folder.collection, root);
|
|
174
173
|
}
|
|
175
|
-
|
|
174
|
+
const parts = normalizeBrowsePath(folder.path).split("/").filter(Boolean);
|
|
175
|
+
if (parts.length > 0) {
|
|
176
|
+
ensureFolderNode(root, childrenByNode, folder.collection, parts, false);
|
|
177
|
+
}
|
|
176
178
|
}
|
|
177
179
|
|
|
178
180
|
const sortedRoots = [...roots.values()].sort((a, b) =>
|
|
@@ -181,9 +183,32 @@ export function buildBrowseTree(
|
|
|
181
183
|
for (const root of sortedRoots) {
|
|
182
184
|
sortNodes(root.children);
|
|
183
185
|
}
|
|
186
|
+
indexBrowseTree(sortedRoots);
|
|
184
187
|
return sortedRoots;
|
|
185
188
|
}
|
|
186
189
|
|
|
190
|
+
const browseTreeIndex = new WeakMap<
|
|
191
|
+
BrowseTreeNode[],
|
|
192
|
+
Map<string, BrowseTreeNode>
|
|
193
|
+
>();
|
|
194
|
+
|
|
195
|
+
function indexBrowseTree(roots: BrowseTreeNode[]): Map<string, BrowseTreeNode> {
|
|
196
|
+
const index = new Map<string, BrowseTreeNode>();
|
|
197
|
+
const stack: BrowseTreeNode[] = [...roots];
|
|
198
|
+
while (stack.length > 0) {
|
|
199
|
+
const node = stack.pop();
|
|
200
|
+
if (!node) {
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
index.set(`${node.collection}\u0000${node.path}`, node);
|
|
204
|
+
for (const child of node.children) {
|
|
205
|
+
stack.push(child);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
browseTreeIndex.set(roots, index);
|
|
209
|
+
return index;
|
|
210
|
+
}
|
|
211
|
+
|
|
187
212
|
export function findBrowseNode(
|
|
188
213
|
roots: BrowseTreeNode[],
|
|
189
214
|
collection?: string | null,
|
|
@@ -193,29 +218,12 @@ export function findBrowseNode(
|
|
|
193
218
|
return null;
|
|
194
219
|
}
|
|
195
220
|
|
|
196
|
-
const root = roots.find((node) => node.collection === collection);
|
|
197
|
-
if (!root) {
|
|
198
|
-
return null;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
221
|
const normalizedPath = normalizeBrowsePath(path);
|
|
202
|
-
|
|
203
|
-
|
|
222
|
+
let index = browseTreeIndex.get(roots);
|
|
223
|
+
if (!index) {
|
|
224
|
+
index = indexBrowseTree(roots);
|
|
204
225
|
}
|
|
205
|
-
|
|
206
|
-
const queue = [...root.children];
|
|
207
|
-
while (queue.length > 0) {
|
|
208
|
-
const node = queue.shift();
|
|
209
|
-
if (!node) {
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
if (node.path === normalizedPath) {
|
|
213
|
-
return node;
|
|
214
|
-
}
|
|
215
|
-
queue.push(...node.children);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return null;
|
|
226
|
+
return index.get(`${collection}\u0000${normalizedPath}`) ?? null;
|
|
219
227
|
}
|
|
220
228
|
|
|
221
229
|
export function getBrowseAncestorIds(
|
package/src/serve/connectors.ts
CHANGED
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
} from "../cli/commands/mcp/status";
|
|
22
22
|
import { installSkillToTarget } from "../cli/commands/skill/install";
|
|
23
23
|
import { resolveSkillPaths } from "../cli/commands/skill/paths";
|
|
24
|
-
import { verifyConnectorActivation } from "../core/connector-verifier";
|
|
25
24
|
|
|
26
25
|
export interface ConnectorStatus {
|
|
27
26
|
id: string;
|
|
@@ -423,5 +422,7 @@ export async function verifyInstalledConnector(
|
|
|
423
422
|
target = toMcpConnectorVerificationTarget(definition.id, status);
|
|
424
423
|
}
|
|
425
424
|
|
|
425
|
+
const { verifyConnectorActivation } =
|
|
426
|
+
await import("../core/connector-verifier");
|
|
426
427
|
return verifyConnectorActivation(store, collection, target, options);
|
|
427
428
|
}
|
package/src/serve/context.ts
CHANGED
|
@@ -153,10 +153,19 @@ export async function createServerContext(
|
|
|
153
153
|
embedPort
|
|
154
154
|
);
|
|
155
155
|
const expandUri = preset.expand ?? preset.gen;
|
|
156
|
-
expandPort = lazyGenerationPort(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
expandPort = lazyGenerationPort(
|
|
157
|
+
expandUri,
|
|
158
|
+
() =>
|
|
159
|
+
resolvePort(() =>
|
|
160
|
+
llm.createExpansionPort(expandUri, createPortOptions("expand"))
|
|
161
|
+
),
|
|
162
|
+
{
|
|
163
|
+
resolveModelIdentity: async () => {
|
|
164
|
+
const resolved = await llm.getCache().resolve(expandUri, "expand");
|
|
165
|
+
if (!resolved.ok) return null;
|
|
166
|
+
return { modelPath: resolved.value };
|
|
167
|
+
},
|
|
168
|
+
}
|
|
160
169
|
);
|
|
161
170
|
answerPort = lazyGenerationPort(preset.gen, () =>
|
|
162
171
|
resolvePort(() =>
|
package/src/serve/doc-events.ts
CHANGED
package/src/serve/public/app.tsx
CHANGED
|
@@ -26,9 +26,10 @@ import {
|
|
|
26
26
|
updateActiveTabBrowseState,
|
|
27
27
|
type WorkspaceState,
|
|
28
28
|
} from "./lib/workspace-tabs";
|
|
29
|
-
import ClipperPairing from "./pages/ClipperPairing";
|
|
30
29
|
import Dashboard from "./pages/Dashboard";
|
|
31
30
|
|
|
31
|
+
const ClipperPairing = lazy(() => import("./pages/ClipperPairing"));
|
|
32
|
+
|
|
32
33
|
const QuickSwitcher = lazy(() =>
|
|
33
34
|
import("./components/QuickSwitcher").then((module) => ({
|
|
34
35
|
default: module.QuickSwitcher,
|
|
@@ -109,6 +110,20 @@ function AppContent({
|
|
|
109
110
|
}: AppContentProps) {
|
|
110
111
|
const { openCapture } = useCaptureModal();
|
|
111
112
|
const [quickSwitcherOpen, setQuickSwitcherOpen] = useState(false);
|
|
113
|
+
const [hasMountedQuickSwitcher, setHasMountedQuickSwitcher] = useState(false);
|
|
114
|
+
const [hasMountedShortcutHelp, setHasMountedShortcutHelp] = useState(false);
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (quickSwitcherOpen && !hasMountedQuickSwitcher) {
|
|
118
|
+
setHasMountedQuickSwitcher(true);
|
|
119
|
+
}
|
|
120
|
+
}, [quickSwitcherOpen, hasMountedQuickSwitcher]);
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (shortcutHelpOpen && !hasMountedShortcutHelp) {
|
|
124
|
+
setHasMountedShortcutHelp(true);
|
|
125
|
+
}
|
|
126
|
+
}, [shortcutHelpOpen, hasMountedShortcutHelp]);
|
|
112
127
|
|
|
113
128
|
useEffect(() => {
|
|
114
129
|
const basePath = location.split("?")[0];
|
|
@@ -249,19 +264,25 @@ function AppContent({
|
|
|
249
264
|
</footer>
|
|
250
265
|
</div>
|
|
251
266
|
<HelpButton onClick={() => setShortcutHelpOpen(true)} />
|
|
252
|
-
|
|
253
|
-
<
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
267
|
+
{(quickSwitcherOpen || hasMountedQuickSwitcher) && (
|
|
268
|
+
<Suspense fallback={null}>
|
|
269
|
+
<QuickSwitcher
|
|
270
|
+
location={location}
|
|
271
|
+
navigate={(to) => navigate(to)}
|
|
272
|
+
onCreateNote={openCapture}
|
|
273
|
+
onOpenChange={setQuickSwitcherOpen}
|
|
274
|
+
open={quickSwitcherOpen}
|
|
275
|
+
/>
|
|
276
|
+
</Suspense>
|
|
277
|
+
)}
|
|
278
|
+
{(shortcutHelpOpen || hasMountedShortcutHelp) && (
|
|
279
|
+
<Suspense fallback={null}>
|
|
280
|
+
<ShortcutHelpModal
|
|
281
|
+
onOpenChange={setShortcutHelpOpen}
|
|
282
|
+
open={shortcutHelpOpen}
|
|
283
|
+
/>
|
|
284
|
+
</Suspense>
|
|
285
|
+
)}
|
|
265
286
|
</>
|
|
266
287
|
);
|
|
267
288
|
}
|
|
@@ -362,13 +383,16 @@ function App() {
|
|
|
362
383
|
[]
|
|
363
384
|
);
|
|
364
385
|
|
|
386
|
+
const workspaceContextValue = useMemo(
|
|
387
|
+
() => ({
|
|
388
|
+
activeTab: activeTab ?? null,
|
|
389
|
+
updateActiveTabBrowseState: updateActiveBrowseState,
|
|
390
|
+
}),
|
|
391
|
+
[activeTab, updateActiveBrowseState]
|
|
392
|
+
);
|
|
393
|
+
|
|
365
394
|
return (
|
|
366
|
-
<WorkspaceProvider
|
|
367
|
-
value={{
|
|
368
|
-
activeTab: activeTab ?? null,
|
|
369
|
-
updateActiveTabBrowseState: updateActiveBrowseState,
|
|
370
|
-
}}
|
|
371
|
-
>
|
|
395
|
+
<WorkspaceProvider value={workspaceContextValue}>
|
|
372
396
|
<CaptureModalProvider>
|
|
373
397
|
<AppContent
|
|
374
398
|
location={location}
|
|
@@ -392,7 +416,11 @@ if (!rootElement) {
|
|
|
392
416
|
const root = createRoot(rootElement);
|
|
393
417
|
if (window.location.pathname === "/clipper/pair") {
|
|
394
418
|
const launch = consumeClipperPairLaunch(window.location, window.history);
|
|
395
|
-
root.render(
|
|
419
|
+
root.render(
|
|
420
|
+
<Suspense fallback={null}>
|
|
421
|
+
<ClipperPairing pairId={launch.pairId} />
|
|
422
|
+
</Suspense>
|
|
423
|
+
);
|
|
396
424
|
} else {
|
|
397
425
|
root.render(<App />);
|
|
398
426
|
}
|
|
@@ -26,25 +26,33 @@ interface VisibleBrowseNode {
|
|
|
26
26
|
parentId: string | null;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
function
|
|
29
|
+
function flattenInto(
|
|
30
30
|
nodes: BrowseTreeNode[],
|
|
31
31
|
expandedNodeIds: Set<string>,
|
|
32
|
-
parentId: string | null
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
parentId: string | null,
|
|
33
|
+
out: VisibleBrowseNode[]
|
|
34
|
+
): void {
|
|
36
35
|
for (const node of nodes) {
|
|
37
|
-
|
|
36
|
+
out.push({ node, parentId });
|
|
38
37
|
if (node.children.length > 0 && expandedNodeIds.has(node.id)) {
|
|
39
|
-
|
|
40
|
-
...flattenVisibleNodes(node.children, expandedNodeIds, node.id)
|
|
41
|
-
);
|
|
38
|
+
flattenInto(node.children, expandedNodeIds, node.id, out);
|
|
42
39
|
}
|
|
43
40
|
}
|
|
41
|
+
}
|
|
44
42
|
|
|
43
|
+
function flattenVisibleNodes(
|
|
44
|
+
nodes: BrowseTreeNode[],
|
|
45
|
+
expandedNodeIds: Set<string>
|
|
46
|
+
): VisibleBrowseNode[] {
|
|
47
|
+
const flat: VisibleBrowseNode[] = [];
|
|
48
|
+
flattenInto(nodes, expandedNodeIds, null, flat);
|
|
45
49
|
return flat;
|
|
46
50
|
}
|
|
47
51
|
|
|
52
|
+
const VIRTUALIZE_THRESHOLD = 100;
|
|
53
|
+
const VIRTUAL_ROW_HEIGHT_PX = 36;
|
|
54
|
+
const VIRTUAL_OVERSCAN_ROWS = 12;
|
|
55
|
+
|
|
48
56
|
export function BrowseTreeSidebar({
|
|
49
57
|
collections,
|
|
50
58
|
expandedNodeIds,
|
|
@@ -55,24 +63,90 @@ export function BrowseTreeSidebar({
|
|
|
55
63
|
onToggleFavoriteCollection,
|
|
56
64
|
}: BrowseTreeSidebarProps) {
|
|
57
65
|
const nodeRefs = useRef(new Map<string, HTMLButtonElement>());
|
|
66
|
+
const treeScrollRef = useRef<HTMLDivElement | null>(null);
|
|
58
67
|
const [focusedNodeId, setFocusedNodeId] = useState<string | null>(
|
|
59
68
|
selectedNodeId
|
|
60
69
|
);
|
|
70
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
71
|
+
const [viewportHeight, setViewportHeight] = useState(640);
|
|
61
72
|
const expandedNodeSet = useMemo(
|
|
62
73
|
() => new Set(expandedNodeIds),
|
|
63
74
|
[expandedNodeIds]
|
|
64
75
|
);
|
|
76
|
+
const favoriteCollectionSet = useMemo(
|
|
77
|
+
() => new Set(favoriteCollections),
|
|
78
|
+
[favoriteCollections]
|
|
79
|
+
);
|
|
65
80
|
const visibleNodes = useMemo(
|
|
66
81
|
() => flattenVisibleNodes(collections, expandedNodeSet),
|
|
67
82
|
[collections, expandedNodeSet]
|
|
68
83
|
);
|
|
84
|
+
const visibleIndexById = useMemo(() => {
|
|
85
|
+
const map = new Map<string, number>();
|
|
86
|
+
for (let i = 0; i < visibleNodes.length; i += 1) {
|
|
87
|
+
map.set(visibleNodes[i]!.node.id, i);
|
|
88
|
+
}
|
|
89
|
+
return map;
|
|
90
|
+
}, [visibleNodes]);
|
|
69
91
|
|
|
70
92
|
useEffect(() => {
|
|
71
93
|
setFocusedNodeId(selectedNodeId);
|
|
72
94
|
}, [selectedNodeId]);
|
|
73
95
|
|
|
74
|
-
const
|
|
75
|
-
|
|
96
|
+
const shouldVirtualize = visibleNodes.length > VIRTUALIZE_THRESHOLD;
|
|
97
|
+
|
|
98
|
+
// Keep a deep-linked or externally selected row mounted in the virtual window
|
|
99
|
+
// so keyboard users always have a reachable tab stop on the selected folder.
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (!shouldVirtualize || !selectedNodeId) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const selectedIndex = visibleIndexById.get(selectedNodeId);
|
|
105
|
+
if (selectedIndex === undefined) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const targetTop = selectedIndex * VIRTUAL_ROW_HEIGHT_PX;
|
|
109
|
+
const targetBottom = targetTop + VIRTUAL_ROW_HEIGHT_PX;
|
|
110
|
+
const container = treeScrollRef.current;
|
|
111
|
+
const effectiveHeight = container?.clientHeight || viewportHeight;
|
|
112
|
+
const currentTop = container ? container.scrollTop : scrollTop;
|
|
113
|
+
if (targetTop < currentTop || targetBottom > currentTop + effectiveHeight) {
|
|
114
|
+
const nextTop = Math.max(0, targetTop - Math.floor(effectiveHeight / 2));
|
|
115
|
+
if (container) {
|
|
116
|
+
container.scrollTop = nextTop;
|
|
117
|
+
}
|
|
118
|
+
setScrollTop(nextTop);
|
|
119
|
+
}
|
|
120
|
+
}, [selectedNodeId, shouldVirtualize, visibleIndexById, viewportHeight]);
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (!shouldVirtualize) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const container = treeScrollRef.current;
|
|
127
|
+
if (!container) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const updateViewport = () => {
|
|
131
|
+
const nextHeight = container.clientHeight || 640;
|
|
132
|
+
setViewportHeight(nextHeight);
|
|
133
|
+
};
|
|
134
|
+
updateViewport();
|
|
135
|
+
const onScroll = () => {
|
|
136
|
+
setScrollTop(container.scrollTop);
|
|
137
|
+
};
|
|
138
|
+
container.addEventListener("scroll", onScroll, { passive: true });
|
|
139
|
+
window.addEventListener("resize", updateViewport);
|
|
140
|
+
return () => {
|
|
141
|
+
container.removeEventListener("scroll", onScroll);
|
|
142
|
+
window.removeEventListener("resize", updateViewport);
|
|
143
|
+
};
|
|
144
|
+
}, [shouldVirtualize]);
|
|
145
|
+
|
|
146
|
+
const favoriteRoots = useMemo(
|
|
147
|
+
() =>
|
|
148
|
+
collections.filter((node) => favoriteCollectionSet.has(node.collection)),
|
|
149
|
+
[collections, favoriteCollectionSet]
|
|
76
150
|
);
|
|
77
151
|
|
|
78
152
|
const moveFocus = (nodeId: string | null) => {
|
|
@@ -80,11 +154,57 @@ export function BrowseTreeSidebar({
|
|
|
80
154
|
return;
|
|
81
155
|
}
|
|
82
156
|
setFocusedNodeId(nodeId);
|
|
83
|
-
|
|
157
|
+
if (shouldVirtualize) {
|
|
158
|
+
const targetIndex = visibleIndexById.get(nodeId);
|
|
159
|
+
const container = treeScrollRef.current;
|
|
160
|
+
if (targetIndex !== undefined && container) {
|
|
161
|
+
const targetTop = targetIndex * VIRTUAL_ROW_HEIGHT_PX;
|
|
162
|
+
const targetBottom = targetTop + VIRTUAL_ROW_HEIGHT_PX;
|
|
163
|
+
if (targetTop < container.scrollTop) {
|
|
164
|
+
container.scrollTop = targetTop;
|
|
165
|
+
setScrollTop(targetTop);
|
|
166
|
+
} else if (
|
|
167
|
+
targetBottom >
|
|
168
|
+
container.scrollTop + container.clientHeight
|
|
169
|
+
) {
|
|
170
|
+
const nextTop = Math.max(0, targetBottom - container.clientHeight);
|
|
171
|
+
container.scrollTop = nextTop;
|
|
172
|
+
setScrollTop(nextTop);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
requestAnimationFrame(() => {
|
|
177
|
+
nodeRefs.current.get(nodeId)?.focus();
|
|
178
|
+
});
|
|
84
179
|
};
|
|
85
180
|
|
|
86
181
|
const getVisibleIndex = (nodeId: string | null) =>
|
|
87
|
-
|
|
182
|
+
nodeId ? (visibleIndexById.get(nodeId) ?? -1) : -1;
|
|
183
|
+
|
|
184
|
+
const startIndex = shouldVirtualize
|
|
185
|
+
? Math.max(
|
|
186
|
+
0,
|
|
187
|
+
Math.floor(scrollTop / VIRTUAL_ROW_HEIGHT_PX) - VIRTUAL_OVERSCAN_ROWS
|
|
188
|
+
)
|
|
189
|
+
: 0;
|
|
190
|
+
const endIndex = shouldVirtualize
|
|
191
|
+
? Math.min(
|
|
192
|
+
visibleNodes.length,
|
|
193
|
+
Math.ceil((scrollTop + viewportHeight) / VIRTUAL_ROW_HEIGHT_PX) +
|
|
194
|
+
VIRTUAL_OVERSCAN_ROWS
|
|
195
|
+
)
|
|
196
|
+
: visibleNodes.length;
|
|
197
|
+
const renderedNodes = shouldVirtualize
|
|
198
|
+
? visibleNodes.slice(startIndex, endIndex)
|
|
199
|
+
: visibleNodes;
|
|
200
|
+
const activeTabTarget = focusedNodeId ?? selectedNodeId;
|
|
201
|
+
const activeTabTargetMounted =
|
|
202
|
+
activeTabTarget !== null &&
|
|
203
|
+
renderedNodes.some(({ node }) => node.id === activeTabTarget);
|
|
204
|
+
const topSpacerPx = shouldVirtualize ? startIndex * VIRTUAL_ROW_HEIGHT_PX : 0;
|
|
205
|
+
const bottomSpacerPx = shouldVirtualize
|
|
206
|
+
? (visibleNodes.length - endIndex) * VIRTUAL_ROW_HEIGHT_PX
|
|
207
|
+
: 0;
|
|
88
208
|
|
|
89
209
|
return (
|
|
90
210
|
<ScrollArea className="h-full">
|
|
@@ -114,12 +234,25 @@ export function BrowseTreeSidebar({
|
|
|
114
234
|
<div className="px-2 font-mono text-[11px] text-muted-foreground uppercase tracking-[0.2em]">
|
|
115
235
|
Workspace Tree
|
|
116
236
|
</div>
|
|
117
|
-
<div
|
|
118
|
-
|
|
237
|
+
<div
|
|
238
|
+
aria-label="Browse tree"
|
|
239
|
+
className={
|
|
240
|
+
shouldVirtualize
|
|
241
|
+
? "max-h-[calc(100vh-14rem)] overflow-y-auto"
|
|
242
|
+
: undefined
|
|
243
|
+
}
|
|
244
|
+
ref={treeScrollRef}
|
|
245
|
+
role="tree"
|
|
246
|
+
>
|
|
247
|
+
{topSpacerPx > 0 && (
|
|
248
|
+
<div aria-hidden="true" style={{ height: `${topSpacerPx}px` }} />
|
|
249
|
+
)}
|
|
250
|
+
{renderedNodes.map(({ node, parentId }, localIndex) => {
|
|
119
251
|
const isExpanded = expandedNodeSet.has(node.id);
|
|
120
252
|
const isSelected = node.id === selectedNodeId;
|
|
121
253
|
const isFocused = node.id === focusedNodeId;
|
|
122
254
|
const hasChildren = node.children.length > 0;
|
|
255
|
+
const isFavorite = favoriteCollectionSet.has(node.collection);
|
|
123
256
|
|
|
124
257
|
return (
|
|
125
258
|
<Fragment key={node.id}>
|
|
@@ -223,11 +356,13 @@ export function BrowseTreeSidebar({
|
|
|
223
356
|
role="treeitem"
|
|
224
357
|
style={{ paddingLeft: `${node.depth * 0.9 + 0.5}rem` }}
|
|
225
358
|
tabIndex={
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
:
|
|
359
|
+
activeTabTargetMounted
|
|
360
|
+
? node.id === activeTabTarget
|
|
361
|
+
? 0
|
|
362
|
+
: -1
|
|
363
|
+
: localIndex === 0
|
|
364
|
+
? 0
|
|
365
|
+
: -1
|
|
231
366
|
}
|
|
232
367
|
type="button"
|
|
233
368
|
>
|
|
@@ -250,7 +385,7 @@ export function BrowseTreeSidebar({
|
|
|
250
385
|
{node.kind === "collection" && (
|
|
251
386
|
<button
|
|
252
387
|
aria-label={
|
|
253
|
-
|
|
388
|
+
isFavorite
|
|
254
389
|
? `Unpin ${node.collection}`
|
|
255
390
|
: `Pin ${node.collection}`
|
|
256
391
|
}
|
|
@@ -263,8 +398,7 @@ export function BrowseTreeSidebar({
|
|
|
263
398
|
<StarIcon
|
|
264
399
|
className={cn(
|
|
265
400
|
"size-3.5",
|
|
266
|
-
|
|
267
|
-
"fill-current text-secondary"
|
|
401
|
+
isFavorite && "fill-current text-secondary"
|
|
268
402
|
)}
|
|
269
403
|
/>
|
|
270
404
|
</button>
|
|
@@ -273,6 +407,12 @@ export function BrowseTreeSidebar({
|
|
|
273
407
|
</Fragment>
|
|
274
408
|
);
|
|
275
409
|
})}
|
|
410
|
+
{bottomSpacerPx > 0 && (
|
|
411
|
+
<div
|
|
412
|
+
aria-hidden="true"
|
|
413
|
+
style={{ height: `${bottomSpacerPx}px` }}
|
|
414
|
+
/>
|
|
415
|
+
)}
|
|
276
416
|
</div>
|
|
277
417
|
</div>
|
|
278
418
|
</div>
|
|
@@ -195,26 +195,30 @@ export function CaptureModal({
|
|
|
195
195
|
}
|
|
196
196
|
setSelectedPresetId(presetId || "blank");
|
|
197
197
|
|
|
198
|
-
void apiFetch<
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
void apiFetch<Array<{ name: string; path: string }> | CollectionsResponse>(
|
|
199
|
+
"/api/collections"
|
|
200
|
+
).then(({ data }) => {
|
|
201
|
+
const rawList = Array.isArray(data) ? data : data?.collections;
|
|
202
|
+
if (rawList) {
|
|
203
|
+
// Preserve SQLite ORDER BY name (code-point / BINARY order) matching
|
|
204
|
+
// /api/status so first-use default collection selection is identical
|
|
205
|
+
// even for names like `a-b` vs `a_b`.
|
|
206
|
+
const list = [...rawList].sort((a, b) =>
|
|
207
|
+
a.name < b.name ? -1 : a.name > b.name ? 1 : 0
|
|
202
208
|
);
|
|
209
|
+
setCollections(list.map((c) => ({ name: c.name, path: c.path })));
|
|
203
210
|
|
|
204
211
|
const requestedCollection = defaultCollection.trim();
|
|
205
212
|
const lastUsed = localStorage.getItem(STORAGE_KEY);
|
|
206
213
|
if (
|
|
207
214
|
requestedCollection &&
|
|
208
|
-
|
|
215
|
+
list.some((c) => c.name === requestedCollection)
|
|
209
216
|
) {
|
|
210
217
|
setCollection(requestedCollection);
|
|
211
|
-
} else if (
|
|
212
|
-
lastUsed &&
|
|
213
|
-
data.collections.some((c) => c.name === lastUsed)
|
|
214
|
-
) {
|
|
218
|
+
} else if (lastUsed && list.some((c) => c.name === lastUsed)) {
|
|
215
219
|
setCollection(lastUsed);
|
|
216
220
|
} else {
|
|
217
|
-
const firstCollection =
|
|
221
|
+
const firstCollection = list.at(0);
|
|
218
222
|
if (firstCollection) {
|
|
219
223
|
setCollection(firstCollection.name);
|
|
220
224
|
}
|