inplan 0.3.9 → 0.3.11

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.
@@ -1497,7 +1497,17 @@ function createWindow() {
1497
1497
  if (!w.isDestroyed()) w.show();
1498
1498
  };
1499
1499
  const revealFallback = setTimeout(reveal, 5e3);
1500
- 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
+ });
1501
1511
  w.webContents.once("did-fail-load", reveal);
1502
1512
  w.webContents.once("render-process-gone", reveal);
1503
1513
  win.on("page-title-updated", (e) => e.preventDefault());
@@ -1684,24 +1694,64 @@ ${body.replace(/\s*$/, "")}
1684
1694
  return { ok: false };
1685
1695
  }
1686
1696
  });
1697
+ let restarting = false;
1698
+ const logRestart = (msg) => {
1699
+ try {
1700
+ node_fs.appendFileSync(node_path.join(node_os.homedir(), ".inplan", "restart.log"), `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
1701
+ `);
1702
+ } catch {
1703
+ }
1704
+ };
1687
1705
  electron.ipcMain.handle("app:restart", async () => {
1688
1706
  const file = session?.paths.file;
1689
- if (file) {
1690
- const r = await runCli(["launch-editor", file], void 0, 2e4);
1707
+ const cli = process.env.INPLAN_CLI;
1708
+ if (!file || !cli || restarting) return { ok: false };
1709
+ restarting = true;
1710
+ let dir;
1711
+ try {
1712
+ dir = node_fs.mkdtempSync(node_path.join(node_os.tmpdir(), "inplan-restart-"));
1713
+ const readyPath = node_path.join(dir, "ready");
1714
+ const { ELECTRON_RUN_AS_NODE: _runAsNode, ...env } = process.env;
1715
+ const attempts = [];
1716
+ if (process.env.INPLAN_NODE) attempts.push([process.env.INPLAN_NODE, {}]);
1717
+ attempts.push(["node", {}], [process.execPath, { ELECTRON_RUN_AS_NODE: "1" }]);
1691
1718
  let launched = false;
1692
- try {
1693
- launched = JSON.parse(r.stdout.trim() || "{}").status === "launched";
1694
- } catch {
1719
+ for (const [exe, extra] of attempts) {
1720
+ launched = await new Promise((done) => {
1721
+ node_child_process.execFile(exe, [cli, "launch-editor", file], { env: { ...env, ...extra, INPLAN_RESTART_READY: readyPath }, timeout: 2e4 }, (err, stdout, stderr) => {
1722
+ try {
1723
+ done(!err && JSON.parse(stdout.trim()).status === "launched");
1724
+ } catch {
1725
+ done(false);
1726
+ } finally {
1727
+ if (err) logRestart(`launch via ${exe} failed: ${err.message} ${stderr.trim()}`);
1728
+ }
1729
+ });
1730
+ });
1731
+ if (launched) break;
1695
1732
  }
1696
- if (launched) {
1697
- electron.app.exit(0);
1698
- return;
1733
+ if (!launched) return { ok: false };
1734
+ const deadline = Date.now() + 15e3;
1735
+ while (!node_fs.existsSync(readyPath)) {
1736
+ if (Date.now() >= deadline) {
1737
+ logRestart("the replacement started but never reported ready");
1738
+ return { ok: false };
1739
+ }
1740
+ await new Promise((done) => setTimeout(done, 100));
1741
+ }
1742
+ } catch {
1743
+ return { ok: false };
1744
+ } finally {
1745
+ restarting = false;
1746
+ if (dir) {
1747
+ try {
1748
+ node_fs.rmSync(dir, { recursive: true, force: true });
1749
+ } catch {
1750
+ }
1699
1751
  }
1700
- process.stderr.write(`[inplan] restart: launch-editor failed (${r.code}): ${r.stderr.trim() || r.stdout.trim()}
1701
- `);
1702
1752
  }
1703
- electron.app.relaunch();
1704
1753
  electron.app.exit(0);
1754
+ return { ok: true };
1705
1755
  });
1706
1756
  electron.ipcMain.on("onboarding:get", (e) => {
1707
1757
  e.returnValue = isOnboarded();
@@ -280,6 +280,7 @@ body {
280
280
  /* rail — a soft recessed paper surface so the comment cards read as light, floating
281
281
  cards rather than rows. */
282
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; }
283
284
  .ap-rail-scroll { flex: 1; min-height: 0; overflow: auto; }
284
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; }
285
286
  .ap-rail-tools { display: flex; align-items: center; gap: 6px; }
@@ -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(() => {
@@ -47304,13 +47324,17 @@ function App(props = {}) {
47304
47324
  reactExports.useEffect(() => {
47305
47325
  if (!loaded || !pendingFocusCommentId) return;
47306
47326
  const id2 = pendingFocusCommentId;
47307
- setPendingFocusCommentId(null);
47308
47327
  const c = doc2.comments.find((x2) => x2.id === id2);
47309
47328
  const rootId = c?.parentId ?? id2;
47310
47329
  if (!visible.some((o) => o.thread.root.id === rootId)) setShowResolvedOrphaned(true);
47311
- const raf = requestAnimationFrame(() => focusComment(id2));
47330
+ if (panes === 1) setCommentOverlay(true);
47331
+ if (panes === 2 && rightTab !== "comments") setRightTab("comments");
47332
+ const raf = requestAnimationFrame(() => {
47333
+ focusComment(id2);
47334
+ setPendingFocusCommentId(null);
47335
+ });
47312
47336
  return () => cancelAnimationFrame(raf);
47313
- }, [loaded, pendingFocusCommentId, focusComment, doc2.comments, visible]);
47337
+ }, [loaded, pendingFocusCommentId, focusComment, doc2.comments, visible, panes, rightTab]);
47314
47338
  const revealTip = resolvedCount > 0 && orphanedCount > 0 ? t2("rail.showResolved", { resolved: resolvedCount, orphaned: orphanedCount }) : resolvedCount > 0 ? t2("rail.showResolvedOnly", { resolved: resolvedCount }) : t2("rail.showOrphanedOnly", { orphaned: orphanedCount });
47315
47339
  const selBlocker = reactExports.useMemo(() => {
47316
47340
  const sel = window.getSelection();
@@ -47397,7 +47421,7 @@ function App(props = {}) {
47397
47421
  t2("app.loading")
47398
47422
  ] });
47399
47423
  const showSource = panes === 3 || panes === 2 && rightTab === "source";
47400
- const showComments = panes === 3 || panes === 2 && rightTab === "comments";
47424
+ const showComments = overlayComments || panes === 3 || panes === 2 && rightTab === "comments";
47401
47425
  const focusedRootId = (() => {
47402
47426
  const byId = new Map(doc2.comments.map((x2) => [x2.id, x2]));
47403
47427
  let id2 = focused;
@@ -47505,17 +47529,23 @@ function App(props = {}) {
47505
47529
  ] }),
47506
47530
  " ",
47507
47531
  t2("banner.restartToApply"),
47532
+ restartState === "failed" && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { role: "alert", className: "ap-update-err", children: t2("banner.restartFailed") }),
47508
47533
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spacer" }),
47509
47534
  /* @__PURE__ */ jsxRuntimeExports.jsx(
47510
47535
  "button",
47511
47536
  {
47512
47537
  className: "ap-primary",
47538
+ disabled: restartState === "running",
47513
47539
  onClick: async () => {
47514
- await awaitSettled();
47515
- const current = serialize(docRef.current);
47516
- if (current !== savedRef.current) await hostApi().save(current, { kind: "apply", cadence });
47517
- if (hostApi().restartApp) await hostApi().restartApp();
47518
- else await hostApi().closeWindow();
47540
+ setRestartState("running");
47541
+ try {
47542
+ await awaitSettled();
47543
+ const current = serialize(docRef.current);
47544
+ if (current !== savedRef.current) await hostApi().save(current, { kind: "apply", cadence });
47545
+ if ((await hostApi().restartApp?.())?.ok) return;
47546
+ } catch {
47547
+ }
47548
+ setRestartState("failed");
47519
47549
  },
47520
47550
  children: t2("banner.restart")
47521
47551
  }
@@ -47746,6 +47776,7 @@ function App(props = {}) {
47746
47776
  const anchor = target.closest("[data-cmt]");
47747
47777
  if (anchor) {
47748
47778
  e.preventDefault();
47779
+ if (panes === 1) setCommentOverlay(true);
47749
47780
  focusComment(anchor.getAttribute("data-cmt"), true);
47750
47781
  return;
47751
47782
  }
@@ -47798,8 +47829,8 @@ function App(props = {}) {
47798
47829
  ] })
47799
47830
  ] }),
47800
47831
  showComments && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
47801
- /* @__PURE__ */ jsxRuntimeExports.jsx(VSplitter, { width: cmtW, setWidth: setCmtW }),
47802
- /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: "ap-pane ap-rail", ref: railRef, style: { width: cmtW }, "data-onboard": "comments", children: [
47832
+ !overlayComments && /* @__PURE__ */ jsxRuntimeExports.jsx(VSplitter, { width: cmtW, setWidth: setCmtW }),
47833
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("section", { className: `ap-pane ap-rail${overlayComments ? " ap-rail--overlay" : ""}`, ref: railRef, style: { width: cmtW }, "data-onboard": "comments", children: [
47803
47834
  panes === 2 && /* @__PURE__ */ jsxRuntimeExports.jsx(PaneTabs, { tab: rightTab, onTab: setRightTab }),
47804
47835
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-rail-scroll", children: [
47805
47836
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-rail-head", children: [
@@ -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-BXB1lexl.js"></script>
25
- <link rel="stylesheet" crossorigin href="./assets/index-RtdWGNC5.css">
24
+ <script type="module" crossorigin src="./assets/index-ZIjVITZE.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 {
@@ -2881,7 +2888,7 @@ function resolveBundledApp() {
2881
2888
  }
2882
2889
  function spawnApp(file) {
2883
2890
  const { ELECTRON_RUN_AS_NODE: _runAsNode, ...inherited } = process.env;
2884
- const env = { ...inherited, INPLAN_CLI: process.argv[1] ?? "" };
2891
+ const env = { ...inherited, INPLAN_CLI: process.argv[1] ?? "", ...process.versions.electron ? {} : { INPLAN_NODE: process.execPath } };
2885
2892
  const override = process.env.INPLAN_APP_CMD;
2886
2893
  if (override) {
2887
2894
  const child = spawn3(override, [file], { detached: true, stdio: "ignore", shell: true, env });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inplan",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
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": {