inplan 0.1.30 → 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.
- package/app/main/index.cjs +269 -18
- package/app/preload/index.mjs +1 -1
- package/app/renderer/assets/{index-BsT_GmrR.css → index-Bo--UUib.css} +15 -0
- package/app/renderer/assets/{index-C2B4aV88.js → index-Cv94hl_t.js} +761 -166
- package/app/renderer/index.html +2 -2
- package/bin/cli.js +744 -150
- package/package.json +2 -2
- package/skill/SKILL.md +65 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
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
|
-
|
|
7173
|
-
this.
|
|
7174
|
-
|
|
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);
|
|
@@ -43230,17 +43259,17 @@ function addSpanComment(doc2, selectedText, fields, span) {
|
|
|
43230
43259
|
if (!range) return null;
|
|
43231
43260
|
const id2 = genId(takenIds(doc2));
|
|
43232
43261
|
const body = wrapSpanWithComment(doc2.body, range.start, range.end, id2);
|
|
43233
|
-
const comment2 = { id: id2, author: fields.author, date: nowIso(), resolved: false, text: fields.text, ...fields.question ? { question: fields.question } : {}, ...fields.agent === false ? { agent: false } : {} };
|
|
43262
|
+
const comment2 = { id: id2, author: fields.author, date: nowIso(), resolved: false, text: fields.text, ...fields.question ? { question: fields.question } : {}, ...fields.agent === false ? { agent: false } : {}, ...fields.mentions?.length ? { mentions: fields.mentions } : {} };
|
|
43234
43263
|
return { doc: { body, comments: [...doc2.comments, comment2] }, id: id2 };
|
|
43235
43264
|
}
|
|
43236
43265
|
function addDocComment(doc2, fields) {
|
|
43237
43266
|
const id2 = genId(takenIds(doc2));
|
|
43238
|
-
const comment2 = { id: id2, anchor: "doc", author: fields.author, date: nowIso(), resolved: false, text: fields.text, ...fields.question ? { question: fields.question } : {}, ...fields.agent === false ? { agent: false } : {} };
|
|
43267
|
+
const comment2 = { id: id2, anchor: "doc", author: fields.author, date: nowIso(), resolved: false, text: fields.text, ...fields.question ? { question: fields.question } : {}, ...fields.agent === false ? { agent: false } : {}, ...fields.mentions?.length ? { mentions: fields.mentions } : {} };
|
|
43239
43268
|
return { doc: { ...doc2, comments: [...doc2.comments, comment2] }, id: id2 };
|
|
43240
43269
|
}
|
|
43241
|
-
function addReply(doc2, parentId, text2, author) {
|
|
43270
|
+
function addReply(doc2, parentId, text2, author, mentions) {
|
|
43242
43271
|
const id2 = genId(takenIds(doc2));
|
|
43243
|
-
const comment2 = { id: id2, parentId, author, date: nowIso(), resolved: false, text: text2 };
|
|
43272
|
+
const comment2 = { id: id2, parentId, author, date: nowIso(), resolved: false, text: text2, ...mentions?.length ? { mentions } : {} };
|
|
43244
43273
|
return { doc: { ...doc2, comments: [...doc2.comments, comment2] }, id: id2 };
|
|
43245
43274
|
}
|
|
43246
43275
|
function addAnswer(doc2, parentId, selected, text2, author) {
|
|
@@ -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
|
|
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
|
}
|
|
@@ -43982,6 +44048,203 @@ var IconImage = () => /* @__PURE__ */ jsxRuntimeExports.jsxs(Glyph, { children:
|
|
|
43982
44048
|
/* @__PURE__ */ jsxRuntimeExports.jsx("circle", { cx: "8.5", cy: "8.5", r: "1.5" }),
|
|
43983
44049
|
/* @__PURE__ */ jsxRuntimeExports.jsx("polyline", { points: "21 15 16 10 5 21" })
|
|
43984
44050
|
] });
|
|
44051
|
+
function detectMentionTrigger(value, caret) {
|
|
44052
|
+
if (caret < 0 || caret > value.length) return null;
|
|
44053
|
+
const upTo = value.slice(0, caret);
|
|
44054
|
+
const at = upTo.lastIndexOf("@");
|
|
44055
|
+
if (at === -1) return null;
|
|
44056
|
+
const query = upTo.slice(at + 1);
|
|
44057
|
+
if (/[\s@]/.test(query)) return null;
|
|
44058
|
+
const before = upTo[at - 1];
|
|
44059
|
+
if (before !== void 0 && !/\s/.test(before)) return null;
|
|
44060
|
+
return { start: at, query };
|
|
44061
|
+
}
|
|
44062
|
+
function filterMentionCandidates(users, query) {
|
|
44063
|
+
const q2 = query.toLowerCase();
|
|
44064
|
+
const matches = q2 ? users.filter((u2) => u2.email.toLowerCase().includes(q2) || u2.name?.toLowerCase().includes(q2)) : users;
|
|
44065
|
+
return matches.slice(0, 6);
|
|
44066
|
+
}
|
|
44067
|
+
function escapeRegExp(s) {
|
|
44068
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
44069
|
+
}
|
|
44070
|
+
var sharedRosterCache = null;
|
|
44071
|
+
var sharedRosterPromise = null;
|
|
44072
|
+
var rosterGeneration = 0;
|
|
44073
|
+
function resetMentionRoster() {
|
|
44074
|
+
sharedRosterCache = null;
|
|
44075
|
+
sharedRosterPromise = null;
|
|
44076
|
+
rosterGeneration++;
|
|
44077
|
+
}
|
|
44078
|
+
function loadSharedRoster() {
|
|
44079
|
+
if (sharedRosterCache) return Promise.resolve(sharedRosterCache);
|
|
44080
|
+
if (!sharedRosterPromise) {
|
|
44081
|
+
const generation = rosterGeneration;
|
|
44082
|
+
const list2 = hostApi()?.listMentionableUsers?.();
|
|
44083
|
+
sharedRosterPromise = list2 ? list2.then((u2) => {
|
|
44084
|
+
if (generation === rosterGeneration) sharedRosterCache = u2;
|
|
44085
|
+
return u2;
|
|
44086
|
+
}) : Promise.resolve([]);
|
|
44087
|
+
sharedRosterPromise.catch(() => {
|
|
44088
|
+
if (generation === rosterGeneration) sharedRosterPromise = null;
|
|
44089
|
+
});
|
|
44090
|
+
}
|
|
44091
|
+
return sharedRosterPromise;
|
|
44092
|
+
}
|
|
44093
|
+
function useMentionAutocomplete(taRef, text2, setText) {
|
|
44094
|
+
const [users, setUsers] = reactExports.useState(sharedRosterCache);
|
|
44095
|
+
const [open, setOpen] = reactExports.useState(false);
|
|
44096
|
+
const [query, setQuery] = reactExports.useState("");
|
|
44097
|
+
const [activeIndex, setActiveIndex] = reactExports.useState(0);
|
|
44098
|
+
const mentionsRef = reactExports.useRef(/* @__PURE__ */ new Set());
|
|
44099
|
+
const pendingCaretRef = reactExports.useRef(null);
|
|
44100
|
+
const requestedRosterRef = reactExports.useRef(false);
|
|
44101
|
+
const listboxId = reactExports.useId();
|
|
44102
|
+
reactExports.useEffect(() => {
|
|
44103
|
+
if (pendingCaretRef.current == null) return;
|
|
44104
|
+
const caret = pendingCaretRef.current;
|
|
44105
|
+
pendingCaretRef.current = null;
|
|
44106
|
+
taRef.current?.setSelectionRange(caret, caret);
|
|
44107
|
+
}, [text2, taRef]);
|
|
44108
|
+
const candidates = open && users && users.length ? filterMentionCandidates(users, query) : [];
|
|
44109
|
+
const isOpen = open && candidates.length > 0;
|
|
44110
|
+
const sync = reactExports.useCallback(() => {
|
|
44111
|
+
const el2 = taRef.current;
|
|
44112
|
+
if (!el2) {
|
|
44113
|
+
setOpen(false);
|
|
44114
|
+
return;
|
|
44115
|
+
}
|
|
44116
|
+
const trigger = detectMentionTrigger(el2.value, el2.selectionStart ?? el2.value.length);
|
|
44117
|
+
if (!trigger) {
|
|
44118
|
+
setOpen(false);
|
|
44119
|
+
return;
|
|
44120
|
+
}
|
|
44121
|
+
if (users == null) {
|
|
44122
|
+
setOpen(false);
|
|
44123
|
+
if (!requestedRosterRef.current) {
|
|
44124
|
+
requestedRosterRef.current = true;
|
|
44125
|
+
void loadSharedRoster().then(
|
|
44126
|
+
(u2) => setUsers((prev) => prev ?? u2),
|
|
44127
|
+
() => {
|
|
44128
|
+
requestedRosterRef.current = false;
|
|
44129
|
+
}
|
|
44130
|
+
);
|
|
44131
|
+
}
|
|
44132
|
+
return;
|
|
44133
|
+
}
|
|
44134
|
+
if (!users.length) {
|
|
44135
|
+
setOpen(false);
|
|
44136
|
+
return;
|
|
44137
|
+
}
|
|
44138
|
+
setQuery(trigger.query);
|
|
44139
|
+
setActiveIndex(0);
|
|
44140
|
+
setOpen(true);
|
|
44141
|
+
}, [users, taRef]);
|
|
44142
|
+
reactExports.useEffect(() => {
|
|
44143
|
+
if (users) sync();
|
|
44144
|
+
}, [users, sync]);
|
|
44145
|
+
const pick = reactExports.useCallback(
|
|
44146
|
+
(c) => {
|
|
44147
|
+
const el2 = taRef.current;
|
|
44148
|
+
if (!el2) return;
|
|
44149
|
+
const caret = el2.selectionStart ?? el2.value.length;
|
|
44150
|
+
const trigger = detectMentionTrigger(el2.value, caret);
|
|
44151
|
+
if (!trigger) return;
|
|
44152
|
+
const before = el2.value.slice(0, trigger.start);
|
|
44153
|
+
const after = el2.value.slice(caret);
|
|
44154
|
+
const inserted = `@${c.email} `;
|
|
44155
|
+
mentionsRef.current.add(c.email);
|
|
44156
|
+
pendingCaretRef.current = before.length + inserted.length;
|
|
44157
|
+
setText(before + inserted + after);
|
|
44158
|
+
setOpen(false);
|
|
44159
|
+
el2.focus();
|
|
44160
|
+
},
|
|
44161
|
+
[taRef, setText]
|
|
44162
|
+
);
|
|
44163
|
+
const onKeyDown = reactExports.useCallback(
|
|
44164
|
+
(e) => {
|
|
44165
|
+
if (!isOpen) return false;
|
|
44166
|
+
if (e.key === "ArrowDown") {
|
|
44167
|
+
e.preventDefault();
|
|
44168
|
+
setActiveIndex((i) => (i + 1) % candidates.length);
|
|
44169
|
+
return true;
|
|
44170
|
+
}
|
|
44171
|
+
if (e.key === "ArrowUp") {
|
|
44172
|
+
e.preventDefault();
|
|
44173
|
+
setActiveIndex((i) => (i - 1 + candidates.length) % candidates.length);
|
|
44174
|
+
return true;
|
|
44175
|
+
}
|
|
44176
|
+
if (e.key === "Escape") {
|
|
44177
|
+
e.preventDefault();
|
|
44178
|
+
setOpen(false);
|
|
44179
|
+
return true;
|
|
44180
|
+
}
|
|
44181
|
+
if (e.key === "Tab" || e.key === "Enter" && !e.metaKey && !e.ctrlKey) {
|
|
44182
|
+
e.preventDefault();
|
|
44183
|
+
const c = candidates[activeIndex];
|
|
44184
|
+
if (c) pick(c);
|
|
44185
|
+
return true;
|
|
44186
|
+
}
|
|
44187
|
+
return false;
|
|
44188
|
+
},
|
|
44189
|
+
[isOpen, candidates, activeIndex, pick]
|
|
44190
|
+
);
|
|
44191
|
+
const activeMentions = reactExports.useCallback((currentText) => {
|
|
44192
|
+
return Array.from(mentionsRef.current).filter((email) => new RegExp(`(?:^|\\s)@${escapeRegExp(email)}(?=$|\\s|[.,;:!?)\\]])`).test(currentText));
|
|
44193
|
+
}, []);
|
|
44194
|
+
const reset = reactExports.useCallback(() => {
|
|
44195
|
+
mentionsRef.current.clear();
|
|
44196
|
+
setOpen(false);
|
|
44197
|
+
}, []);
|
|
44198
|
+
const optionId = reactExports.useCallback((index) => `${listboxId}-opt-${index}`, [listboxId]);
|
|
44199
|
+
return {
|
|
44200
|
+
/** A trigger word is active. Prefer {@link isOpen} for anything UI-visible (aria-expanded,
|
|
44201
|
+
* aria-controls) — `open` can be true with zero matches (e.g. "@zzz"). */
|
|
44202
|
+
open,
|
|
44203
|
+
/** The dropdown is actually visibly showing candidates. */
|
|
44204
|
+
isOpen,
|
|
44205
|
+
candidates,
|
|
44206
|
+
activeIndex,
|
|
44207
|
+
sync,
|
|
44208
|
+
pick,
|
|
44209
|
+
onKeyDown,
|
|
44210
|
+
activeMentions,
|
|
44211
|
+
reset,
|
|
44212
|
+
setActiveIndex,
|
|
44213
|
+
listboxId,
|
|
44214
|
+
optionId,
|
|
44215
|
+
activeDescendantId: isOpen && candidates[activeIndex] ? optionId(activeIndex) : void 0
|
|
44216
|
+
};
|
|
44217
|
+
}
|
|
44218
|
+
function MentionDropdown({
|
|
44219
|
+
candidates,
|
|
44220
|
+
activeIndex,
|
|
44221
|
+
onPick,
|
|
44222
|
+
onHover,
|
|
44223
|
+
listboxId,
|
|
44224
|
+
optionId
|
|
44225
|
+
}) {
|
|
44226
|
+
if (candidates.length === 0) return null;
|
|
44227
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-mention-dropdown", role: "listbox", id: listboxId, children: candidates.map((c, i) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
44228
|
+
"button",
|
|
44229
|
+
{
|
|
44230
|
+
id: optionId(i),
|
|
44231
|
+
type: "button",
|
|
44232
|
+
role: "option",
|
|
44233
|
+
"aria-selected": i === activeIndex,
|
|
44234
|
+
className: `ap-mention-item${i === activeIndex ? " active" : ""}`,
|
|
44235
|
+
onMouseEnter: () => onHover(i),
|
|
44236
|
+
onMouseDown: (e) => {
|
|
44237
|
+
e.preventDefault();
|
|
44238
|
+
onPick(c);
|
|
44239
|
+
},
|
|
44240
|
+
children: [
|
|
44241
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-mention-email", children: c.email }),
|
|
44242
|
+
c.name && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-mention-name", children: c.name })
|
|
44243
|
+
]
|
|
44244
|
+
},
|
|
44245
|
+
c.email
|
|
44246
|
+
)) });
|
|
44247
|
+
}
|
|
43985
44248
|
function ComposerPopover({
|
|
43986
44249
|
target,
|
|
43987
44250
|
pos,
|
|
@@ -43996,6 +44259,7 @@ function ComposerPopover({
|
|
|
43996
44259
|
const box = reactExports.useRef(null);
|
|
43997
44260
|
const ta2 = reactExports.useRef(null);
|
|
43998
44261
|
const drag = reactExports.useRef(null);
|
|
44262
|
+
const mention = useMentionAutocomplete(ta2, text2, setText);
|
|
43999
44263
|
reactExports.useEffect(() => {
|
|
44000
44264
|
ta2.current?.focus();
|
|
44001
44265
|
}, []);
|
|
@@ -44025,33 +44289,54 @@ function ComposerPopover({
|
|
|
44025
44289
|
el2.style.height = `${Math.min(el2.scrollHeight, 8 * 22)}px`;
|
|
44026
44290
|
};
|
|
44027
44291
|
const submit = () => {
|
|
44028
|
-
if (text2.trim()) onSubmit(text2.trim(), talkToAgent);
|
|
44292
|
+
if (text2.trim()) onSubmit(text2.trim(), talkToAgent, mention.activeMentions(text2));
|
|
44029
44293
|
};
|
|
44030
44294
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-composer ap-composer-float", ref: box, style: { left: p2.x, top: p2.y, right: "auto" }, children: [
|
|
44031
44295
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-composer-head", onMouseDown: (e) => drag.current = { dx: e.clientX - p2.x, dy: e.clientY - p2.y }, children: [
|
|
44032
44296
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-quote", children: target ? t2("composer.on", { target }) : t2("composer.docLevel") }),
|
|
44033
44297
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-drag", title: t2("composer.dragToMove"), children: "⠿" })
|
|
44034
44298
|
] }),
|
|
44035
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
44036
|
-
|
|
44037
|
-
|
|
44038
|
-
|
|
44039
|
-
|
|
44040
|
-
|
|
44041
|
-
|
|
44042
|
-
|
|
44043
|
-
|
|
44044
|
-
|
|
44045
|
-
|
|
44046
|
-
|
|
44047
|
-
|
|
44048
|
-
|
|
44049
|
-
|
|
44050
|
-
|
|
44299
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { position: "relative" }, children: [
|
|
44300
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
44301
|
+
"textarea",
|
|
44302
|
+
{
|
|
44303
|
+
ref: ta2,
|
|
44304
|
+
className: "ap-grow",
|
|
44305
|
+
placeholder: t2("composer.placeholder", { mod: MOD_KEY }),
|
|
44306
|
+
value: text2,
|
|
44307
|
+
disabled,
|
|
44308
|
+
role: "combobox",
|
|
44309
|
+
"aria-expanded": mention.isOpen,
|
|
44310
|
+
"aria-controls": mention.isOpen ? mention.listboxId : void 0,
|
|
44311
|
+
"aria-autocomplete": "list",
|
|
44312
|
+
"aria-activedescendant": mention.activeDescendantId,
|
|
44313
|
+
onChange: (e) => {
|
|
44314
|
+
setText(e.target.value);
|
|
44315
|
+
grow(e.target);
|
|
44316
|
+
mention.sync();
|
|
44317
|
+
},
|
|
44318
|
+
onSelect: () => mention.sync(),
|
|
44319
|
+
onKeyDown: (e) => {
|
|
44320
|
+
if (mention.onKeyDown(e)) return;
|
|
44321
|
+
if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
|
|
44322
|
+
e.preventDefault();
|
|
44323
|
+
submit();
|
|
44324
|
+
}
|
|
44051
44325
|
}
|
|
44052
44326
|
}
|
|
44053
|
-
|
|
44054
|
-
|
|
44327
|
+
),
|
|
44328
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
44329
|
+
MentionDropdown,
|
|
44330
|
+
{
|
|
44331
|
+
candidates: mention.candidates,
|
|
44332
|
+
activeIndex: mention.activeIndex,
|
|
44333
|
+
onPick: mention.pick,
|
|
44334
|
+
onHover: mention.setActiveIndex,
|
|
44335
|
+
listboxId: mention.listboxId,
|
|
44336
|
+
optionId: mention.optionId
|
|
44337
|
+
}
|
|
44338
|
+
)
|
|
44339
|
+
] }),
|
|
44055
44340
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-row", children: [
|
|
44056
44341
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "ap-agent-toggle", role: "radiogroup", "aria-label": t2("composer.audience"), children: [
|
|
44057
44342
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -45315,6 +45600,19 @@ Select any line above, then press the comment shortcut to leave a note on it.
|
|
|
45315
45600
|
]
|
|
45316
45601
|
-->
|
|
45317
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
|
+
}
|
|
45318
45616
|
function createMemoryApi(opts) {
|
|
45319
45617
|
const store = new MemoryDocumentStore(opts.content);
|
|
45320
45618
|
const channel = new MemoryControlChannel();
|
|
@@ -45395,10 +45693,14 @@ function createMemoryApi(opts) {
|
|
|
45395
45693
|
closed = true;
|
|
45396
45694
|
},
|
|
45397
45695
|
async getProposal() {
|
|
45398
|
-
|
|
45696
|
+
const mine = await store.myPendingProposal();
|
|
45697
|
+
return mine ? { id: mine.id, content: mine.content, baseContent: mine.baseContent, pending: 1 } : null;
|
|
45399
45698
|
},
|
|
45400
|
-
async clearProposal() {
|
|
45401
|
-
await store.
|
|
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`);
|
|
45402
45704
|
},
|
|
45403
45705
|
async openDoc() {
|
|
45404
45706
|
}
|
|
@@ -45411,9 +45713,12 @@ function createMemoryApi(opts) {
|
|
|
45411
45713
|
for (const cb2 of external) cb2({ path: "memory://doc", content: content2 });
|
|
45412
45714
|
},
|
|
45413
45715
|
proposeRevision(content2) {
|
|
45414
|
-
|
|
45415
|
-
|
|
45416
|
-
|
|
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
|
+
})();
|
|
45417
45722
|
},
|
|
45418
45723
|
markActive() {
|
|
45419
45724
|
void channel.append({ actor: "agent", type: LogEventType.AgentRevised });
|
|
@@ -45544,6 +45849,105 @@ function applySegments(segs, accepted) {
|
|
|
45544
45849
|
}
|
|
45545
45850
|
return out.join("\n");
|
|
45546
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
|
+
}
|
|
45547
45951
|
var USER_AUTHOR = "You";
|
|
45548
45952
|
var EMPTY = { body: "", comments: [] };
|
|
45549
45953
|
var IMAGE_EXT_BY_MIME = {
|
|
@@ -45612,6 +46016,7 @@ function commentBlockReason(raw, body, range, root) {
|
|
|
45612
46016
|
if (b === "not-found") return anchorFailureReason(range);
|
|
45613
46017
|
return null;
|
|
45614
46018
|
}
|
|
46019
|
+
var NO_REVIEW = { key: null, accepted: [], edits: {}, editingHunk: null, cursor: -1 };
|
|
45615
46020
|
function CloudSignInOverlay({ url, onDismiss }) {
|
|
45616
46021
|
reactExports.useEffect(() => {
|
|
45617
46022
|
const onKey = (e) => {
|
|
@@ -45688,6 +46093,8 @@ function App(props = {}) {
|
|
|
45688
46093
|
const [activePreviewLine, setActivePreviewLine] = reactExports.useState(null);
|
|
45689
46094
|
const [proposal, setProposal] = reactExports.useState(null);
|
|
45690
46095
|
const [reviewOpen, setReviewOpen] = reactExports.useState(false);
|
|
46096
|
+
const [settling, setSettling] = reactExports.useState(false);
|
|
46097
|
+
const [queueCount, setQueueCount] = reactExports.useState(void 0);
|
|
45691
46098
|
const [findOpen, setFindOpen] = reactExports.useState(false);
|
|
45692
46099
|
const [findOpts, setFindOpts] = reactExports.useState({ query: "", ci: false, inPreview: true, inEditor: false, inComments: false });
|
|
45693
46100
|
const [openPanel, setOpenPanel] = reactExports.useState(null);
|
|
@@ -45695,6 +46102,27 @@ function App(props = {}) {
|
|
|
45695
46102
|
const [closingPanel, setClosingPanel] = reactExports.useState(null);
|
|
45696
46103
|
const lastOpenPanelRef = reactExports.useRef(null);
|
|
45697
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);
|
|
45698
46126
|
docRef.current = doc2;
|
|
45699
46127
|
const previewRef = reactExports.useRef(null);
|
|
45700
46128
|
const ctxBlockRef = reactExports.useRef(null);
|
|
@@ -45705,6 +46133,7 @@ function App(props = {}) {
|
|
|
45705
46133
|
const docPathRef = reactExports.useRef("");
|
|
45706
46134
|
const railRef = reactExports.useRef(null);
|
|
45707
46135
|
const editorRef = reactExports.useRef(null);
|
|
46136
|
+
const [pendingFocusCommentId, setPendingFocusCommentId] = reactExports.useState(null);
|
|
45708
46137
|
const autosaveTimer = reactExports.useRef(null);
|
|
45709
46138
|
const history2 = reactExports.useRef([]);
|
|
45710
46139
|
const future = reactExports.useRef([]);
|
|
@@ -45726,24 +46155,69 @@ function App(props = {}) {
|
|
|
45726
46155
|
setAcceptance(s.acceptance === "auto" ? "auto" : "review");
|
|
45727
46156
|
});
|
|
45728
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
|
+
}, []);
|
|
45729
46176
|
reactExports.useEffect(() => {
|
|
45730
|
-
const showProposal = (content2) => {
|
|
45731
|
-
setProposal({ baseBody: docRef.current.body, next: parse(content2) });
|
|
45732
|
-
setReviewOpen(true);
|
|
45733
|
-
setAgentThinking(false);
|
|
45734
|
-
setStatus(t2("msg.proposedReview"));
|
|
45735
|
-
};
|
|
45736
46177
|
const commentStore = hostApi().commentStore ?? null;
|
|
45737
|
-
|
|
46178
|
+
const loadGen = docGenRef.current;
|
|
46179
|
+
hostApi().load().then(({ content: content2, path, readOnly: ro, focusCommentId }) => {
|
|
46180
|
+
if (docGenRef.current !== loadGen) return;
|
|
45738
46181
|
docPathRef.current = path;
|
|
45739
46182
|
setReadOnly(!!ro);
|
|
46183
|
+
setPendingFocusCommentId(focusCommentId ?? null);
|
|
45740
46184
|
const parsed = parse(content2);
|
|
45741
46185
|
const d = commentStore ? { ...parsed, comments: commentStore.list() } : parsed;
|
|
45742
46186
|
setDoc(d);
|
|
46187
|
+
docRef.current = d;
|
|
45743
46188
|
savedRef.current = serialize(d);
|
|
45744
46189
|
setLoaded(true);
|
|
45745
|
-
|
|
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
|
+
});
|
|
45746
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;
|
|
45747
46221
|
const subs = [
|
|
45748
46222
|
hostApi().onExternalChange(({ content: content2 }) => {
|
|
45749
46223
|
const prevDoc = docRef.current;
|
|
@@ -45754,10 +46228,23 @@ function App(props = {}) {
|
|
|
45754
46228
|
savedRef.current = serialize(next);
|
|
45755
46229
|
setDirty(false);
|
|
45756
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
|
+
}
|
|
45757
46236
|
setStatus(t2("msg.agentUpdated"));
|
|
45758
46237
|
}),
|
|
45759
46238
|
// Review-mode body changes arrive parked, as a proposal to accept/reject.
|
|
45760
|
-
hostApi().onProposal(({ content: 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
|
+
}),
|
|
45761
46248
|
hostApi().onAgentDone(() => setAgentDone(true)),
|
|
45762
46249
|
hostApi().onReload(() => {
|
|
45763
46250
|
setReloadReady(true);
|
|
@@ -45772,26 +46259,12 @@ function App(props = {}) {
|
|
|
45772
46259
|
hostApi().onAgentMessage?.((msg) => setAgentMessages((prev) => [...prev, msg])),
|
|
45773
46260
|
// Desktop only: the window followed a link to another doc — reset to it (a fresh
|
|
45774
46261
|
// load), clearing any in-flight proposal/turn state, then re-show a parked proposal.
|
|
45775
|
-
hostApi().onNavigated?.((
|
|
45776
|
-
if (
|
|
45777
|
-
|
|
45778
|
-
|
|
45779
|
-
|
|
45780
|
-
|
|
45781
|
-
setDoc(d);
|
|
45782
|
-
savedRef.current = serialize(d);
|
|
45783
|
-
setDirty(false);
|
|
45784
|
-
const restored = historyByDoc.current.get(path);
|
|
45785
|
-
history2.current = restored?.undo ?? [];
|
|
45786
|
-
future.current = restored?.redo ?? [];
|
|
45787
|
-
setProposal(null);
|
|
45788
|
-
setReviewOpen(false);
|
|
45789
|
-
setAgentThinking(false);
|
|
45790
|
-
setAgentDone(false);
|
|
45791
|
-
setAgentMessages([]);
|
|
45792
|
-
setActivePreviewLine(null);
|
|
45793
|
-
setStatus(`opened ${path.split("/").pop() ?? path}`);
|
|
45794
|
-
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);
|
|
45795
46268
|
}),
|
|
45796
46269
|
hostApi().onNavState?.((s) => setNavState(s)),
|
|
45797
46270
|
// Desktop only: a newer npm version is available.
|
|
@@ -45810,10 +46283,17 @@ function App(props = {}) {
|
|
|
45810
46283
|
for (const dispose of subs) dispose?.();
|
|
45811
46284
|
};
|
|
45812
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]);
|
|
45813
46293
|
reactExports.useEffect(() => {
|
|
45814
46294
|
if (reloadIn === null) return;
|
|
45815
46295
|
if (reloadIn <= 0) {
|
|
45816
|
-
void hostApi().closeWindow();
|
|
46296
|
+
void awaitSettled().then(() => hostApi().closeWindow());
|
|
45817
46297
|
return;
|
|
45818
46298
|
}
|
|
45819
46299
|
const timer = setTimeout(() => setReloadIn((s) => s === null ? null : s - 1), 1e3);
|
|
@@ -46124,7 +46604,7 @@ function App(props = {}) {
|
|
|
46124
46604
|
);
|
|
46125
46605
|
const [forceSettingsOpen, setForceSettingsOpen] = reactExports.useState(false);
|
|
46126
46606
|
const confirmQuit = reactExports.useCallback((opts) => {
|
|
46127
|
-
realHostApi().exit?.quit(serialize(docRef.current), opts);
|
|
46607
|
+
void awaitSettled().then(() => realHostApi().exit?.quit(serialize(docRef.current), opts));
|
|
46128
46608
|
setQuitOpen(false);
|
|
46129
46609
|
}, []);
|
|
46130
46610
|
reactExports.useEffect(() => {
|
|
@@ -46135,7 +46615,7 @@ function App(props = {}) {
|
|
|
46135
46615
|
});
|
|
46136
46616
|
}, [props.onboarding]);
|
|
46137
46617
|
const addComment = reactExports.useCallback(
|
|
46138
|
-
(text2, target, span, question2, talkToAgent = true) => {
|
|
46618
|
+
(text2, target, span, question2, talkToAgent = true, mentions = []) => {
|
|
46139
46619
|
const agent = talkToAgent ? void 0 : false;
|
|
46140
46620
|
const memoPayload = talkToAgent ? {} : { agent: false };
|
|
46141
46621
|
if (target) {
|
|
@@ -46144,7 +46624,7 @@ function App(props = {}) {
|
|
|
46144
46624
|
setStatus(blocker === "overlap" ? t2("topbar.cantOverlap") : t2("msg.cantAnchor"));
|
|
46145
46625
|
return;
|
|
46146
46626
|
}
|
|
46147
|
-
const res = addSpanComment(docRef.current, target, { text: text2, author: userAuthorRef.current, question: question2, agent }, span ?? void 0);
|
|
46627
|
+
const res = addSpanComment(docRef.current, target, { text: text2, author: userAuthorRef.current, question: question2, agent, mentions }, span ?? void 0);
|
|
46148
46628
|
if (!res) {
|
|
46149
46629
|
setStatus(t2("msg.cantAnchor"));
|
|
46150
46630
|
return;
|
|
@@ -46153,7 +46633,7 @@ function App(props = {}) {
|
|
|
46153
46633
|
hostApi().telemetry?.("comment_created", { kind: "span" });
|
|
46154
46634
|
setFocused(res.id);
|
|
46155
46635
|
} else {
|
|
46156
|
-
const res = addDocComment(docRef.current, { text: text2, author: userAuthorRef.current, question: question2, agent });
|
|
46636
|
+
const res = addDocComment(docRef.current, { text: text2, author: userAuthorRef.current, question: question2, agent, mentions });
|
|
46157
46637
|
apply(res.doc, { type: "comment_created", payload: { id: res.id, anchor: "doc", ...memoPayload } });
|
|
46158
46638
|
hostApi().telemetry?.("comment_created", { kind: "doc" });
|
|
46159
46639
|
setFocused(res.id);
|
|
@@ -46404,29 +46884,99 @@ function App(props = {}) {
|
|
|
46404
46884
|
const have = new Set(live.map((c) => c.id));
|
|
46405
46885
|
const merged = [...live, ...proposal.next.comments.filter((c) => !have.has(c.id))];
|
|
46406
46886
|
const comments = merged.map((c) => !c.parentId && c.anchor !== "doc" && !body.includes(`](#${c.id})`) ? { ...c, anchor: "doc" } : c);
|
|
46407
|
-
|
|
46408
|
-
|
|
46409
|
-
setProposal(null);
|
|
46410
|
-
setReviewOpen(false);
|
|
46411
|
-
const serialized = serialize(finalDoc);
|
|
46412
|
-
savedRef.current = serialized;
|
|
46413
|
-
setDirty(false);
|
|
46887
|
+
let finalDoc = { body, comments };
|
|
46888
|
+
let serialized = serialize(finalDoc);
|
|
46414
46889
|
const acceptedCount = accepted2.filter(Boolean).length;
|
|
46415
|
-
|
|
46416
|
-
|
|
46417
|
-
|
|
46418
|
-
|
|
46419
|
-
}
|
|
46420
|
-
|
|
46421
|
-
|
|
46422
|
-
|
|
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));
|
|
46423
46965
|
},
|
|
46424
|
-
[proposal, cadence, editingLocked, syncExternalDoc]
|
|
46966
|
+
[proposal, cadence, editingLocked, syncExternalDoc, showProposal]
|
|
46425
46967
|
);
|
|
46426
46968
|
const reviewSegs = reactExports.useMemo(() => proposal ? lineSegments(proposal.baseBody, proposal.next.body) : [], [proposal]);
|
|
46427
46969
|
const changeCount = reactExports.useMemo(() => reviewSegs.filter(isChange).length, [reviewSegs]);
|
|
46428
|
-
const [
|
|
46429
|
-
const
|
|
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
|
+
);
|
|
46430
46980
|
const editedSegs = reactExports.useMemo(() => {
|
|
46431
46981
|
let ci2 = -1;
|
|
46432
46982
|
return reviewSegs.map((s) => {
|
|
@@ -46435,76 +46985,71 @@ function App(props = {}) {
|
|
|
46435
46985
|
return edits[ci2] ? { ...s, added: edits[ci2] } : s;
|
|
46436
46986
|
});
|
|
46437
46987
|
}, [reviewSegs, edits]);
|
|
46438
|
-
const reviewHist = reactExports.useRef([]);
|
|
46439
|
-
const
|
|
46440
|
-
|
|
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]);
|
|
46441
46998
|
const [editDraft, setEditDraft] = reactExports.useState("");
|
|
46442
|
-
reactExports.useEffect(() => {
|
|
46443
|
-
setAccepted(new Array(changeCount).fill(true));
|
|
46444
|
-
setEdits({});
|
|
46445
|
-
reviewHist.current = [];
|
|
46446
|
-
reviewFuture.current = [];
|
|
46447
|
-
setEditingHunk(null);
|
|
46448
|
-
}, [changeCount, proposal]);
|
|
46449
46999
|
const commitReview = reactExports.useCallback(
|
|
46450
|
-
(nextAccepted, nextEdits) => {
|
|
46451
|
-
|
|
46452
|
-
|
|
46453
|
-
|
|
46454
|
-
|
|
46455
|
-
|
|
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 });
|
|
46456
47006
|
},
|
|
46457
|
-
[accepted, edits]
|
|
47007
|
+
[accepted, edits, editingHunk, patchReview, reviewTimeline]
|
|
46458
47008
|
);
|
|
46459
47009
|
const toggleHunk = reactExports.useCallback((idx, val) => commitReview(accepted.map((v2, k2) => k2 === idx ? val : v2), edits), [commitReview, accepted, edits]);
|
|
46460
47010
|
const setAllAccepted = reactExports.useCallback((val) => commitReview(new Array(changeCount).fill(val), edits), [commitReview, changeCount, edits]);
|
|
46461
47011
|
const reviewUndo = reactExports.useCallback(() => {
|
|
46462
|
-
const
|
|
47012
|
+
const h = reviewTimeline();
|
|
47013
|
+
const prev = h.past.pop();
|
|
46463
47014
|
if (!prev) return;
|
|
46464
|
-
|
|
46465
|
-
|
|
46466
|
-
setAccepted(prev.accepted);
|
|
46467
|
-
setEdits(prev.edits);
|
|
47015
|
+
h.future.push({ accepted, edits });
|
|
47016
|
+
patchReview({ ...prev, editingHunk: null });
|
|
46468
47017
|
setStatus(t2("msg.undid"));
|
|
46469
|
-
}, [accepted, edits]);
|
|
47018
|
+
}, [accepted, edits, patchReview, reviewTimeline]);
|
|
46470
47019
|
const reviewRedo = reactExports.useCallback(() => {
|
|
46471
|
-
const
|
|
47020
|
+
const h = reviewTimeline();
|
|
47021
|
+
const next = h.future.pop();
|
|
46472
47022
|
if (!next) return;
|
|
46473
|
-
|
|
46474
|
-
|
|
46475
|
-
setAccepted(next.accepted);
|
|
46476
|
-
setEdits(next.edits);
|
|
47023
|
+
h.past.push({ accepted, edits });
|
|
47024
|
+
patchReview({ ...next, editingHunk: null });
|
|
46477
47025
|
setStatus(t2("msg.redid"));
|
|
46478
|
-
}, [accepted, edits]);
|
|
47026
|
+
}, [accepted, edits, patchReview, reviewTimeline]);
|
|
46479
47027
|
reviewUndoRef.current = reviewUndo;
|
|
46480
47028
|
reviewRedoRef.current = reviewRedo;
|
|
46481
47029
|
const startEditHunk = reactExports.useCallback(
|
|
46482
47030
|
(idx) => {
|
|
46483
47031
|
const blocks = editedSegs.filter(isChange);
|
|
46484
47032
|
setEditDraft((blocks[idx]?.added ?? []).join("\n"));
|
|
46485
|
-
|
|
47033
|
+
patchReview({ editingHunk: idx });
|
|
46486
47034
|
},
|
|
46487
|
-
[editedSegs]
|
|
47035
|
+
[editedSegs, patchReview]
|
|
46488
47036
|
);
|
|
46489
47037
|
const saveEditHunk = reactExports.useCallback(() => {
|
|
46490
47038
|
if (editingHunk == null) return;
|
|
46491
|
-
commitReview(accepted, { ...edits, [editingHunk]: editDraft.split("\n") });
|
|
46492
|
-
setEditingHunk(null);
|
|
47039
|
+
commitReview(accepted, { ...edits, [editingHunk]: editDraft.split("\n") }, null);
|
|
46493
47040
|
}, [editingHunk, editDraft, commitReview, accepted, edits]);
|
|
46494
|
-
const cancelEditHunk = reactExports.useCallback(() =>
|
|
47041
|
+
const cancelEditHunk = reactExports.useCallback(() => patchReview({ editingHunk: null }), [patchReview]);
|
|
46495
47042
|
const applyReview = reactExports.useCallback(() => applyProposal(editedSegs, accepted), [applyProposal, editedSegs, accepted]);
|
|
46496
|
-
const [reviewCursor, setReviewCursor] = reactExports.useState(-1);
|
|
46497
|
-
reactExports.useEffect(() => setReviewCursor(-1), [proposal]);
|
|
46498
47043
|
const reviewNext = reactExports.useCallback(() => {
|
|
46499
47044
|
if (!changeCount) return;
|
|
46500
47045
|
const n2 = (reviewCursor + 1) % changeCount;
|
|
46501
|
-
|
|
47046
|
+
patchReview({ cursor: n2 });
|
|
46502
47047
|
if (panes === 2 && rightTab !== "source") setRightTab("source");
|
|
46503
47048
|
requestAnimationFrame(() => {
|
|
46504
47049
|
previewRef.current?.querySelector(`[data-hunk="${n2}"]`)?.scrollIntoView({ block: "start", behavior: "smooth" });
|
|
46505
47050
|
document.querySelector(`.ap-diffsource [data-hunk="${n2}"]`)?.scrollIntoView({ block: "start", behavior: "smooth" });
|
|
46506
47051
|
});
|
|
46507
|
-
}, [changeCount, reviewCursor, panes, rightTab]);
|
|
47052
|
+
}, [changeCount, reviewCursor, patchReview, panes, rightTab]);
|
|
46508
47053
|
const threads = reactExports.useMemo(() => buildThreads(doc2.comments), [doc2.comments]);
|
|
46509
47054
|
const ordered = reactExports.useMemo(() => {
|
|
46510
47055
|
const annotate = (thread) => {
|
|
@@ -46517,6 +47062,16 @@ function App(props = {}) {
|
|
|
46517
47062
|
const visible = ordered.filter((o) => showResolvedOrphaned || !o.thread.root.resolved && !o.orphaned);
|
|
46518
47063
|
const resolvedCount = ordered.filter((o) => o.thread.root.resolved).length;
|
|
46519
47064
|
const orphanedCount = ordered.filter((o) => o.orphaned).length;
|
|
47065
|
+
reactExports.useEffect(() => {
|
|
47066
|
+
if (!loaded || !pendingFocusCommentId) return;
|
|
47067
|
+
const id2 = pendingFocusCommentId;
|
|
47068
|
+
setPendingFocusCommentId(null);
|
|
47069
|
+
const c = doc2.comments.find((x2) => x2.id === id2);
|
|
47070
|
+
const rootId = c?.parentId ?? id2;
|
|
47071
|
+
if (!visible.some((o) => o.thread.root.id === rootId)) setShowResolvedOrphaned(true);
|
|
47072
|
+
const raf = requestAnimationFrame(() => focusComment(id2));
|
|
47073
|
+
return () => cancelAnimationFrame(raf);
|
|
47074
|
+
}, [loaded, pendingFocusCommentId, focusComment, doc2.comments, visible]);
|
|
46520
47075
|
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 });
|
|
46521
47076
|
const selBlocker = reactExports.useMemo(() => {
|
|
46522
47077
|
const sel = window.getSelection();
|
|
@@ -46654,7 +47209,7 @@ function App(props = {}) {
|
|
|
46654
47209
|
forceSettingsOpen,
|
|
46655
47210
|
locked: editingLocked,
|
|
46656
47211
|
agentThinking,
|
|
46657
|
-
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
|
|
46658
47213
|
}
|
|
46659
47214
|
),
|
|
46660
47215
|
findOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -46679,7 +47234,7 @@ function App(props = {}) {
|
|
|
46679
47234
|
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: t2("banner.reloadingIn", { n: reloadIn ?? 0 }) }),
|
|
46680
47235
|
" ",
|
|
46681
47236
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spacer" }),
|
|
46682
|
-
/* @__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") }),
|
|
46683
47238
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
46684
47239
|
"button",
|
|
46685
47240
|
{
|
|
@@ -46707,7 +47262,9 @@ function App(props = {}) {
|
|
|
46707
47262
|
{
|
|
46708
47263
|
className: "ap-primary",
|
|
46709
47264
|
onClick: async () => {
|
|
46710
|
-
|
|
47265
|
+
await awaitSettled();
|
|
47266
|
+
const current = serialize(docRef.current);
|
|
47267
|
+
if (current !== savedRef.current) await hostApi().save(current, { kind: "apply", cadence });
|
|
46711
47268
|
if (hostApi().restartApp) await hostApi().restartApp();
|
|
46712
47269
|
else await hostApi().closeWindow();
|
|
46713
47270
|
},
|
|
@@ -46746,13 +47303,21 @@ function App(props = {}) {
|
|
|
46746
47303
|
] }) }),
|
|
46747
47304
|
readOnly2 && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-banner ap-banner--readonly", role: "status", children: t2("banner.readOnly") }),
|
|
46748
47305
|
proposal && !reviewOpen && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-banner", children: [
|
|
46749
|
-
t2("banner.proposalPending"),
|
|
47306
|
+
(queueCount ?? 1) > 1 ? t2("banner.proposalQueue", { n: queueCount }) : t2("banner.proposalPending"),
|
|
46750
47307
|
" ",
|
|
46751
47308
|
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: () => setReviewOpen(true), children: t2("banner.review") })
|
|
46752
47309
|
] }),
|
|
46753
47310
|
proposal && reviewOpen && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-review-bar", children: [
|
|
46754
47311
|
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { children: t2("banner.proposedChanges") }),
|
|
46755
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
|
+
] }),
|
|
46756
47321
|
t2(changeCount === 1 ? "banner.changesShown" : "banner.changesShownPlural", { n: changeCount }),
|
|
46757
47322
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-spacer" }),
|
|
46758
47323
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("button", { onClick: reviewNext, disabled: !changeCount, title: t2("banner.scrollToNext"), children: [
|
|
@@ -46767,7 +47332,7 @@ function App(props = {}) {
|
|
|
46767
47332
|
disabled: editingLocked || !changeCount
|
|
46768
47333
|
}
|
|
46769
47334
|
),
|
|
46770
|
-
/* @__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") }),
|
|
46771
47336
|
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", onClick: () => setReviewOpen(false), children: t2("banner.laterLower") }),
|
|
46772
47337
|
editingLocked && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-muted", children: t2("banner.locked") })
|
|
46773
47338
|
] }),
|
|
@@ -46777,8 +47342,8 @@ function App(props = {}) {
|
|
|
46777
47342
|
target: composer.target,
|
|
46778
47343
|
pos: composer.pos,
|
|
46779
47344
|
disabled: editingLocked,
|
|
46780
|
-
onSubmit: (text2, talkToAgent) => {
|
|
46781
|
-
addComment(text2, composer.target, composer.span, void 0, talkToAgent);
|
|
47345
|
+
onSubmit: (text2, talkToAgent, mentions) => {
|
|
47346
|
+
addComment(text2, composer.target, composer.span, void 0, talkToAgent, mentions);
|
|
46782
47347
|
setComposer(null);
|
|
46783
47348
|
},
|
|
46784
47349
|
onClose: () => setComposer(null)
|
|
@@ -46929,17 +47494,18 @@ function App(props = {}) {
|
|
|
46929
47494
|
onPaste: onPreviewPasteImage,
|
|
46930
47495
|
onClick: (e) => {
|
|
46931
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
|
+
}
|
|
46932
47503
|
const a = target.closest("a");
|
|
46933
47504
|
if (a) {
|
|
46934
47505
|
e.preventDefault();
|
|
46935
|
-
const cmt = a.getAttribute("data-cmt");
|
|
46936
|
-
if (cmt) {
|
|
46937
|
-
focusComment(cmt, true);
|
|
46938
|
-
return;
|
|
46939
|
-
}
|
|
46940
47506
|
const href = a.getAttribute("href") ?? "";
|
|
46941
47507
|
if (isInternalDocLink(href)) {
|
|
46942
|
-
void hostApi().openDoc(resolveDocPath(docPathRef.current, href));
|
|
47508
|
+
navigateGuarded(() => void hostApi().openDoc(resolveDocPath(docPathRef.current, href)));
|
|
46943
47509
|
return;
|
|
46944
47510
|
}
|
|
46945
47511
|
if (/^https?:/.test(href)) window.open(href, "_blank");
|
|
@@ -47021,7 +47587,7 @@ function App(props = {}) {
|
|
|
47021
47587
|
synced: syncedCommentId === o.thread.root.id,
|
|
47022
47588
|
disabled: editingLocked,
|
|
47023
47589
|
onFocus: () => focusComment(o.thread.root.id, false, true),
|
|
47024
|
-
onReply: (text2) => apply(addReply(docRef.current, o.thread.root.id, text2, userAuthorRef.current).doc, { type: "comment_created", payload: { parentId: o.thread.root.id } }),
|
|
47590
|
+
onReply: (text2, mentions) => apply(addReply(docRef.current, o.thread.root.id, text2, userAuthorRef.current, mentions).doc, { type: "comment_created", payload: { parentId: o.thread.root.id } }),
|
|
47025
47591
|
onAnswer: (selected, text2) => apply(setAnswer(docRef.current, o.thread.root.id, selected, text2, userAuthorRef.current).doc, { type: "comment_answered", payload: { parentId: o.thread.root.id, selected } }),
|
|
47026
47592
|
onAnswerPending: (p2) => setQuestionPending(o.thread.root.id, p2),
|
|
47027
47593
|
onResolve: (r2) => apply(setResolved(docRef.current, o.thread.root.id, r2), { type: "comment_resolved", payload: { id: o.thread.root.id, resolved: r2 } }),
|
|
@@ -47090,13 +47656,13 @@ function AppRoot() {
|
|
|
47090
47656
|
setPhase("real");
|
|
47091
47657
|
setApiReady(true);
|
|
47092
47658
|
}, []);
|
|
47093
|
-
const
|
|
47659
|
+
const replay2 = reactExports.useCallback(() => {
|
|
47094
47660
|
installSample();
|
|
47095
47661
|
setPhase("onboarding");
|
|
47096
47662
|
setApiReady(true);
|
|
47097
47663
|
}, [installSample]);
|
|
47098
47664
|
if (!apiReady) return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-app" });
|
|
47099
|
-
return phase === "onboarding" ? /* @__PURE__ */ jsxRuntimeExports.jsx(App, { onboarding: true, onFinishOnboarding: finish }, "onboarding") : /* @__PURE__ */ jsxRuntimeExports.jsx(App, { onReplayOnboarding:
|
|
47665
|
+
return phase === "onboarding" ? /* @__PURE__ */ jsxRuntimeExports.jsx(App, { onboarding: true, onFinishOnboarding: finish }, "onboarding") : /* @__PURE__ */ jsxRuntimeExports.jsx(App, { onReplayOnboarding: replay2 }, "real");
|
|
47100
47666
|
}
|
|
47101
47667
|
function PaneIcon({ n: n2 }) {
|
|
47102
47668
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ap-pane-ic", "aria-hidden": "true", children: Array.from({ length: n2 }, (_, i) => /* @__PURE__ */ jsxRuntimeExports.jsx("i", {}, i)) });
|
|
@@ -47250,7 +47816,7 @@ function TopBar(props) {
|
|
|
47250
47816
|
)
|
|
47251
47817
|
] });
|
|
47252
47818
|
}
|
|
47253
|
-
var
|
|
47819
|
+
var escapeRegExp2 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
47254
47820
|
function FindReplaceBar({
|
|
47255
47821
|
doc: doc2,
|
|
47256
47822
|
seed,
|
|
@@ -47278,7 +47844,7 @@ function FindReplaceBar({
|
|
|
47278
47844
|
const flags = "g" + (ci2 ? "i" : "");
|
|
47279
47845
|
const out = [];
|
|
47280
47846
|
const scan = (text2, make) => {
|
|
47281
|
-
const re2 = new RegExp(
|
|
47847
|
+
const re2 = new RegExp(escapeRegExp2(find2), flags);
|
|
47282
47848
|
let m2;
|
|
47283
47849
|
while (m2 = re2.exec(text2)) {
|
|
47284
47850
|
out.push(make(m2.index, m2.index + m2[0].length));
|
|
@@ -47314,8 +47880,8 @@ function FindReplaceBar({
|
|
|
47314
47880
|
const replaceAll2 = () => {
|
|
47315
47881
|
if (!find2) return;
|
|
47316
47882
|
const flags = "g" + (ci2 ? "i" : "");
|
|
47317
|
-
const body = inPreview || inEditor ? doc2.body.replace(new RegExp(
|
|
47318
|
-
const comments = inComments ? doc2.comments.map((c) => ({ ...c, text: c.text.replace(new RegExp(
|
|
47883
|
+
const body = inPreview || inEditor ? doc2.body.replace(new RegExp(escapeRegExp2(find2), flags), replace2) : doc2.body;
|
|
47884
|
+
const comments = inComments ? doc2.comments.map((c) => ({ ...c, text: c.text.replace(new RegExp(escapeRegExp2(find2), flags), replace2) })) : doc2.comments;
|
|
47319
47885
|
onApply({ body, comments }, { type: "document_edited", payload: { findReplace: "all" } });
|
|
47320
47886
|
};
|
|
47321
47887
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-find", children: [
|
|
@@ -47551,6 +48117,8 @@ function ThreadCard(props) {
|
|
|
47551
48117
|
const [replying, setReplying] = reactExports.useState(false);
|
|
47552
48118
|
const [editingId, setEditingId] = reactExports.useState(null);
|
|
47553
48119
|
const [editText, setEditText] = reactExports.useState("");
|
|
48120
|
+
const replyTa = reactExports.useRef(null);
|
|
48121
|
+
const replyMention = useMentionAutocomplete(replyTa, replyText, setReplyText);
|
|
47554
48122
|
const [menuOpenId, setMenuOpenId] = reactExports.useState(null);
|
|
47555
48123
|
reactExports.useEffect(() => {
|
|
47556
48124
|
if (!menuOpenId) return;
|
|
@@ -47675,32 +48243,58 @@ function ThreadCard(props) {
|
|
|
47675
48243
|
thread.replies.map((r2) => renderComment(r2, true)),
|
|
47676
48244
|
!replying && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "ap-row ap-thread-actions", children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "ap-link", disabled, onClick: () => setReplying(true), children: t2("rail.reply") }) }),
|
|
47677
48245
|
replying && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-reply-box", children: [
|
|
47678
|
-
/* @__PURE__ */ jsxRuntimeExports.
|
|
47679
|
-
|
|
47680
|
-
|
|
47681
|
-
|
|
47682
|
-
|
|
47683
|
-
|
|
47684
|
-
|
|
47685
|
-
|
|
47686
|
-
|
|
47687
|
-
|
|
47688
|
-
|
|
47689
|
-
|
|
47690
|
-
|
|
47691
|
-
|
|
48246
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { position: "relative" }, children: [
|
|
48247
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
48248
|
+
"textarea",
|
|
48249
|
+
{
|
|
48250
|
+
ref: replyTa,
|
|
48251
|
+
className: "ap-grow",
|
|
48252
|
+
placeholder: t2("thread.replyPlaceholder"),
|
|
48253
|
+
value: replyText,
|
|
48254
|
+
disabled,
|
|
48255
|
+
autoFocus: true,
|
|
48256
|
+
role: "combobox",
|
|
48257
|
+
"aria-expanded": replyMention.isOpen,
|
|
48258
|
+
"aria-controls": replyMention.isOpen ? replyMention.listboxId : void 0,
|
|
48259
|
+
"aria-autocomplete": "list",
|
|
48260
|
+
"aria-activedescendant": replyMention.activeDescendantId,
|
|
48261
|
+
onChange: (e) => {
|
|
48262
|
+
setReplyText(e.target.value);
|
|
48263
|
+
replyMention.sync();
|
|
48264
|
+
},
|
|
48265
|
+
onSelect: () => replyMention.sync(),
|
|
48266
|
+
onKeyDown: (e) => {
|
|
48267
|
+
if (replyMention.onKeyDown(e)) return;
|
|
48268
|
+
if ((e.metaKey || e.ctrlKey) && e.key === "Enter" && replyText.trim()) {
|
|
48269
|
+
props.onReply(replyText.trim(), replyMention.activeMentions(replyText));
|
|
48270
|
+
setReplyText("");
|
|
48271
|
+
replyMention.reset();
|
|
48272
|
+
setReplying(false);
|
|
48273
|
+
}
|
|
47692
48274
|
}
|
|
47693
48275
|
}
|
|
47694
|
-
|
|
47695
|
-
|
|
48276
|
+
),
|
|
48277
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
48278
|
+
MentionDropdown,
|
|
48279
|
+
{
|
|
48280
|
+
candidates: replyMention.candidates,
|
|
48281
|
+
activeIndex: replyMention.activeIndex,
|
|
48282
|
+
onPick: replyMention.pick,
|
|
48283
|
+
onHover: replyMention.setActiveIndex,
|
|
48284
|
+
listboxId: replyMention.listboxId,
|
|
48285
|
+
optionId: replyMention.optionId
|
|
48286
|
+
}
|
|
48287
|
+
)
|
|
48288
|
+
] }),
|
|
47696
48289
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "ap-row", children: [
|
|
47697
48290
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
47698
48291
|
"button",
|
|
47699
48292
|
{
|
|
47700
48293
|
disabled: disabled || !replyText.trim(),
|
|
47701
48294
|
onClick: () => {
|
|
47702
|
-
props.onReply(replyText.trim());
|
|
48295
|
+
props.onReply(replyText.trim(), replyMention.activeMentions(replyText));
|
|
47703
48296
|
setReplyText("");
|
|
48297
|
+
replyMention.reset();
|
|
47704
48298
|
setReplying(false);
|
|
47705
48299
|
},
|
|
47706
48300
|
children: t2("thread.comment")
|
|
@@ -47712,6 +48306,7 @@ function ThreadCard(props) {
|
|
|
47712
48306
|
className: "ap-link",
|
|
47713
48307
|
onClick: () => {
|
|
47714
48308
|
setReplyText("");
|
|
48309
|
+
replyMention.reset();
|
|
47715
48310
|
setReplying(false);
|
|
47716
48311
|
},
|
|
47717
48312
|
children: t2("thread.cancel")
|