Repository navigation
feat(bots): run bots on matching canopy events - #1386
Merged
Merged
Conversation
This was referenced Nov 28, 2026
nixuuu
marked this pull request as ready for review
November 28, 2026 01:08
nixuuu
force-pushed
the
feat/bot-event-triggers
branch
3 times, most recently
from
November 28, 2026 02:04
19ebecc to
886ae5c
Compare
Event triggers let a bot run in the background when a Canopy event it subscribed to happens: thread turns and requests, CI results, schedule runs, usage limits and memory habits. Each trigger filters by event type, concrete resources and field conditions; matched events are coalesced, rate limited and checked again before the run starts, and a noisy trigger pauses itself. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nixuuu
force-pushed
the
feat/bot-event-triggers
branch
from
November 28, 2026 02:14
886ae5c to
de2fc96
Compare
nixuuu
added a commit
that referenced
this pull request
Nov 28, 2026
Part 1 of 3 of the bot event triggers stack (#1385 → #1386 → #1387). The stack merges at once. ## What changes A question (`ask_user`) or an approval card raised by a **background run** no longer blocks the bot's FIFO queue: - Routine runs, verified reminders (`wakeup:<id>`) and verified continuations (`parked:<id>`) **park** the card (`bot_approvals.parked`). The model gets `status: parked`, the run ends, and the private chat stays free. Conversation and bot-to-bot turns never park. - The owner's answer, a decline or 24-hour expiry enqueues a **continuation** turn `parked:<card>`. An approved action runs **once** in the gateway before the model reads the continuation (`bot_turns.resume_approval_id`, migration 0228). The approved proposal (`proposed_bot`) and the restricted destination are kept. - The continuation input is bounded: the card prompt is clipped to 8000 characters, and the owner's answer (≤ 32 000) is kept whole. The asking run's final note is attached when the continuation starts, even if the owner answered before that run ended. - Bot workspace (file) tools are **not** parked. A background run waits for them as it does on `dev`, because a continuation gets a new workspace without the run's files. - Locks follow one order (module → bot → turn → card) in answer, expiry and routine disable. A disabled routine discards its pending parked cards. - Bot moves carry continuations: the target restores `resume_approval_id` after approvals, and validation rejects references outside the moved cards. Docs: `docs/bots.md`, section "Parkowane pytania i zgody rutyn". ## Verification Ran locally on this layer: gateway typecheck, web `svelte-check`, mobile typecheck, oxlint on the changed files, and these integration tests: `bot-parked-interactions` (7), `computer-moves` (10), `bots-harness-approvals` (14). CI runs the full gate. Reviewed with the next layers by GPT 6.2 Astra over 11 rounds. The final verdict was **ACCEPT**. Accepted limitation: file-tool approvals in background runs still wait, as on `dev`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
nixuuu
added a commit
that referenced
this pull request
Nov 28, 2026
Part 3 of 3 of the bot event triggers stack (#1385 → #1386 → #1387). The stack merges at once. ## What changes Bot details on web, desktop and mobile: - **Event triggers**: each trigger shows its plain filter description, last 7 days' counts ("1 event · 2 runs in 7 days"), last run and pause state ("Paused after running too often"). The owner can pause, resume or delete it. - **Waiting for you**: parked questions and approvals ("Your answer or decision starts a new background run."). "Show in chat" scrolls to the card; on narrow layouts it closes the overlay first. - Cards and rows name their origin: "From event trigger “…”", "From routine “…”", or "from a reminder" when a card has no routine. - Parked cards say "Your answer starts a new run" or "Your decision starts a new run". - The countdown switches to hours ("Expires in 19 hours"). - A background status line names a trigger run "Event trigger “…”" instead of "Routine “…”". ## Copy audit (docs/copy.md §8) 1. One idea per sentence, sentence case, active voice: pass. Long origin lines were split with ` · `. 2. Glossary: pass. Added "event trigger"; "routine" and "reminder" are unchanged. 3. Verbs: pass ("Show in chat", "Pause", "Resume", "Delete"). 4. Errors: pass. "Update this worker to run bots, or pick another worker." and "This bot's worker was removed. Pick another worker in Runs on." each say what happened and what to do. 5. Empty states: pass. Both sections are hidden when empty. 6. Repetition: pass. The section description isn't repeated in each row; origin labels stay because they tell trigger, routine and reminder cards apart. 7. External gaps: none. 8. "Soul" sentences: none. 9. Short, typical and long values: pass. Checked a long trigger title and description, at 1440 px and in a narrow window. 10. Colour/icon-only cues: pass. Pause state and origin are text. ## Verification Ran locally: web `svelte-check`, mobile typecheck, oxlint and oxfmt check on the changed files. Checked in a real browser on the test gateway with the shared web renderer: - the "Waiting for you" section and the cards and their origins; - the trigger list, with a long title and the paused state; - answering a parked question, then the follow-up activity and the status line; - a desktop width and a narrow window. Not checked on a native mobile device: only the mobile typecheck ran. Reviewed with the lower layers by GPT 6.2 Astra. The final verdict was **ACCEPT**. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
nixuuu
added a commit
that referenced
this pull request
Nov 28, 2026
…1402) A workspace with a GitHub App installation could show pull requests in the PR panel while the new-thread composer found nothing for the same repository. The composer only consulted project-granted MCP accounts. The gateway now searches the GitHub account selected for the workspace remote. A number such as `#1386` looks up the issue or pull request directly, including closed and merged items. The picker also supports text, links and recent open items. GitHub results share the existing reference format, and sending the message checks current access to the workspace repository. A GitHub MCP connector may still provide its own results. When both return the same PR, the picker shows the repository account's result once. ## Verification - All 17 focused tests passed across the GitHub App, linked-computer mentions and provider suites. They cover delivery to the worker, removal of installation access, repository boundaries and duplicate results. - Gateway and integration-test typechecks passed, along with edited-file lint and formatting. - On the new-thread page in Chromium, typing `#1386` and choosing the PR inserted the expected chip at 1440 × 900 and 390 × 844 with fixture responses at the HTTP boundary. - Live GraphQL queries by number and title both found the merged `#1386`. - Repository-wide verification runs in CI. ## Copy audit The empty state previously directed users only to Settings → Connectors. It now points to both GitHub repository access and connector access. Read failures and unavailable references give a next action. Reviewed the changed English copy against §8 and verified wrapping at both browser widths. Fixes: #1176
nixuuu
added a commit
that referenced
this pull request
Nov 28, 2026
GitHub now has one default connection flow on web, desktop and mobile. Adding GitHub in Connectors opens Settings → GitHub. Existing MCP accounts retain their reconnect action and grants. Advanced connections supports a PAT, an OAuth app and custom MCP servers. At each installed repository, the owner chooses projects and bots. They can read text files, issues and pull requests. Enabling **Allow changes on GitHub** also permits creating issues, posting comments and opening pull requests between branches of that repository, subject to the thread or bot approval policy. The gateway binds every grant to the account and immutable repository ID. It checks the current grant before a call and before returning private results. The same project grant can confirm an exact merge during worktree cleanup. GitHub credentials and native grants remain on their home gateway. Previously saved grants can still be removed after an uninstall. ### Verification - Schema, grant RPC, linked-home routing, consolidation, legacy connector and bot settings, worker and bot dispatch, revocation during reads, uncertain writes, replay, and worktree cleanup passed focused tests against local PostgreSQL and a GitHub API fixture. - Chromium at 1440 and 390 px exercised setup, grant editing, stale revisions, revocation, advanced connections, and switching homes. An Android emulator exercised local and linked-home grants, revocation, PAT, reconnect and long names with controlled RPC responses. - In the same two Chromium viewports, the composer showed the distinct GitHub and Jira/Linear setup guidance with no clipping. Bot Connections rendered the scoped repository and linked to GitHub settings. - Gateway, integration-test, web and mobile typechecks and edited-file lint were checked locally. The full repository gate runs in CI. - The repository tool request builder and result parser handled three live public GitHub reads in `itsoltech/canopy` by numeric repository ID. PR #1386 returned its merged state and canonical link, listing closed PRs returned three items, and reading `README.md` from `dev` returned the file text. Private data and writes were tested using fixtures. - The new linked-computer capability follows the original protocol-1 entries. Seven focused cases for older desktop peers and GitHub routing passed locally. ### Copy audit The previous Add GitHub entry presented a second authorization flow. It now opens the common GitHub setup. The grant editor names files, issues and pull requests before a user selects recipients. “Allow changes on GitHub” makes writes a separate choice. Advanced options name their credentials explicitly. Error actions, accessible control labels, narrow layouts and long repository names were checked against docs/copy.md §8. Second part of the GitHub unification stack, based on #1405.
This was referenced Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of 3 of the bot event triggers stack (#1385 → #1386 → #1387). The stack merges at once.
What changes
Event triggers: a bot runs in the background when a Canopy event it subscribed to happens.
bot_routinesrow withkind = 'trigger'. Its event type, atomic filter, scope and revision live in migration 0229. Its scope rows (bot_trigger_scopes) exist only while it can match.gtethreshold crossing per worker, profile, window and reset, deduplicated by receipts;packages/domain/src/bot-triggers): one event type, concrete resource ids the owner can see, conditions on catalogue fields,exclude_own, a quiet window and an hourly limit.bot_trigger_record, one statement that checks module eligibility, candidates and a module generation stamp. An owner without matching scopes costs one index lookup and writes nothing.check_after. Three consecutive saturated hours pause the trigger.create_trigger,update_trigger(needsrevision; onlyenabled=trueresumes a trigger),preview_trigger,list_triggers,delete_triggerandlist_trigger_event_types. Only a private owner message can change triggers. A frequent or unestimated trigger needs an approval card with a 7-day estimate.move_bot_triggers_v1capability is required to move a bot with triggers.runBotTurnhanded to a link is recorded as attempted before the frame leaves;BOT_WORKER_OUTDATED);BOT_WORKER_REMOVED), including while it waits for an interrupt acknowledgement.The gateway API for the next layer is included:
BotApproval.routine_kind(proto field 1115) and the trigger views.Docs:
docs/bots.md("Wyzwalacze zdarzeń"),docs/linked-computers.md(move capability),docs/copy.md(glossary: event trigger).Verification
Ran locally on the stack tip, rebased on the current
dev:svelte-check;bun run gen: no diff;bot-event-triggersbot-event-trigger-sourcesbot-parked-interactionsbots-harnessbots-harness-regressionsbots-harness-approvalsbots-harness-errorsbots-harness-contextbots-harness-defaultsbots-remotebot-filesbot-routinesbot-background-continuationsbot-handoffbot-module-suspensionbot-deletioncomputer-movesconsolidation-preflightworker-configuration-compatibilitypackages/dbschema testLeft to CI: these tests need
psql, which this machine doesn't have:apps/gateway/test/consolidation-importapps/gateway/test/consolidation-projectiongateway-relocationTest gateway (fresh database, real PostgreSQL source triggers): a failed turn in a watched project was recorded, matched and coalesced into an open batch. Answering a parked trigger question queued its
parked:continuation with the trigger's instructions.Reviewed by GPT 6.2 Astra over 11 rounds. The final verdict was ACCEPT.
🤖 Generated with Claude Code