Skip to content

feat(automations): refresh incoming webhooks for current runtime - #31121

Open
oliver-mee wants to merge 12 commits into
stablyai:mainfrom
oliver-mee:fix/webhook-dispatch-admission
Open

oliver-mee wants to merge 12 commits into
stablyai:mainfrom
oliver-mee:fix/webhook-dispatch-admission

Conversation

@oliver-mee

@oliver-mee oliver-mee commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

External systems can POST to an automation instead of waiting for its next scheduled run. If Orca cannot dispatch the work, the sender receives a refusal rather than a misleading acceptance.

What Changed

Carry Ptah-CT's incoming-webhook implementation from #5617 onto the current automation architecture. Preserve the original commit and use the current host-owned dispatch lanes, durable run writer, split persistence, preload APIs and editor surfaces.

The receiver supports per-automation authentication, bounded payloads and rate limits. Requested token/HMAC verification stays fail-closed when its secret is blank; it never silently becomes unauthenticated. Untrusted terminal control bytes are removed only from the composed prompt, with raw captured delivery retained. Expired rate-limit sources are pruned while serving. Bind/port fields commit validated drafts on blur or Enter, avoiding intermediate rebinds. Webhook copy uses the localisation layer and missing translations retain the standard English fallback. Webhook runs retain their captured payload and distinct trigger. Settings start, stop and rebind the receiver with the scheduler's lifetime. Old hosts refuse webhook configuration before mutation.

Dispatch results now reach the HTTP boundary. Unavailable, interactive-auth-required and failed dispatch return 503; legitimate admitted or completed runs return 202. Separate deliveries received in the same millisecond retain separate run identities.

Why

The existing implementation no longer applies cleanly to main. Porting it through the current owners avoids restoring the former renderer-only dispatcher or synchronous persistence path. Returning 202 for refused work leaves external senders unaware that nothing was launched.

Linked Issue

Partial implementation of #12400. This continues #5617 by Ptah-CT, whose implementation commit remains in the ancestry. HTTPS enforcement and delivery-idempotency keys requested by #12400 remain outstanding; complete issue closure is not claimed.

Visual Proof

Screenshots from the hidden Electron app are published on a separate evidence branch, outside the implementation diff. Settings display the actual listening address. The editor shows the unsaved-URL explanation, disables URL copying until saved, and exposes HMAC verification and secret generation. All data is synthetic; no automation was saved or triggered.

Receiver disabled Receiver enabled
Receiver disabled Receiver listening
Trigger off HMAC verification
Trigger off HMAC verification and generated synthetic secret

Testing

October 25 refresh: merged current main at 1d2b5361efa7851e95c4b24e5a9b298863f8fb7b, preserving the existing contribution history. Current head 40c12054e1bd901ff46a0239847b83316eff4a9f: 111 focused tests across 15 files, Node and renderer native typechecks, scoped lint and localization-catalog validation pass. Kept upstream’s startup update-prompt suppression and new settings groups, and repaired test imports after upstream moved the persistence fixtures. Earlier application/Electron acceptance below belongs to its recorded earlier heads and was not repeated for this refresh. Substantive upstream CI remains a separate maintainer approval gate.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Pinned main baseline: 411b5c024abef11dcc269779377bc7d3aefa897c. Submitted head: 723c8040da562e4b1346604fc9a4f051c328b68f, preserving Ptah-CT's original commit ancestry.

  • 347 focused tests across 42 files pass on the refreshed tree, covering automation dispatch and webhook HTTP/authentication.
  • The new legacy-target regression proves webhook execution persists the host context before publishing its dispatch snapshot. Removing capture makes the assertion fail; restoring it passes.
  • Node and renderer native typechecks pass. Scoped lint passes across all nine changed TypeScript/TSX files in this review correction; earlier unchanged feature files retain their prior scoped validation. Localisation catalog, coverage and runtime-subset checks pass.
  • App and bundled CLI were built from production-source commit 522550531d. The current head adds only a DOM assertion: after Enter commits the new port, the rendered listener status must show that exact port. The strengthened scenario passes with retries disabled on the same unchanged app build; its changed-spec lint passes.
  • App and bundled CLI build. All four hidden Electron lifecycle/settings/editor/draft-binding scenarios pass together, with retries disabled, against the E2E-mode app build. Receiver enable, rebind, disable, actual listening state, unsaved URL controls and HMAC secret generation are exercised. The added scenario proves port/bind editing remains local until blur or Enter and invalid empty ports do not persist.
  • The initial three acceptance attempts failed at the store hook before feature interaction: the application had been built without E2E mode, then reused with SKIP_BUILD=1. Rebuilding with the repository's documented --mode e2e fixes the build mismatch; no test assertion or timeout changed. Original failures are retained.
  • The committed tree matches the retained validated tree exactly, including the helper and regression additions. Commit hooks introduced no source drift.
  • New review regressions reproduce four pre-fix failures for blank verification, terminal controls and retained source entries. Two real loopback HTTP cases additionally reproduce 202 instead of 401 for blank token/HMAC secrets; corrected requests return 401 without dispatch. The settings scenario reproduces premature port persistence before the draft commit fix. All negative controls and failures are retained.
  • Before the original admission fix, four receiver regressions fail with HTTP 202 instead of 503. This negative control is historical admission evidence; the legacy-target control above belongs to this refresh.

