Skip to content

feat(workflows): sim trigger, logs v2 block, toolbar renaming#4941

Merged
icecrasher321 merged 12 commits into
stagingfrom
feat/hooks-wf
Jun 10, 2026
Merged

feat(workflows): sim trigger, logs v2 block, toolbar renaming#4941
icecrasher321 merged 12 commits into
stagingfrom
feat/hooks-wf

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

  • Replace the notifications feature with a Sim trigger block — deployed workflows now run as side-effects of workspace events (execution success/error, deploys, and the ported alert rules: consecutive failures, failure/latency/cost thresholds, latency spikes, error counts, inactivity) with per-block cooldowns, credit-denominated thresholds, and loop prevention; all notification UI, APIs, tables, and background jobs are removed (migration 0231, requires the workspace-events-poll cron repoint in infra).

  • Add a Logs v2 block and canvas polish — Query Logs (run IDs with the full Logs-page filter set) + Get Run Details (trace spans, credit costs) for building log-driven automations; toolbar renamed (Blocks → Core Blocks, Tools → Integrations), multi-select inputs now summarize with +N chips, and shared subblock display resolvers keep editor/preview hydration consistent.

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

icecrasher321 and others added 6 commits June 9, 2026 20:05
…low SQL scoping

Code-review fixes: read the canonical workflowIds param in logs_v2 (the
serializer deletes the source pair ids), aggregate failure-rate in the DB
and switch rule windows to the indexed startedAt column, clamp rule config
to the legacy contract bounds, push no_activity watch scoping into SQL
before the LIMIT, fix the generated sim icon-map key, normalize docs
wording, and drop dead exports.

Co-authored-by: Cursor <cursoragent@cursor.com>
…splay module hygiene

Second-pass review fixes: round integer rule fields so fractional input
never reaches SQL LIMIT, gate workflow-name readiness on a successful
non-placeholder load in both editor and preview (errored loads mislabeled
valid workflows as deleted), lazily read the variables store in preview
rows, move the filter-field JSON preview into the shared display module
and unexport its single-consumer helpers, and align >= boundary copy
(failure rate, error count, cooldown window) with implementation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

# Conflicts:
#	apps/sim/app/workspace/[workspaceId]/logs/components/logs-toolbar/components/notifications/notifications.tsx
#	apps/sim/app/workspace/[workspaceId]/logs/logs.tsx
Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 10, 2026 5:59pm

Request Review

@cursor

cursor Bot commented Jun 10, 2026

Copy link
Copy Markdown

PR Summary

High Risk
Large removal of notification delivery paths and introduction of in-process workspace event triggering affects alerting behavior and execution side-effects; auth and webhook routing changes touch security-sensitive surfaces.

Overview
Replaces workspace log notifications (webhook/email/Slack subscriptions, Logs-page configuration UI, CRUD/test APIs, workflow notification email templates, and the workspace-notification-delivery background job) with deployed workflows driven by a Sim trigger for execution success/error, deploys, and the former alert rules (including no-activity via repointed workspace-events/poll cron).

Adds docs and icons for the Sim trigger and Logs block (query run IDs + get run details), and retargets External API docs away from notification webhooks toward the Sim trigger pattern.

Platform hardening and UX: internal sim/table trigger paths return 404 on forged HTTP deliveries; log-by-execution supports session or internal auth; editor toolbar labels become Core Blocks / Integrations; multi-select overlays use +N chips; subblock display logic moves to shared resolvers for canvas and preview (safer workflow-map hydration).

Reviewed by Cursor Bugbot for commit 140da44. Configure here.

@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces the notifications system with a Sim trigger block (workspace-event-driven workflow execution) and adds a Logs v2 block for log-driven automations. All notification UI, APIs, tables, and background jobs are removed; migration 0231 drops the two notification tables and creates sim_trigger_state for cooldown tracking.

  • Sim trigger: Deploys as a webhook-backed subscription; supports plain events (execution success/error, deploy) and rule-based alert conditions (consecutive failures, failure rate, latency threshold/spike, cost threshold, error count, no-activity). Cooldown state is keyed by (workflowId, blockId, scopeKey) so it survives redeploys. Loop prevention blocks self-triggering and sim-triggered executions are excluded from rule statistics.
  • Logs v2 block: Two operations — Query Logs (returns run IDs with the full filter set) and Get Run Details (trace spans, credits). Internal trigger providers are blocked from HTTP delivery at the webhook route layer.
  • Canvas polish: Shared display.ts module extracts subblock display logic from workflow-block.tsx for use in both the canvas editor and the read-only preview; toolbar labels renamed and multi-select inputs summarized with +N chips.

