@agent-native/core 0.119.6 → 0.120.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/corpus/README.md +1 -1
- package/corpus/core/CHANGELOG.md +12 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/cli/index.ts +64 -3
- package/corpus/core/src/templates/default/package.json +1 -1
- package/corpus/templates/assets/package.json +1 -1
- package/corpus/templates/brain/package.json +1 -1
- package/corpus/templates/calendar/package.json +1 -1
- package/corpus/templates/clips/package.json +1 -1
- package/corpus/templates/content/actions/add-database-item.ts +1 -0
- package/corpus/templates/content/actions/set-document-property.ts +0 -4
- package/corpus/templates/content/app/components/editor/DocumentBlockFields.tsx +10 -1
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +10 -4
- package/corpus/templates/content/app/components/editor/DocumentInfoPanel.tsx +5 -1
- package/corpus/templates/content/app/components/editor/DocumentProperties.tsx +6 -0
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +52 -33
- package/corpus/templates/content/app/components/editor/previewDocumentSaveController.ts +16 -4
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +16 -7
- package/corpus/templates/content/app/hooks/use-create-page.ts +8 -3
- package/corpus/templates/content/app/hooks/use-document-properties.ts +1 -0
- package/corpus/templates/content/app/hooks/use-documents.ts +3 -1
- package/corpus/templates/content/app/lib/optimistic-document.ts +29 -0
- package/corpus/templates/content/changelog/2026-07-21-editing-a-database-property-no-longer-refreshes-unrelated-co.md +6 -0
- package/corpus/templates/content/changelog/2026-07-23-new-database-ready.md +6 -0
- package/corpus/templates/content/package.json +1 -1
- package/corpus/templates/content/shared/api.ts +1 -0
- package/corpus/templates/design/package.json +1 -1
- package/corpus/templates/dispatch/package.json +1 -1
- package/corpus/templates/forms/package.json +1 -1
- package/corpus/templates/macros/package.json +1 -1
- package/corpus/templates/mail/package.json +1 -1
- package/corpus/templates/slides/package.json +1 -1
- package/dist/cli/index.js +53 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +2 -2
- package/dist/progress/routes.d.ts +1 -1
- package/dist/secrets/routes.d.ts +3 -3
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/templates/default/package.json +1 -1
- package/package.json +1 -1
- package/src/cli/index.ts +64 -3
- package/src/templates/default/package.json +1 -1
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import { useContentSpaces } from "@/hooks/use-content-spaces";
|
|
13
13
|
import { useCreateDocument } from "@/hooks/use-documents";
|
|
14
14
|
import { useLocalStorage } from "@/hooks/use-local-storage";
|
|
15
|
+
import { markDocumentCreationPending } from "@/lib/optimistic-document";
|
|
15
16
|
|
|
16
17
|
const LIST_DOCUMENTS_QUERY_KEY = [
|
|
17
18
|
"action",
|
|
@@ -63,7 +64,7 @@ export function useCreatePage(opts?: {
|
|
|
63
64
|
}
|
|
64
65
|
const id = nanoid();
|
|
65
66
|
const now = new Date().toISOString();
|
|
66
|
-
const tempDoc
|
|
67
|
+
const tempDoc = markDocumentCreationPending({
|
|
67
68
|
id,
|
|
68
69
|
parentId: parentId ?? null,
|
|
69
70
|
title: "",
|
|
@@ -75,7 +76,7 @@ export function useCreatePage(opts?: {
|
|
|
75
76
|
visibility: "private",
|
|
76
77
|
createdAt: now,
|
|
77
78
|
updatedAt: now,
|
|
78
|
-
};
|
|
79
|
+
});
|
|
79
80
|
|
|
80
81
|
queryClient.setQueryData(LIST_DOCUMENTS_QUERY_KEY, (old: any) => {
|
|
81
82
|
const docs: Document[] =
|
|
@@ -90,12 +91,16 @@ export function useCreatePage(opts?: {
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
const persist = async () => {
|
|
93
|
-
await createDocument.mutateAsync({
|
|
94
|
+
const created = await createDocument.mutateAsync({
|
|
94
95
|
id,
|
|
95
96
|
title: "",
|
|
96
97
|
parentId: parentId ?? undefined,
|
|
97
98
|
spaceId,
|
|
98
99
|
});
|
|
100
|
+
queryClient.setQueryData(
|
|
101
|
+
["action", "get-document", { id: created.id }],
|
|
102
|
+
created,
|
|
103
|
+
);
|
|
99
104
|
// Replace optimistic doc with real server doc + clear any 404 error
|
|
100
105
|
// state from the in-flight fetch that ran before create completed.
|
|
101
106
|
queryClient.invalidateQueries({
|
|
@@ -70,6 +70,7 @@ export function useSetDocumentProperty(
|
|
|
70
70
|
DocumentPropertiesResponse,
|
|
71
71
|
SetDocumentPropertyRequest
|
|
72
72
|
>("set-document-property", {
|
|
73
|
+
skipActionQueryInvalidation: true,
|
|
73
74
|
onMutate: async (variables) => {
|
|
74
75
|
await queryClient.cancelQueries(
|
|
75
76
|
contentDatabaseQueryFilter(databaseDocumentId),
|
|
@@ -342,7 +342,9 @@ export function useUpdatePreviewDocumentDraft() {
|
|
|
342
342
|
expectedTitle: string;
|
|
343
343
|
expectedContent: string;
|
|
344
344
|
}
|
|
345
|
-
>("update-preview-document-draft"
|
|
345
|
+
>("update-preview-document-draft", {
|
|
346
|
+
skipActionQueryInvalidation: true,
|
|
347
|
+
});
|
|
346
348
|
}
|
|
347
349
|
|
|
348
350
|
export function useCreateDocument() {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Document } from "@shared/api";
|
|
2
|
+
|
|
3
|
+
const pendingDocumentCreation = Symbol("pendingDocumentCreation");
|
|
4
|
+
|
|
5
|
+
type PendingDocument = Document & {
|
|
6
|
+
[pendingDocumentCreation]?: true;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function markDocumentCreationPending(document: Document): Document {
|
|
10
|
+
return Object.assign(document, { [pendingDocumentCreation]: true as const });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function isDocumentCreationPending(document: Document): boolean {
|
|
14
|
+
return (document as PendingDocument)[pendingDocumentCreation] === true;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isDatabaseChoicePending(
|
|
18
|
+
document: Document,
|
|
19
|
+
databaseCreationPending: boolean,
|
|
20
|
+
): boolean {
|
|
21
|
+
return databaseCreationPending || isDocumentCreationPending(document);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function shouldCreateDocumentOptimistically(args: {
|
|
25
|
+
localFileMode: boolean;
|
|
26
|
+
filesDatabaseId?: string;
|
|
27
|
+
}): boolean {
|
|
28
|
+
return !args.localFileMode || Boolean(args.filesDatabaseId);
|
|
29
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "agent-native dev",
|
|
7
|
+
"dev": "agent-native dev --inspect",
|
|
8
8
|
"dev:database": "node scripts/check-native-deps.mjs && node scripts/dev-database.mjs",
|
|
9
9
|
"build": "agent-native build",
|
|
10
10
|
"start": "agent-native start",
|
package/dist/cli/index.js
CHANGED
|
@@ -241,6 +241,21 @@ function findBinUpwards(binName) {
|
|
|
241
241
|
function findViteBin() {
|
|
242
242
|
return findBinUpwards("vite") ?? "vite";
|
|
243
243
|
}
|
|
244
|
+
function findViteJsEntry() {
|
|
245
|
+
try {
|
|
246
|
+
const require = createRequire(path.join(process.cwd(), "package.json"));
|
|
247
|
+
const pkgJsonPath = require.resolve("vite/package.json");
|
|
248
|
+
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
|
|
249
|
+
const rel = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.vite;
|
|
250
|
+
if (!rel)
|
|
251
|
+
return null;
|
|
252
|
+
const entry = path.join(path.dirname(pkgJsonPath), rel);
|
|
253
|
+
return fs.existsSync(entry) ? entry : null;
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
244
259
|
function findTsxBin() {
|
|
245
260
|
const localTsx = path.resolve("node_modules/.bin/tsx");
|
|
246
261
|
if (fs.existsSync(localTsx))
|
|
@@ -336,11 +351,23 @@ function isWorkspaceRoot() {
|
|
|
336
351
|
return false;
|
|
337
352
|
}
|
|
338
353
|
}
|
|
354
|
+
function extractNodeInspectFlag(args) {
|
|
355
|
+
const rest = [];
|
|
356
|
+
let inspectFlag = null;
|
|
357
|
+
for (const arg of args) {
|
|
358
|
+
if (/^--inspect(-brk)?(=.+)?$/.test(arg)) {
|
|
359
|
+
inspectFlag = arg;
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
rest.push(arg);
|
|
363
|
+
}
|
|
364
|
+
return { inspectFlag, rest };
|
|
365
|
+
}
|
|
339
366
|
function run(cmd, cmdArgs, opts) {
|
|
340
367
|
const child = spawn(cmd, cmdArgs, {
|
|
341
368
|
stdio: opts?.stdio ?? "inherit",
|
|
342
369
|
shell: process.platform === "win32",
|
|
343
|
-
env: process.env,
|
|
370
|
+
env: opts?.env ?? process.env,
|
|
344
371
|
});
|
|
345
372
|
child.on("exit", (code) => process.exit(code ?? 0));
|
|
346
373
|
// Forward signals to child so Cmd+C doesn't leave zombie processes holding ports
|
|
@@ -475,7 +502,31 @@ switch (command) {
|
|
|
475
502
|
break;
|
|
476
503
|
}
|
|
477
504
|
const vite = findViteBin();
|
|
478
|
-
|
|
505
|
+
const { inspectFlag, rest } = extractNodeInspectFlag(args);
|
|
506
|
+
if (!inspectFlag) {
|
|
507
|
+
run(vite, rest);
|
|
508
|
+
break;
|
|
509
|
+
}
|
|
510
|
+
const viteJsEntry = findViteJsEntry();
|
|
511
|
+
if (!viteJsEntry) {
|
|
512
|
+
console.warn("[agent-native] Could not resolve Vite's JS entry; starting dev " +
|
|
513
|
+
"server without the debugger.");
|
|
514
|
+
run(vite, rest);
|
|
515
|
+
break;
|
|
516
|
+
}
|
|
517
|
+
// Attach inspect flag to server process (not Vite or Nitro process)
|
|
518
|
+
const parsed = inspectFlag.match(/^--(inspect(?:-brk)?)(?:=(.+))?$/);
|
|
519
|
+
const kind = parsed?.[1] ?? "inspect";
|
|
520
|
+
const target = parsed?.[2] ?? "9229";
|
|
521
|
+
const directive = `--${kind}=${target}`;
|
|
522
|
+
const preload = "data:text/javascript," +
|
|
523
|
+
encodeURIComponent(`process.env.NODE_OPTIONS=((process.env.NODE_OPTIONS??"")+" ${directive}").trim();`);
|
|
524
|
+
const env = {
|
|
525
|
+
...process.env,
|
|
526
|
+
NITRO_DEV_RUNNER: process.env.NITRO_DEV_RUNNER ?? "node-process",
|
|
527
|
+
};
|
|
528
|
+
console.log(`[agent-native] API server debugger listening on ${target}`);
|
|
529
|
+
run(process.execPath, ["--import", preload, viteJsEntry, ...rest], { env });
|
|
479
530
|
break;
|
|
480
531
|
}
|
|
481
532
|
case "workspace-dev": {
|