inplan 0.3.8 → 0.3.10

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.
@@ -95,6 +95,9 @@ var CONTROL_LOG_VERSION = 1;
95
95
  var LogEventType = {
96
96
  EditorPid: "editor_pid",
97
97
  ModeChanged: "mode_changed",
98
+ CommentCreated: "comment_created",
99
+ CommentModified: "comment_modified",
100
+ CommentDeleted: "comment_deleted",
98
101
  DocumentEdited: "document_edited",
99
102
  TurnEnded: "turn_ended",
100
103
  AgentRevised: "agent_revised",
@@ -886,9 +889,10 @@ class Session {
886
889
  console.warn("inplan: could not read the pending proposal for review dispatch:", e);
887
890
  });
888
891
  }
892
+ const isAgentFileChange = (e) => e.actor === "agent" && (e.type === LogEventType.DocumentEdited || e.type === LogEventType.CommentCreated || e.type === LogEventType.CommentModified || e.type === LogEventType.CommentDeleted);
889
893
  let applied;
890
894
  for (let i = entries.length - 1; i >= 0 && !applied; i--) {
891
- if (entries[i].actor === "agent" && entries[i].type === LogEventType.DocumentEdited) applied = entries[i];
895
+ if (isAgentFileChange(entries[i])) applied = entries[i];
892
896
  }
893
897
  if (applied && node_fs.existsSync(this.paths.file)) {
894
898
  const via = applied.payload?.via;
@@ -1493,7 +1497,17 @@ function createWindow() {
1493
1497
  if (!w.isDestroyed()) w.show();
1494
1498
  };
1495
1499
  const revealFallback = setTimeout(reveal, 5e3);
1496
- w.once("ready-to-show", reveal);
1500
+ w.once("ready-to-show", () => {
1501
+ reveal();
1502
+ const readyPath = process.env.INPLAN_RESTART_READY;
1503
+ if (readyPath && w === win && !w.isDestroyed()) {
1504
+ delete process.env.INPLAN_RESTART_READY;
1505
+ try {
1506
+ node_fs.writeFileSync(readyPath, "ready");
1507
+ } catch {
1508
+ }
1509
+ }
1510
+ });
1497
1511
  w.webContents.once("did-fail-load", reveal);
1498
1512
  w.webContents.once("render-process-gone", reveal);
1499
1513
  win.on("page-title-updated", (e) => e.preventDefault());
@@ -1680,24 +1694,45 @@ ${body.replace(/\s*$/, "")}
1680
1694
  return { ok: false };
1681
1695
  }
1682
1696
  });
