Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/editor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5414,6 +5414,30 @@ class ProofEditorImpl implements ProofEditor {
if (selectedText.trim()) {
// Create a comment with @proof mention to trigger the agent
markComment(view, selectedText, actor, `@proof ${prompt}`, context.range);

// Also POST to the server ops endpoint so the agent can poll it via HTTP.
// The local Yjs mark is not visible to HTTP readers while a live collab
// session is active (projection repair is blocked by the collab lease).
const slug = shareClient.getSlug();
if (slug) {
const body = JSON.stringify({
type: 'comment.add',
by: actor,
quote: selectedText,
text: `@proof ${prompt}`,
Comment on lines +5423 to +5427
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve a single comment identity across local and /ops writes

This payload creates a second independent comment instead of mirroring the local one: markComment(...) already creates a local mark ID, but /api/agent/:slug/opsPOST /marks/comment assigns a new randomUUID() when no ID is provided, and projection merge preserves DB-only mark IDs (mergePreservedActionMarks), so both comments survive and appear as duplicates after sync. Reuse the local mark ID (or avoid dual-writing the same comment) so one user action maps to one comment record.

Useful? React with 👍 / 👎.

});
fetch(`${shareClient.getApiBaseUrl()}/agent/${encodeURIComponent(slug)}/ops`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
...shareClient.getShareAuthHeaders(),
},
body,
}).catch((err) => {
console.warn('[invokeAgentOnSelection] Failed to POST comment to server ops:', err);
Comment on lines +5436 to +5437
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check /ops response success before treating request as queued

This call only catches thrown fetch errors and never inspects HTTP status, so non-2xx responses are silently ignored. comment.add can return a 409 anchor-not-found when the selected quote is newer than canonical markdown (a common live-collab state), so the backend request may fail while agent_manual_request_queued is still emitted, making Ask Proof look successful even though no pending event was created for polling agents.

Useful? React with 👍 / 👎.

});
}

captureEvent('agent_manual_request_queued', {
trigger_type: 'comment',
});
Expand Down