Tests use isolated application homes and profiles. Windows, installed/signed packages, provider-backed end-to-end automation execution and a full repository matrix remain unverified.

AI Disclosure

GPT-6.1 Sol ported and tested the implementation under human direction; GPT-6 completed the main refresh, E2E build correction and seven actionable review corrections. The original webhook implementation is Ptah-CT's contribution.

Review

Please review dispatch admission, receiver shutdown/rebind ordering, migration safety and old-host capability refusal. A 503 is a refusal, not evidence of queued durable delivery. Rate limits do not provide delivery idempotency.

Agent skill upstream boundary

  • Not applicable; no upstream skill-installer content copied.

Checklist

  • Scope and user-facing behaviour explained
  • Original author credited and commit preserved
  • Self-reviewed for correctness, security and execution-host ownership
  • Before/after UI proof attached
  • Full lint, typecheck, test and build matrix passes (focused validation above)

🤖 Generated with GPT-6.1 Sol and GPT-6
🧑‍💻 Ideated, directed and reviewed by a human, @oliver-mee

Preserve webhook receiver lifecycle and admission behavior while retaining upstream host-routing and layout-owner updates.
Preserve upstream legacy run-target capture before webhook dispatch and extract the validation path within the module budget.
@oliver-mee
oliver-mee marked this pull request as ready for review October 21, 2026 07:56
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 036dbb95-f3c7-4e6d-9ac6-3f5f868ea5e8
📥 Commits

Reviewing files that changed from the base of the PR and between 5225505 and 723c804.

📒 Files selected for processing: 1
  • tests/e2e/webhook-receiver-lifecycle.spec.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • tests/e2e/webhook-receiver-lifecycle.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

This change adds an HTTP webhook receiver and webhook-triggered automation runs. It adds webhook settings, secret verification, request limits, delivery persistence, and prompt composition. The automation editor and advanced settings page expose webhook configuration and receiver status. Remote automation updates and catalog migrations check webhook runtime support. The change also extracts source-control settings update logic and re-exports a run-status predicate.

Priority: Normal

Merge Risk: Minimal · up to 723c8

The listener-status test now checks the committed address and port in the UI. No actionable issue remains from this change; it is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 56 functions across 55 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly identifies the primary change: refreshing incoming webhook support for the current automation runtime.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description includes all required sections, explains the user-visible and technical changes, links issue #12400, provides visual proof, documents testing and limitations, discloses AI use, and inc…
Full details: Description check

Explanation

The description includes all required sections, explains the user-visible and technical changes, links issue #12400, provides visual proof, documents testing and limitations, discloses AI use, and includes the review and checklist information.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 7


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a0921ee5-8858-43f1-8341-e9d5bd38476d
📥 Commits

Reviewing files that changed from the base of the PR and between 411b5c0 and 53ef075.