1697
+ let restarting = false;
1683
1698
  electron.ipcMain.handle("app:restart", async () => {
1684
1699
  const file = session?.paths.file;
1685
- if (file) {
1686
- const r = await runCli(["launch-editor", file], void 0, 2e4);
1687
- let launched = false;
1688
- try {
1689
- launched = JSON.parse(r.stdout.trim() || "{}").status === "launched";
1690
- } catch {
1700
+ const cli = process.env.INPLAN_CLI;
1701
+ if (!file || !cli || restarting) return { ok: false };
1702
+ restarting = true;
1703
+ let dir;
1704
+ try {
1705
+ dir = node_fs.mkdtempSync(node_path.join(node_os.tmpdir(), "inplan-restart-"));
1706
+ const readyPath = node_path.join(dir, "ready");
1707
+ const { ELECTRON_RUN_AS_NODE: _runAsNode, ...env } = process.env;
1708
+ const launched = await new Promise((done) => {
1709
+ node_child_process.execFile("node", [cli, "launch-editor", file], { env: { ...env, INPLAN_RESTART_READY: readyPath }, timeout: 2e4 }, (err, stdout) => {
1710
+ try {
1711
+ done(!err && JSON.parse(stdout.trim()).status === "launched");
1712
+ } catch {
1713
+ done(false);
1714
+ }
1715
+ });
1716
+ });
1717
+ if (!launched) return { ok: false };
1718
+ const deadline = Date.now() + 15e3;
1719
+ while (!node_fs.existsSync(readyPath)) {
1720
+ if (Date.now() >= deadline) return { ok: false };
1721
+ await new Promise((done) => setTimeout(done, 100));
1691
1722
  }
1692
- if (launched) {
1693
- electron.app.exit(0);
1694
- return;
1723
+ } catch {
1724
+ return { ok: false };
1725
+ } finally {
1726
+ restarting = false;
1727
+ if (dir) {
1728
+ try {
1729
+ node_fs.rmSync(dir, { recursive: true, force: true });
1730
+ } catch {
1731
+ }
1695
1732
  }
1696
- process.stderr.write(`[inplan] restart: launch-editor failed (${r.code}): ${r.stderr.trim() || r.stdout.trim()}
1697
- `);
1698
1733
  }
1699
- electron.app.relaunch();
1700
1734
  electron.app.exit(0);
1735
+ return { ok: true };
1701
1736
  });
1702
1737
  electron.ipcMain.on("onboarding:get", (e) => {
1703
1738
  e.returnValue = isOnboarded();
@@ -34315,7 +34315,7 @@ class Buffer {
34315
34315
  });
34316
34316
  }
34317
34317
  }
34318
- let Element$1 = class Element {
34318
+ let Element$2 = class Element2 {
34319
34319
  /**
34320
34320
  @internal
34321
34321
  */
@@ -34363,7 +34363,7 @@ class TreeElement {
34363
34363
  }
34364
34364
  }
34365
34365
  function elt(type, from, to, children) {
34366
- return new Element$1(type, from, to, children);
34366
+ return new Element$2(type, from, to, children);
34367
34367
  }
34368
34368
  const EmphasisUnderscore = { resolve: "Emphasis", mark: "EmphasisMark" };
34369
34369
  const EmphasisAsterisk = { resolve: "Emphasis", mark: "EmphasisMark" };
@@ -34708,7 +34708,7 @@ class InlineContext {
34708
34708
  if (open.type.mark)
34709
34709
  content2.push(this.elt(open.type.mark, start, open.to));
34710
34710
  for (let k2 = j + 1; k2 < i; k2++) {
34711
- if (this.parts[k2] instanceof Element$1)
34711
+ if (this.parts[k2] instanceof Element$2)
34712
34712
  content2.push(this.parts[k2]);
34713
34713
  this.parts[k2] = null;
34714
34714
  }
@@ -34725,7 +34725,7 @@ class InlineContext {
34725
34725
  let result = [];
34726
34726
  for (let i = from; i < this.parts.length; i++) {
34727
34727
  let part = this.parts[i];
34728
- if (part instanceof Element$1)
34728
+ if (part instanceof Element$2)
34729
34729
  result.push(part);
34730
34730
  }
34731
34731
  return result;
@@ -34792,8 +34792,8 @@ function injectMarks(elements, marks) {
34792
34792
  eI++;
34793
34793
  if (eI < elts.length && elts[eI].from < mark.from) {
34794
34794
  let e = elts[eI];
34795
- if (e instanceof Element$1)
34796
- elts[eI] = new Element$1(e.type, e.from, e.to, injectMarks(e.children, [mark]));
34795
+ if (e instanceof Element$2)
34796
+ elts[eI] = new Element$2(e.type, e.from, e.to, injectMarks(e.children, [mark]));
34797
34797
  } else {
34798
34798
  elts.splice(eI++, 0, mark);
34799
34799
  }
@@ -36978,7 +36978,7 @@ function getSpecializer(spec) {
36978
36978
  }
36979
36979
  return spec.get;
36980
36980
  }
36981
- const scriptText = 55, StartCloseScriptTag = 1, styleText = 56, StartCloseStyleTag = 2, textareaText = 57, StartCloseTextareaTag = 3, EndTag = 4, SelfClosingEndTag = 5, StartTag = 6, StartScriptTag = 7, StartStyleTag = 8, StartTextareaTag = 9, StartSelfClosingTag = 10, StartCloseTag = 11, NoMatchStartCloseTag = 12, MismatchedStartCloseTag = 13, missingCloseTag = 58, IncompleteTag = 14, IncompleteCloseTag = 15, commentContent$1 = 59, Element2 = 21, TagName = 23, Attribute = 24, AttributeName = 25, AttributeValue = 27, UnquotedAttributeValue = 28, ScriptText = 29, StyleText = 32, TextareaText = 35, OpenTag = 37, CloseTag = 38, Dialect_noMatch = 0, Dialect_selfClosing = 1;
36981
+ const scriptText = 55, StartCloseScriptTag = 1, styleText = 56, StartCloseStyleTag = 2, textareaText = 57, StartCloseTextareaTag = 3, EndTag = 4, SelfClosingEndTag = 5, StartTag = 6, StartScriptTag = 7, StartStyleTag = 8, StartTextareaTag = 9, StartSelfClosingTag = 10, StartCloseTag = 11, NoMatchStartCloseTag = 12, MismatchedStartCloseTag = 13, missingCloseTag = 58, IncompleteTag = 14, IncompleteCloseTag = 15, commentContent$1 = 59, Element$1 = 21, TagName = 23, Attribute = 24, AttributeName = 25, AttributeValue = 27, UnquotedAttributeValue = 28, ScriptText = 29, StyleText = 32, TextareaText = 35, OpenTag = 37, CloseTag = 38, Dialect_noMatch = 0, Dialect_selfClosing = 1;
36982
36982
  const selfClosers$1 = {
36983
36983
  area: true,
36984
36984
  base: true,
@@ -37086,7 +37086,7 @@ const elementContext = new ContextTracker({
37086
37086
  return startTagTerms.indexOf(term) > -1 ? new ElementContext(tagNameAfter(input, 1) || "", context) : context;
37087
37087
  },
37088
37088
  reduce(context, term) {
37089
- return term == Element2 && context ? context.parent : context;
37089
+ return term == Element$1 && context ? context.parent : context;
37090
37090
  },
37091
37091
  reuse(context, node, stack, input) {
37092
37092
  let type = node.type.id;
@@ -37250,7 +37250,7 @@ function configureNesting(tags2 = [], attributes = []) {
37250
37250
  if (id2 == ScriptText) return maybeNest(node, input, script);
37251
37251
  if (id2 == StyleText) return maybeNest(node, input, style);
37252
37252
  if (id2 == TextareaText) return maybeNest(node, input, textarea);
37253
- if (id2 == Element2 && other.length) {
37253
+ if (id2 == Element$1 && other.length) {
37254
37254
  let n2 = node.node, open = n2.firstChild, tagName = open && findTagName(open, input), attrs2;
37255
37255
  if (tagName) for (let tag of other) {
37256
37256
  if (tag.tag == tagName && (!tag.attrs || tag.attrs(attrs2 || (attrs2 = getAttrs(open, input))))) {
@@ -43726,6 +43726,7 @@ var EN = {
43726
43726
  "banner.reloadNow": "Reload now",
43727
43727
  "banner.cancel": "Cancel",
43728
43728
  "banner.updated": "✅ Updated to",
43729
+ "banner.restartFailed": "Could not reopen inplan. This window is still open; try Restart again.",
43729
43730
  "banner.restartToApply": "— restart inplan to apply.",
43730
43731
  "banner.restart": "Restart",
43731
43732
  "banner.newVersion": "⬆️ A new version is available",
@@ -46142,6 +46143,7 @@ function App(props = {}) {
46142
46143
  return p2 === 1 || p2 === 2 || p2 === 3 ? p2 : 2;
46143
46144
  });
46144
46145
  const [onboardSourceEdits, setOnboardSourceEdits] = reactExports.useState(0);
46146
+ const [commentOverlay, setCommentOverlay] = reactExports.useState(false);
46145
46147
  const [rightTab, setRightTab] = reactExports.useState(() => readLayout().rightTab === "source" ? "source" : "comments");
46146
46148
  const [srcW, setSrcW] = reactExports.useState(() => {
46147
46149
  const w2 = readLayout().srcW;
@@ -46177,6 +46179,7 @@ function App(props = {}) {
46177
46179
  const userAuthorRef = reactExports.useRef(userAuthor);
46178
46180
  userAuthorRef.current = userAuthor;
46179
46181
  const [updating, setUpdating] = reactExports.useState("idle");
46182
+ const [restartState, setRestartState] = reactExports.useState("idle");
46180
46183
  const [showResolvedOrphaned, setShowResolvedOrphaned] = reactExports.useState(() => readLayout().showResolvedOrphaned === true);
46181
46184
  const [selectionText, setSelectionText] = reactExports.useState("");
46182
46185
  const [composer, setComposer] = reactExports.useState(null);
@@ -46227,6 +46230,22 @@ function App(props = {}) {
46227
46230
  const docPathRef = reactExports.useRef("");
46228
46231
  const docLinkRef = reactExports.useRef("");
46229
46232
  const railRef = reactExports.useRef(null);
46233
+ const overlayComments = panes === 1 && commentOverlay;
46234
+ reactExports.useEffect(() => {
46235
+ if (panes !== 1) setCommentOverlay(false);
46236
+ if (!overlayComments) return;
46237
+ const dismiss = (event) => {
46238
+ const target = event.target;
46239
+ if (!(target instanceof Node) || railRef.current?.contains(target) || target instanceof Element && target.closest(".ap-rendered [data-cmt]")) return;
46240
+ setCommentOverlay(false);
46241
+ };
46242
+ document.addEventListener("click", dismiss, true);
46243
+ return () => document.removeEventListener("click", dismiss, true);
46244
+ }, [panes, overlayComments]);
46245
+ reactExports.useEffect(() => {
46246
+ if (!overlayComments || !focused) return;
46247
+ railRef.current?.querySelector(`[data-cmt-card="${CSS.escape(focused)}"]`)?.scrollIntoView?.({ block: "nearest" });
46248
+ }, [overlayComments, focused]);
46230
46249
  const editorRef = reactExports.useRef(null);
46231
46250
  const [pendingFocusCommentId, setPendingFocusCommentId] = reactExports.useState(null);
46232
46251
  const autosaveTimer = reactExports.useRef(null);
@@ -46322,6 +46341,7 @@ function App(props = {}) {
46322
46341
  setAgentDone(false);
46323
46342
  setAgentMessages([]);
46324
46343
  setDraftPendingModel(draftPending?.model ?? null);
46344
+ setCommentOverlay(false);
46325
46345
  setActivePreviewLine(null);
46326
46346
  setStatus(`opened ${path.split("/").pop() ?? path}`);
46327
46347
  void hostApi().getProposal().then((parked) => docGenRef.current === gen && parked != null && showProposal(parked.content, parked.id, parked.baseContent, parked.pending)).catch(() => {
@@ -47397,7 +47417,7 @@ function App(props = {}) {
47397
47417
  t2("app.loading")
47398
47418
  ] });
47399
47419
  const showSource = panes === 3 || panes === 2 && rightTab === "source";
47400
- const showComments = panes === 3 || panes === 2 && rightTab === "comments";
47420
+ const showComments = overlayComments || panes === 3 || panes === 2 && rightTab === "comments";
47401
47421
  const focusedRootId = (() => {
47402
47422
  const byId = new Map(doc2.comments.map((x2) => [x2.id, x2]));
47403
47423
  let id2 = focused;
@@ -47467,6 +47487,7 @@ function App(props = {}) {
47467
47487
  }
47468
47488
  ),
47469
47489
  draftPendingModel !== null && bodyEmpty && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-banner", role: "status", children: [
47490
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spinner-sm", "aria-hidden": "true" }),
47470
47491
  t2("banner.draftPending", { model: draftPendingModel }),
47471
47492
  " ",
47472
47493
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: () => setDraftPendingModel(null), children: t2("banner.dismiss") })
@@ -47504,17 +47525,23 @@ function App(props = {}) {
47504
47525
  ] }),
47505
47526
  " ",
47506
47527
  t2("banner.restartToApply"),
47528
+ restartState === "failed" && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { role: "alert", className: "ap-update-err", children: t2("banner.restartFailed") }),
47507
47529
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spacer" }),
47508
47530
  /* @__PURE__ */ jsxRuntimeExports.jsx(
47509
47531
  "button",
47510
47532
  {
47511
47533
  className: "ap-primary",
47534
+ disabled: restartState === "running",
47512
47535
  onClick: async () => {
47513
- await awaitSettled();
47514
- const current = serialize(docRef.current);
47515
- if (current !== savedRef.current) await hostApi().save(current, { kind: "apply", cadence });
47516
- if (hostApi().restartApp) await hostApi().restartApp();
47517
- else await hostApi().closeWindow();
47536
+ setRestartState("running");
47537
+ try {
47538
+ await awaitSettled();
47539
+ const current = serialize(docRef.current);
47540
+ if (current !== savedRef.current) await hostApi().save(current, { kind: "apply", cadence });
47541
+ if ((await hostApi().restartApp?.())?.ok) return;
47542
+ } catch {
47543
+ }
47544
+ setRestartState("failed");
47518
47545
  },
47519
47546
  children: t2("banner.restart")
47520
47547
  }
@@ -47745,6 +47772,7 @@ function App(props = {}) {
47745
47772
  const anchor = target.closest("[data-cmt]");
47746
47773
  if (anchor) {
47747
47774
  e.preventDefault();
47775
+ if (panes === 1) setCommentOverlay(true);
47748
47776
  focusComment(anchor.getAttribute("data-cmt"), true);
47749
47777
  return;
47750
47778
  }
@@ -47797,8 +47825,8 @@ function App(props = {}) {
47797
47825
  ] })
47798
47826
  ] }),
47799
47827
  showComments && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
47800
- /* @__PURE__ */ jsxRuntimeExports.jsx(VSplitter, { width: cmtW, setWidth: setCmtW }),
47801
- /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "ap-pane ap-rail", ref: railRef, style: { width: cmtW }, "data-onboard": "comments", children: [
47828
+ !overlayComments && /* @__PURE__ */ jsxRuntimeExports.jsx(VSplitter, { width: cmtW, setWidth: setCmtW }),
47829
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: `ap-pane ap-rail${overlayComments ? " ap-rail--overlay" : ""}`, ref: railRef, style: { width: cmtW }, "data-onboard": "comments", children: [
47802
47830
  panes === 2 && /* @__PURE__ */ jsxRuntimeExports.jsx(PaneTabs, { tab: rightTab, onTab: setRightTab }),
47803
47831
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-rail-scroll", children: [
47804
47832
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-rail-head", children: [
@@ -45,6 +45,7 @@ body {
45
45
  /* Centred, with a spinner: the old top-left grey "Loading…" read as an empty document. */
46
46
  .ap-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; height: 100vh; height: 100dvh; color: var(--muted); }
47
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
+ .ap-spinner-sm { width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: ap-spin 0.8s linear infinite; flex-shrink: 0; }
48
49
  @keyframes ap-spin { to { transform: rotate(360deg); } }
49
50
  @media (prefers-reduced-motion: reduce) { .ap-spinner { animation-duration: 2.4s; } }
50
51
 
@@ -279,6 +280,7 @@ body {
279
280
  /* rail — a soft recessed paper surface so the comment cards read as light, floating
280
281
  cards rather than rows. */
281
282
  .ap-rail { background: var(--paper); } /* flex column (from .ap-pane); the inner scroller below scrolls, so PaneTabs stays pinned */
283
+ .ap-rail.ap-rail--overlay { position: absolute; inset: 0 0 0 auto; z-index: 21; max-width: 100%; border-left: 1px solid var(--line); box-shadow: -8px 0 24px #0002; }
282
284
  .ap-rail-scroll { flex: 1; min-height: 0; overflow: auto; }
283
285
  .ap-rail-head { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 1; font-size: 12px; }
284
286
  .ap-rail-tools { display: flex; align-items: center; gap: 6px; }
@@ -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-Dm0uGzyR.js"></script>
25
- <link rel="stylesheet" crossorigin href="./assets/index-DziuyBKZ.css">
24
+ <script type="module" crossorigin src="./assets/index-C5EEY2VA.js"></script>
25
+ <link rel="stylesheet" crossorigin href="./assets/index-CD5LIK6f.css">
26
26
  </head>
27
27
  <body>
28
28
  <div id="root"></div>
package/bin/cli.js CHANGED
@@ -2184,7 +2184,14 @@ async function applyGatedEdit(store, channel, ev, ctx) {
2184
2184
  function shouldQuarantine(acceptance, canonicalText, current) {
2185
2185
  if (acceptance !== "review") return false;
2186
2186
  if (emptyDocument(canonicalText)) return false;
2187
- return body(canonicalText) !== body(current);
2187
+ return reviewBody(canonicalText) !== reviewBody(current);
2188
+ }
2189
+ function reviewBody(text) {
2190
+ try {
2191
+ return stripAnchors(parse(text).body);
2192
+ } catch {
2193
+ return text;
2194
+ }
2188
2195
  }
2189
2196
  function emptyDocument(text) {
2190
2197
  try {
@@ -4834,6 +4841,13 @@ async function main() {
4834
4841
  mayResolve: hasFlag(args, "may-resolve")
4835
4842
  });
4836
4843
  writeFileSync10(file, nextText);
4844
+ const p = docPaths(file);
4845
+ mkdirSync10(p.controlDir, { recursive: true });
4846
+ await new FsControlChannel(p).append({
4847
+ actor: "agent",
4848
+ type: LogEventType.CommentCreated,
4849
+ payload: { id: comment.id }
4850
+ });
4837
4851
  output({ status: "commented", id: comment.id, date: comment.date, author: comment.author });
4838
4852
  } catch (err) {
4839
4853
  if (err instanceof AddCommentError) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inplan",
3
- "version": "0.3.8",
3
+ "version": "0.3.10",
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": {