Skip to content

Deeplink to Search From Charts and Tables - #1410

Merged
kodiakhq[bot] merged 20 commits into
mainfrom
brandon/chart-filtering
Nov 28, 2025
Merged

kodiakhq[bot] merged 20 commits into
mainfrom
brandon/chart-filtering

Conversation

@brandon-pereira

@brandon-pereira brandon-pereira commented Nov 25, 2025 •

Copy link
Copy Markdown
Member

This PR adds the ability to click on tables or graphs across the app, and be able to deep link into the search page to view the correlated search events.

deeplinking.mov

Things to try:

  1. Attributable Functions (min, max, average, p95, etc) can all reliably give us a y value back to enable filtering directly to the y-values value
  2. Non-attributable Functions (count, sum, etc) can’t rely on the y value since it depends on the group by logic. As such, these will simply allow you to search by the service without passing the y value for deeper analysis.
  3. Multiple Group Bys (ex ServiceName, SpanName)
  4. Where Clause (SQL or Lucene)
  5. Do a general test across the app to ensure everywhere that uses charting behaves the same or better than before.

Some things that don’t work:

  1. Aliases in the group by - we are hitting limitations with node-sql-parser that causes the aliasMap to not generate correctly when using aggregate functions in most cases. We may need to either fix these issues or find an alternative solution.
  2. Expressions in Group By - If you have expressions in the group by, the filtering will not work based on the current implementation, it does not factor in the result of the expression in the filter value.
  3. Filters are not reflected in the UI on Search - When you deeplink, the filters in the sidebar do not reflect what is actually being queried. This is because the filter UI logic uses IN but the deeplinking uses = to achieve the best level of precision (and avoid false positives). As such, this is something that could be improved in the future.

Fixes HDX-2844, HDX-2922

@changeset-bot

changeset-bot Bot commented Nov 25, 2025 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 513e110

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch

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

@vercel

vercel Bot commented Nov 25, 2025 •

Copy link
Copy Markdown

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

Project Deployment Preview Comments Updated (UTC)
hyperdx-v2-oss-app Ready Ready Preview Comment Nov 27, 2025 8:42pm

@claude

claude Bot commented Nov 25, 2025 •

Copy link
Copy Markdown

PR Review: Deeplink to Search From Charts and Tables

Critical Issues

SQL Injection vulnerability in ChartUtils.tsx:990 - column parameter is not escaped before being used in SQL condition. While value is escaped with SqlString.escape(), the column name itself is inserted directly into the SQL string. Fix: Validate/sanitize column names against a whitelist or use proper SQL identifier escaping.

SQL Injection vulnerability in ChartUtils.tsx:1005 - expression parameter is not escaped before being used in BETWEEN clause. Fix: Validate/sanitize expression against expected format or use proper escaping.

Important Issues

State synchronization issue in FilterRangeDisplay - When range prop changes externally, local state (localMin, localMax) won't update. Missing effect to sync props to state (lines 237-238). Fix: Add useEffect to update local state when range prop changes.

Unused props in FilterRangeDisplay signature - name and onClearClick props are declared but never used in the component body (lines 231-234). Fix: Remove unused props.

Quality Notes

Good use of SqlString.escape() for value escaping, proper TypeScript typing throughout, clear separation of concerns with buildEventsSearchUrl and buildTableRowSearchUrl, good UX with minimum drag distance to distinguish clicks from drags.

Summary

Must fix SQL injection vulnerabilities before merge. The column names and expressions need proper validation/escaping to prevent malicious input from being injected into SQL queries.

@github-actions

github-actions Bot commented Nov 25, 2025 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 46 passed • 3 skipped • 262s

Status Count
✅ Passed 46
❌ Failed 0
⚠️ Flaky 0
⏭️ Skipped 3

View full report →

@pulpdrew

Copy link
Copy Markdown
Contributor

Thoughts on usability:

  1. When I click and drag a particular time range on a graph, I wish I had the option to View Events for that entire range
  2. It's weird that when we navigate with a yValue range, that yValue range (BETWEEN condition) doesn't show up anywhere in the UI. It's also not clear to me how I can remove it.
  3. Sometimes when I click, it immediately changes the time range instead of showing a View Events button. I think this existed prior to these changes, but it's frustrating when it happens
  4. With some longer functions (eg. quantile) or group names, it's not possible to tell which series I am clicking on:
Screenshot 2025-11-26 at 2 34 06 PM

Comment thread packages/app/src/ChartUtils.tsx Resolved
Comment thread packages/app/src/searchFilters.tsx Resolved
Comment on lines +861 to +867
if (isMetricChart && source?.logSourceId == null) {
notifications.show({
color: 'yellow',
message: 'No log source is associated with the selected metric source.',
});
return null;
}

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.

I'm wondering, should we allow any deeplinking for metric charts? There are columns in metric tables which can be in the where which would result in there being an error when arriving on the search page.

If we do want to link metrics, should we just do so by time range and not include the filters/where?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Updated it to show this error if no log source exists. If it does exist, it still deeplinks but only on time range :)

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.

The user may want to link to traces insetad of logs, can do that as a follow up. Additionally, we can try to filter by resource attributes (if any).

@brandon-pereira

Copy link
Copy Markdown
Member Author