Confidence Score: 5/5

Safe to merge; the new event emission path is fully fire-and-forget and cannot affect existing execution flows.

The core event system (emitter, rules, state, subscriptions) is well-structured with correct atomic cooldown claiming, keyset-paginated no-activity polling, and loop-prevention guards. The only findings are non-blocking style observations — the two DB queries added per execution completion are fire-and-forget and do not affect correctness.

No files require special attention. The emitter and display resolver comments flag improvement opportunities but not correctness issues.

Important Files Changed

Filename Overview
apps/sim/lib/workspace-events/emitter.ts New execution-completion event emitter; includes loop-prevention, rule evaluation, and cooldown claiming. Two DB queries run on every non-sim-triggered execution even when no Sim-trigger subscriptions exist.
apps/sim/lib/workspace-events/no-activity.ts Keyset-paginated no-activity poller; previous ORDER BY and cap concerns from earlier reviews are fully addressed.
apps/sim/lib/workspace-events/state.ts Atomic cooldown claim via upsert with setWhere; correctly prevents concurrent double-fires. PK covers all lookup patterns.
apps/sim/lib/workspace-events/rules.ts Rule evaluation functions with correct DB-side aggregates and excludeSimExecutionsCondition guard. latency_threshold correctly fires on both success and error runs.
apps/sim/lib/workspace-events/subscriptions.ts Workspace-scoped subscription fetch with deployment-version join. parseSubscriptionConfig correctly bounds all numeric fields.
packages/db/migrations/0231_sim_trigger_workspace_events.sql Creates sim_trigger_state table and drops notification tables. CASCADE removes dependent rows; foreign key to workflow correctly uses cascade on delete.
apps/sim/blocks/blocks/logs.ts Adds LogsV2Block with query/get-run-details operations. canonicalParamId wiring for workflowSelector/manualWorkflowIds is consistent with existing block patterns. Time range to startDate conversion is correct.
apps/sim/tools/logs/query_runs.ts New Query Logs tool; correctly converts credit-denominated costValue to dollars before sending to the API. All optional params have proper null/undefined guards.
apps/sim/tools/logs/get_run_details.ts New Get Run Details tool; accesses executionData.totalDuration which matches the executionDataDetailSchema contract. Credit conversion applied correctly.
apps/sim/lib/workflows/subblocks/display.ts New shared display helper module; correctly extracted from workflow-block.tsx for use in both canvas and preview. Workflow multi-select detection relies on naming convention rather than an explicit marker.
apps/sim/app/api/webhooks/trigger/[path]/route.ts Correctly rejects HTTP deliveries to internal trigger providers (sim, table) with 404. Mixed internal+external path edge case is handled.
apps/sim/triggers/sim/workspace-event.ts Sim trigger config with full subblock definitions; excludeActiveWorkflow correctly prevents self-subscription. SIM_EVENT_PAYLOAD_FIELDS kept in sync via constants.
apps/sim/lib/workflows/orchestration/deploy.ts Adds fire-and-forget workflow_deployed event emission on deploy and version activation. void-dispatched so failures never affect the deploy result.
apps/sim/app/api/workspace-events/poll/route.ts Redis-locked cron endpoint for no-activity polling; runDetached pattern consistent with other polling routes.

Sequence Diagram

sequenceDiagram
    participant Exec as ExecutionLogger
    participant Emitter as workspace-events/emitter
    participant DB as Database
    participant Queue as Job Queue
    participant Subscriber as Subscriber Workflow

    Exec->>Emitter: emitExecutionCompletedEvent(log) [fire-and-forget]
    Emitter->>DB: getActiveWorkflowContext(workflowId)
    Emitter->>DB: fetchSimTriggerSubscriptions(workspaceId)
    loop for each matching subscription
        Emitter->>DB: readLastFiredAt(workflowId, blockId, scopeKey)
        alt within cooldown
            Emitter-->>Emitter: skip
        else
            Emitter->>DB: evaluateRule(eventType, config, context)
            Emitter->>DB: claimCooldown (atomic upsert)
            alt claimed
                Emitter->>Queue: processPolledWebhookEvent
                Queue->>Subscriber: execute workflow
            end
        end
    end

    Note over Emitter,DB: no_activity handled separately by pollNoActivityEvents() cron
    Note over Emitter,Queue: loop prevention: log.trigger === 'sim' → early return
