inplan 0.3.2 → 0.3.4
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/app/main/index.cjs
CHANGED
|
@@ -81,6 +81,16 @@ var ParseError = class extends Error {
|
|
|
81
81
|
this.name = "ParseError";
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
|
+
function decodeSegment(seg) {
|
|
85
|
+
try {
|
|
86
|
+
return decodeURIComponent(seg);
|
|
87
|
+
} catch {
|
|
88
|
+
return seg;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function decodeLinkPath(target) {
|
|
92
|
+
return target.split("/").map(decodeSegment).join("/");
|
|
93
|
+
}
|
|
84
94
|
var CONTROL_LOG_VERSION = 1;
|
|
85
95
|
var LogEventType = {
|
|
86
96
|
EditorPid: "editor_pid",
|
|
@@ -99,7 +109,12 @@ var LogEventType = {
|
|
|
99
109
|
* Payload `{ path }` is the new doc; the attached agent's `wait` steps down and
|
|
100
110
|
* the human's agent re-attaches there (the local analogue of save-locally). */
|
|
101
111
|
NavigatedTo: "navigated_to",
|
|
102
|
-
SessionClosed: "session_closed"
|
|
112
|
+
SessionClosed: "session_closed",
|
|
113
|
+
/** `inplan open` created this document on an agent's behalf (it was passed `--model`) and the
|
|
114
|
+
* agent is about to write the first draft. Payload `{ model }`. The editor shows a dismissible
|
|
115
|
+
* "may be writing the first draft" banner while the body is still empty, so the empty page
|
|
116
|
+
* doesn't read as a broken load. Informational only — not a wake signal. */
|
|
117
|
+
DraftPending: "draft_pending"
|
|
103
118
|
};
|
|
104
119
|
function serializeLogEntry(entry) {
|
|
105
120
|
return JSON.stringify(entry);
|
|
@@ -561,6 +576,8 @@ function safeJoin(root, child) {
|
|
|
561
576
|
return rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel) ? full : null;
|
|
562
577
|
}
|
|
563
578
|
var base = (u) => u.endsWith("/") ? u : `${u}/`;
|
|
579
|
+
var PLUGIN_FETCH_TIMEOUT_MS = 8e3;
|
|
580
|
+
var bounded = () => ({ signal: AbortSignal.timeout(PLUGIN_FETCH_TIMEOUT_MS) });
|
|
564
581
|
function loadCached(cacheDir2, version, publicKey, now) {
|
|
565
582
|
try {
|
|
566
583
|
const dir = safeJoin(cacheDir2, version);
|
|
@@ -583,7 +600,7 @@ function loadCached(cacheDir2, version, publicKey, now) {
|
|
|
583
600
|
}
|
|
584
601
|
async function fetchAndCache(bundleUrl, leaseToken, opts) {
|
|
585
602
|
const root = base(bundleUrl);
|
|
586
|
-
const mres = await opts.fetchImpl(`${root}manifest.json
|
|
603
|
+
const mres = await opts.fetchImpl(`${root}manifest.json`, bounded());
|
|
587
604
|
if (!mres.ok) return null;
|
|
588
605
|
const manifest = await mres.json();
|
|
589
606
|
if (!manifest?.version || !Array.isArray(manifest.files)) return null;
|
|
@@ -594,7 +611,8 @@ async function fetchAndCache(bundleUrl, leaseToken, opts) {
|
|
|
594
611
|
for (const entry of manifest.files) {
|
|
595
612
|
const filePath = safeJoin(dir, entry.name);
|
|
596
613
|
if (!filePath) return null;
|
|
597
|
-
|
|
614
|
+
if (fs.existsSync(filePath) && verifyBundleBytes(fs.readFileSync(filePath), entry, opts.publicKey)) continue;
|
|
615
|
+
const r = await opts.fetchImpl(`${root}${entry.name}`, bounded());
|
|
598
616
|
if (!r.ok) return null;
|
|
599
617
|
const bytes = Buffer.from(await r.arrayBuffer());
|
|
600
618
|
if (!verifyBundleBytes(bytes, entry, opts.publicKey)) return null;
|
|
@@ -621,7 +639,7 @@ async function resolvePluginOutcome(options) {
|
|
|
621
639
|
if (!publicKey) return { plugin: null, reason: "unavailable" };
|
|
622
640
|
if (options.token) {
|
|
623
641
|
try {
|
|
624
|
-
const res = await fetchImpl(`${base(options.apiBase)}api/v1/desktop-plugin`, { headers: { authorization: `Bearer ${options.token}` } });
|
|
642
|
+
const res = await fetchImpl(`${base(options.apiBase)}api/v1/desktop-plugin`, { ...bounded(), headers: { authorization: `Bearer ${options.token}` } });
|
|
625
643
|
if (res.ok) {
|
|
626
644
|
const grant = await res.json();
|
|
627
645
|
if (grant.entitled === false) return { plugin: null, reason: "unentitled" };
|
|
@@ -694,11 +712,36 @@ class Session {
|
|
|
694
712
|
}
|
|
695
713
|
}
|
|
696
714
|
}
|
|
715
|
+
/** The model an agent named when it created this document with `inplan open`, while its first
|
|
716
|
+
* draft is still to come. Null otherwise. The log is never reset, so the entry must be retired by
|
|
717
|
+
* whatever ends that expectation — not only the draft arriving (as an edit, or parked as a
|
|
718
|
+
* proposal), but the session it was raised in closing, or the human saving the document.
|
|
719
|
+
* Otherwise an agent that died before writing, or a page the human later cleared, would bring the
|
|
720
|
+
* banner back on some later open with no agent anywhere. */
|
|
721
|
+
draftPending() {
|
|
722
|
+
const entries = readLog(this.paths.logPath);
|
|
723
|
+
let model = null;
|
|
724
|
+
for (const e of entries) {
|
|
725
|
+
if (e.type === LogEventType.DraftPending) {
|
|
726
|
+
const m = e.payload?.model;
|
|
727
|
+
model = typeof m === "string" && m.trim() ? m : null;
|
|
728
|
+
} else if (e.actor === "agent" && (e.type === LogEventType.DocumentEdited || e.type === LogEventType.AgentRevised || e.type === LogEventType.AgentRevisionProposed)) {
|
|
729
|
+
model = null;
|
|
730
|
+
} else if (e.type === LogEventType.SessionClosed) {
|
|
731
|
+
model = null;
|
|
732
|
+
} else if (e.actor === "user" && (e.type === LogEventType.DocumentEdited || e.type === LogEventType.TurnEnded)) {
|
|
733
|
+
model = null;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
return model ? { model } : null;
|
|
737
|
+
}
|
|
697
738
|
async load() {
|
|
739
|
+
const pendingDraft = this.draftPending();
|
|
740
|
+
const withDraft = (p) => pendingDraft ? { ...p, draftPending: pendingDraft } : p;
|
|
698
741
|
const content = node_fs.readFileSync(this.paths.file, "utf8");
|
|
699
742
|
if (!node_fs.existsSync(this.paths.canonicalPath)) {
|
|
700
743
|
node_fs.writeFileSync(this.paths.canonicalPath, content);
|
|
701
|
-
return { path: this.paths.file, content };
|
|
744
|
+
return withDraft({ path: this.paths.file, content });
|
|
702
745
|
}
|
|
703
746
|
let pending;
|
|
704
747
|
try {
|
|
@@ -708,9 +751,9 @@ class Session {
|
|
|
708
751
|
}
|
|
709
752
|
const current = node_fs.readFileSync(this.paths.file, "utf8");
|
|
710
753
|
if (pending !== null && pending.content === current) {
|
|
711
|
-
return { path: this.paths.file, content: node_fs.readFileSync(this.paths.canonicalPath, "utf8") };
|
|
754
|
+
return withDraft({ path: this.paths.file, content: node_fs.readFileSync(this.paths.canonicalPath, "utf8") });
|
|
712
755
|
}
|
|
713
|
-
return { path: this.paths.file, content: current };
|
|
756
|
+
return withDraft({ path: this.paths.file, content: current });
|
|
714
757
|
}
|
|
715
758
|
save(content, options) {
|
|
716
759
|
if (options.kind === "backup") {
|
|
@@ -1192,6 +1235,7 @@ let win = null;
|
|
|
1192
1235
|
let stopWatching = null;
|
|
1193
1236
|
let quitConfirmed = false;
|
|
1194
1237
|
let rendererReady = false;
|
|
1238
|
+
let editorReported = false;
|
|
1195
1239
|
let quitFallbackTimer = null;
|
|
1196
1240
|
const QUIT_CONFIRM_TIMEOUT_MS = 8e3;
|
|
1197
1241
|
const navHistory = [];
|
|
@@ -1411,7 +1455,7 @@ function quitNow(reason) {
|
|
|
1411
1455
|
electron.app.quit();
|
|
1412
1456
|
}
|
|
1413
1457
|
function rendererCanConfirm() {
|
|
1414
|
-
return !!win && !win.isDestroyed() && !win.webContents.isDestroyed() && !win.webContents.isCrashed() && rendererReady;
|
|
1458
|
+
return !!win && !win.isDestroyed() && !win.webContents.isDestroyed() && !win.webContents.isCrashed() && rendererReady && editorReported;
|
|
1415
1459
|
}
|
|
1416
1460
|
function armQuitFallback() {
|
|
1417
1461
|
if (quitFallbackTimer) return;
|
|
@@ -1426,17 +1470,34 @@ function setDocTitle(file) {
|
|
|
1426
1470
|
}
|
|
1427
1471
|
function createWindow() {
|
|
1428
1472
|
rendererReady = false;
|
|
1473
|
+
editorReported = false;
|
|
1429
1474
|
win = new electron.BrowserWindow({
|
|
1430
1475
|
width: 1200,
|
|
1431
1476
|
height: 800,
|
|
1432
1477
|
title: "inplan",
|
|
1433
1478
|
icon: appIcon,
|
|
1434
1479
|
// window/taskbar icon on Windows + Linux (macOS uses the dock icon below)
|
|
1480
|
+
// Hidden until the renderer's first paint (below), on the editor's own paper colour: shown at
|
|
1481
|
+
// once, the window sat plain white while the editor bundle loaded.
|
|
1482
|
+
show: false,
|
|
1483
|
+
backgroundColor: "#fdfbf6",
|
|
1435
1484
|
webPreferences: {
|
|
1436
1485
|
preload: node_path.join(__dirname$1, "../preload/index.mjs"),
|
|
1437
1486
|
sandbox: false
|
|
1438
1487
|
}
|
|
1439
1488
|
});
|
|
1489
|
+
const w = win;
|
|
1490
|
+
let revealed = false;
|
|
1491
|
+
const reveal = () => {
|
|
1492
|
+
if (revealed) return;
|
|
1493
|
+
revealed = true;
|
|
1494
|
+
clearTimeout(revealFallback);
|
|
1495
|
+
if (!w.isDestroyed()) w.show();
|
|
1496
|
+
};
|
|
1497
|
+
const revealFallback = setTimeout(reveal, 5e3);
|
|
1498
|
+
w.once("ready-to-show", reveal);
|
|
1499
|
+
w.webContents.once("did-fail-load", reveal);
|
|
1500
|
+
w.webContents.once("render-process-gone", reveal);
|
|
1440
1501
|
win.on("page-title-updated", (e) => e.preventDefault());
|
|
1441
1502
|
setDocTitle(session?.paths.file ?? null);
|
|
1442
1503
|
win.webContents.setWindowOpenHandler(({ url }) => {
|
|
@@ -1492,6 +1553,7 @@ function registerIpc() {
|
|
|
1492
1553
|
track(event, session?.getSettings().telemetry === true, props);
|
|
1493
1554
|
});
|
|
1494
1555
|
electron.ipcMain.handle("doc:report-state", (_e, dirty, content) => {
|
|
1556
|
+
editorReported = true;
|
|
1495
1557
|
session?.setPending(dirty, content);
|
|
1496
1558
|
});
|
|
1497
1559
|
electron.ipcMain.handle("doc:set-mode", (_e, cadence, acceptance) => {
|
|
@@ -1584,7 +1646,8 @@ ${body.replace(/\s*$/, "")}
|
|
|
1584
1646
|
return { relPath: toPosix(node_path.relative(docDir, abs)) };
|
|
1585
1647
|
});
|
|
1586
1648
|
electron.ipcMain.handle("doc:open", (_e, target) => {
|
|
1587
|
-
const
|
|
1649
|
+
const decoded = node_path.resolve("/", decodeLinkPath(target));
|
|
1650
|
+
const abs = node_fs.existsSync(decoded) ? decoded : node_path.resolve("/", target);
|
|
1588
1651
|
if (!abs.endsWith(".md") || !node_fs.existsSync(abs)) {
|
|
1589
1652
|
process.stderr.write(`[inplan] open-doc: no such .md file: ${abs}
|
|
1590
1653
|
`);
|
|
@@ -7083,12 +7083,29 @@ function orderComments(comments) {
|
|
|
7083
7083
|
for (const c of comments.slice().sort(cmp)) emit(c);
|
|
7084
7084
|
return out;
|
|
7085
7085
|
}
|
|
7086
|
+
var COMMENT_KEY_ORDER = ["id", "parentId", "anchor", "text", "author", "date", "resolved", "may_resolve", "question", "selected", "agent", "mentions"];
|
|
7087
|
+
function canonicalizeComment(c) {
|
|
7088
|
+
const out = {};
|
|
7089
|
+
const rec = c;
|
|
7090
|
+
for (const k2 of COMMENT_KEY_ORDER) if (rec[k2] !== void 0) out[k2] = rec[k2];
|
|
7091
|
+
for (const k2 of Object.keys(rec).sort()) if (!(k2 in out) && rec[k2] !== void 0) out[k2] = rec[k2];
|
|
7092
|
+
return out;
|
|
7093
|
+
}
|
|
7086
7094
|
var ParseError = class extends Error {
|
|
7087
7095
|
constructor(message) {
|
|
7088
7096
|
super(message);
|
|
7089
7097
|
this.name = "ParseError";
|
|
7090
7098
|
}
|
|
7091
7099
|
};
|
|
7100
|
+
function encodeSegment(seg) {
|
|
7101
|
+
return encodeURIComponent(seg).replace(/\(/g, "%28").replace(/\)/g, "%29");
|
|
7102
|
+
}
|
|
7103
|
+
function markdownLink(text2, path) {
|
|
7104
|
+
return `[${text2}](${path.split("/").map(encodeSegment).join("/")})`;
|
|
7105
|
+
}
|
|
7106
|
+
function escapeLinkText(text2) {
|
|
7107
|
+
return text2.replace(/[\\[\]]/g, (c) => `\\${c}`);
|
|
7108
|
+
}
|
|
7092
7109
|
var LogEventType = {
|
|
7093
7110
|
ModeChanged: "mode_changed",
|
|
7094
7111
|
DocumentEdited: "document_edited",
|
|
@@ -43219,7 +43236,7 @@ function spanSource(body, selected, span) {
|
|
|
43219
43236
|
function linkSelectionToDoc(body, selected, span, target) {
|
|
43220
43237
|
const r2 = locateCleanSpan(body, selected, span);
|
|
43221
43238
|
if (!r2) return null;
|
|
43222
|
-
return body.slice(0, r2.start) +
|
|
43239
|
+
return body.slice(0, r2.start) + markdownLink(body.slice(r2.start, r2.end), target) + body.slice(r2.end);
|
|
43223
43240
|
}
|
|
43224
43241
|
function spanLineRange(body, span) {
|
|
43225
43242
|
if (!span || !Number.isInteger(span.startLine) || !Number.isInteger(span.endLine) || span.startLine < 0 || span.endLine < span.startLine) return null;
|
|
@@ -43257,7 +43274,7 @@ function moveSelectionToDoc(doc2, selected, span, title, target) {
|
|
|
43257
43274
|
if (after === "") sep = sep ? "\n" : "";
|
|
43258
43275
|
const remaining = {
|
|
43259
43276
|
...doc2,
|
|
43260
|
-
body: before + prefix +
|
|
43277
|
+
body: before + prefix + markdownLink(escapeLinkText(title), target) + sep + after,
|
|
43261
43278
|
comments: doc2.comments.filter((c) => !moved.has(c.id))
|
|
43262
43279
|
};
|
|
43263
43280
|
return { remaining, movedBody, movedComments: doc2.comments.filter((c) => moved.has(c.id)) };
|
|
@@ -43336,7 +43353,12 @@ function deleteComment(doc2, id2) {
|
|
|
43336
43353
|
}
|
|
43337
43354
|
return { body, comments: doc2.comments.filter((c) => !removed.has(c.id)) };
|
|
43338
43355
|
}
|
|
43339
|
-
function buildThreads(comments) {
|
|
43356
|
+
function buildThreads(comments, now = Date.now()) {
|
|
43357
|
+
const order = new Map(comments.map((c, i) => [c.id, i]));
|
|
43358
|
+
const at = (c) => {
|
|
43359
|
+
const t2 = Date.parse(c.date);
|
|
43360
|
+
return Number.isNaN(t2) ? Number.NEGATIVE_INFINITY : Math.min(t2, now);
|
|
43361
|
+
};
|
|
43340
43362
|
const byParent = /* @__PURE__ */ new Map();
|
|
43341
43363
|
for (const c of comments) {
|
|
43342
43364
|
if (c.parentId) {
|
|
@@ -43353,7 +43375,7 @@ function buildThreads(comments) {
|
|
|
43353
43375
|
out.push(c);
|
|
43354
43376
|
stack.push(...byParent.get(c.id) ?? []);
|
|
43355
43377
|
}
|
|
43356
|
-
return out.sort((a, b) => a.
|
|
43378
|
+
return out.sort((a, b) => at(a) - at(b) || (order.get(a.id) ?? 0) - (order.get(b.id) ?? 0));
|
|
43357
43379
|
};
|
|
43358
43380
|
return comments.filter((c) => c.parentId === void 0).map((root) => ({ root, replies: collect(root.id) }));
|
|
43359
43381
|
}
|
|
@@ -43697,6 +43719,7 @@ var EN = {
|
|
|
43697
43719
|
"rail.reply": "Reply",
|
|
43698
43720
|
// banners
|
|
43699
43721
|
"banner.agentReady": "The agent thinks the plan is ready.",
|
|
43722
|
+
"banner.draftPending": "{model} may be writing the first draft. You can start editing anytime.",
|
|
43700
43723
|
"banner.dismiss": "dismiss",
|
|
43701
43724
|
"banner.newBuild": "🔄 A new build is ready —",
|
|
43702
43725
|
"banner.reloadingIn": "reloading in {n}s",
|
|
@@ -43763,6 +43786,9 @@ var EN = {
|
|
|
43763
43786
|
"thread.cancel": "Cancel",
|
|
43764
43787
|
"thread.save": "Save",
|
|
43765
43788
|
"thread.more": "More",
|
|
43789
|
+
"thread.copyDocLink": "Copy link to document",
|
|
43790
|
+
"msg.copyDocLinkDone": "Link copied to the clipboard.",
|
|
43791
|
+
"msg.copyDocLinkFailed": "Copying the link failed — nothing was placed on the clipboard.",
|
|
43766
43792
|
"thread.modify": "Modify",
|
|
43767
43793
|
"thread.delete": "Delete"
|
|
43768
43794
|
};
|
|
@@ -44963,7 +44989,9 @@ function RelativeTime({ iso, className }) {
|
|
|
44963
44989
|
}, []);
|
|
44964
44990
|
const d = dayjs(iso);
|
|
44965
44991
|
if (!d.isValid()) return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className, children: iso });
|
|
44966
|
-
|
|
44992
|
+
const now = dayjs();
|
|
44993
|
+
const shown = d.isAfter(now) ? now : d;
|
|
44994
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("time", { className, dateTime: iso, title: d.format("MMM D, YYYY, h:mm:ss A"), children: shown.fromNow() });
|
|
44967
44995
|
}
|
|
44968
44996
|
var TOKEN = /\*\*([\s\S]+?)\*\*|`([^`]+?)`/g;
|
|
44969
44997
|
function renderInline(text2) {
|
|
@@ -45655,7 +45683,8 @@ async function harnessHash(text2) {
|
|
|
45655
45683
|
function createMemoryApi(opts) {
|
|
45656
45684
|
const store = new MemoryDocumentStore(opts.content);
|
|
45657
45685
|
const channel = new MemoryControlChannel();
|
|
45658
|
-
let currentPath = "memory://doc";
|
|
45686
|
+
let currentPath = opts.path ?? "memory://doc";
|
|
45687
|
+
let currentShareLink = opts.shareLink;
|
|
45659
45688
|
let currentReadOnly = opts.readOnly === true;
|
|
45660
45689
|
let settings = opts.settings ?? { autoResolve: true };
|
|
45661
45690
|
let closed = false;
|
|
@@ -45677,7 +45706,7 @@ function createMemoryApi(opts) {
|
|
|
45677
45706
|
const api = {
|
|
45678
45707
|
async load() {
|
|
45679
45708
|
if (await store.getCanonical() === null) await store.setCanonical(opts.content);
|
|
45680
|
-
return { path: currentPath, content: await store.loadDoc(), ...currentReadOnly ? { readOnly: true } : {} };
|
|
45709
|
+
return { path: currentPath, content: await store.loadDoc(), ...currentReadOnly ? { readOnly: true } : {}, ...currentShareLink ? { shareLink: currentShareLink } : {} };
|
|
45681
45710
|
},
|
|
45682
45711
|
async save(content2, options) {
|
|
45683
45712
|
if (options.kind === "backup") {
|
|
@@ -45776,12 +45805,13 @@ function createMemoryApi(opts) {
|
|
|
45776
45805
|
void channel.append({ actor: "agent", type: LogEventType.AgentMessage, payload: { text: text2 }, ts });
|
|
45777
45806
|
for (const cb2 of messages) cb2({ text: text2, ts });
|
|
45778
45807
|
},
|
|
45779
|
-
navigate(content2, path = "memory://doc2", readOnly2 = opts.readOnly === true) {
|
|
45808
|
+
navigate(content2, path = "memory://doc2", readOnly2 = opts.readOnly === true, shareLink) {
|
|
45780
45809
|
void store.saveDoc(content2);
|
|
45781
45810
|
void store.setCanonical(content2);
|
|
45782
45811
|
currentPath = path;
|
|
45783
45812
|
currentReadOnly = readOnly2;
|
|
45784
|
-
|
|
45813
|
+
currentShareLink = shareLink;
|
|
45814
|
+
for (const cb2 of navigated) cb2({ path, content: content2, ...readOnly2 ? { readOnly: true } : {}, ...currentShareLink ? { shareLink: currentShareLink } : {} });
|
|
45785
45815
|
},
|
|
45786
45816
|
async log() {
|
|
45787
45817
|
return (await channel.readSince(0)).entries;
|
|
@@ -45997,22 +46027,28 @@ var IMAGE_EXT_BY_MIME = {
|
|
|
45997
46027
|
"image/avif": "avif",
|
|
45998
46028
|
"image/svg+xml": "svg"
|
|
45999
46029
|
};
|
|
46030
|
+
var BINDING_READY_TIMEOUT_MS = 1e4;
|
|
46031
|
+
function settleWithin(ready, ms) {
|
|
46032
|
+
if (!ready) return Promise.resolve(false);
|
|
46033
|
+
let timer;
|
|
46034
|
+
return Promise.race([
|
|
46035
|
+
ready.then(
|
|
46036
|
+
() => true,
|
|
46037
|
+
() => false
|
|
46038
|
+
),
|
|
46039
|
+
new Promise((resolve) => {
|
|
46040
|
+
timer = setTimeout(() => resolve(false), ms);
|
|
46041
|
+
})
|
|
46042
|
+
]).finally(() => clearTimeout(timer));
|
|
46043
|
+
}
|
|
46000
46044
|
var ZOOM_MIN = 0.6;
|
|
46001
46045
|
var ZOOM_MAX = 1.8;
|
|
46002
46046
|
function anchoredText(body, id2) {
|
|
46003
46047
|
const m2 = new RegExp(`\\[([^\\]]*)\\]\\(#${id2}\\)`).exec(body);
|
|
46004
46048
|
return m2 ? m2[1] : null;
|
|
46005
46049
|
}
|
|
46006
|
-
var COMMENT_KEY_ORDER = ["id", "parentId", "anchor", "text", "author", "date", "resolved", "may_resolve", "question", "selected", "agent", "mentions"];
|
|
46007
|
-
function canonicalComment(c) {
|
|
46008
|
-
const rec = c;
|
|
46009
|
-
const out = {};
|
|
46010
|
-
for (const k2 of COMMENT_KEY_ORDER) if (rec[k2] !== void 0) out[k2] = rec[k2];
|
|
46011
|
-
for (const k2 of Object.keys(rec).sort()) if (!(k2 in out) && rec[k2] !== void 0) out[k2] = rec[k2];
|
|
46012
|
-
return out;
|
|
46013
|
-
}
|
|
46014
46050
|
function sameComment(a, b) {
|
|
46015
|
-
return JSON.stringify(
|
|
46051
|
+
return JSON.stringify(canonicalizeComment(a)) === JSON.stringify(canonicalizeComment(b));
|
|
46016
46052
|
}
|
|
46017
46053
|
function anchorLine(body, id2) {
|
|
46018
46054
|
const idx = body.indexOf(`](#${id2})`);
|
|
@@ -46088,6 +46124,7 @@ function readLayout() {
|
|
|
46088
46124
|
function App(props = {}) {
|
|
46089
46125
|
const t2 = useT();
|
|
46090
46126
|
const [loaded, setLoaded] = reactExports.useState(false);
|
|
46127
|
+
const externalAdoptedRef = reactExports.useRef(0);
|
|
46091
46128
|
const [doc2, setDoc] = reactExports.useState(EMPTY);
|
|
46092
46129
|
const [readOnly2, setReadOnly] = reactExports.useState(false);
|
|
46093
46130
|
const modes = reactExports.useMemo(() => [TURN_MODE, ...hostApi().extraModes ?? []], []);
|
|
@@ -46124,6 +46161,11 @@ function App(props = {}) {
|
|
|
46124
46161
|
const [status, setStatus] = reactExports.useState("");
|
|
46125
46162
|
const [agentThinking, setAgentThinking] = reactExports.useState(false);
|
|
46126
46163
|
const [agentDone, setAgentDone] = reactExports.useState(false);
|
|
46164
|
+
const [draftPendingModel, setDraftPendingModel] = reactExports.useState(null);
|
|
46165
|
+
const bodyEmpty = doc2.body.trim() === "";
|
|
46166
|
+
reactExports.useEffect(() => {
|
|
46167
|
+
if (!bodyEmpty) setDraftPendingModel(null);
|
|
46168
|
+
}, [bodyEmpty]);
|
|
46127
46169
|
const [agentMessages, setAgentMessages] = reactExports.useState([]);
|
|
46128
46170
|
const [navState, setNavState] = reactExports.useState({ canBack: false, canForward: false });
|
|
46129
46171
|
const [reloadReady, setReloadReady] = reactExports.useState(false);
|
|
@@ -46183,6 +46225,7 @@ function App(props = {}) {
|
|
|
46183
46225
|
});
|
|
46184
46226
|
const commentRangeRef = reactExports.useRef(null);
|
|
46185
46227
|
const docPathRef = reactExports.useRef("");
|
|
46228
|
+
const docLinkRef = reactExports.useRef("");
|
|
46186
46229
|
const railRef = reactExports.useRef(null);
|
|
46187
46230
|
const editorRef = reactExports.useRef(null);
|
|
46188
46231
|
const [pendingFocusCommentId, setPendingFocusCommentId] = reactExports.useState(null);
|
|
@@ -46209,6 +46252,7 @@ function App(props = {}) {
|
|
|
46209
46252
|
});
|
|
46210
46253
|
}, []);
|
|
46211
46254
|
const showProposal = reactExports.useCallback((content2, id2, baseContent, pending, openPanel2 = true) => {
|
|
46255
|
+
setDraftPendingModel(null);
|
|
46212
46256
|
const next = parse(content2);
|
|
46213
46257
|
const baseBody = docRef.current.body;
|
|
46214
46258
|
const baseParsed = baseContent !== void 0 ? parse(baseContent).body : void 0;
|
|
@@ -46229,25 +46273,34 @@ function App(props = {}) {
|
|
|
46229
46273
|
reactExports.useEffect(() => {
|
|
46230
46274
|
const commentStore = hostApi().commentStore ?? null;
|
|
46231
46275
|
const loadGen = docGenRef.current;
|
|
46232
|
-
|
|
46233
|
-
|
|
46276
|
+
let cancelled = false;
|
|
46277
|
+
const adoptedAtStart = externalAdoptedRef.current;
|
|
46278
|
+
const bindingReady = settleWithin(hostApi().binding?.ready, BINDING_READY_TIMEOUT_MS);
|
|
46279
|
+
Promise.all([hostApi().load(), bindingReady]).then(([{ content: content2, path, readOnly: ro, focusCommentId, shareLink, draftPending }, synced]) => {
|
|
46280
|
+
if (cancelled || docGenRef.current !== loadGen) return;
|
|
46234
46281
|
docPathRef.current = path;
|
|
46235
46282
|
humanTouchedComments.current = /* @__PURE__ */ new Set();
|
|
46283
|
+
docLinkRef.current = shareLink?.trim() ? shareLink : path;
|
|
46236
46284
|
setReadOnly(!!ro);
|
|
46237
46285
|
setPendingFocusCommentId(focusCommentId ?? null);
|
|
46238
|
-
|
|
46239
|
-
|
|
46240
|
-
|
|
46241
|
-
|
|
46242
|
-
|
|
46286
|
+
if (externalAdoptedRef.current === adoptedAtStart) {
|
|
46287
|
+
const binding = synced ? hostApi().binding : null;
|
|
46288
|
+
const parsed = binding ? commentStore ? { body: binding.getText(), comments: [] } : parse(binding.getText()) : parse(content2);
|
|
46289
|
+
const d = commentStore ? { ...parsed, comments: commentStore.list() } : parsed;
|
|
46290
|
+
setDoc(d);
|
|
46291
|
+
docRef.current = d;
|
|
46292
|
+
savedRef.current = serialize(d);
|
|
46293
|
+
}
|
|
46294
|
+
setDraftPendingModel(draftPending?.model ?? null);
|
|
46243
46295
|
setLoaded(true);
|
|
46244
46296
|
const gen = ++docGenRef.current;
|
|
46245
46297
|
void hostApi().getProposal().then((parked) => docGenRef.current === gen && parked != null && showProposal(parked.content, parked.id, parked.baseContent, parked.pending)).catch(() => {
|
|
46246
46298
|
});
|
|
46247
46299
|
}).catch(() => setLoaded(true));
|
|
46248
|
-
const processNavigated = ({ content: content2, path, readOnly: ro, focusCommentId }) => {
|
|
46300
|
+
const processNavigated = ({ content: content2, path, readOnly: ro, focusCommentId, shareLink, draftPending }) => {
|
|
46249
46301
|
if (docPathRef.current) historyByDoc.current.set(docPathRef.current, { undo: history2.current, redo: future.current, touched: humanTouchedComments.current });
|
|
46250
46302
|
docPathRef.current = path;
|
|
46303
|
+
docLinkRef.current = shareLink?.trim() ? shareLink : path;
|
|
46251
46304
|
setLoaded(true);
|
|
46252
46305
|
setReadOnly(!!ro);
|
|
46253
46306
|
resetMentionRoster();
|
|
@@ -46268,6 +46321,7 @@ function App(props = {}) {
|
|
|
46268
46321
|
setAgentThinking(false);
|
|
46269
46322
|
setAgentDone(false);
|
|
46270
46323
|
setAgentMessages([]);
|
|
46324
|
+
setDraftPendingModel(draftPending?.model ?? null);
|
|
46271
46325
|
setActivePreviewLine(null);
|
|
46272
46326
|
setStatus(`opened ${path.split("/").pop() ?? path}`);
|
|
46273
46327
|
void hostApi().getProposal().then((parked) => docGenRef.current === gen && parked != null && showProposal(parked.content, parked.id, parked.baseContent, parked.pending)).catch(() => {
|
|
@@ -46352,6 +46406,7 @@ function App(props = {}) {
|
|
|
46352
46406
|
settleExternal(commentStore ? settledDelta : settleList, settledRemovals);
|
|
46353
46407
|
setDoc(withComments);
|
|
46354
46408
|
docRef.current = withComments;
|
|
46409
|
+
externalAdoptedRef.current++;
|
|
46355
46410
|
let bodyMoved = true;
|
|
46356
46411
|
try {
|
|
46357
46412
|
bodyMoved = savedRef.current !== "" ? incoming.body !== parse(savedRef.current).body : incoming.body.trim() !== "";
|
|
@@ -46362,6 +46417,7 @@ function App(props = {}) {
|
|
|
46362
46417
|
return;
|
|
46363
46418
|
}
|
|
46364
46419
|
setDoc(next);
|
|
46420
|
+
externalAdoptedRef.current++;
|
|
46365
46421
|
settleExternal(settledDelta, settledRemovals);
|
|
46366
46422
|
humanTouchedComments.current = new Set(
|
|
46367
46423
|
[...humanTouchedComments.current].filter((id2) => {
|
|
@@ -46419,11 +46475,32 @@ function App(props = {}) {
|
|
|
46419
46475
|
hostApi().cloudSignIn?.onClose(() => setSignInUrl(null)),
|
|
46420
46476
|
// Comment store (plugin): adopt the external store's comments whenever it (or this editor)
|
|
46421
46477
|
// changes them. Body stays driven by the editor/binding; only `comments` is synced.
|
|
46422
|
-
commentStore?.observe(() => setDoc((d) => ({ ...d, comments: commentStore.list() })))
|
|
46478
|
+
commentStore?.observe(() => setDoc((d) => ({ ...d, comments: commentStore.list() }))),
|
|
46479
|
+
// The binding owns the body. Follow it whether or not a source pane is mounted to report it:
|
|
46480
|
+
// otherwise the editor's copy goes stale whenever the shared text changes from elsewhere, and
|
|
46481
|
+
// every programmatic edit built from that copy writes the change away. Body only, functional
|
|
46482
|
+
// and idempotent: this editor's own setText echoes back here, and must neither re-render nor
|
|
46483
|
+
// touch dirty tracking (a bound editor doesn't track it).
|
|
46484
|
+
hostApi().binding?.observe?.(() => {
|
|
46485
|
+
const binding = hostApi().binding;
|
|
46486
|
+
if (!binding) return;
|
|
46487
|
+
const text2 = binding.getText();
|
|
46488
|
+
let body;
|
|
46489
|
+
if (commentStore) body = text2;
|
|
46490
|
+
else {
|
|
46491
|
+
try {
|
|
46492
|
+
body = parse(text2).body;
|
|
46493
|
+
} catch {
|
|
46494
|
+
return;
|
|
46495
|
+
}
|
|
46496
|
+
}
|
|
46497
|
+
setDoc((d) => d.body === body ? d : { ...d, body });
|
|
46498
|
+
})
|
|
46423
46499
|
];
|
|
46424
46500
|
const onSel = () => setSelectionText(window.getSelection()?.toString() ?? "");
|
|
46425
46501
|
document.addEventListener("selectionchange", onSel);
|
|
46426
46502
|
return () => {
|
|
46503
|
+
cancelled = true;
|
|
46427
46504
|
document.removeEventListener("selectionchange", onSel);
|
|
46428
46505
|
for (const dispose of subs) dispose?.();
|
|
46429
46506
|
};
|
|
@@ -47314,7 +47391,11 @@ function App(props = {}) {
|
|
|
47314
47391
|
}),
|
|
47315
47392
|
[doc2.comments, panes, onboardSourceEdits]
|
|
47316
47393
|
);
|
|
47317
|
-
if (!loaded)
|
|
47394
|
+
if (!loaded)
|
|
47395
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-loading", role: "status", children: [
|
|
47396
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spinner", "aria-hidden": "true" }),
|
|
47397
|
+
t2("app.loading")
|
|
47398
|
+
] });
|
|
47318
47399
|
const showSource = panes === 3 || panes === 2 && rightTab === "source";
|
|
47319
47400
|
const showComments = panes === 3 || panes === 2 && rightTab === "comments";
|
|
47320
47401
|
const focusedRootId = (() => {
|
|
@@ -47385,6 +47466,11 @@ function App(props = {}) {
|
|
|
47385
47466
|
onQuery: reportFind
|
|
47386
47467
|
}
|
|
47387
47468
|
),
|
|
47469
|
+
draftPendingModel !== null && bodyEmpty && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-banner", role: "status", children: [
|
|
47470
|
+
t2("banner.draftPending", { model: draftPendingModel }),
|
|
47471
|
+
" ",
|
|
47472
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: () => setDraftPendingModel(null), children: t2("banner.dismiss") })
|
|
47473
|
+
] }),
|
|
47388
47474
|
agentDone && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-banner", children: [
|
|
47389
47475
|
t2("banner.agentReady"),
|
|
47390
47476
|
" ",
|
|
@@ -47754,7 +47840,9 @@ function App(props = {}) {
|
|
|
47754
47840
|
onAnswerPending: (p2) => setQuestionPending(o.thread.root.id, p2),
|
|
47755
47841
|
onResolve: (r2) => apply(setResolved(docRef.current, o.thread.root.id, r2), { type: "comment_resolved", payload: { id: o.thread.root.id, resolved: r2 } }),
|
|
47756
47842
|
onEdit: (id2, text2) => apply(editCommentText(docRef.current, id2, text2), { type: "comment_modified", payload: { id: id2 } }),
|
|
47757
|
-
onDelete: (id2) => apply(deleteComment(docRef.current, id2), { type: "comment_deleted", payload: { id: id2 } })
|
|
47843
|
+
onDelete: (id2) => apply(deleteComment(docRef.current, id2), { type: "comment_deleted", payload: { id: id2 } }),
|
|
47844
|
+
docLink: () => docLinkRef.current,
|
|
47845
|
+
onCopyOutcome: (ok2) => setStatus(t2(ok2 ? "msg.copyDocLinkDone" : "msg.copyDocLinkFailed"))
|
|
47758
47846
|
}
|
|
47759
47847
|
)
|
|
47760
47848
|
] }, o.thread.root.id)),
|
|
@@ -48327,6 +48415,18 @@ function ThreadCard(props) {
|
|
|
48327
48415
|
}
|
|
48328
48416
|
),
|
|
48329
48417
|
menuOpenId === c.id && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-cmenu-pop", onClick: (e) => e.stopPropagation(), children: [
|
|
48418
|
+
props.docLink() !== "" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
48419
|
+
"button",
|
|
48420
|
+
{
|
|
48421
|
+
onClick: () => {
|
|
48422
|
+
const write = navigator.clipboard?.writeText?.(props.docLink());
|
|
48423
|
+
if (write) void write.then(() => props.onCopyOutcome(true), () => props.onCopyOutcome(false));
|
|
48424
|
+
else props.onCopyOutcome(false);
|
|
48425
|
+
setMenuOpenId(null);
|
|
48426
|
+
},
|
|
48427
|
+
children: t2("thread.copyDocLink")
|
|
48428
|
+
}
|
|
48429
|
+
),
|
|
48330
48430
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
48331
48431
|
"button",
|
|
48332
48432
|
{
|
|
@@ -42,7 +42,11 @@ body {
|
|
|
42
42
|
page scrolls, carrying the top bar + banners off-screen. `100dvh` (with a 100vh fallback)
|
|
43
43
|
is self-clamping regardless of the parent, and `overflow:hidden` stops any shell-level scroll. */
|
|
44
44
|
.ap-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
|
|
45
|
-
|
|
45
|
+
/* Centred, with a spinner: the old top-left grey "Loading…" read as an empty document. */
|
|
46
|
+
.ap-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; height: 100vh; height: 100dvh; color: var(--muted); }
|
|
47
|
+
.ap-spinner { width: 28px; height: 28px; border: 3px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: ap-spin 0.8s linear infinite; }
|
|
48
|
+
@keyframes ap-spin { to { transform: rotate(360deg); } }
|
|
49
|
+
@media (prefers-reduced-motion: reduce) { .ap-spinner { animation-duration: 2.4s; } }
|
|
46
50
|
|
|
47
51
|
/* top bar */
|
|
48
52
|
.ap-topbar { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
|
package/app/renderer/index.html
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
content="default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' inplan-plugin:; img-src 'self' file: https:; connect-src 'self' inplan-plugin: ws://127.0.0.1:* ws://localhost:*; frame-src https://inplan.ai http://127.0.0.1:* http://localhost:*"
|
|
22
22
|
/>
|
|
23
23
|
<title>inplan</title>
|
|
24
|
-
<script type="module" crossorigin src="./assets/index-
|
|
25
|
-
<link rel="stylesheet" crossorigin href="./assets/index-
|
|
24
|
+
<script type="module" crossorigin src="./assets/index-C1AH6VQU.js"></script>
|
|
25
|
+
<link rel="stylesheet" crossorigin href="./assets/index-DziuyBKZ.css">
|
|
26
26
|
</head>
|
|
27
27
|
<body>
|
|
28
28
|
<div id="root"></div>
|
package/bin/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ import { homedir as homedir7 } from "os";
|
|
|
9
9
|
import { basename as basename3, dirname as dirname11, extname, isAbsolute as isAbsolute2, join as join10, relative as relative4, resolve as resolve3 } from "path";
|
|
10
10
|
import { fileURLToPath as fileURLToPath2, pathToFileURL as pathToFileURL2 } from "url";
|
|
11
11
|
|
|
12
|
-
// ../core/dist/chunk-
|
|
12
|
+
// ../core/dist/chunk-56Z7HGQ3.js
|
|
13
13
|
function isReply(c) {
|
|
14
14
|
return c.parentId !== void 0;
|
|
15
15
|
}
|
|
@@ -193,6 +193,18 @@ ${block}` : `${body2}
|
|
|
193
193
|
|
|
194
194
|
${block}`;
|
|
195
195
|
}
|
|
196
|
+
var DATE_SKEW_TOLERANCE_MS = 5 * 6e4;
|
|
197
|
+
function stampImpossibleDates(comments, now = Date.now()) {
|
|
198
|
+
const repaired = [];
|
|
199
|
+
let step = 0;
|
|
200
|
+
const out = comments.map((c) => {
|
|
201
|
+
const t = Date.parse(c.date);
|
|
202
|
+
if (!Number.isNaN(t) && t <= now + DATE_SKEW_TOLERANCE_MS) return c;
|
|
203
|
+
repaired.push(c.id);
|
|
204
|
+
return { ...c, date: new Date(now + step++).toISOString() };
|
|
205
|
+
});
|
|
206
|
+
return { comments: repaired.length ? out : comments, repaired };
|
|
207
|
+
}
|
|
196
208
|
var ParseError = class extends Error {
|
|
197
209
|
constructor(message) {
|
|
198
210
|
super(message);
|
|
@@ -279,7 +291,12 @@ var LogEventType = {
|
|
|
279
291
|
* Payload `{ path }` is the new doc; the attached agent's `wait` steps down and
|
|
280
292
|
* the human's agent re-attaches there (the local analogue of save-locally). */
|
|
281
293
|
NavigatedTo: "navigated_to",
|
|
282
|
-
SessionClosed: "session_closed"
|
|
294
|
+
SessionClosed: "session_closed",
|
|
295
|
+
/** `inplan open` created this document on an agent's behalf (it was passed `--model`) and the
|
|
296
|
+
* agent is about to write the first draft. Payload `{ model }`. The editor shows a dismissible
|
|
297
|
+
* "may be writing the first draft" banner while the body is still empty, so the empty page
|
|
298
|
+
* doesn't read as a broken load. Informational only — not a wake signal. */
|
|
299
|
+
DraftPending: "draft_pending"
|
|
283
300
|
};
|
|
284
301
|
function serializeLogEntry(entry) {
|
|
285
302
|
return JSON.stringify(entry);
|
|
@@ -757,6 +774,8 @@ function safeJoin(root, child) {
|
|
|
757
774
|
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel) ? full : null;
|
|
758
775
|
}
|
|
759
776
|
var base = (u) => u.endsWith("/") ? u : `${u}/`;
|
|
777
|
+
var PLUGIN_FETCH_TIMEOUT_MS = 8e3;
|
|
778
|
+
var bounded = () => ({ signal: AbortSignal.timeout(PLUGIN_FETCH_TIMEOUT_MS) });
|
|
760
779
|
function loadCached(cacheDir, version, publicKey, now) {
|
|
761
780
|
try {
|
|
762
781
|
const dir = safeJoin(cacheDir, version);
|
|
@@ -779,7 +798,7 @@ function loadCached(cacheDir, version, publicKey, now) {
|
|
|
779
798
|
}
|
|
780
799
|
async function fetchAndCache(bundleUrl, leaseToken, opts) {
|
|
781
800
|
const root = base(bundleUrl);
|
|
782
|
-
const mres = await opts.fetchImpl(`${root}manifest.json
|
|
801
|
+
const mres = await opts.fetchImpl(`${root}manifest.json`, bounded());
|
|
783
802
|
if (!mres.ok) return null;
|
|
784
803
|
const manifest = await mres.json();
|
|
785
804
|
if (!manifest?.version || !Array.isArray(manifest.files)) return null;
|
|
@@ -790,7 +809,8 @@ async function fetchAndCache(bundleUrl, leaseToken, opts) {
|
|
|
790
809
|
for (const entry of manifest.files) {
|
|
791
810
|
const filePath = safeJoin(dir, entry.name);
|
|
792
811
|
if (!filePath) return null;
|
|
793
|
-
|
|
812
|
+
if (existsSync7(filePath) && verifyBundleBytes(readFileSync6(filePath), entry, opts.publicKey)) continue;
|
|
813
|
+
const r = await opts.fetchImpl(`${root}${entry.name}`, bounded());
|
|
794
814
|
if (!r.ok) return null;
|
|
795
815
|
const bytes = Buffer.from(await r.arrayBuffer());
|
|
796
816
|
if (!verifyBundleBytes(bytes, entry, opts.publicKey)) return null;
|
|
@@ -817,7 +837,7 @@ async function resolvePluginOutcome(options) {
|
|
|
817
837
|
if (!publicKey) return { plugin: null, reason: "unavailable" };
|
|
818
838
|
if (options.token) {
|
|
819
839
|
try {
|
|
820
|
-
const res = await fetchImpl(`${base(options.apiBase)}api/v1/desktop-plugin`, { headers: { authorization: `Bearer ${options.token}` } });
|
|
840
|
+
const res = await fetchImpl(`${base(options.apiBase)}api/v1/desktop-plugin`, { ...bounded(), headers: { authorization: `Bearer ${options.token}` } });
|
|
821
841
|
if (res.ok) {
|
|
822
842
|
const grant = await res.json();
|
|
823
843
|
if (grant.entitled === false) return { plugin: null, reason: "unentitled" };
|
|
@@ -2902,6 +2922,21 @@ function spawnApp(file) {
|
|
|
2902
2922
|
}
|
|
2903
2923
|
return null;
|
|
2904
2924
|
}
|
|
2925
|
+
function stampQuietly(text) {
|
|
2926
|
+
const doc = parse(text);
|
|
2927
|
+
const { comments } = stampImpossibleDates(doc.comments);
|
|
2928
|
+
return serialize({ ...doc, comments });
|
|
2929
|
+
}
|
|
2930
|
+
function stampAgentDates(text) {
|
|
2931
|
+
const doc = parse(text);
|
|
2932
|
+
const { comments, repaired } = stampImpossibleDates(doc.comments);
|
|
2933
|
+
if (repaired.length === 0) return text;
|
|
2934
|
+
process.stderr.write(
|
|
2935
|
+
`inplan: ${repaired.length} comment date(s) were absent or in the future and have been stamped from this machine's clock (${repaired.join(", ")}) \u2014 a date in the future sorts a reply after the replies that answered it.
|
|
2936
|
+
`
|
|
2937
|
+
);
|
|
2938
|
+
return serialize({ ...doc, comments });
|
|
2939
|
+
}
|
|
2905
2940
|
function modeFrom(entries) {
|
|
2906
2941
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
2907
2942
|
if (entries[i].type === LogEventType.ModeChanged) {
|
|
@@ -2956,7 +2991,8 @@ async function waitCycle(backend, explicitCursor, confirmed, model, gate = null,
|
|
|
2956
2991
|
const { channel, store } = backend;
|
|
2957
2992
|
const history = await backend.history();
|
|
2958
2993
|
const cursor = explicitCursor ?? (await channel.getCursor() || maxSeqFrom(history));
|
|
2959
|
-
const
|
|
2994
|
+
const rawDoc = await store.loadDoc();
|
|
2995
|
+
const current = stampAgentDates(rawDoc);
|
|
2960
2996
|
const resolveCanonical = async (text) => {
|
|
2961
2997
|
if (gate) {
|
|
2962
2998
|
try {
|
|
@@ -2971,6 +3007,11 @@ async function waitCycle(backend, explicitCursor, confirmed, model, gate = null,
|
|
|
2971
3007
|
return { canonicalText: text, usePlugin: false };
|
|
2972
3008
|
};
|
|
2973
3009
|
const { canonicalText, usePlugin } = await resolveCanonical(current);
|
|
3010
|
+
if (current !== rawDoc && !usePlugin) {
|
|
3011
|
+
await store.saveDoc(current);
|
|
3012
|
+
const persistedBase = await store.getCanonical();
|
|
3013
|
+
if (persistedBase !== null && stampQuietly(persistedBase) === current) await store.setCanonical(current);
|
|
3014
|
+
}
|
|
2974
3015
|
const ev = evaluateAgentEdit(canonicalText, current, confirmed);
|
|
2975
3016
|
if (ev.unconfirmed.length > 0) {
|
|
2976
3017
|
output({
|
|
@@ -4775,9 +4816,10 @@ async function main() {
|
|
|
4775
4816
|
return;
|
|
4776
4817
|
}
|
|
4777
4818
|
if (cmd === "open") {
|
|
4778
|
-
ensureDocFile(file);
|
|
4819
|
+
const created = ensureDocFile(file);
|
|
4779
4820
|
const p = docPaths(file);
|
|
4780
4821
|
mkdirSync10(p.controlDir, { recursive: true });
|
|
4822
|
+
if (created && model) await new FsControlChannel(p).append({ actor: "agent", type: LogEventType.DraftPending, payload: { model } });
|
|
4781
4823
|
const st = readStatus(p.statusPath);
|
|
4782
4824
|
if (st.location !== "cloud") writeStatus(p.statusPath, { ...st, location: "local", originalPath: file });
|
|
4783
4825
|
const existing = runningEditorPid(p.logPath);
|