-
Notifications
You must be signed in to change notification settings - Fork 112
fix: relay Ask Proof comment to server ops endpoint so HTTP agents can poll it #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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}`, | ||
| }); | ||
| 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This call only catches thrown fetch errors and never inspects HTTP status, so non-2xx responses are silently ignored. Useful? React with 👍 / 👎. |
||
| }); | ||
| } | ||
|
|
||
| captureEvent('agent_manual_request_queued', { | ||
| trigger_type: 'comment', | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This payload creates a second independent comment instead of mirroring the local one:
markComment(...)already creates a local mark ID, but/api/agent/:slug/ops→POST /marks/commentassigns a newrandomUUID()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 👍 / 👎.