Loading

Reviews (2): Last reviewed commit: "fix(workspace-events): skip no_activity ..." | Re-trigger Greptile

Comment thread apps/sim/lib/workspace-events/no-activity.ts Outdated
Comment thread apps/sim/lib/workspace-events/no-activity.ts Outdated
Comment thread apps/sim/lib/workspace-events/emitter.ts
icecrasher321 and others added 3 commits June 10, 2026 10:13
A fixed LIMIT 500 with no ORDER BY silently starved subscriptions beyond
the cap once the global count exceeded it. The poll now pages by webhook
id so every subscription is visited each cycle; pagination bounds memory,
not total work.

Co-authored-by: Cursor <cursoragent@cursor.com>
The 500-row LIMIT silently and deterministically excluded high-id
workflows from no_activity coverage in watch-everything subscriptions on
large workspaces. The scan now pages by workflow id, mirroring the
subscription scan; per-workflow checks move into a helper so the
pagination loop stays flat.

Co-authored-by: Cursor <cursoragent@cursor.com>
…n-completion path

no_activity is poller-owned and can never fire from a completed execution,
but it passed into the rule branch and cost a pointless cooldown point-read
per subscription on the hottest path. Early-continue alongside the
workflow_deployed guard.

Co-authored-by: Cursor <cursoragent@cursor.com>
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 140da44. Configure here.

Comment thread apps/sim/lib/workspace-events/rules.ts
…iled runs

Co-authored-by: Cursor <cursoragent@cursor.com>
It's a Sim-native capability (registry enrichments over a managed provider
cascade, like Search), not a third-party integration. Moves it to Core
Blocks in the toolbar, out of the integrations catalog, and relocates its
docs page to blocks/ with the icon-map allowlist keeping the docs card icon.

Co-authored-by: Cursor <cursoragent@cursor.com>
…rations

External-system connectors with host/credential auth belong under
Integrations, not Core Blocks — consistent with MongoDB, Redis,
ClickHouse, and the other datastore integrations. They already carried
integrationType and /tools docsLinks; the regenerated docs pages turn
those previously-dangling links into real pages, and the blocks join the
integrations catalog and icon maps.

Co-authored-by: Cursor <cursoragent@cursor.com>
@icecrasher321 icecrasher321 merged commit 6abcf82 into staging Jun 10, 2026
13 checks passed
ouiliame added a commit to ouiliame/sim-docs that referenced this pull request Jun 10, 2026
… blocks, re-shown DB integrations

Staging's simstudioai#4941 added the Sim workspace-event trigger (hand-written page adopted
into Core Triggers), the Enrichment and Logs blocks (category 'blocks' — added
to NATIVE_RESOURCE_BLOCK_TYPES so they live in the integrations catalog like
table/knowledge/memory), and re-categorized mysql/postgresql/sftp/smtp/ssh back
to visible tools (their pages return to the catalog). Generator sets merged as
the union of both sides (sim in HANDWRITTEN_TRIGGER_DOCS + SKIP_TRIGGER_PROVIDERS,
enrichment in the icon allowlist).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@waleedlatif1 waleedlatif1 deleted the feat/hooks-wf branch June 10, 2026 20:58
ouiliame added a commit to ouiliame/sim-docs that referenced this pull request Jun 10, 2026
… blocks, re-shown DB integrations

Staging's simstudioai#4941 added the Sim workspace-event trigger (hand-written page adopted
into Core Triggers), the Enrichment and Logs blocks (category 'blocks' — added
to NATIVE_RESOURCE_BLOCK_TYPES so they live in the integrations catalog like
table/knowledge/memory), and re-categorized mysql/postgresql/sftp/smtp/ssh back
to visible tools (their pages return to the catalog). Generator sets merged as
the union of both sides (sim in HANDWRITTEN_TRIGGER_DOCS + SKIP_TRIGGER_PROVIDERS,
enrichment in the icon allowlist).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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