When I click and drag a particular time range on a graph, I wish I had the option to View Events for that entire range

@pulpdrew you cool if we punt this for now? I think ideally, on dragging we show a tooltip that gives an option between Zooming and Inspecting (naming TBD) which would be better as its own task

@pulpdrew

Copy link
Copy Markdown
Contributor

When I click and drag a particular time range on a graph, I wish I had the option to View Events for that entire range

@pulpdrew you cool if we punt this for now? I think ideally, on dragging we show a tooltip that gives an option between Zooming and Inspecting (naming TBD) which would be better as its own task

Yep!

@brandon-pereira

brandon-pereira commented Nov 26, 2025 •

Copy link
Copy Markdown
Member Author

It's weird that when we navigate with a yValue range, that yValue range (BETWEEN condition) doesn't show up anywhere in the UI. It's also not clear to me how I can remove it.

@pulpdrew Working on this one.. I originally built a UI For Min-Max Inputs but it felt not great because the numbers in this instance are massive. Thoughts on instead showing just that a filter has been applied, and a way to remove it (more UI work needed to hide no options found, pinning, etc)

Screenshot 2025-11-26 at 2 52 50 PM

@pulpdrew

Copy link
Copy Markdown
Contributor

It's weird that when we navigate with a yValue range, that yValue range (BETWEEN condition) doesn't show up anywhere in the UI. It's also not clear to me how I can remove it.

@pulpdrew Working on this one.. I originally built a UI For Min-Max Inputs but it felt not great because the numbers in this instance are massive. Thoughts on instead showing just that a filter has been applied, and a way to remove it (more UI work needed to hide no options found, pinning, etc)

Screenshot 2025-11-26 at 2 52 50 PM

Yeah IMO, showing that a filter has been applied and giving the user a way to remove it is probably key here. Allowing them to change it in some way other than clearing it could be an enhancement.

@brandon-pereira

Copy link
Copy Markdown
Member Author

Finally resolved all these conflicts! There was a lot!

@MikeShi42 this is ready for you now!

One heads up, we discussed in this PR that the previous data comparisons are not supported in drilling yet

export function buildTableRowSearchUrl({
row,
source,
config,

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.

Not for now since this implementation is complete, but would it be possible to instead generate URLs from the return data instead of the config? In theory - this will allow us to take any response from ClickHouse (including raw user-defined SQL queries) and still behave properly for table responses (which is why some other chart util functions use return type information as opposed to chart config information)

Comment on lines +861 to +867
if (isMetricChart && source?.logSourceId == null) {
notifications.show({
color: 'yellow',
message: 'No log source is associated with the selected metric source.',
});
return null;
}

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.

The user may want to link to traces insetad of logs, can do that as a follow up. Additionally, we can try to filter by resource attributes (if any).

@brandon-pereira

brandon-pereira commented Nov 27, 2025 •

Copy link
Copy Markdown
Member Author

@MikeShi42 fixed the ones you flagged, I'll open a followup for this:

The user may want to link to traces insetad of logs, can do that as a follow up. Additionally, we can try to filter by resource attributes (if any).

I'll also see how much of a lift it is to change the implementation to the row data instead of the chart config

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

Looks good, unfortunately this feature now stresses our filter bar logic a lot more and I think it exposes a few bugs in how we parse/split the filters object.

Something worth us looking at later to clean up the experience:

@kodiakhq
kodiakhq Bot merged commit 337be9a into main Nov 28, 2025
1 check passed
@kodiakhq
kodiakhq Bot deleted the brandon/chart-filtering branch November 28, 2025 21:26
knudtty pushed a commit that referenced this pull request Apr 16, 2026
This PR adds the ability to click on tables or graphs across the app, and be able to deep link into the search page to view the correlated search events. 

https://github.com/user-attachments/assets/e5c7c2f2-9b59-42de-bb73-2fa4cb5d09a2


Things to try:

1. **Attributable Functions** (min, max, average, p95, etc) can all reliably give us a y value back to enable filtering directly to the y-values value
2. **Non-attributable Functions** (count, sum, etc) can’t rely on the y value since it depends on the group by logic. As such, these will simply allow you to search by the service without passing the y value for deeper analysis.
3. **Multiple Group Bys** (ex `ServiceName, SpanName`)
4. **Where Clause** (SQL or Lucene)
5. Do a **general test** across the app to ensure everywhere that uses charting behaves the same or better than before.

Some things that don’t work:

1. **Aliases in the group by** - we are hitting limitations with `node-sql-parser` that causes the aliasMap to not generate correctly when using aggregate functions in most cases. We may need to either fix these issues or find an alternative solution.
2. **Expressions in Group By** - If you have expressions in the group by, the filtering will not work based on the current implementation, it does not factor in the result of the expression in the filter value.
3. **Filters are not reflected in the UI on Search** - When you deeplink, the filters in the sidebar do not reflect what is actually being queried. This is because the filter UI logic uses `IN` but the deeplinking uses `=` to achieve the best level of precision (and avoid false positives). As such, this is something that could be improved in the future.

Fixes HDX-2844, HDX-2922
kodiakhq Bot pushed a commit that referenced this pull request Nov 18, 2026
…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)

This branch was successfully deployed

1 active deployment
Preview — 513e1106 Deployed Nov 27, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants