Repository navigation
Mount Columns and Sort on the search page - #3432
elizabetdev wants to merge 21 commits into
Conversation
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
| const knownColumns = new Set(columns.map(column => column.name)); | ||
| // Field discovery is off for some teams, and `useAllFields` then returns | ||
| // [] rather than "still loading". Scalar columns are still known. | ||
| const keys = |
There was a problem hiding this comment.
🟠 major — Columns and Sort pickers never offer Timestamp or other DateTime fields, nor whole Map/JSON columns
getSqlSourceKeys/getSqlSourceColumnKeys (packages/app/src/components/AdhocDashboardFilter/useAdhocFilterOptions.ts:63-88) belong to the ad hoc filter. They drop every key where isAdhocComparableDataType (common-utils/src/filters.ts:963, !/\bDateTime/) is false, and they skip non-scalar top-level columns. So Timestamp/TimestampTime, the most common sort fields, never show up under 'Add sort' or 'Search columns', and neither does a whole column such as LogAttributes. Build the clause options from all columns plus map/JSON subpaths without the DateTime filter. Add a hook test with a DateTime64 column. The popover tests pass a hardcoded fieldOptions=['Body','Timestamp'], so they cannot catch this.
Nothing blocks merge automatically, but a maintainer will expect this fixed if it is a real defect in code this PR changes. If it is about surrounding code, reply and say so instead of patching. Do not widen the PR. How to respond
| isFieldMetadataDisabled || fields == null | ||
| ? getSqlSourceColumnKeys(columns) | ||
| : getSqlSourceKeys(fields, columns); | ||
| return Array.from( |
There was a problem hiding this comment.
🔵 minor — Keys are quoted twice; the second toQuotedClickHouseKeyExpression pass and its knownColumns set can't change anything
getSqlSourceKeys and getSqlSourceColumnKeys already run every key through toQuotedKeys → toQuotedClickHouseKeyExpression (useAdhocFilterOptions.ts:54-57), and that function leaves already-quoted input alone. Drop the extra .map(...) and the knownColumns set, and just dedupe and sort the keys.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
PR Review
1 finding(s): 🔴 0 P0/P1 · 🟡 1 P2 · 🔵 0 P3 Already reported on an earlier push — no new comments. 1 unchanged from an earlier push (already inline above). Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
E2E Test Results✅ All tests passed • 474 passed • 1 skipped • 1042s
Tests ran across 4 shards in parallel. |
Deep Review✅ No critical issues found. This PR moves SELECT/ORDER BY editing off the query form into Columns and Sort popovers on the results table (results mode only), prunes sorts whose alias a removed column dropped, and adds a discard-confirm flow when closing a popover with unsaved edits. I traced the core clause-resolution logic ( 🟡 P2 — recommended
🔵 P3 nitpicks (1)
Reviewers (1): direct multi-dimensional analysis (correctness, adversarial/edge-case, frontend-race, TypeScript, testing, maintainability, prior-comment resolution, agent-native). Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
| </> | ||
| ); | ||
| }; | ||
| const applySelect = useCallback( |
There was a problem hiding this comment.
🔵 minor — applySelect repeats toggleColumn's logic for pruning ORDER BY
applySelect repeats toggleColumn's steps (lines 1838-1872): set select, read orderBy with getValues, call orderByAfterRemovingSelectItem with defaultSearchConfig.orderBy, then setValue('orderBy'). Move this into one helper, for example pruneOrderByForRemovedItems(items), and call it from both places, so a change to the pruning rule cannot reach only one of them.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
🦋 Changeset detectedLatest commit: 1a4e6ad 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.
|
[Medium impact] The changes affect the search page and its results-table workflow. Fix sort cleanup for removed aliases before merging.
|
SELECT and ORDER BY move off the query form onto the results table, and the where row wraps under the time controls on a narrow form. Co-authored-by: Cursor <cursoragent@cursor.com>
2096af9 to
b5442e5
Compare
| ); | ||
| }; | ||
| const applySelect = useCallback( | ||
| (select: string, removedItems: string[]) => { |
There was a problem hiding this comment.
🔵 minor — applySelect repeats the ORDER BY pruning that toggleColumn already does
Lines 2307-2316 copy the getValues('orderBy') → orderByAfterRemovingSelectItem(..., defaultSearchConfig.orderBy) → setValue('orderBy') sequence from toggleColumn at lines 1851-1860. Move it into one local helper, for example pruneOrderByForRemoved(items: string[]), and call it from both, so the two column-removal paths can't drift apart.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
Columns, Sort, and the table actions move onto another line instead of overlapping when the results panel is narrow. Co-authored-by: Cursor <cursoragent@cursor.com>
…is empty An empty form ORDER BY means "use the saved sort". The helper treated the empty string as already clean, so removing an aliased column after resetting Sort left the saved alias sort in the query and it failed on an unknown identifier. Run the empty case through the same alias removal. Co-authored-by: Cursor <cursoragent@cursor.com>
The popover handles Escape before the input does, so closing the column or sort suggestions also closed the popover and dropped the text that had not been added yet. Skip that close while the suggestion list is open. Co-authored-by: Cursor <cursoragent@cursor.com>
Changing an aliased column's expression or the case of AS (for example upper(Body) AS message to lower(Body) AS message) counted the old item as removed. The sort on the alias was then dropped even though the alias was still selected. Ignore a removed item whose alias is still in the new SELECT. Co-authored-by: Cursor <cursoragent@cursor.com>
| wrap="wrap" | ||
| // The SQL completion list overflows the editor onto these buttons. | ||
| // Fields mode uses an in-popover Autocomplete, which must stay above them. | ||
| style={ |
There was a problem hiding this comment.
🟡 P2 — SQL-mode footer at max z-index covers the completion entries it overlaps
The comment says the CodeMirror completion list spills onto the footer. Raising the Reset/Cancel/Apply row to --mantine-z-index-max puts those buttons on top of the list (.cm-tooltip is z-index 100 in the same dropdown stacking context). On a short Sort editor, completion entries under the buttons can't be seen or clicked. Keep the footer below the tooltip. If Apply has to stay clickable, use tooltips({ position: 'fixed', parent }) or reserve space under the editor instead of stacking the buttons over the list.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
Not changing this. Apply has to stay reachable when the completion list is open, so the footer stays above the list. Raising the .cm-tooltip above it would also cover the Reset/Cancel/Apply row. Left as is.
| if (availableWidth > 0) { | ||
| elements.floating.style.maxWidth = `${availableWidth}px`; | ||
| } | ||
| if (availableHeight > 0) { |
There was a problem hiding this comment.
🟡 P2 — maxHeight from the size middleware has no effect without overflow
Mantine's Popover.Dropdown sets no overflow. Content taller than availableHeight therefore spills past the capped box, and on a short viewport Apply still ends up off screen. Add overflowY: 'auto' to the dropdown, or to an inner scroll wrapper that excludes the footer, so the cap actually keeps Apply reachable.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
Not changing this. Adding overflow: auto to the dropdown clips the Fields autocomplete and the SQL completion list, which was the earlier overflow thread. The height cap keeps the popover inside the viewport; the list itself can still extend past the popover's box. Left as is.
Apply stores an empty SELECT when the draft matches the default. The alias check then read no aliases from the new SELECT and dropped a sort on an alias the default still defines. Check against the effective SELECT instead. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the phone search-row layout, and hide live tail while the duration heatmap is open. Co-authored-by: Cursor <cursoragent@cursor.com>
| // The SQL completion list overflows the editor onto these buttons. | ||
| // Fields mode uses an in-popover Autocomplete, which must stay above them. | ||
| style={ | ||
| mode === 'sql' |
There was a problem hiding this comment.
🟡 P2 — In SQL mode the footer is raised above the autocomplete list, so suggestions behind it can't be seen or clicked
The footer Group spans the full popover width and gets position: relative; z-index: var(--mantine-z-index-max). The CodeMirror tooltip renders inside the editor (ColumnsPopover and SortPopover pass no parentRef), and it ends up under this footer, so any completion rows that overlap the Reset/Cancel/Apply row are hidden and can't be clicked. The e2e applyClause helper has to work around this. Fix: let the completion list render above the footer, for example by passing parentRef={document.body} to SQLInlineEditor or by giving the editor a higher stacking context, rather than raising the footer to max z-index.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
Not changing this. Raising the footer is what keeps Apply clickable while the SQL completion list is open. Passing parentRef would move the list out of the popover, and I have not verified that it stays clickable under the footer. Left as is; the e2e helper works around it.
The merge added them so the pre-commit warning check would pass. The app one puts eslint-disable above its baseline, which fails the lint job. Co-authored-by: Cursor <cursoragent@cursor.com>
| elements.floating.style.maxWidth = `${availableWidth}px`; | ||
| } | ||
| if (availableHeight > 0) { | ||
| elements.floating.style.maxHeight = `${availableHeight}px`; |
There was a problem hiding this comment.
🟡 P2 — The size middleware caps the dropdown's maxHeight, but nothing in the dropdown scrolls
Mantine's Popover.Dropdown does not set overflow by default. On a short viewport the Stack (including Apply/Cancel) therefore spills outside the bordered dropdown instead of scrolling. Put overflowY: 'auto' on an inner wrapper around the mode content, not on the footer, so the SQL completion list is not clipped. Or drop the maxHeight cap.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
Not changing this. It is the same overflow question as the earlier thread. overflowY: auto on the dropdown or a wrapper would clip the Fields and SQL completion lists, so the height cap keeps the popover on screen and leaves the lists unclipped. Left as is.
Apply stores an empty SELECT or sort when the draft matches the default. On a saved search the default is the saved clause, so Update wrote the source default SELECT and cleared the sort. Save the clause the results table runs: the saved one when the form is blank, else the source default. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Moves SELECT and ORDER BY off the query form. On a results search, Columns and Sort sit on the results table and edit those clauses. Event Deltas and Event Patterns do not show them. On a form narrower than 900px, the where clause and the time controls each take a full row, with the where clause first. Columns and Sort wrap with the table actions instead of overlapping them.
The editors landed in #3431.
Screenshots were not captured.
Screenshots or video
How to reproduce
Starting point:
yarn app:dev:localconnected to the demo server, or the Vercel preview. Open a log search and run it.On
main:On this branch:
How to test on Vercel preview
Preview routes: /search
Steps:
References