📒 Files selected for processing: 70
  • src/main/automations/automation-run-precheck.ts
  • src/main/automations/automation-run-writer.test.ts
  • src/main/automations/automation-run-writer.ts
  • src/main/automations/headless-automation-agent-launch.ts
  • src/main/automations/headless-workspace-create.ts
  • src/main/automations/runtime-automation-service-retention.test.ts
  • src/main/automations/runtime-automation-service.ts
  • src/main/automations/service-webhook-legacy-target.test.ts
  • src/main/automations/service.test.ts
  • src/main/automations/service.ts
  • src/main/automations/webhook-run-target.ts
  • src/main/ipc/automations.ts
  • src/main/orcad/orcad-automations.test.ts
  • src/main/orcad/orcad-automations.ts
  • src/main/persistence/applying-settings/settings-update.ts
  • src/main/persistence/applying-settings/source-control-settings.ts
  • src/main/persistence/loading-store/automation-persistence.ts
  • src/main/persistence/loading-store/normalize-loaded-global-settings.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-automation-state.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-webhook-migration.test.ts
  • src/main/persistence/scheduling-automations/automation-definition-operations.ts
  • src/main/persistence/scheduling-automations/automation-run-operations.ts
  • src/main/persistence/webhook-persistence.test.ts
  • src/main/runtime/runtime-automation-controller.ts
  • src/main/runtime/runtime-automation-update-value.ts
  • src/main/ssh/orcad-migration-catalog-client-extra-agent-args.test.ts
  • src/main/ssh/orcad-migration-catalog-client.ts
  • src/main/webhooks/automation-webhook-lifecycle.test.ts
  • src/main/webhooks/automation-webhook-lifecycle.ts
  • src/main/webhooks/webhook-rate-limiter.test.ts
  • src/main/webhooks/webhook-rate-limiter.ts
  • src/main/webhooks/webhook-secret.test.ts
  • src/main/webhooks/webhook-secret.ts
  • src/main/webhooks/webhook-server.test.ts
  • src/main/webhooks/webhook-server.ts
  • src/preload/api/automation-api.ts
  • src/preload/api/automations-bridge.ts
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/renderer/src/components/automations/AutomationEditorSettingsSidebar.tsx
  • src/renderer/src/components/automations/AutomationWebhookEditor.tsx
  • src/renderer/src/components/automations/AutomationWebhookSection.tsx
  • src/renderer/src/components/automations/AutomationsPageSurface.tsx
  • src/renderer/src/components/automations/automation-capability-probe.ts
  • src/renderer/src/components/automations/automation-edit-draft.ts
  • src/renderer/src/components/automations/automation-host-client.ts
  • src/renderer/src/components/automations/automation-orca-save.ts
  • src/renderer/src/components/automations/automation-scoped-list-client.ts
  • src/renderer/src/components/automations/use-automation-editor-actions.ts
  • src/renderer/src/components/automations/use-automations-page-local-state.ts
  • src/renderer/src/components/settings/AdvancedPane.tsx
  • src/renderer/src/components/settings/WebhookServerSetting.tsx
  • src/renderer/src/hooks/automation-dispatch-handler.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/automation-run-status.ts
  • src/shared/automation-runtime-capabilities.ts
  • src/shared/automation-webhook.test.ts
  • src/shared/automation-webhook.ts
  • src/shared/automations-types.ts
  • src/shared/default-global-settings.ts
  • src/shared/global-settings-base.ts
  • src/shared/orcad-migration/orcad-migration-dormant-automation-validation.ts
  • src/shared/rpc-contract/automation-params.ts
  • src/shared/webhook-server-settings.test.ts
  • src/shared/webhook-server-settings.ts
  • tests/e2e/webhook-editor-proof.spec.ts
  • tests/e2e/webhook-receiver-lifecycle.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/renderer/src/i18n/locales/ko.json Resolved
Comment thread src/shared/automation-webhook.ts Resolved
Comment thread src/shared/automation-webhook.ts Resolved
@oliver-mee
oliver-mee marked this pull request as draft October 21, 2026 08:23
Keep blank verification secrets fail-closed and remove terminal control bytes from untrusted payload prompts. Prune expired rate-limit sources, commit bind fields only after editing, and preserve localisation fallback.
@oliver-mee
oliver-mee marked this pull request as ready for review October 21, 2026 08:35

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6c4e4449-327e-445c-867e-9003f11ae382
📥 Commits

Reviewing files that changed from the base of the PR and between 53ef075 and 5225505.

📒 Files selected for processing: 14
  • src/main/webhooks/webhook-config-security.test.ts
  • src/main/webhooks/webhook-rate-limiter.test.ts
  • src/main/webhooks/webhook-rate-limiter.ts
  • src/main/webhooks/webhook-server.test.ts
  • src/renderer/src/components/automations/AutomationWebhookSection.tsx
  • src/renderer/src/components/settings/WebhookServerSetting.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/shared/automation-webhook.test.ts
  • src/shared/automation-webhook.ts
  • tests/e2e/webhook-receiver-lifecycle.spec.ts
🚧 Files skipped from review as they are similar to previous changes: 3
  • src/renderer/src/components/automations/AutomationWebhookSection.tsx
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/ko.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant