feat(server): wake the agent when a Forgejo checkbox is toggled #230
No reviewers
Labels
No labels
Agent
Ignore
Agent
In Progress
Agent
Planned
Agent
Planning
Agent
Ready
Agent
Triage
Compat
Breaking
Kind
Bug
Kind
Documentation
Kind
Enhancement
Kind
Feature
Kind
Security
Kind
Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lucas/omp-deck!230
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/issue-229-checkbox-trigger"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes: #229
Ticking or unticking a box in a markdown checklist now wakes the agent — in a comment, in an inline review comment (which Forgejo delivers as an ordinary
issue_commentedit), or in the issue/pull request description, including checklists the agent wrote itself.What changed
Receiver (
forgejo/webhook.ts)action: "edited"the acting principal is the editor (sender.login), notcomment.user.login. An edit of the agent's own comment is therefore accepted (commentAuthor= the editor); only the agent editing is ignored, as"self-edited"— that is the loop guard, since the agent rewrites its own checklists.createdis unchanged.changes.body.fromis"no body change", which is what separates a content edit from the title change Forgejo also sends asedited.dedupeKeytakes the edited subject (the comment, or the issue/PR for a description edit with comment id0); successive toggles differ inbody, so each toggle keeps its own key inside one second.New pure module (
forgejo/checkbox-diff.ts)parseTaskItems,checklistBlocks,diffCheckboxes. Code fences and>quotes are skipped. Items are paired on the first word of their label, so a tick survives an accompanying prose edit; a pure reorder, and any edit leaving every item's first word and state alone, returnsnull(non-event). Lists that cannot be paired positionally yieldflips: nulland hand the agent both checklists rather than guessing.Detection (
forgejo/conversation-detect.ts)"checkbox-change"reason (also inCONVERSATION_REASONS, so it runs workspace-less). It requires that the agent took part in the artifact: it wrote the edited text, or it appears in the conversation (which includes the opening entry, so an artifact it opened counts). A failed participation check falls through to the existingedited-mentionrule, so no behaviour is lost.buildCheckboxEditSeedbuilds the turn: which items flipped, the checklist as it stands now, and an explicitly neutral closing paragraph — a tick implies nothing in particular; the agent decides from the conversation.Dispatcher (
forgejo/dispatcher.ts)CHECKBOX_SETTLE_MS): the rendered widget posts one request per click, so toggles of the same text collapse into one turn. Siblings are read from the stored payloads at gate time, so a crash inside the window loses nothing. An edit with no checkbox change is never delayed.editedrows that are not a checkbox change (for every other rowcommentAuthoris the sender, so the old comparison was a no-op there). A checkbox change is authorised in the editor's own name instead.write/adminuser passes. The issue/PR-opener shortcut and thereadfallback do not apply, so an outside contributor cannot drive the agent by ticking boxes in an issue they opened.Verification
src/forgejo/checkbox-diff.test.ts(tick, untick, reorder, prose-only edit, simultaneous tick+untick, inserted item, fenced/quoted checklists,checklistBlocks).webhook.test.ts: edit of the agent's comment accepted with the editor as author;self-edited; description edit accepted withchanges.body.fromand ignored (no body change) without it; per-toggle dedupe keys. The old"unsupported action edited"assertions are replaced.conversation-detect.test.ts:checkbox-changewith an agent entry and witheditedAuthor= agent;nullwithout participation;edited-mentionstill wins when no checkbox moved.dispatcher.test.ts: a tick in the agent's comment by the repo owner starts a turn whose seed carriesTrigger: a checkbox was ticked or untickedand- [x] alpha; areadeditor who opened the issue is dropped;edited-mentionstill runs; a non-author edit is still dropped; two pending toggles stay deferred inside the window and then run as one turn, the other row dropped withcoalesced into ….bun test(1242 tests) andbun run typecheckpass from the repository root.Note on deployment
The receiver now classifies
issues/pull_requestediteddeliveries, but whether this deployment's webhook has the Issues and Pull request events ticked lives in Forgejo, not in this repo — unverified here. If description-edit triggers never arrive, check the hook's event selection; comment edits ride on the already-subscribed comment events.