Repository navigation
feat: add event patterns as a first-class dashboard tile type - #2604
Conversation
Event patterns can now be created, edited, and saved as dashboard tiles with full parity across the UI, MCP, and External API v2. - Add EventPatterns to the DisplayType enum and all exhaustive switches (rawSqlParams, constants, external API conversions) - Dedicated Pattern Expression input in the tile edit UI with the sources default body expression as placeholder - Fix config persistence: select is now correctly saved as a string for EventPatterns (was falling through to the series array path) - Fix source switching: override from/connection/select from the live source so stale columns dont leak into queries - Add isStringSelectDisplayType guard to consolidate the repeated Search/EventPatterns display-type checks - Add MCP tile schema to both save and patch unions so agents can create pattern tiles - Add External API v2 Zod schema and bidirectional conversion so pattern tiles round-trip through GET/PUT without downgrade - Remove variant prop from PatternTable - parent containers own bg - Hide PatternColumnSelector in dashboard/preview contexts
🦋 Changeset detectedLatest commit: 3576cdc The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🔴 Tier 4 — CriticalTouches auth, data models, config, tasks, OTel pipeline, ClickHouse, or CI/CD. Why this tier:
Review process: Deep review from a domain expert. Synchronous walkthrough may be required. Stats
|
Greptile SummaryThis PR promotes event pattern mining to a first-class dashboard tile type, wiring it end-to-end across the chart editor UI, dashboard rendering, MCP server, and External API v2. The
Confidence Score: 5/5Safe to merge — the new EventPatterns tile type is well-isolated and follows all existing conventions for config persistence, source resolution, and API schema design. The change is additive across all layers (UI, dashboard rendering, MCP, External API) without modifying any existing tile-type behavior. Config persistence, source-switching, and the bracket-aware single-expression guard are all correctly implemented. Round-trip tests cover the external API path, and the isStringSelectDisplayType refactor reduces duplication without altering Search behavior. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User selects Patterns tab in ChartEditor] --> B[ChartEditorControls renders Pattern Expression + WHERE inputs]
B --> C[Form state: select as string, series cleared]
C --> D{Save tile}
D --> E[convertFormStateToSavedChartConfig\nisStringSelectDisplayType stores select as string]
E --> F[(Dashboard DB\ndisplayType: event_patterns\nselect: expression or '')]
F --> G[Dashboard tile renders]
G --> H{isSingleExpression\nbracket-aware check}
H -->|valid single expr| I[PatternTable with custom bodyValueExpression]
H -->|empty or multi-column| J[PatternTable with source getEventBody default]
F --> K[External API GET /v2/dashboards]
K --> L[convertToExternalTileChartConfig\nstringValueOrDefault for select+where]
L --> M[EventPatternsChartConfig JSON response]
N[External API PUT / MCP create] --> O[externalDashboardEventPatternsChartConfigSchema\nZod validation + defaults]
O --> P[convertToInternalTileConfig\npick select+where]
P --> F
G --> Q[ChartPreviewPanel\noverrides from/connection/timestampValueExpression\nfrom live tableSource]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[User selects Patterns tab in ChartEditor] --> B[ChartEditorControls renders Pattern Expression + WHERE inputs]
B --> C[Form state: select as string, series cleared]
C --> D{Save tile}
D --> E[convertFormStateToSavedChartConfig\nisStringSelectDisplayType stores select as string]
E --> F[(Dashboard DB\ndisplayType: event_patterns\nselect: expression or '')]
F --> G[Dashboard tile renders]
G --> H{isSingleExpression\nbracket-aware check}
H -->|valid single expr| I[PatternTable with custom bodyValueExpression]
H -->|empty or multi-column| J[PatternTable with source getEventBody default]
F --> K[External API GET /v2/dashboards]
K --> L[convertToExternalTileChartConfig\nstringValueOrDefault for select+where]
L --> M[EventPatternsChartConfig JSON response]
N[External API PUT / MCP create] --> O[externalDashboardEventPatternsChartConfigSchema\nZod validation + defaults]
O --> P[convertToInternalTileConfig\npick select+where]
P --> F
G --> Q[ChartPreviewPanel\noverrides from/connection/timestampValueExpression\nfrom live tableSource]
Reviews (3): Last reviewed commit: "Merge branch 'main' into brandon/brandon..." | Re-trigger Greptile |
E2E Test Results✅ All tests passed • 227 passed • 3 skipped • 1500s
Tests ran across 4 shards in parallel. |
Deep ReviewMulti-agent review of PR #2604 (event patterns as a first-class dashboard tile type). 10 reviewers ran against the diff vs base ✅ No critical issues found. No data loss, auth, injection, or guaranteed-crash paths. The security reviewer confirmed the pattern-expression sink ( 🟡 P2 — recommended
🔵 P3 nitpicks (6)
Reviewers (10): correctness, security, adversarial, api-contract, kieran-typescript, testing, maintainability, project-standards, agent-native, julik-frontend-races. Testing gaps:
|
- Replace naive comma heuristic with bracket-aware isSingleExpression() helper so expressions like COALESCE(a, b) are not silently discarded as multi-column strings - Normalize where field via stringValueOrDefault in external API EventPatterns conversion, matching the Search arm - Add changeset for the feature
pulpdrew
left a comment
There was a problem hiding this comment.
This is great, and should also enable showing more MCP requests as Notebook Tiles!
Just a few thoughts / comments
- Show warning when pattern expression is multi-column and will be overridden with the source default - Add EventPatternsChartConfig to OpenAPI JSDoc spec and regenerate openapi.json - Add event_patterns tile to POST and PUT round-trip integration tests - Use minHeight instead of fixed height for event patterns preview
## Summary Event patterns can now be created, edited, and saved as dashboard tiles — with full support across the UI, MCP server, and External API v2. Previously, pattern mining was only available on the search page. Dashboard tiles had no way to persist a custom pattern expression, and the `PatternColumnSelector` used internal component state that was lost on reload. The MCP and External API schemas didn't include `event_patterns` at all, so agents and API consumers couldn't create or round-trip pattern tiles. ### What changed **Tile edit UI** — EventPatterns gets its own editor section with a "Pattern Expression" input (labeled, with the source's default body expression as placeholder) and a WHERE filter. This replaces the generic SELECT input that Search uses, which was semantically wrong for patterns. **Config persistence fix** — `convertFormStateToSavedChartConfig` and `convertFormStateToChartConfig` now correctly persist `select` as a string for EventPatterns (it was falling through to the `form.series` array path, discarding the user's input). A new `isStringSelectDisplayType` guard consolidates the repeated `Search || EventPatterns` checks across 4 call sites. **Source-switching fix** — The preview panel now overrides `from`, `connection`, `timestampValueExpression`, and `select` from the live `tableSource` (matching how the Search preview already works). This prevents stale columns from a previous source (e.g. `SeverityText` from a log source) from leaking into a trace-table query. The `bodyValueExpression` fallback also rejects multi-column strings (containing commas) to guard against pre-fix saved tiles that stored `defaultTableSelectExpression` as the pattern expression. **MCP** — New `mcpEventPatternsTileSchema` added to both the save and patch tile unions. Agents can create pattern tiles with `displayType: "event_patterns"`, `sourceId`, optional `select` (pattern expression), `where`, and `whereLanguage`. **External API v2** — New Zod schema + bidirectional conversion. Pattern tiles now round-trip through GET/PUT without being silently downgraded to line charts. **PatternTable cleanup** — Removed the `variant` prop (parent containers own the background). The `PatternColumnSelector` is now only shown when external handlers are provided (search page); dashboard/preview tiles configure the expression in the edit UI instead. ## Screenshots <img width="1663" height="819" alt="Screenshot 2026-07-07 at 4 13 42 PM" src="https://github.com/user-attachments/assets/50fdfd63-49aa-4475-a6da-ea91f9e723d2" /> <img width="1583" height="747" alt="Screenshot 2026-07-07 at 4 14 06 PM" src="https://github.com/user-attachments/assets/be2c386a-6ab2-46db-9c13-451b7de29eff" />
…hreads (#3464) ## Summary Today the review bot posts **every** finding it can anchor as an inline thread, at every severity, labelled with its own `critical`/`major`/`minor` self-estimate. Apart from #3138 (triage guidance for the author's agent), the reviewer has not changed since #3024. This PR adds a separate grading pass that assigns each finding a priority, posts only P0–P2 inline, and folds P3 into the sticky summary. It also stops reworded findings from being re-posted as new threads on later pushes. ## Production today vs this PR | | production (`main`) | this PR | |---|---|---| | Label users see | reviewer's own severity: 🔴 critical · 🟠 major · 🔵 minor | priority only: 🔴 P0/P1 · 🟡 P2 · 🔵 P3 (same icons as deep-review) | | Inline threads | every anchored finding | P0–P2 | | Folded into the summary | only `minor` findings that could not be anchored | every P3, anchored or not. Folded, never dropped | | Grading | none | a second pass (Sonnet, `Read` only) grades the finished findings. It cannot add, drop or reword them | | Reworded finding on a later push | opens a new thread (dedup keyed on the exact title) | recognised as the same finding | | Grading fails | n/a | nothing is folded; the review posts exactly as on `main` | ### How a finding's priority is decided (`effectivePriority` in `priority.cjs`) A finding is folded only when **both** graders call it low, and nothing says it matters today: - the reviewer itself labelled it `minor`, **and** - the grading pass put it at P2 or P3, **and** - the grader doesn't say the harm is reachable in the merged code, **and** - it doesn't read as security-related. Neither grader can fold anything on its own: a grader P3 on a finding the reviewer called major or critical is shown as P2. Without a grade, nothing is folded (critical → P0, major → P1, minor → P2). ## Measured against human votes Data: 👍/👎 reactions maintainers left on this bot's inline comments, covering **75 graded findings across 29 PRs** (53 👍, 22 👎) from 4 maintainers. Two kinds of vote are excluded: reactions cast by bots, and "blanket" votes, where one person thumbed ≥10 findings on a PR without a single 👎. The "this PR" column comes from running this branch's `effectivePriority` over the grading pass's output. | | production | this PR | |---|---|---| | Inline threads | 75 / 75 | **49 / 75** | | Folded as P3 | 0 | **26 (35%)** | | 👍 major/critical findings still inline | 17 / 17 | **17 / 17** | | 👎 findings folded | 0 / 22 | 8 / 22 | | 👍 findings folded | 0 | 18, all ones the reviewer labelled `minor` | So, on this sample, about a third fewer inline threads, with no upvoted major/critical finding hidden. The cost is 18 upvoted minor findings moving from inline threads into the folded section of the summary. ## Checked against the gold set The vote data can only see the severity the bot assigned. It can't tell whether a folded finding was one a human treated as **must-fix**. That's what the gold set measures. It contains human review comments on 30 past PRs (93 items, 29 of them must-fix). The deployed reviewer's findings on those PRs were re-graded with this PR's grading prompt and routed with this PR's rule, reusing the existing match judgements. | | production | this PR | same rule, no reachable-today floor | |---|---|---|---| | Inline threads | 122 (4.1/PR) | **93 (3.1/PR)** | 70 (2.3/PR) | | Must-fix items the reviewer caught | 10/29 | 10/29 | 10/29 | | …of those, folded out of the inline threads | 0 | **0** | **3** | Must-fix recall can't move, because grading never changes what was found. The column to read is the last row. The grader rated 3 of the 10 caught must-fix items P2, and the reviewer had labelled all 3 `minor`, so the minor-P2 fold alone would have hidden them: - #1410: deep-linked equality/range filters are silently dropped from the filter sidebar - #2604: OpenAPI spec not regenerated for the new tile type - #2696: `getRecentAlertGroupSummaries` has no DB-side document cap, unlike its sibling The reachable-today floor is what keeps all three inline. On this data it is the difference between hiding 0 and 3 of the 10. ## Dedup fix The cross-push dedup key was `file + exact title`, on the assumption that titles are stable between runs. They aren't. #3039 was reviewed four times in 2.3 hours, and one defect was posted three times under three titles; all three were thumbed down. Restatements are now matched by title-word overlap within the same file: at least 0.4 overlap **and** at least 3 shared content words. The second condition stops short titles like "Missing timeout in fetchUser" and "Missing retry in fetchUser" from merging. The threshold (0.4) was set from all 140 same-PR, same-file pairs of voted findings. Every pair scoring 0.36 or higher is a restatement. At 0.333, restatements collide with genuinely distinct findings. On #3129, "signs every user out on each container restart" and "still signs sessions with the public secret" are two real defects (the second critical) at exactly that score. So one known reword on #3039 is still missed rather than risk merging those two. Both cases are verbatim test fixtures. ## Limits and what isn't measured yet - **The gold-set result rests on 10 caught must-fix items** from one reviewer run (Sonnet; production runs Opus). Zero folded is the bar, but each item is worth 10 points. - **The votes are sparse and uneven.** There are 22 👎, mostly from two people whose thresholds differ ~4×, and only 1 of 197 voted comments has more than one reactor. - **The reachable-today floor costs volume.** In the vote sample it didn't separate 👍 from 👎 (~30% 👎 either way), and it lowers the fold rate there from 52% to 35%. On the gold set it is what keeps all 3 at-risk must-fix items visible, so the cost buys something. - **Premise findings.** The grading prompt describes findings that object to the change's premise as "published in their own section". This PR does not build that section; those findings are routed by priority like any other. - **Cost:** one more Sonnet call per reviewed push that has at least one finding. Not yet measured in CI. - **This PR's own review runs the old workflow,** because `pull_request_target` loads it from `main`. To exercise the new path before merge, dispatch **Claude Code Review** from this branch against an open PR. ## Test plan - [x] `node --test .github/scripts/code-review/__tests__/*.test.mjs`: 58/58. The priority rule and the title dedup live in `priority.cjs` and `dedup.cjs`. - [x] Workflow YAML parses; Prettier and knip clean on the changed files - [x] Ran the helpers over a real PR's findings and grades (#3258: 7 findings → 4 shown, 3 folded) - [ ] Dispatch from this branch on 2–3 open PRs and check the inline/folded split - [x] Gold-set check: 0 of 10 caught must-fix items folded (3 without the reachable-today floor) ## Also tried (not in this PR) - **The reviewer assigning P0–P3 itself, in a single pass.** Its grades were better calibrated, but it caught 7/29 must-fix items against 10/29 (one run each, so possibly noise). - **Folding all P2s, not just minor ones.** This hid 61% of comments but lost 4 of the 17 upvoted major/critical findings. - **Folding on the reviewer's `minor` label alone.** On the gold set it hid 46% of the findings humans treated as merge-blocking. - **Using `reachableToday` as the main signal.** It didn't distinguish 👍 from 👎 in the votes, so here it only acts as a floor. As a floor, it's what protects must-fix items on the gold set. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
Event patterns can now be created, edited, and saved as dashboard tiles — with full support across the UI, MCP server, and External API v2.
Previously, pattern mining was only available on the search page. Dashboard tiles had no way to persist a custom pattern expression, and the
PatternColumnSelectorused internal component state that was lost on reload. The MCP and External API schemas didn't includeevent_patternsat all, so agents and API consumers couldn't create or round-trip pattern tiles.What changed
Tile edit UI — EventPatterns gets its own editor section with a "Pattern Expression" input (labeled, with the source's default body expression as placeholder) and a WHERE filter. This replaces the generic SELECT input that Search uses, which was semantically wrong for patterns.
Config persistence fix —
convertFormStateToSavedChartConfigandconvertFormStateToChartConfignow correctly persistselectas a string for EventPatterns (it was falling through to theform.seriesarray path, discarding the user's input). A newisStringSelectDisplayTypeguard consolidates the repeatedSearch || EventPatternschecks across 4 call sites.Source-switching fix — The preview panel now overrides
from,connection,timestampValueExpression, andselectfrom the livetableSource(matching how the Search preview already works). This prevents stale columns from a previous source (e.g.SeverityTextfrom a log source) from leaking into a trace-table query. ThebodyValueExpressionfallback also rejects multi-column strings (containing commas) to guard against pre-fix saved tiles that storeddefaultTableSelectExpressionas the pattern expression.MCP — New
mcpEventPatternsTileSchemaadded to both the save and patch tile unions. Agents can create pattern tiles withdisplayType: "event_patterns",sourceId, optionalselect(pattern expression),where, andwhereLanguage.External API v2 — New Zod schema + bidirectional conversion. Pattern tiles now round-trip through GET/PUT without being silently downgraded to line charts.
PatternTable cleanup — Removed the
variantprop (parent containers own the background). ThePatternColumnSelectoris now only shown when external handlers are provided (search page); dashboard/preview tiles configure the expression in the edit UI instead.Screenshots