inplan 0.1.31 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7082,6 +7082,12 @@ var LogEventType = {
7082
7082
  HumanReclaimed: "human_reclaimed",
7083
7083
  SessionClosed: "session_closed"
7084
7084
  };
7085
+ function mintProposalId() {
7086
+ const c = globalThis.crypto;
7087
+ if (c?.randomUUID) return c.randomUUID();
7088
+ const hex = (n2) => Math.floor(Math.random() * n2).toString(16);
7089
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (ch2) => ch2 === "x" ? hex(16) : (Math.floor(Math.random() * 4) + 8).toString(16));
7090
+ }
7085
7091
  var MemoryControlChannel = class {
7086
7092
  /** Deterministic timestamp source (override in tests); defaults to wall clock. */
7087
7093
  constructor(now = () => (/* @__PURE__ */ new Date()).toISOString()) {
@@ -7143,7 +7149,7 @@ var MemoryControlChannel = class {
7143
7149
  var MemoryDocumentStore = class {
7144
7150
  doc;
7145
7151
  canonical = null;
7146
- proposed = null;
7152
+ proposals = [];
7147
7153
  backups = [];
7148
7154
  constructor(initial = "") {
7149
7155
  this.doc = initial;
@@ -7162,16 +7168,39 @@ var MemoryDocumentStore = class {
7162
7168
  this.canonical = content2;
7163
7169
  return Promise.resolve();
7164
7170
  }
7165
- getProposed() {
7166
- return Promise.resolve(this.proposed);
7167
- }
7168
- setProposed(content2) {
7169
- this.proposed = content2;
7171
+ createProposal(input) {
7172
+ const pendingSame = input.id ? void 0 : this.proposals.find((r2) => r2.state === "pending" && r2.content === input.content);
7173
+ const id2 = input.id ?? pendingSame?.id ?? mintProposalId();
7174
+ const existing = this.proposals.find((r2) => r2.id === id2);
7175
+ if (existing) {
7176
+ if (existing.state === "pending") Object.assign(existing, { content: input.content, baseHash: input.baseHash, baseContent: input.baseContent });
7177
+ return Promise.resolve({ id: id2 });
7178
+ }
7179
+ for (const r2 of this.proposals) if (r2.state === "pending") r2.state = "superseded";
7180
+ this.proposals.push({ id: id2, content: input.content, baseHash: input.baseHash, baseContent: input.baseContent, state: "pending", createdAt: (/* @__PURE__ */ new Date()).toISOString() });
7181
+ return Promise.resolve({ id: id2 });
7182
+ }
7183
+ myPendingProposal() {
7184
+ const r2 = this.proposals.find((x2) => x2.state === "pending");
7185
+ return Promise.resolve(r2 ? { ...r2 } : null);
7186
+ }
7187
+ getProposal(id2) {
7188
+ const r2 = this.proposals.find((x2) => x2.id === id2);
7189
+ return Promise.resolve(r2 ? { ...r2 } : null);
7190
+ }
7191
+ withdrawProposal(id2) {
7192
+ const r2 = this.proposals.find((x2) => x2.id === id2);
7193
+ if (r2 && r2.state === "pending") r2.state = "withdrawn";
7170
7194
  return Promise.resolve();
7171
7195
  }
7172
- clearProposed() {
7173
- this.proposed = null;
7174
- return Promise.resolve();
7196
+ decideProposal(id2, state) {
7197
+ const r2 = this.proposals.find((x2) => x2.id === id2);
7198
+ if (r2 && r2.state === "pending") {
7199
+ r2.state = state;
7200
+ r2.decidedAt = (/* @__PURE__ */ new Date()).toISOString();
7201
+ return Promise.resolve({ transitioned: true });
7202
+ }
7203
+ return Promise.resolve({ transitioned: false });
7175
7204
  }
7176
7205
  backup(content2) {
7177
7206
  this.backups.push(content2);
@@ -43655,7 +43684,18 @@ var EN = {
43655
43684
  "banner.updateNow": "Update now",
43656
43685
  "banner.later": "Later",
43657
43686
  "banner.proposalPending": "The agent proposed changes awaiting your review.",
43687
+ "banner.proposalQueue": "{n} proposals await your review (oldest shown first).",
43688
+ "banner.queuePosition": "1 of {n}",
43689
+ "banner.stale": "written against an older version; shown merged onto the current document",
43690
+ "banner.staleTitle": "The document changed after this proposal was written. The diff below replays the proposal's edits onto the current text (a 3-way merge from its recorded base).",
43658
43691
  "banner.review": "Review",
43692
+ "msg.appliedRevision": "Applied agent revision ({accepted}/{total} hunks).",
43693
+ "msg.navWhileSettling": "Finishing the review decision — try the link again in a moment.",
43694
+ "msg.queueRefreshFailed": "Could not check for the next queued proposal — it will surface on the next park or reload.",
43695
+ "msg.decisionUnconfirmed": "The decision could not be confirmed — this proposal's current state is unknown; it will reconcile on the next reload or park.",
43696
+ "msg.decisionFailedRetry": "The decision could not be recorded — the proposal is still pending; try Apply again.",
43697
+ "msg.decidedElsewhere": "This proposal was decided elsewhere — your apply was not recorded and the document is unchanged.",
43698
+ "msg.decisionSaveFailed": "The decision was recorded but the content could not be saved — it stays in the editor as unsaved work and persists on your next save or quit.",
43659
43699
  "banner.proposedChanges": "Agent proposed changes",
43660
43700
  "banner.changesShown": "— {n} change shown inline below",
43661
43701
  "banner.changesShownPlural": "— {n} changes shown inline below",
@@ -43820,6 +43860,7 @@ var renderHtmlToken = (tokens, idx) => {
43820
43860
  };
43821
43861
  md.renderer.rules.html_block = (tokens, idx) => renderHtmlToken(tokens, idx);
43822
43862
  md.renderer.rules.html_inline = (tokens, idx) => renderHtmlToken(tokens, idx);
43863
+ md.renderer.rules.hardbreak = () => "<br>";
43823
43864
  var defaultLinkOpen = md.renderer.rules.link_open ?? ((tokens, idx, opts, _env, self2) => self2.renderToken(tokens, idx, opts));
43824
43865
  var defaultLinkClose = md.renderer.rules.link_close ?? ((tokens, idx, opts, _env, self2) => self2.renderToken(tokens, idx, opts));
43825
43866
  md.renderer.rules.link_open = (tokens, idx, opts, env, self2) => {
@@ -43873,11 +43914,36 @@ for (const name2 of BLOCK_RULES) {
43873
43914
  return orig ? orig(tokens, idx, options, env, self2) : self2.renderToken(tokens, idx, options);
43874
43915
  };
43875
43916
  }
43917
+ var CODE_ANCHOR_RE = /\[([^\]]*)\]\(#(cmt-[0-9a-z]+)\)/gi;
43918
+ var HAS_CODE_ANCHOR = new RegExp(CODE_ANCHOR_RE.source, "i");
43919
+ function codeBodyWithAnchors(content2, showAnchor) {
43920
+ let out = "";
43921
+ let last = 0;
43922
+ for (const m2 of content2.matchAll(CODE_ANCHOR_RE)) {
43923
+ out += md.utils.escapeHtml(content2.slice(last, m2.index));
43924
+ const id2 = m2[2].toLowerCase();
43925
+ const label = md.utils.escapeHtml(m2[1]);
43926
+ out += showAnchor && !showAnchor(id2) ? label : `<span data-cmt="${id2}" class="ap-anchor">${label}</span>`;
43927
+ last = m2.index + m2[0].length;
43928
+ }
43929
+ return out + md.utils.escapeHtml(content2.slice(last));
43930
+ }
43876
43931
  for (const name2 of ["fence", "code_block"]) {
43877
43932
  const orig = md.renderer.rules[name2];
43878
43933
  md.renderer.rules[name2] = (tokens, idx, options, env, self2) => {
43879
- const html2 = orig ? orig(tokens, idx, options, env, self2) : self2.renderToken(tokens, idx, options);
43934
+ const render = () => orig ? orig(tokens, idx, options, env, self2) : self2.renderToken(tokens, idx, options);
43880
43935
  const tok = tokens[idx];
43936
+ let html2;
43937
+ if (HAS_CODE_ANCHOR.test(tok.content)) {
43938
+ const raw = tok.content;
43939
+ tok.content = "";
43940
+ const shell = render();
43941
+ tok.content = raw;
43942
+ const at = shell.lastIndexOf("</code>");
43943
+ html2 = at < 0 ? render() : shell.slice(0, at) + codeBodyWithAnchors(raw, env.showAnchor) + shell.slice(at);
43944
+ } else {
43945
+ html2 = render();
43946
+ }
43881
43947
  return tok.map ? html2.replace(/^<pre/, `<pre data-line="${tok.map[0]}"`) : html2;
43882
43948
  };
43883
43949
  }
@@ -45534,6 +45600,19 @@ Select any line above, then press the comment shortcut to leave a note on it.
45534
45600
  ]
45535
45601
  -->
45536
45602
  `;
45603
+ async function harnessHash(text2) {
45604
+ const subtle = globalThis.crypto?.subtle;
45605
+ if (subtle) {
45606
+ const digest = await subtle.digest("SHA-256", new TextEncoder().encode(text2));
45607
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
45608
+ }
45609
+ let h = 2166136261;
45610
+ for (let i = 0; i < text2.length; i++) {
45611
+ h ^= text2.charCodeAt(i);
45612
+ h = Math.imul(h, 16777619);
45613
+ }
45614
+ return `fnv1a-${(h >>> 0).toString(16)}`;
45615
+ }
45537
45616
  function createMemoryApi(opts) {
45538
45617
  const store = new MemoryDocumentStore(opts.content);
45539
45618
  const channel = new MemoryControlChannel();
@@ -45614,10 +45693,14 @@ function createMemoryApi(opts) {
45614
45693
  closed = true;
45615
45694
  },
45616
45695
  async getProposal() {
45617
- return store.getProposed();
45696
+ const mine = await store.myPendingProposal();
45697
+ return mine ? { id: mine.id, content: mine.content, baseContent: mine.baseContent, pending: 1 } : null;
45618
45698
  },
45619
- async clearProposal() {
45620
- await store.clearProposed();
45699
+ async clearProposal(outcome, id2) {
45700
+ const target = id2 ?? (await store.myPendingProposal())?.id;
45701
+ if (!target) throw new Error("no pending proposal to settle (it was decided or withdrawn elsewhere)");
45702
+ const { transitioned } = await store.decideProposal(target, outcome ?? "accepted");
45703
+ if (!transitioned) throw new Error(`proposal ${target} was decided elsewhere`);
45621
45704
  },
45622
45705
  async openDoc() {
45623
45706
  }
@@ -45630,9 +45713,12 @@ function createMemoryApi(opts) {
45630
45713
  for (const cb2 of external) cb2({ path: "memory://doc", content: content2 });
45631
45714
  },
45632
45715
  proposeRevision(content2) {
45633
- void store.setProposed(content2);
45634
- void channel.append({ actor: "agent", type: LogEventType.AgentRevisionProposed, payload: { bytes: content2.length } });
45635
- for (const cb2 of proposal) cb2({ content: content2 });
45716
+ return (async () => {
45717
+ const base2 = await store.getCanonical() ?? await store.loadDoc();
45718
+ const { id: id2 } = await store.createProposal({ content: content2, baseHash: await harnessHash(base2), baseContent: base2 });
45719
+ await channel.append({ actor: "agent", type: LogEventType.AgentRevisionProposed, payload: { bytes: new TextEncoder().encode(content2).byteLength, hash: await harnessHash(content2), proposal_id: id2 } });
45720
+ for (const cb2 of proposal) cb2({ content: content2, id: id2, baseContent: base2, pending: 1 });
45721
+ })();
45636
45722
  },
45637
45723
  markActive() {
45638
45724
  void channel.append({ actor: "agent", type: LogEventType.AgentRevised });
@@ -45763,6 +45849,105 @@ function applySegments(segs, accepted) {
45763
45849
  }
45764
45850
  return out.join("\n");
45765
45851
  }
45852
+ function changeBlocks(fullBase, fullNext) {
45853
+ let pre = 0;
45854
+ while (pre < fullBase.length && pre < fullNext.length && fullBase[pre] === fullNext[pre]) pre++;
45855
+ let suf = 0;
45856
+ while (suf < fullBase.length - pre && suf < fullNext.length - pre && fullBase[fullBase.length - 1 - suf] === fullNext[fullNext.length - 1 - suf]) suf++;
45857
+ const base2 = fullBase.slice(pre, fullBase.length - suf);
45858
+ const next = fullNext.slice(pre, fullNext.length - suf);
45859
+ const n2 = base2.length;
45860
+ const m2 = next.length;
45861
+ const dp = Array.from({ length: n2 + 1 }, () => new Array(m2 + 1).fill(0));
45862
+ for (let i2 = n2 - 1; i2 >= 0; i2--) {
45863
+ for (let j2 = m2 - 1; j2 >= 0; j2--) {
45864
+ dp[i2][j2] = base2[i2] === next[j2] ? dp[i2 + 1][j2 + 1] + 1 : Math.max(dp[i2 + 1][j2], dp[i2][j2 + 1]);
45865
+ }
45866
+ }
45867
+ const blocks = [];
45868
+ let cur2 = null;
45869
+ const open = (at) => {
45870
+ if (!cur2) {
45871
+ cur2 = { start: at, count: 0, out: [] };
45872
+ blocks.push(cur2);
45873
+ }
45874
+ return cur2;
45875
+ };
45876
+ let i = 0;
45877
+ let j = 0;
45878
+ while (i < n2 && j < m2) {
45879
+ if (base2[i] === next[j]) {
45880
+ cur2 = null;
45881
+ i++;
45882
+ j++;
45883
+ } else if (dp[i + 1][j] >= dp[i][j + 1]) {
45884
+ open(i).count++;
45885
+ i++;
45886
+ } else {
45887
+ open(i).out.push(next[j]);
45888
+ j++;
45889
+ }
45890
+ }
45891
+ while (i < n2) {
45892
+ open(i).count++;
45893
+ i++;
45894
+ }
45895
+ while (j < m2) {
45896
+ open(n2).out.push(next[j]);
45897
+ j++;
45898
+ }
45899
+ for (const b of blocks) b.start += pre;
45900
+ return blocks;
45901
+ }
45902
+ function replay(base2, lo, hi2, blocks) {
45903
+ const out = [];
45904
+ let idx = lo;
45905
+ for (const b of blocks) {
45906
+ for (; idx < b.start; idx++) out.push(base2[idx]);
45907
+ out.push(...b.out);
45908
+ idx = b.start + b.count;
45909
+ }
45910
+ for (; idx < hi2; idx++) out.push(base2[idx]);
45911
+ return out;
45912
+ }
45913
+ function merge3(base2, ours, theirs) {
45914
+ const B2 = base2.split("\n");
45915
+ const blocksO = changeBlocks(B2, ours.split("\n"));
45916
+ const blocksT = changeBlocks(B2, theirs.split("\n"));
45917
+ const touches = (a, b) => {
45918
+ if (a.count > 0 && b.count > 0) return a.start < b.start + b.count && b.start < a.start + a.count;
45919
+ return a.start <= b.start + b.count && b.start <= a.start + a.count;
45920
+ };
45921
+ const all = [...blocksO.map((b) => ({ ...b, side: "ours" })), ...blocksT.map((b) => ({ ...b, side: "theirs" }))].sort(
45922
+ (a, b) => a.start - b.start || a.side.localeCompare(b.side)
45923
+ );
45924
+ const out = [];
45925
+ let base_idx = 0;
45926
+ let k2 = 0;
45927
+ while (k2 < all.length) {
45928
+ let lo = all[k2].start;
45929
+ let hi2 = all[k2].start + all[k2].count;
45930
+ const region = [all[k2]];
45931
+ k2++;
45932
+ while (k2 < all.length && all[k2].start <= hi2 && region.some((r2) => touches(r2, all[k2]))) {
45933
+ hi2 = Math.max(hi2, all[k2].start + all[k2].count);
45934
+ region.push(all[k2]);
45935
+ k2++;
45936
+ }
45937
+ for (; base_idx < lo; base_idx++) out.push(B2[base_idx]);
45938
+ const oursHere = region.filter((b) => b.side === "ours");
45939
+ const theirsHere = region.filter((b) => b.side === "theirs");
45940
+ const oursOut = replay(B2, lo, hi2, oursHere);
45941
+ const theirsOut = replay(B2, lo, hi2, theirsHere);
45942
+ if (theirsHere.length === 0) out.push(...oursOut);
45943
+ else if (oursHere.length === 0) out.push(...theirsOut);
45944
+ else if (oursOut.join("\n") === theirsOut.join("\n")) out.push(...oursOut);
45945
+ else out.push(...theirsOut);
45946
+ base_idx = hi2;
45947
+ }
45948
+ for (; base_idx < B2.length; base_idx++) out.push(B2[base_idx]);
45949
+ return out.join("\n");
45950
+ }
45766
45951
  var USER_AUTHOR = "You";
45767
45952
  var EMPTY = { body: "", comments: [] };
45768
45953
  var IMAGE_EXT_BY_MIME = {
@@ -45831,6 +46016,7 @@ function commentBlockReason(raw, body, range, root) {
45831
46016
  if (b === "not-found") return anchorFailureReason(range);
45832
46017
  return null;
45833
46018
  }
46019
+ var NO_REVIEW = { key: null, accepted: [], edits: {}, editingHunk: null, cursor: -1 };
45834
46020
  function CloudSignInOverlay({ url, onDismiss }) {
45835
46021
  reactExports.useEffect(() => {
45836
46022
  const onKey = (e) => {
@@ -45907,6 +46093,8 @@ function App(props = {}) {
45907
46093
  const [activePreviewLine, setActivePreviewLine] = reactExports.useState(null);
45908
46094
  const [proposal, setProposal] = reactExports.useState(null);
45909
46095
  const [reviewOpen, setReviewOpen] = reactExports.useState(false);
46096
+ const [settling, setSettling] = reactExports.useState(false);
46097
+ const [queueCount, setQueueCount] = reactExports.useState(void 0);
45910
46098
  const [findOpen, setFindOpen] = reactExports.useState(false);
45911
46099
  const [findOpts, setFindOpts] = reactExports.useState({ query: "", ci: false, inPreview: true, inEditor: false, inComments: false });
45912
46100
  const [openPanel, setOpenPanel] = reactExports.useState(null);
@@ -45914,6 +46102,27 @@ function App(props = {}) {
45914
46102
  const [closingPanel, setClosingPanel] = reactExports.useState(null);
45915
46103
  const lastOpenPanelRef = reactExports.useRef(null);
45916
46104
  const docRef = reactExports.useRef(doc2);
46105
+ const proposalRef = reactExports.useRef(proposal);
46106
+ proposalRef.current = proposal;
46107
+ const queueCountRef = reactExports.useRef(queueCount);
46108
+ queueCountRef.current = queueCount;
46109
+ const reviewOpenRef = reactExports.useRef(reviewOpen);
46110
+ reviewOpenRef.current = reviewOpen;
46111
+ const settlingRef = reactExports.useRef(settling);
46112
+ settlingRef.current = settling;
46113
+ const pendingNavRef = reactExports.useRef(null);
46114
+ const processNavigatedRef = reactExports.useRef(null);
46115
+ const awaitSettled = reactExports.useCallback(async () => {
46116
+ for (let i = 0; i < 100 && settlingRef.current; i++) await new Promise((r2) => setTimeout(r2, 100));
46117
+ }, []);
46118
+ const navigateGuarded = reactExports.useCallback((go) => {
46119
+ if (settlingRef.current) {
46120
+ setStatus(t2("msg.navWhileSettling"));
46121
+ return;
46122
+ }
46123
+ go();
46124
+ }, []);
46125
+ const docGenRef = reactExports.useRef(0);
45917
46126
  docRef.current = doc2;
45918
46127
  const previewRef = reactExports.useRef(null);
45919
46128
  const ctxBlockRef = reactExports.useRef(null);
@@ -45946,25 +46155,69 @@ function App(props = {}) {
45946
46155
  setAcceptance(s.acceptance === "auto" ? "auto" : "review");
45947
46156
  });
45948
46157
  }, []);
46158
+ const showProposal = reactExports.useCallback((content2, id2, baseContent, pending, openPanel2 = true) => {
46159
+ const next = parse(content2);
46160
+ const baseBody = docRef.current.body;
46161
+ const baseParsed = baseContent !== void 0 ? parse(baseContent).body : void 0;
46162
+ const stale = baseParsed !== void 0 && baseParsed !== baseBody;
46163
+ setProposal({
46164
+ ...id2 ? { id: id2 } : {},
46165
+ baseBody,
46166
+ next: stale ? { ...next, body: merge3(baseParsed, baseBody, next.body) } : next,
46167
+ ...stale ? { stale } : {},
46168
+ raw: content2,
46169
+ ...baseContent !== void 0 ? { base: baseContent } : {}
46170
+ });
46171
+ setQueueCount(pending);
46172
+ if (openPanel2) setReviewOpen(true);
46173
+ setAgentThinking(false);
46174
+ setStatus(t2("msg.proposedReview"));
46175
+ }, []);
45949
46176
  reactExports.useEffect(() => {
45950
- const showProposal = (content2) => {
45951
- setProposal({ baseBody: docRef.current.body, next: parse(content2) });
45952
- setReviewOpen(true);
45953
- setAgentThinking(false);
45954
- setStatus(t2("msg.proposedReview"));
45955
- };
45956
46177
  const commentStore = hostApi().commentStore ?? null;
46178
+ const loadGen = docGenRef.current;
45957
46179
  hostApi().load().then(({ content: content2, path, readOnly: ro, focusCommentId }) => {
46180
+ if (docGenRef.current !== loadGen) return;
45958
46181
  docPathRef.current = path;
45959
46182
  setReadOnly(!!ro);
45960
46183
  setPendingFocusCommentId(focusCommentId ?? null);
45961
46184
  const parsed = parse(content2);
45962
46185
  const d = commentStore ? { ...parsed, comments: commentStore.list() } : parsed;
45963
46186
  setDoc(d);
46187
+ docRef.current = d;
45964
46188
  savedRef.current = serialize(d);
45965
46189
  setLoaded(true);
45966
- void hostApi().getProposal().then((parked) => parked != null && showProposal(parked));
46190
+ const gen = ++docGenRef.current;
46191
+ void hostApi().getProposal().then((parked) => docGenRef.current === gen && parked != null && showProposal(parked.content, parked.id, parked.baseContent, parked.pending)).catch(() => {
46192
+ });
45967
46193
  }).catch(() => setLoaded(true));
46194
+ const processNavigated = ({ content: content2, path, readOnly: ro, focusCommentId }) => {
46195
+ if (docPathRef.current) historyByDoc.current.set(docPathRef.current, { undo: history2.current, redo: future.current });
46196
+ docPathRef.current = path;
46197
+ setReadOnly(!!ro);
46198
+ resetMentionRoster();
46199
+ setPendingFocusCommentId(focusCommentId ?? null);
46200
+ const parsed = parse(content2);
46201
+ const d = commentStore ? { ...parsed, comments: commentStore.list() } : parsed;
46202
+ setDoc(d);
46203
+ docRef.current = d;
46204
+ const gen = ++docGenRef.current;
46205
+ savedRef.current = serialize(d);
46206
+ setDirty(false);
46207
+ const restored = historyByDoc.current.get(path);
46208
+ history2.current = restored?.undo ?? [];
46209
+ future.current = restored?.redo ?? [];
46210
+ setProposal(null);
46211
+ setReviewOpen(false);
46212
+ setAgentThinking(false);
46213
+ setAgentDone(false);
46214
+ setAgentMessages([]);
46215
+ setActivePreviewLine(null);
46216
+ setStatus(`opened ${path.split("/").pop() ?? path}`);
46217
+ void hostApi().getProposal().then((parked) => docGenRef.current === gen && parked != null && showProposal(parked.content, parked.id, parked.baseContent, parked.pending)).catch(() => {
46218
+ });
46219
+ };
46220
+ processNavigatedRef.current = processNavigated;
45968
46221
  const subs = [
45969
46222
  hostApi().onExternalChange(({ content: content2 }) => {
45970
46223
  const prevDoc = docRef.current;
@@ -45975,10 +46228,23 @@ function App(props = {}) {
45975
46228
  savedRef.current = serialize(next);
45976
46229
  setDirty(false);
45977
46230
  syncExternalDoc(next, prevDoc.comments, prevDoc.body);
46231
+ docRef.current = next;
46232
+ const open = proposalRef.current;
46233
+ if (open?.raw !== void 0 && open.base !== void 0) {
46234
+ showProposal(open.raw, open.id, open.base, queueCountRef.current, reviewOpenRef.current);
46235
+ }
45978
46236
  setStatus(t2("msg.agentUpdated"));
45979
46237
  }),
45980
46238
  // Review-mode body changes arrive parked, as a proposal to accept/reject.
45981
- hostApi().onProposal(({ content: content2 }) => showProposal(content2)),
46239
+ hostApi().onProposal(({ content: content2, id: id2, baseContent, pending, path }) => {
46240
+ if (path !== void 0 && docPathRef.current !== "" && path !== docPathRef.current) return;
46241
+ const cur2 = proposalRef.current;
46242
+ if (cur2 && cur2.id !== void 0 && cur2.id === id2 && cur2.raw === content2 && cur2.base === baseContent) {
46243
+ if (pending !== void 0) setQueueCount(pending);
46244
+ return;
46245
+ }
46246
+ showProposal(content2, id2, baseContent, pending);
46247
+ }),
45982
46248
  hostApi().onAgentDone(() => setAgentDone(true)),
45983
46249
  hostApi().onReload(() => {
45984
46250
  setReloadReady(true);
@@ -45993,28 +46259,12 @@ function App(props = {}) {
45993
46259
  hostApi().onAgentMessage?.((msg) => setAgentMessages((prev) => [...prev, msg])),
45994
46260
  // Desktop only: the window followed a link to another doc — reset to it (a fresh
45995
46261
  // load), clearing any in-flight proposal/turn state, then re-show a parked proposal.
45996
- hostApi().onNavigated?.(({ content: content2, path, readOnly: ro, focusCommentId }) => {
45997
- if (docPathRef.current) historyByDoc.current.set(docPathRef.current, { undo: history2.current, redo: future.current });
45998
- docPathRef.current = path;
45999
- setReadOnly(!!ro);
46000
- resetMentionRoster();
46001
- setPendingFocusCommentId(focusCommentId ?? null);
46002
- const parsed = parse(content2);
46003
- const d = commentStore ? { ...parsed, comments: commentStore.list() } : parsed;
46004
- setDoc(d);
46005
- savedRef.current = serialize(d);
46006
- setDirty(false);
46007
- const restored = historyByDoc.current.get(path);
46008
- history2.current = restored?.undo ?? [];
46009
- future.current = restored?.redo ?? [];
46010
- setProposal(null);
46011
- setReviewOpen(false);
46012
- setAgentThinking(false);
46013
- setAgentDone(false);
46014
- setAgentMessages([]);
46015
- setActivePreviewLine(null);
46016
- setStatus(`opened ${path.split("/").pop() ?? path}`);
46017
- void hostApi().getProposal().then((parked) => parked != null && showProposal(parked));
46262
+ hostApi().onNavigated?.((payload) => {
46263
+ if (settlingRef.current) {
46264
+ pendingNavRef.current = payload;
46265
+ return;
46266
+ }
46267
+ processNavigated(payload);
46018
46268
  }),
46019
46269
  hostApi().onNavState?.((s) => setNavState(s)),
46020
46270
  // Desktop only: a newer npm version is available.
@@ -46033,10 +46283,17 @@ function App(props = {}) {
46033
46283
  for (const dispose of subs) dispose?.();
46034
46284
  };
46035
46285
  }, []);
46286
+ reactExports.useEffect(() => {
46287
+ if (!settling && pendingNavRef.current && processNavigatedRef.current) {
46288
+ const payload = pendingNavRef.current;
46289
+ pendingNavRef.current = null;
46290
+ processNavigatedRef.current(payload);
46291
+ }
46292
+ }, [settling]);
46036
46293
  reactExports.useEffect(() => {
46037
46294
  if (reloadIn === null) return;
46038
46295
  if (reloadIn <= 0) {
46039
- void hostApi().closeWindow();
46296
+ void awaitSettled().then(() => hostApi().closeWindow());
46040
46297
  return;
46041
46298
  }
46042
46299
  const timer = setTimeout(() => setReloadIn((s) => s === null ? null : s - 1), 1e3);
@@ -46347,7 +46604,7 @@ function App(props = {}) {
46347
46604
  );
46348
46605
  const [forceSettingsOpen, setForceSettingsOpen] = reactExports.useState(false);
46349
46606
  const confirmQuit = reactExports.useCallback((opts) => {
46350
- realHostApi().exit?.quit(serialize(docRef.current), opts);
46607
+ void awaitSettled().then(() => realHostApi().exit?.quit(serialize(docRef.current), opts));
46351
46608
  setQuitOpen(false);
46352
46609
  }, []);
46353
46610
  reactExports.useEffect(() => {
@@ -46627,29 +46884,99 @@ function App(props = {}) {
46627
46884
  const have = new Set(live.map((c) => c.id));
46628
46885
  const merged = [...live, ...proposal.next.comments.filter((c) => !have.has(c.id))];
46629
46886
  const comments = merged.map((c) => !c.parentId && c.anchor !== "doc" && !body.includes(`](#${c.id})`) ? { ...c, anchor: "doc" } : c);
46630
- const finalDoc = { body, comments };
46631
- setDoc(finalDoc);
46632
- setProposal(null);
46633
- setReviewOpen(false);
46634
- const serialized = serialize(finalDoc);
46635
- savedRef.current = serialized;
46636
- setDirty(false);
46887
+ let finalDoc = { body, comments };
46888
+ let serialized = serialize(finalDoc);
46637
46889
  const acceptedCount = accepted2.filter(Boolean).length;
46638
- if (syncExternalDoc(finalDoc, prevDoc.comments, prevDoc.body)) {
46639
- setCheckpoint(serialized);
46640
- } else {
46641
- void hostApi().save(serialized, { kind: "apply", cadence }).then(() => setCheckpoint(serialized));
46642
- }
46643
- void hostApi().clearProposal();
46644
- void hostApi().logAction(acceptedCount === accepted2.length ? "revision_accepted_all" : acceptedCount === 0 ? "revision_rejected_all" : "revision_hunk_accepted", { accepted: acceptedCount, total: accepted2.length });
46645
- setStatus(`applied agent revision (${acceptedCount}/${accepted2.length} hunks)`);
46890
+ const gen = docGenRef.current;
46891
+ const advance = (attempt = 0) => hostApi().getProposal().then((queued) => {
46892
+ if (docGenRef.current !== gen) return;
46893
+ if (queued != null) showProposal(queued.content, queued.id, queued.baseContent, queued.pending);
46894
+ }).catch(() => {
46895
+ if (docGenRef.current !== gen) return;
46896
+ if (attempt < 1) return new Promise((res) => setTimeout(res, 2e3)).then(() => advance(attempt + 1));
46897
+ setStatus(t2("msg.queueRefreshFailed"));
46898
+ });
46899
+ setSettling(true);
46900
+ hostApi().clearProposal(acceptedCount === accepted2.length ? "accepted" : acceptedCount === 0 ? "rejected" : "partially_accepted", proposal.id).then(
46901
+ () => {
46902
+ if (docGenRef.current !== gen) return;
46903
+ const current = docRef.current;
46904
+ if (current !== prevDoc) {
46905
+ const rebasedBody = merge3(prevDoc.body, finalDoc.body, current.body);
46906
+ const currentIds = new Set(current.comments.map((c) => c.id));
46907
+ const rebasedComments = [...current.comments, ...finalDoc.comments.filter((c) => !currentIds.has(c.id))].map(
46908
+ (c) => !c.parentId && c.anchor !== "doc" && !rebasedBody.includes(`](#${c.id})`) ? { ...c, anchor: "doc" } : c
46909
+ );
46910
+ finalDoc = { body: rebasedBody, comments: rebasedComments };
46911
+ serialized = serialize(finalDoc);
46912
+ }
46913
+ setDoc(finalDoc);
46914
+ docRef.current = finalDoc;
46915
+ setDirty(true);
46916
+ setProposal(null);
46917
+ setReviewOpen(false);
46918
+ void hostApi().logAction(acceptedCount === accepted2.length ? "revision_accepted_all" : acceptedCount === 0 ? "revision_rejected_all" : "revision_hunk_accepted", {
46919
+ accepted: acceptedCount,
46920
+ total: accepted2.length,
46921
+ ...proposal.id ? { proposal_id: proposal.id } : {}
46922
+ }).catch(() => {
46923
+ });
46924
+ const persisted = syncExternalDoc(finalDoc, current.comments, current.body) ? Promise.resolve() : hostApi().save(serialized, { kind: "apply", cadence });
46925
+ return persisted.then(
46926
+ () => {
46927
+ if (docGenRef.current !== gen) return;
46928
+ if (docRef.current === finalDoc) {
46929
+ savedRef.current = serialized;
46930
+ setDirty(false);
46931
+ setCheckpoint(serialized);
46932
+ } else {
46933
+ const cur2 = serialize(docRef.current);
46934
+ if (savedRef.current === cur2) {
46935
+ void hostApi().save(cur2, { kind: "apply", cadence }).catch(() => {
46936
+ });
46937
+ }
46938
+ }
46939
+ return advance().then(() => docGenRef.current === gen && setStatus(t2("msg.appliedRevision", { accepted: acceptedCount, total: accepted2.length })));
46940
+ },
46941
+ () => {
46942
+ if (docGenRef.current !== gen) return;
46943
+ return advance().then(() => docGenRef.current === gen && setStatus(t2("msg.decisionSaveFailed")));
46944
+ }
46945
+ );
46946
+ },
46947
+ () => {
46948
+ if (docGenRef.current !== gen) return;
46949
+ return hostApi().getProposal().then((head) => {
46950
+ if (docGenRef.current !== gen) return;
46951
+ const sameRow = head != null && head.content === proposal.raw && head.baseContent === proposal.base && (proposal.id !== void 0 ? head.id === proposal.id : head.id === void 0);
46952
+ if (sameRow) {
46953
+ setStatus(t2("msg.decisionFailedRetry"));
46954
+ return;
46955
+ }
46956
+ setProposal(null);
46957
+ setReviewOpen(false);
46958
+ if (head != null) showProposal(head.content, head.id, head.baseContent, head.pending);
46959
+ setStatus(t2("msg.decidedElsewhere"));
46960
+ }).catch(() => {
46961
+ if (docGenRef.current === gen) setStatus(t2("msg.decisionUnconfirmed"));
46962
+ });
46963
+ }
46964
+ ).finally(() => setSettling(false));
46646
46965
  },
46647
- [proposal, cadence, editingLocked, syncExternalDoc]
46966
+ [proposal, cadence, editingLocked, syncExternalDoc, showProposal]
46648
46967
  );
46649
46968
  const reviewSegs = reactExports.useMemo(() => proposal ? lineSegments(proposal.baseBody, proposal.next.body) : [], [proposal]);
46650
46969
  const changeCount = reactExports.useMemo(() => reviewSegs.filter(isChange).length, [reviewSegs]);
46651
- const [accepted, setAccepted] = reactExports.useState([]);
46652
- const [edits, setEdits] = reactExports.useState({});
46970
+ const [reviewState, setReviewState] = reactExports.useState(NO_REVIEW);
46971
+ const pristineReview = reactExports.useMemo(
46972
+ () => ({ ...NO_REVIEW, key: proposal, accepted: new Array(changeCount).fill(true) }),
46973
+ [proposal, changeCount]
46974
+ );
46975
+ const { accepted, edits, editingHunk, cursor: reviewCursor } = reviewState.key === proposal ? reviewState : pristineReview;
46976
+ const patchReview = reactExports.useCallback(
46977
+ (patch) => setReviewState((cur2) => ({ ...cur2.key === proposal ? cur2 : pristineReview, ...patch, key: proposal })),
46978
+ [proposal, pristineReview]
46979
+ );
46653
46980
  const editedSegs = reactExports.useMemo(() => {
46654
46981
  let ci2 = -1;
46655
46982
  return reviewSegs.map((s) => {
@@ -46658,76 +46985,71 @@ function App(props = {}) {
46658
46985
  return edits[ci2] ? { ...s, added: edits[ci2] } : s;
46659
46986
  });
46660
46987
  }, [reviewSegs, edits]);
46661
- const reviewHist = reactExports.useRef([]);
46662
- const reviewFuture = reactExports.useRef([]);
46663
- const [editingHunk, setEditingHunk] = reactExports.useState(null);
46988
+ const reviewHist = reactExports.useRef({ key: null, past: [], future: [] });
46989
+ const reviewTimeline = reactExports.useCallback(() => {
46990
+ const h = reviewHist.current;
46991
+ if (h.key !== proposal) {
46992
+ h.key = proposal;
46993
+ h.past = [];
46994
+ h.future = [];
46995
+ }
46996
+ return h;
46997
+ }, [proposal]);
46664
46998
  const [editDraft, setEditDraft] = reactExports.useState("");
46665
- reactExports.useEffect(() => {
46666
- setAccepted(new Array(changeCount).fill(true));
46667
- setEdits({});
46668
- reviewHist.current = [];
46669
- reviewFuture.current = [];
46670
- setEditingHunk(null);
46671
- }, [changeCount, proposal]);
46672
46999
  const commitReview = reactExports.useCallback(
46673
- (nextAccepted, nextEdits) => {
46674
- reviewHist.current.push({ accepted, edits });
46675
- if (reviewHist.current.length > 200) reviewHist.current.shift();
46676
- reviewFuture.current = [];
46677
- setAccepted(nextAccepted);
46678
- setEdits(nextEdits);
47000
+ (nextAccepted, nextEdits, nextEditingHunk = editingHunk) => {
47001
+ const h = reviewTimeline();
47002
+ h.past.push({ accepted, edits });
47003
+ if (h.past.length > 200) h.past.shift();
47004
+ h.future = [];
47005
+ patchReview({ accepted: nextAccepted, edits: nextEdits, editingHunk: nextEditingHunk });
46679
47006
  },
46680
- [accepted, edits]
47007
+ [accepted, edits, editingHunk, patchReview, reviewTimeline]
46681
47008
  );
46682
47009
  const toggleHunk = reactExports.useCallback((idx, val) => commitReview(accepted.map((v2, k2) => k2 === idx ? val : v2), edits), [commitReview, accepted, edits]);
46683
47010
  const setAllAccepted = reactExports.useCallback((val) => commitReview(new Array(changeCount).fill(val), edits), [commitReview, changeCount, edits]);
46684
47011
  const reviewUndo = reactExports.useCallback(() => {
46685
- const prev = reviewHist.current.pop();
47012
+ const h = reviewTimeline();
47013
+ const prev = h.past.pop();
46686
47014
  if (!prev) return;
46687
- reviewFuture.current.push({ accepted, edits });
46688
- setEditingHunk(null);
46689
- setAccepted(prev.accepted);
46690
- setEdits(prev.edits);
47015
+ h.future.push({ accepted, edits });
47016
+ patchReview({ ...prev, editingHunk: null });
46691
47017
  setStatus(t2("msg.undid"));
46692
- }, [accepted, edits]);
47018
+ }, [accepted, edits, patchReview, reviewTimeline]);
46693
47019
  const reviewRedo = reactExports.useCallback(() => {
46694
- const next = reviewFuture.current.pop();
47020
+ const h = reviewTimeline();
47021
+ const next = h.future.pop();
46695
47022
  if (!next) return;
46696
- reviewHist.current.push({ accepted, edits });
46697
- setEditingHunk(null);
46698
- setAccepted(next.accepted);
46699
- setEdits(next.edits);
47023
+ h.past.push({ accepted, edits });
47024
+ patchReview({ ...next, editingHunk: null });
46700
47025
  setStatus(t2("msg.redid"));
46701
- }, [accepted, edits]);
47026
+ }, [accepted, edits, patchReview, reviewTimeline]);
46702
47027
  reviewUndoRef.current = reviewUndo;
46703
47028
  reviewRedoRef.current = reviewRedo;
46704
47029
  const startEditHunk = reactExports.useCallback(
46705
47030
  (idx) => {
46706
47031
  const blocks = editedSegs.filter(isChange);
46707
47032
  setEditDraft((blocks[idx]?.added ?? []).join("\n"));
46708
- setEditingHunk(idx);
47033
+ patchReview({ editingHunk: idx });
46709
47034
  },
46710
- [editedSegs]
47035
+ [editedSegs, patchReview]
46711
47036
  );
46712
47037
  const saveEditHunk = reactExports.useCallback(() => {
46713
47038
  if (editingHunk == null) return;
46714
- commitReview(accepted, { ...edits, [editingHunk]: editDraft.split("\n") });
46715
- setEditingHunk(null);
47039
+ commitReview(accepted, { ...edits, [editingHunk]: editDraft.split("\n") }, null);
46716
47040
  }, [editingHunk, editDraft, commitReview, accepted, edits]);
46717
- const cancelEditHunk = reactExports.useCallback(() => setEditingHunk(null), []);
47041
+ const cancelEditHunk = reactExports.useCallback(() => patchReview({ editingHunk: null }), [patchReview]);
46718
47042
  const applyReview = reactExports.useCallback(() => applyProposal(editedSegs, accepted), [applyProposal, editedSegs, accepted]);
46719
- const [reviewCursor, setReviewCursor] = reactExports.useState(-1);
46720
- reactExports.useEffect(() => setReviewCursor(-1), [proposal]);
46721
47043
  const reviewNext = reactExports.useCallback(() => {
46722
47044
  if (!changeCount) return;
46723
47045
  const n2 = (reviewCursor + 1) % changeCount;
46724
- setReviewCursor(n2);
47046
+ patchReview({ cursor: n2 });
46725
47047
  if (panes === 2 && rightTab !== "source") setRightTab("source");
46726
47048
  requestAnimationFrame(() => {
46727
47049
  previewRef.current?.querySelector(`[data-hunk="${n2}"]`)?.scrollIntoView({ block: "start", behavior: "smooth" });
46728
47050
  document.querySelector(`.ap-diffsource [data-hunk="${n2}"]`)?.scrollIntoView({ block: "start", behavior: "smooth" });
46729
47051
  });
46730
- }, [changeCount, reviewCursor, panes, rightTab]);
47052
+ }, [changeCount, reviewCursor, patchReview, panes, rightTab]);
46731
47053
  const threads = reactExports.useMemo(() => buildThreads(doc2.comments), [doc2.comments]);
46732
47054
  const ordered = reactExports.useMemo(() => {
46733
47055
  const annotate = (thread) => {
@@ -46887,7 +47209,7 @@ function App(props = {}) {
46887
47209
  forceSettingsOpen,
46888
47210
  locked: editingLocked,
46889
47211
  agentThinking,
46890
- nav: typeof hostApi().navigate === "function" ? { canBack: navState.canBack, canForward: navState.canForward, onBack: () => void hostApi().navigate?.("back"), onForward: () => void hostApi().navigate?.("forward") } : void 0
47212
+ nav: typeof hostApi().navigate === "function" ? { canBack: navState.canBack, canForward: navState.canForward, onBack: () => navigateGuarded(() => void hostApi().navigate?.("back")), onForward: () => navigateGuarded(() => void hostApi().navigate?.("forward")) } : void 0
46891
47213
  }
46892
47214
  ),
46893
47215
  findOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -46912,7 +47234,7 @@ function App(props = {}) {
46912
47234
  /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: t2("banner.reloadingIn", { n: reloadIn ?? 0 }) }),
46913
47235
  " ",
46914
47236
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spacer" }),
46915
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-primary", onClick: () => void hostApi().closeWindow(), children: t2("banner.reloadNow") }),
47237
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-primary", onClick: () => void awaitSettled().then(() => hostApi().closeWindow()), children: t2("banner.reloadNow") }),
46916
47238
  /* @__PURE__ */ jsxRuntimeExports.jsx(
46917
47239
  "button",
46918
47240
  {
@@ -46940,7 +47262,9 @@ function App(props = {}) {
46940
47262
  {
46941
47263
  className: "ap-primary",
46942
47264
  onClick: async () => {
46943
- if (dirty) await hostApi().save(serialize(docRef.current), { kind: "apply", cadence });
47265
+ await awaitSettled();
47266
+ const current = serialize(docRef.current);
47267
+ if (current !== savedRef.current) await hostApi().save(current, { kind: "apply", cadence });
46944
47268
  if (hostApi().restartApp) await hostApi().restartApp();
46945
47269
  else await hostApi().closeWindow();
46946
47270
  },
@@ -46979,13 +47303,21 @@ function App(props = {}) {
46979
47303
  ] }) }),
46980
47304
  readOnly2 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-banner ap-banner--readonly", role: "status", children: t2("banner.readOnly") }),
46981
47305
  proposal && !reviewOpen && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-banner", children: [
46982
- t2("banner.proposalPending"),
47306
+ (queueCount ?? 1) > 1 ? t2("banner.proposalQueue", { n: queueCount }) : t2("banner.proposalPending"),
46983
47307
  " ",
46984
47308
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: () => setReviewOpen(true), children: t2("banner.review") })
46985
47309
  ] }),
