Repository navigation
feat(bots): show event triggers and waiting cards in bot details - #1387
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-ui
branch
3 times, most recently
from
November 28, 2026 02:04
0d8ef23 to
0a2b11f
Compare
Bot details on web, desktop and mobile list a bot's event triggers with their filter, weekly counts and pause state, and let the owner pause, resume or delete them. A "Waiting for you" section lists parked questions and approvals and jumps to their card in the chat; cards say whether they came from an event trigger, a routine or a reminder. Co-Authored-By: Claude Opus 5.5 <[email protected]>
nixuuu
force-pushed
the
feat/bot-event-triggers-ui
branch
from
November 28, 2026 02:14
0a2b11f to
48840fb
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 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. - A trigger is a `bot_routines` row with `kind = '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. - **Event types**: - thread events (0230): turn finished, request opened; - CI results of watched pull requests; - schedule runs; - provider usage limits: a `gte` threshold crossing per worker, profile, window and reset, deduplicated by receipts; - memory habits (0231). - **Filter** (`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. - **Recording**: PostgreSQL source triggers call `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. - **Matcher** (locks candidates in id order): - excludes the bot's own work (watches, started threads, steers); - holds events of a bot frozen by an undecided move; - drops events of an older module generation. - **Batches**: matched events coalesce into a batch. The hourly limit holds a batch with `check_after`. Three consecutive saturated hours pause the trigger. - **Rechecks before the run starts**: the run reports only events that are still current. It checks again at claim, under its lease before the first worker command, and before the first send. A command refused unsent is retired: the run restarts with the remaining events or ends without a model call. - **Pinned workers**: a trigger run waits for its pinned worker's bot link on any gateway. - **Read policy for trigger runs**: no threads, schedules, requests or files from external conversations, and no threads of other computers. - **Tools**: `create_trigger`, `update_trigger` (needs `revision`; only `enabled=true` resumes a trigger), `preview_trigger`, `list_triggers`, `delete_trigger` and `list_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. - **Consolidation and moves**: - events, batches, generations and receipts are local-only; - scopes are imported from 0229, and project ids are rewritten on merge; - source triggers are fenced during import; - the new `move_bot_triggers_v1` capability is required to move a bot with triggers. - **Shared harness fixes this work needed (all bot turns)**: - a `runBotTurn` handed to a link is recorded as attempted before the frame leaves; - a capability refusal comes only from the worker's current registration, for a command never attempted (`BOT_WORKER_OUTDATED`); - a turn waiting for a worker that was archived or revoked ends with a configuration error (`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`: - gateway, domain and mobile typecheck; web `svelte-check`; - oxlint and oxfmt check on the changed files; - `bun run gen`: no diff; - migrations 0001–0231 applied to a fresh database; - integration tests, run one file at a time: | Test file | Passed | | --- | --- | | `bot-event-triggers` | 10 | | `bot-event-trigger-sources` | 6 | | `bot-parked-interactions` | 8 | | `bots-harness` | 26 | | `bots-harness-regressions` | 12 | | `bots-harness-approvals` | 14 | | `bots-harness-errors` | 7 | | `bots-harness-context` | 2 | | `bots-harness-defaults` | 2 | | `bots-remote` | 8 | | `bot-files` | 9 | | `bot-routines` | 11 | | `bot-background-continuations` | 11 | | `bot-handoff` | 10 | | `bot-module-suspension` | 5 | | `bot-deletion` | 3 | | `computer-moves` | 10 | | `consolidation-preflight` | 1 | | `worker-configuration-compatibility` | 2 | | `packages/db` schema test | 26 | Left to CI: these tests need `psql`, which this machine doesn't have: - `apps/gateway/test/consolidation-import` - `apps/gateway/test/consolidation-projection` - `gateway-relocation` Test 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](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
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 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:
Copy audit (docs/copy.md §8)
·.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:
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