inplan 0.3.2 → 0.3.3

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.
@@ -99,7 +99,12 @@ var LogEventType = {
99
99
  * Payload `{ path }` is the new doc; the attached agent's `wait` steps down and
100
100
  * the human's agent re-attaches there (the local analogue of save-locally). */
101
101
  NavigatedTo: "navigated_to",
102
- SessionClosed: "session_closed"
102
+ SessionClosed: "session_closed",
103
+ /** `inplan open` created this document on an agent's behalf (it was passed `--model`) and the
104
+ * agent is about to write the first draft. Payload `{ model }`. The editor shows a dismissible
105
+ * "may be writing the first draft" banner while the body is still empty, so the empty page
106
+ * doesn't read as a broken load. Informational only — not a wake signal. */
107
+ DraftPending: "draft_pending"
103
108
  };
104
109
  function serializeLogEntry(entry) {
105
110
  return JSON.stringify(entry);
@@ -694,11 +699,36 @@ class Session {
694
699
  }
695
700
  }
696
701
  }
702
+ /** The model an agent named when it created this document with `inplan open`, while its first
703
+ * draft is still to come. Null otherwise. The log is never reset, so the entry must be retired by
704
+ * whatever ends that expectation — not only the draft arriving (as an edit, or parked as a
705
+ * proposal), but the session it was raised in closing, or the human saving the document.
706
+ * Otherwise an agent that died before writing, or a page the human later cleared, would bring the
707
+ * banner back on some later open with no agent anywhere. */
708
+ draftPending() {
709
+ const entries = readLog(this.paths.logPath);
710
+ let model = null;
711
+ for (const e of entries) {
712
+ if (e.type === LogEventType.DraftPending) {
713
+ const m = e.payload?.model;
714
+ model = typeof m === "string" && m.trim() ? m : null;
715
+ } else if (e.actor === "agent" && (e.type === LogEventType.DocumentEdited || e.type === LogEventType.AgentRevised || e.type === LogEventType.AgentRevisionProposed)) {
716
+ model = null;
717
+ } else if (e.type === LogEventType.SessionClosed) {
718
+ model = null;
719
+ } else if (e.actor === "user" && (e.type === LogEventType.DocumentEdited || e.type === LogEventType.TurnEnded)) {
720
+ model = null;
721
+ }
722
+ }
723
+ return model ? { model } : null;
724
+ }
697
725
  async load() {
726
+ const pendingDraft = this.draftPending();
727
+ const withDraft = (p) => pendingDraft ? { ...p, draftPending: pendingDraft } : p;
698
728
  const content = node_fs.readFileSync(this.paths.file, "utf8");
699
729
  if (!node_fs.existsSync(this.paths.canonicalPath)) {
700
730
  node_fs.writeFileSync(this.paths.canonicalPath, content);
701
- return { path: this.paths.file, content };
731
+ return withDraft({ path: this.paths.file, content });
702
732
  }
703
733
  let pending;
704
734
  try {
@@ -708,9 +738,9 @@ class Session {
708
738
  }
709
739
  const current = node_fs.readFileSync(this.paths.file, "utf8");
710
740
  if (pending !== null && pending.content === current) {
711
- return { path: this.paths.file, content: node_fs.readFileSync(this.paths.canonicalPath, "utf8") };
741
+ return withDraft({ path: this.paths.file, content: node_fs.readFileSync(this.paths.canonicalPath, "utf8") });
712
742
  }
713
- return { path: this.paths.file, content: current };
743
+ return withDraft({ path: this.paths.file, content: current });
714
744
  }
715
745
  save(content, options) {
716
746
  if (options.kind === "backup") {
@@ -1192,6 +1222,7 @@ let win = null;
1192
1222
  let stopWatching = null;
1193
1223
  let quitConfirmed = false;
1194
1224
  let rendererReady = false;
1225
+ let editorReported = false;
1195
1226
  let quitFallbackTimer = null;
1196
1227
  const QUIT_CONFIRM_TIMEOUT_MS = 8e3;
1197
1228
  const navHistory = [];
@@ -1411,7 +1442,7 @@ function quitNow(reason) {
1411
1442
  electron.app.quit();
1412
1443
  }
1413
1444
  function rendererCanConfirm() {
1414
- return !!win && !win.isDestroyed() && !win.webContents.isDestroyed() && !win.webContents.isCrashed() && rendererReady;
1445
+ return !!win && !win.isDestroyed() && !win.webContents.isDestroyed() && !win.webContents.isCrashed() && rendererReady && editorReported;
1415
1446
  }
1416
1447
  function armQuitFallback() {
1417
1448
  if (quitFallbackTimer) return;
@@ -1426,17 +1457,34 @@ function setDocTitle(file) {
1426
1457
  }
1427
1458
  function createWindow() {
1428
1459
  rendererReady = false;
1460
+ editorReported = false;
1429
1461
  win = new electron.BrowserWindow({
1430
1462
  width: 1200,
1431
1463
  height: 800,
1432
1464
  title: "inplan",
1433
1465
  icon: appIcon,
1434
1466
  // window/taskbar icon on Windows + Linux (macOS uses the dock icon below)
1467
+ // Hidden until the renderer's first paint (below), on the editor's own paper colour: shown at
1468
+ // once, the window sat plain white while the editor bundle loaded.
1469
+ show: false,
1470
+ backgroundColor: "#fdfbf6",
1435
1471
  webPreferences: {
1436
1472
  preload: node_path.join(__dirname$1, "../preload/index.mjs"),
1437
1473
  sandbox: false
1438
1474
  }
1439
1475
  });
1476
+ const w = win;
1477
+ let revealed = false;
1478
+ const reveal = () => {
1479
+ if (revealed) return;
1480
+ revealed = true;
1481
+ clearTimeout(revealFallback);
1482
+ if (!w.isDestroyed()) w.show();
1483
+ };
1484
+ const revealFallback = setTimeout(reveal, 5e3);
1485
+ w.once("ready-to-show", reveal);
1486
+ w.webContents.once("did-fail-load", reveal);
1487
+ w.webContents.once("render-process-gone", reveal);
1440
1488
  win.on("page-title-updated", (e) => e.preventDefault());
1441
1489
  setDocTitle(session?.paths.file ?? null);
1442
1490
  win.webContents.setWindowOpenHandler(({ url }) => {
@@ -1492,6 +1540,7 @@ function registerIpc() {
1492
1540
  track(event, session?.getSettings().telemetry === true, props);
1493
1541
  });
1494
1542
  electron.ipcMain.handle("doc:report-state", (_e, dirty, content) => {
1543
+ editorReported = true;
1495
1544
  session?.setPending(dirty, content);
1496
1545
  });
1497
1546
  electron.ipcMain.handle("doc:set-mode", (_e, cadence, acceptance) => {
@@ -43336,7 +43336,12 @@ function deleteComment(doc2, id2) {
43336
43336
  }
43337
43337
  return { body, comments: doc2.comments.filter((c) => !removed.has(c.id)) };
43338
43338
  }
43339
- function buildThreads(comments) {
43339
+ function buildThreads(comments, now = Date.now()) {
43340
+ const order = new Map(comments.map((c, i) => [c.id, i]));
43341
+ const at = (c) => {
43342
+ const t2 = Date.parse(c.date);
43343
+ return Number.isNaN(t2) ? Number.NEGATIVE_INFINITY : Math.min(t2, now);
43344
+ };
43340
43345
  const byParent = /* @__PURE__ */ new Map();
43341
43346
  for (const c of comments) {
43342
43347
  if (c.parentId) {
@@ -43353,7 +43358,7 @@ function buildThreads(comments) {
43353
43358
  out.push(c);
43354
43359
  stack.push(...byParent.get(c.id) ?? []);
43355
43360
  }
43356
- return out.sort((a, b) => a.date.localeCompare(b.date));
43361
+ return out.sort((a, b) => at(a) - at(b) || (order.get(a.id) ?? 0) - (order.get(b.id) ?? 0));
43357
43362
  };
43358
43363
  return comments.filter((c) => c.parentId === void 0).map((root) => ({ root, replies: collect(root.id) }));
43359
43364
  }
@@ -43697,6 +43702,7 @@ var EN = {
43697
43702
  "rail.reply": "Reply",
43698
43703
  // banners
43699
43704
  "banner.agentReady": "The agent thinks the plan is ready.",
43705
+ "banner.draftPending": "{model} may be writing the first draft. You can start editing anytime.",
43700
43706
  "banner.dismiss": "dismiss",
43701
43707
  "banner.newBuild": "🔄 A new build is ready —",
43702
43708
  "banner.reloadingIn": "reloading in {n}s",
@@ -43763,6 +43769,9 @@ var EN = {
43763
43769
  "thread.cancel": "Cancel",
43764
43770
  "thread.save": "Save",
43765
43771
  "thread.more": "More",
43772
+ "thread.copyDocLink": "Copy link to document",
43773
+ "msg.copyDocLinkDone": "Link copied to the clipboard.",
43774
+ "msg.copyDocLinkFailed": "Copying the link failed — nothing was placed on the clipboard.",
43766
43775
  "thread.modify": "Modify",
43767
43776
  "thread.delete": "Delete"
43768
43777
  };
@@ -44963,7 +44972,9 @@ function RelativeTime({ iso, className }) {
44963
44972
  }, []);
44964
44973
  const d = dayjs(iso);
44965
44974
  if (!d.isValid()) return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className, children: iso });
44966
- return /* @__PURE__ */ jsxRuntimeExports.jsx("time", { className, dateTime: iso, title: d.format("MMM D, YYYY, h:mm:ss A"), children: d.fromNow() });
44975
+ const now = dayjs();
44976
+ const shown = d.isAfter(now) ? now : d;
44977
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("time", { className, dateTime: iso, title: d.format("MMM D, YYYY, h:mm:ss A"), children: shown.fromNow() });
44967
44978
  }
44968
44979
  var TOKEN = /\*\*([\s\S]+?)\*\*|`([^`]+?)`/g;
44969
44980
  function renderInline(text2) {
@@ -45655,7 +45666,8 @@ async function harnessHash(text2) {
45655
45666
  function createMemoryApi(opts) {
45656
45667
  const store = new MemoryDocumentStore(opts.content);
45657
45668
  const channel = new MemoryControlChannel();
45658
- let currentPath = "memory://doc";
45669
+ let currentPath = opts.path ?? "memory://doc";
45670
+ let currentShareLink = opts.shareLink;
45659
45671
  let currentReadOnly = opts.readOnly === true;
45660
45672
  let settings = opts.settings ?? { autoResolve: true };
45661
45673
  let closed = false;
@@ -45677,7 +45689,7 @@ function createMemoryApi(opts) {
45677
45689
  const api = {
45678
45690
  async load() {
45679
45691
  if (await store.getCanonical() === null) await store.setCanonical(opts.content);
45680
- return { path: currentPath, content: await store.loadDoc(), ...currentReadOnly ? { readOnly: true } : {} };
45692
+ return { path: currentPath, content: await store.loadDoc(), ...currentReadOnly ? { readOnly: true } : {}, ...currentShareLink ? { shareLink: currentShareLink } : {} };
45681
45693
  },
45682
45694
  async save(content2, options) {
45683
45695
  if (options.kind === "backup") {
@@ -45776,12 +45788,13 @@ function createMemoryApi(opts) {
45776
45788
  void channel.append({ actor: "agent", type: LogEventType.AgentMessage, payload: { text: text2 }, ts });
45777
45789
  for (const cb2 of messages) cb2({ text: text2, ts });
45778
45790
  },
45779
- navigate(content2, path = "memory://doc2", readOnly2 = opts.readOnly === true) {
45791
+ navigate(content2, path = "memory://doc2", readOnly2 = opts.readOnly === true, shareLink) {
45780
45792
  void store.saveDoc(content2);
45781
45793
  void store.setCanonical(content2);
45782
45794
  currentPath = path;
45783
45795
  currentReadOnly = readOnly2;
45784
- for (const cb2 of navigated) cb2({ path, content: content2, ...readOnly2 ? { readOnly: true } : {} });
45796
+ currentShareLink = shareLink;
45797
+ for (const cb2 of navigated) cb2({ path, content: content2, ...readOnly2 ? { readOnly: true } : {}, ...currentShareLink ? { shareLink: currentShareLink } : {} });
45785
45798
  },
45786
45799
  async log() {
45787
45800
  return (await channel.readSince(0)).entries;
@@ -45997,6 +46010,20 @@ var IMAGE_EXT_BY_MIME = {
45997
46010
  "image/avif": "avif",
45998
46011
  "image/svg+xml": "svg"
45999
46012
  };
46013
+ var BINDING_READY_TIMEOUT_MS = 1e4;
46014
+ function settleWithin(ready, ms) {
46015
+ if (!ready) return Promise.resolve(false);
46016
+ let timer;
46017
+ return Promise.race([
46018
+ ready.then(
46019
+ () => true,
46020
+ () => false
46021
+ ),
46022
+ new Promise((resolve) => {
46023
+ timer = setTimeout(() => resolve(false), ms);
46024
+ })
46025
+ ]).finally(() => clearTimeout(timer));
46026
+ }
46000
46027
  var ZOOM_MIN = 0.6;
46001
46028
  var ZOOM_MAX = 1.8;
46002
46029
  function anchoredText(body, id2) {
@@ -46088,6 +46115,7 @@ function readLayout() {
46088
46115
  function App(props = {}) {
46089
46116
  const t2 = useT();
46090
46117
  const [loaded, setLoaded] = reactExports.useState(false);
46118
+ const externalAdoptedRef = reactExports.useRef(0);
46091
46119
  const [doc2, setDoc] = reactExports.useState(EMPTY);
46092
46120
  const [readOnly2, setReadOnly] = reactExports.useState(false);
46093
46121
  const modes = reactExports.useMemo(() => [TURN_MODE, ...hostApi().extraModes ?? []], []);
@@ -46124,6 +46152,11 @@ function App(props = {}) {
46124
46152
  const [status, setStatus] = reactExports.useState("");
46125
46153
  const [agentThinking, setAgentThinking] = reactExports.useState(false);
46126
46154
  const [agentDone, setAgentDone] = reactExports.useState(false);
46155
+ const [draftPendingModel, setDraftPendingModel] = reactExports.useState(null);
46156
+ const bodyEmpty = doc2.body.trim() === "";
46157
+ reactExports.useEffect(() => {
46158
+ if (!bodyEmpty) setDraftPendingModel(null);
46159
+ }, [bodyEmpty]);
46127
46160
  const [agentMessages, setAgentMessages] = reactExports.useState([]);
46128
46161
  const [navState, setNavState] = reactExports.useState({ canBack: false, canForward: false });
46129
46162
  const [reloadReady, setReloadReady] = reactExports.useState(false);
@@ -46183,6 +46216,7 @@ function App(props = {}) {
46183
46216
  });
46184
46217
  const commentRangeRef = reactExports.useRef(null);
46185
46218
  const docPathRef = reactExports.useRef("");
46219
+ const docLinkRef = reactExports.useRef("");
46186
46220
  const railRef = reactExports.useRef(null);
46187
46221
  const editorRef = reactExports.useRef(null);
46188
46222
  const [pendingFocusCommentId, setPendingFocusCommentId] = reactExports.useState(null);
@@ -46209,6 +46243,7 @@ function App(props = {}) {
46209
46243
  });
46210
46244
  }, []);
46211
46245
  const showProposal = reactExports.useCallback((content2, id2, baseContent, pending, openPanel2 = true) => {
46246
+ setDraftPendingModel(null);
46212
46247
  const next = parse(content2);
46213
46248
  const baseBody = docRef.current.body;
46214
46249
  const baseParsed = baseContent !== void 0 ? parse(baseContent).body : void 0;
@@ -46229,25 +46264,34 @@ function App(props = {}) {
46229
46264
  reactExports.useEffect(() => {
46230
46265
  const commentStore = hostApi().commentStore ?? null;
46231
46266
  const loadGen = docGenRef.current;
46232
- hostApi().load().then(({ content: content2, path, readOnly: ro, focusCommentId }) => {
46233
- if (docGenRef.current !== loadGen) return;
46267
+ let cancelled = false;
46268
+ const adoptedAtStart = externalAdoptedRef.current;
46269
+ const bindingReady = settleWithin(hostApi().binding?.ready, BINDING_READY_TIMEOUT_MS);
46270
+ Promise.all([hostApi().load(), bindingReady]).then(([{ content: content2, path, readOnly: ro, focusCommentId, shareLink, draftPending }, synced]) => {
46271
+ if (cancelled || docGenRef.current !== loadGen) return;
46234
46272
  docPathRef.current = path;
46235
46273
  humanTouchedComments.current = /* @__PURE__ */ new Set();
46274
+ docLinkRef.current = shareLink?.trim() ? shareLink : path;
46236
46275
  setReadOnly(!!ro);
46237
46276
  setPendingFocusCommentId(focusCommentId ?? null);
46238
- const parsed = parse(content2);
46239
- const d = commentStore ? { ...parsed, comments: commentStore.list() } : parsed;
46240
- setDoc(d);
46241
- docRef.current = d;
46242
- savedRef.current = serialize(d);
46277
+ if (externalAdoptedRef.current === adoptedAtStart) {
46278
+ const binding = synced ? hostApi().binding : null;
46279
+ const parsed = binding ? commentStore ? { body: binding.getText(), comments: [] } : parse(binding.getText()) : parse(content2);
46280
+ const d = commentStore ? { ...parsed, comments: commentStore.list() } : parsed;
46281
+ setDoc(d);
46282
+ docRef.current = d;
46283
+ savedRef.current = serialize(d);
46284
+ }
46285
+ setDraftPendingModel(draftPending?.model ?? null);
46243
46286
  setLoaded(true);
46244
46287
  const gen = ++docGenRef.current;
46245
46288
  void hostApi().getProposal().then((parked) => docGenRef.current === gen && parked != null && showProposal(parked.content, parked.id, parked.baseContent, parked.pending)).catch(() => {
46246
46289
  });
46247
46290
  }).catch(() => setLoaded(true));
46248
- const processNavigated = ({ content: content2, path, readOnly: ro, focusCommentId }) => {
46291
+ const processNavigated = ({ content: content2, path, readOnly: ro, focusCommentId, shareLink, draftPending }) => {
46249
46292
  if (docPathRef.current) historyByDoc.current.set(docPathRef.current, { undo: history2.current, redo: future.current, touched: humanTouchedComments.current });
46250
46293
  docPathRef.current = path;
46294
+ docLinkRef.current = shareLink?.trim() ? shareLink : path;
46251
46295
  setLoaded(true);
46252
46296
  setReadOnly(!!ro);
46253
46297
  resetMentionRoster();
@@ -46268,6 +46312,7 @@ function App(props = {}) {
46268
46312
  setAgentThinking(false);
46269
46313
  setAgentDone(false);
46270
46314
  setAgentMessages([]);
46315
+ setDraftPendingModel(draftPending?.model ?? null);
46271
46316
  setActivePreviewLine(null);
46272
46317
  setStatus(`opened ${path.split("/").pop() ?? path}`);
46273
46318
  void hostApi().getProposal().then((parked) => docGenRef.current === gen && parked != null && showProposal(parked.content, parked.id, parked.baseContent, parked.pending)).catch(() => {
@@ -46352,6 +46397,7 @@ function App(props = {}) {
46352
46397
  settleExternal(commentStore ? settledDelta : settleList, settledRemovals);
46353
46398
  setDoc(withComments);
46354
46399
  docRef.current = withComments;
46400
+ externalAdoptedRef.current++;
46355
46401
  let bodyMoved = true;
46356
46402
  try {
46357
46403
  bodyMoved = savedRef.current !== "" ? incoming.body !== parse(savedRef.current).body : incoming.body.trim() !== "";
@@ -46362,6 +46408,7 @@ function App(props = {}) {
46362
46408
  return;
46363
46409
  }
46364
46410
  setDoc(next);
46411
+ externalAdoptedRef.current++;
46365
46412
  settleExternal(settledDelta, settledRemovals);
46366
46413
  humanTouchedComments.current = new Set(
46367
46414
  [...humanTouchedComments.current].filter((id2) => {
@@ -46424,6 +46471,7 @@ function App(props = {}) {
46424
46471
  const onSel = () => setSelectionText(window.getSelection()?.toString() ?? "");
46425
46472
  document.addEventListener("selectionchange", onSel);
46426
46473
  return () => {
46474
+ cancelled = true;
46427
46475
  document.removeEventListener("selectionchange", onSel);
46428
46476
  for (const dispose of subs) dispose?.();
46429
46477
  };
@@ -47314,7 +47362,11 @@ function App(props = {}) {
47314
47362
  }),
47315
47363
  [doc2.comments, panes, onboardSourceEdits]
47316
47364
  );
47317
- if (!loaded) return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-loading", children: t2("app.loading") });
47365
+ if (!loaded)
47366
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-loading", role: "status", children: [
47367
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spinner", "aria-hidden": "true" }),
47368
+ t2("app.loading")
47369
+ ] });
47318
47370
  const showSource = panes === 3 || panes === 2 && rightTab === "source";
47319
47371
  const showComments = panes === 3 || panes === 2 && rightTab === "comments";
47320
47372
  const focusedRootId = (() => {
@@ -47385,6 +47437,11 @@ function App(props = {}) {
47385
47437
  onQuery: reportFind
47386
47438
  }
47387
47439
  ),
47440
+ draftPendingModel !== null && bodyEmpty && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-banner", role: "status", children: [
47441
+ t2("banner.draftPending", { model: draftPendingModel }),
47442
+ " ",
47443
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: () => setDraftPendingModel(null), children: t2("banner.dismiss") })
47444
+ ] }),
47388
47445
  agentDone && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-banner", children: [
47389
47446
  t2("banner.agentReady"),
47390
47447
  " ",
@@ -47754,7 +47811,9 @@ function App(props = {}) {
47754
47811
  onAnswerPending: (p2) => setQuestionPending(o.thread.root.id, p2),
47755
47812
  onResolve: (r2) => apply(setResolved(docRef.current, o.thread.root.id, r2), { type: "comment_resolved", payload: { id: o.thread.root.id, resolved: r2 } }),
47756
47813
  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 } })
47814
+ onDelete: (id2) => apply(deleteComment(docRef.current, id2), { type: "comment_deleted", payload: { id: id2 } }),
47815
+ docLink: () => docLinkRef.current,
47816
+ onCopyOutcome: (ok2) => setStatus(t2(ok2 ? "msg.copyDocLinkDone" : "msg.copyDocLinkFailed"))
47758
47817
  }
47759
47818
  )
47760
47819
  ] }, o.thread.root.id)),
@@ -48327,6 +48386,18 @@ function ThreadCard(props) {
48327
48386
  }
48328
48387
  ),
48329
48388
  menuOpenId === c.id && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-cmenu-pop", onClick: (e) => e.stopPropagation(), children: [
48389
+ props.docLink() !== "" && /* @__PURE__ */ jsxRuntimeExports.jsx(
48390
+ "button",
48391
+ {
48392
+ onClick: () => {
48393
+ const write = navigator.clipboard?.writeText?.(props.docLink());
48394
+ if (write) void write.then(() => props.onCopyOutcome(true), () => props.onCopyOutcome(false));
48395
+ else props.onCopyOutcome(false);
48396
+ setMenuOpenId(null);
48397
+ },
48398
+ children: t2("thread.copyDocLink")
48399
+ }
48400
+ ),
48330
48401
  /* @__PURE__ */ jsxRuntimeExports.jsx(
48331
48402
  "button",
48332
48403
  {
@@ -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
- .ap-loading { padding: 2rem; color: var(--muted); }
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); }
@@ -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-B_F6JMTZ.js"></script>
25
- <link rel="stylesheet" crossorigin href="./assets/index-Bo--UUib.css">
24
+ <script type="module" crossorigin src="./assets/index-CKlJ2VBc.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-J6QADS6T.js
12
+ // ../core/dist/chunk-5WMTJCY6.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);
@@ -2902,6 +2919,21 @@ function spawnApp(file) {
2902
2919
  }
2903
2920
  return null;
2904
2921
  }
2922
+ function stampQuietly(text) {
2923
+ const doc = parse(text);
2924
+ const { comments } = stampImpossibleDates(doc.comments);
2925
+ return serialize({ ...doc, comments });
2926
+ }
2927
+ function stampAgentDates(text) {
2928
+ const doc = parse(text);
2929
+ const { comments, repaired } = stampImpossibleDates(doc.comments);
2930
+ if (repaired.length === 0) return text;
2931
+ process.stderr.write(
2932
+ `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.
2933
+ `
2934
+ );
2935
+ return serialize({ ...doc, comments });
2936
+ }
2905
2937
  function modeFrom(entries) {
2906
2938
  for (let i = entries.length - 1; i >= 0; i--) {
2907
2939
  if (entries[i].type === LogEventType.ModeChanged) {
@@ -2956,7 +2988,8 @@ async function waitCycle(backend, explicitCursor, confirmed, model, gate = null,
2956
2988
  const { channel, store } = backend;
2957
2989
  const history = await backend.history();
2958
2990
  const cursor = explicitCursor ?? (await channel.getCursor() || maxSeqFrom(history));
2959
- const current = await store.loadDoc();
2991
+ const rawDoc = await store.loadDoc();
2992
+ const current = stampAgentDates(rawDoc);
2960
2993
  const resolveCanonical = async (text) => {
2961
2994
  if (gate) {
2962
2995
  try {
@@ -2971,6 +3004,11 @@ async function waitCycle(backend, explicitCursor, confirmed, model, gate = null,
2971
3004
  return { canonicalText: text, usePlugin: false };
2972
3005
  };
2973
3006
  const { canonicalText, usePlugin } = await resolveCanonical(current);
3007
+ if (current !== rawDoc && !usePlugin) {
3008
+ await store.saveDoc(current);
3009
+ const persistedBase = await store.getCanonical();
3010
+ if (persistedBase !== null && stampQuietly(persistedBase) === current) await store.setCanonical(current);
3011
+ }
2974
3012
  const ev = evaluateAgentEdit(canonicalText, current, confirmed);
2975
3013
  if (ev.unconfirmed.length > 0) {
2976
3014
  output({
@@ -4775,9 +4813,10 @@ async function main() {
4775
4813
  return;
4776
4814
  }
4777
4815
  if (cmd === "open") {
4778
- ensureDocFile(file);
4816
+ const created = ensureDocFile(file);
4779
4817
  const p = docPaths(file);
4780
4818
  mkdirSync10(p.controlDir, { recursive: true });
4819
+ if (created && model) await new FsControlChannel(p).append({ actor: "agent", type: LogEventType.DraftPending, payload: { model } });
4781
4820
  const st = readStatus(p.statusPath);
4782
4821
  if (st.location !== "cloud") writeStatus(p.statusPath, { ...st, location: "local", originalPath: file });
4783
4822
  const existing = runningEditorPid(p.logPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inplan",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "inplan — a Markdown editor for human ⇄ coding-agent planning. CLI + desktop editor.",
5
5
  "license": "AGPL-3.0-or-later",
6
6
  "repository": {