Skip to content

improvement(logs-block): filter runs by trigger type - #6824

Merged
waleedlatif1 merged 5 commits into
stagingfrom
feat/logs-block-trigger-filter
Aug 18, 2026
Merged

improvement(logs-block): filter runs by trigger type#6824
waleedlatif1 merged 5 commits into
stagingfrom
feat/logs-block-trigger-filter

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a trigger-type filter to the Logs block, so a query can be scoped to how the run started (API, Chat, manual, schedule, webhook providers, etc.)
  • Basic mode is a multi-select of the same options the Logs page offers — core trigger types plus every registered webhook provider — and advanced mode is a comma-separated field for anything not in the list. Both sit behind the canonical triggers param, matching the block's existing workflow filter
  • Options that share a label are merged into a single entry whose id is the comma-joined set of values, so the reader never sees two identical rows
  • Backwards compatible: the filter is new and defaults to empty, which omits the param entirely — existing Logs blocks query exactly as they did before

No backend work was needed. The logs_query_runs tool, the /api/logs contract, and the indexed trigger column already accepted a comma-separated triggers list; only the block was missing the control.

Type of Change

  • Improvement (enhancement to existing functionality)

Testing

Tested manually. Added unit tests covering the param mapping (empty filter omits triggers, multi-select joins, merged ids flatten, advanced string trims, run-details never sends it) and the option merge — verified they fail when the change is reverted. bun run check:audits (29 audits), bun run lint, bun run type-check, and the block-registry subblock-ID stability check all pass.

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)

The Logs block could filter runs by workflow, status, time, cost, and
duration, but not by how the run started — even though the underlying
tool, the /api/logs contract, and the indexed trigger column all already
accepted a comma-separated triggers filter.

Adds a basic multi-select and an advanced free-text field behind the
canonical `triggers` param, mirroring the block's existing workflow
filter. Options come from the same registry the Logs page reads, so both
surfaces name a run's origin identically; values sharing a label are
merged into one option. Leaving the filter empty omits the param, so
existing blocks query exactly as before.
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 18, 2026 10:37pm

Request Review

@cursor

cursor Bot commented Aug 18, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Block UI and param normalization only; empty default preserves prior queries, and joinIds regressions are explicitly tested for workflow and status filters.

Overview
Adds a trigger-type filter to the Logs V2 block’s Query Logs operation, aligned with the Logs page: basic multi-select (triggerSelector) and advanced comma input (manualTriggers) both map to the canonical triggers param sent to logs_query_runs. Empty selections omit triggers so existing blocks behave unchanged; Get Run Details still only sends runId.

joinIds now splits each entry on commas and trims every token (so merged option ids like copilot,mothership and hand-typed values work with downstream filters). Tests assert workflowIds and level stay unchanged for typical stored values.

fetchTriggerTypeOptions loads the same trigger vocabulary via a lazy import of getTriggerOptions, merges options that share a label into one dropdown row (comma-joined id), and is covered by unit and live-registry tests.

Reviewed by Cursor Bugbot for commit 70e6841. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR adds trigger-type filtering to the Logs block while preserving unfiltered behavior for existing configurations.

  • Adds basic and advanced trigger controls mapped to the canonical triggers parameter.
  • Normalizes selected or manually entered trigger values into the API’s comma-separated string format.
  • Lazily loads and merges trigger options that share a display label.
  • Adds focused unit and live-registry coverage for parameter mapping and option generation.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/logs.ts Adds trigger filtering and correctly declares the transformed canonical input as a string, resolving the prior coercion issue.
apps/sim/blocks/blocks/logs.test.ts Covers trigger normalization, operation scoping, backward compatibility, and the corrected input declaration without explicit any.
apps/sim/lib/workflows/subblocks/options.ts Adds lazy trigger-option loading and deterministic merging of entries with identical labels.
apps/sim/lib/workflows/subblocks/options.test.ts Verifies merged option identifiers and preservation of registry ordering.
apps/sim/lib/workflows/subblocks/trigger-options-live.test.ts Confirms the lazy import resolves against the real registries and produces populated, uniquely labeled options.

Reviews (5): Last reviewed commit: "test(logs-block): exercise the trigger o..." | Re-trigger Greptile

Comment thread apps/sim/blocks/blocks/logs.ts
Comment thread apps/sim/blocks/blocks/logs.test.ts Outdated
Comment thread apps/sim/blocks/blocks/logs.ts
The generic handler JSON.parses any post-transform input declared 'array'
or 'json'. Since `joinIds` has already turned the selection into a
comma-separated string by then, the array declaration logged a parse
warning on every run, and JSON-looking advanced input would have been
turned into an array the tool does not accept.

Matches the legacy Logs block, which already declares triggers as a
string, and locks the invariant with a test. Also drops `any` from the
new test helper.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

joinIds trimmed only the ends of an advanced-mode string, so a hand-typed
'api, schedule, slack' reached the query as ' schedule' and ' slack'. The
filters split on commas without trimming, so those tokens matched no
stored trigger and the filter silently returned nothing.

Splits and trims every entry instead, which also covers empty tokens from
a trailing comma and the multi-value ids behind merged trigger labels.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit fd50a97. Configure here.

joinIds is shared with the workflow and status filters, so the per-entry
trimming added for hand-typed triggers must not move their output. Covers
every value a stored multi-select or advanced field can hold, plus the
block-saved-before-the-filter case where triggers must not reach the query.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e1b61f5. Configure here.

The fetcher reaches the block and trigger registries through a lazy import
to avoid an initialization cycle, so a mocked test cannot show that the
import resolves or that the registry is populated when the dropdown asks.
Covers the populated list, unique labels, and the merged Sim agent option.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 70e6841. Configure here.

@waleedlatif1
waleedlatif1 merged commit 0c09f1d into staging Aug 18, 2026
24 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/logs-block-trigger-filter branch August 18, 2026 22:42
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