46986
47310
  proposal && reviewOpen && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-review-bar", children: [
46987
47311
  /* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: t2("banner.proposedChanges") }),
46988
47312
  " ",
47313
+ (queueCount ?? 1) > 1 && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ap-muted", children: [
47314
+ t2("banner.queuePosition", { n: queueCount }),
47315
+ " "
47316
+ ] }),
47317
+ proposal.stale && /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ap-muted", title: t2("banner.staleTitle"), children: [
47318
+ t2("banner.stale"),
47319
+ " "
47320
+ ] }),
46989
47321
  t2(changeCount === 1 ? "banner.changesShown" : "banner.changesShownPlural", { n: changeCount }),
46990
47322
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spacer" }),
46991
47323
  /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { onClick: reviewNext, disabled: !changeCount, title: t2("banner.scrollToNext"), children: [
@@ -47000,7 +47332,7 @@ function App(props = {}) {
47000
47332
  disabled: editingLocked || !changeCount
47001
47333
  }
47002
47334
  ),
47003
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-primary", disabled: editingLocked, onClick: applyReview, children: t2("banner.apply") }),
47335
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-primary", disabled: editingLocked || settling, onClick: applyReview, children: t2("banner.apply") }),
47004
47336
  /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: () => setReviewOpen(false), children: t2("banner.laterLower") }),
47005
47337
  editingLocked && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-muted", children: t2("banner.locked") })
47006
47338
  ] }),
@@ -47162,17 +47494,18 @@ function App(props = {}) {
47162
47494
  onPaste: onPreviewPasteImage,
47163
47495
  onClick: (e) => {
47164
47496
  const target = e.target;
47497
+ const anchor = target.closest("[data-cmt]");
47498
+ if (anchor) {
47499
+ e.preventDefault();
47500
+ focusComment(anchor.getAttribute("data-cmt"), true);
47501
+ return;
47502
+ }
47165
47503
  const a = target.closest("a");
47166
47504
  if (a) {
47167
47505
  e.preventDefault();
47168
- const cmt = a.getAttribute("data-cmt");
47169
- if (cmt) {
47170
- focusComment(cmt, true);
47171
- return;
47172
- }
47173
47506
  const href = a.getAttribute("href") ?? "";
47174
47507
  if (isInternalDocLink(href)) {
47175
- void hostApi().openDoc(resolveDocPath(docPathRef.current, href));
47508
+ navigateGuarded(() => void hostApi().openDoc(resolveDocPath(docPathRef.current, href)));
47176
47509
  return;
47177
47510
  }
47178
47511
  if (/^https?:/.test(href)) window.open(href, "_blank");
@@ -47323,13 +47656,13 @@ function AppRoot() {
47323
47656
  setPhase("real");
47324
47657
  setApiReady(true);
47325
47658
  }, []);
47326
- const replay = reactExports.useCallback(() => {
47659
+ const replay2 = reactExports.useCallback(() => {
47327
47660
  installSample();
47328
47661
  setPhase("onboarding");
47329
47662
  setApiReady(true);
47330
47663
  }, [installSample]);
47331
47664
  if (!apiReady) return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-app" });
47332
- return phase === "onboarding" ? /* @__PURE__ */ jsxRuntimeExports.jsx(App, { onboarding: true, onFinishOnboarding: finish }, "onboarding") : /* @__PURE__ */ jsxRuntimeExports.jsx(App, { onReplayOnboarding: replay }, "real");
47665
+ return phase === "onboarding" ? /* @__PURE__ */ jsxRuntimeExports.jsx(App, { onboarding: true, onFinishOnboarding: finish }, "onboarding") : /* @__PURE__ */ jsxRuntimeExports.jsx(App, { onReplayOnboarding: replay2 }, "real");
47333
47666
  }
47334
47667
  function PaneIcon({ n: n2 }) {
47335
47668
  return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-pane-ic", "aria-hidden": "true", children: Array.from({ length: n2 }, (_, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("i", {}, i)) });