Repository navigation
Mount Columns and Sort on the search page - #3432
elizabetdev wants to merge 7 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
| export const toRows = (keys: SortKey[] | null): SortRow[] | null => | ||
| keys?.map(key => newSortRow(key.id, key.desc)) ?? null; | ||
|
|
||
| /** A comma inside backticks cannot be split without breaking the identifier. */ |
There was a problem hiding this comment.
🔵 minor — hasCommaInsideBackticks re-implements the backtick scan that splitClauseList already does, and less accurately
splitClauseList (packages/app/src/utils.ts:1302) in this same PR splits around backtick-quoted names through replaceBacktickedIdentifiers (common-utils/src/core/utils.ts:462). That helper also skips string literals, which this scanner does not: position(Body, ',') DESCis wrongly treated as a custom sort. UsesplitClauseListinparseSortKeysinstead of bailing out tonull`, and delete this helper.
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
| 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
5 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 5 minor 5 posted as inline comment(s) on the changed lines. Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
E2E Test Results✅ All tests passed • 458 passed • 1 skipped • 1840s
Tests ran across 4 shards in parallel. |
Deep Review✅ No critical issues found. This is a well-constructed UI relocation: SELECT/ORDER BY move off the query form into the 🟡 P2 — recommended
🔵 P3 nitpicks (3)
Reviewers (3): previous-comments, learnings-researcher, orchestrator-analysis. Coverage note: The remaining dispatched reviewers (correctness, adversarial, testing, maintainability, project-standards, kieran-typescript, julik-frontend-races, agent-native) had not returned results when synthesis was forced; the findings above come from the completed reviewers plus direct orchestrator analysis of every changed source path. No agent-native parity gap was identified — the change relocates the editing surface only. 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 |
|
|
||
| // SELECT and ORDER BY shape the results table, so they sit on that table | ||
| // and stay hidden on Event Deltas and Event Patterns. | ||
| const resultsClauseEditors = |
There was a problem hiding this comment.
🔵 minor — New toolbar element on every render defeats the memo on DBSqlRowTable and RawLogTable
resultsClauseEditors is a new JSX element on every DBSearchPageContent render. It is passed as toolbarLeading through DBSqlRowTableWithSideBar into the memoized DBSqlRowTable (components/DBRowTable.tsx:2071) and RawLogTable. The page memoizes every other prop to that table (useCallback/useMemo), but now any page render re-renders the whole virtualized table, for example each keystroke in the time picker input. Wrap resultsClauseEditors in useMemo, with its inputs as dependencies.
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
| </> | ||
| ); | ||
| }; | ||
| 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: db862a0 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
| // SELECT and ORDER BY shape the results table, so they sit on that table | ||
| // and stay hidden on Event Deltas and Event Patterns. | ||
| const resultsClauseEditors = | ||
| analysisMode === 'results' ? ( |
There was a problem hiding this comment.
🟠 major — resultsClauseEditors is a new element on every page render, so the memoized results table re-renders on every keystroke
toolbarLeading={resultsClauseEditors} gets a fresh JSX element each time DBSearchPageContent renders. That breaks memo on both DBSqlRowTable and RawLogTable (DBRowTable.tsx:2074 and :391), whose other props from DBSqlRowTableWithSidebar are stable. The page re-renders on every WHERE keystroke because of useWatch({ name: 'where' }) at line 1631, so the virtualized table now re-renders on each one. Fix: wrap resultsClauseEditors in useMemo, keyed on analysisMode, inputSelect, inputOrderBy, clauseFieldOptions, knownColumns, applySelect, applyOrderBy, inputSourceTableConnection, inputSource and searchedTimeRange.
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
| ); | ||
| }; | ||
| 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>
| </> | ||
| ); | ||
| }; | ||
| const applySelect = useCallback( |
There was a problem hiding this comment.
🔵 minor — applySelect copies the ORDER BY cleanup from toggleColumn
toggleColumn (lines 1851-1860) already does this: read getValues('orderBy'), apply orderByAfterRemovingSelectItem with defaultSearchConfig.orderBy, then setValue('orderBy'). Move it into one local helper, e.g. orderByWithout(items: string[]), and call it from both places so the two removal paths can't drift apart. The helper should also skip setValue when nothing changed, as toggleColumn does.
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
| </> | ||
| ); | ||
| }; | ||
| const applySelect = useCallback( |
There was a problem hiding this comment.
🔵 minor — No test covers the Columns and Sort apply logic on the search page
The PR says a removed column is also dropped from ORDER BY, but no test checks this. The DBSearchPage unit test mocks ColumnsPopover, SortPopover and useClauseFieldOptions with empty stubs. The changed e2e specs only read the button title. Add a test that removes a SELECT item that is also in ORDER BY through the Columns popover, then checks the submitted orderBy (or the search-sort-button title) after Apply.
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
Typing in the popover reopens the completion list over Apply, so the saved-search click never lands. Co-authored-by: Cursor <cursoragent@cursor.com>
| ); | ||
| }; | ||
| const applySelect = useCallback( | ||
| (select: string, removedItems: string[]) => { |
There was a problem hiding this comment.
🔵 minor — applySelect duplicates toggleColumn's logic for pruning the sort and resubmitting
toggleColumn (DBSearchPage.tsx:1838) already sets select, runs orderByAfterRemovingSelectItem with defaultSearchConfig.orderBy, and calls onSubmit. That is the same as applySelect(newSelect, selected ? [selected] : []). Declare applySelect before toggleColumn and have toggleColumn call it, so the removal-to-sort rule lives in one place.
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
| // SELECT and ORDER BY shape the results table, so they sit on that table | ||
| // and stay hidden on Event Deltas and Event Patterns. | ||
| const resultsClauseEditors = | ||
| analysisMode === 'results' ? ( |
There was a problem hiding this comment.
🔵 minor — A new toolbarLeading element on every render cancels the memo on DBSqlRowTable and RawLogTable
Every other prop passed to DBSqlRowTableWithSideBar is wrapped in useMemo or useCallback (rowTableContext, onSortingChange, initialSortBy, …). resultsClauseEditors is fresh JSX on each render, so the memoized DBSqlRowTable and RawLogTable in DBRowTable.tsx now re-render the virtualized results table on every page render. Wrap resultsClauseEditors in useMemo, keyed on its inputs.
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
An empty SELECT is shown as the source default. That default followed the URL source, so opening Columns after a source switch copied the previous source's column list. Co-authored-by: Cursor <cursoragent@cursor.com>
The raised footer also covered Fields autocomplete options that open inside the popover. Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
||
| // SELECT and ORDER BY shape the results table, so they sit on that table | ||
| // and stay hidden on Event Deltas and Event Patterns. | ||
| const resultsClauseEditors = |
There was a problem hiding this comment.
🔵 minor — resultsClauseEditors is a new JSX element on every render, which defeats the memo on DBSqlRowTable and RawLogTable
DBSqlRowTable and RawLogTable are both wrapped in memo (components/DBRowTable.tsx:355 and :2078). Passing a fresh toolbarLeading element means every DBSearchPageContent render now re-renders the whole results table. Wrap the element in useMemo, keyed on analysisMode, inputSelect, inputOrderBy, defaultSelect, clauseFieldOptions, the two apply callbacks, the connection, the source and the date range. Or pass the popovers' props down and let the table render 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
| // The dropdown source can move before the URL source does. An empty SELECT | ||
| // is shown as this default, so it has to follow the dropdown, the same way | ||
| // the sort default follows useDefaultOrderBy(inputSource). | ||
| const savedSelect = |
There was a problem hiding this comment.
🔵 minor — defaultSelect copies defaultSearchConfig's saved-search check and creates a second SELECT default
savedSelect repeats the _savedSearch gating in defaultSearchConfig (line ~1218). The only difference is that it uses inputSourceObj, while defaultSearchConfig.select uses searchedSource. Header column toggles (displayedColumns/toggleColumn, ~1832) and the Columns popover can therefore start from different defaults while the dropdown and URL sources differ. Expose the gated saved search (or both defaults) from the one memo instead of rebuilding the logic here.
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
| ); | ||
| }; | ||
| const applySelect = useCallback( | ||
| (select: string, removedItems: string[]) => { |
There was a problem hiding this comment.
🔵 minor — applySelect repeats toggleColumn's rule for pruning ORDER BY
toggleColumn (~line 1851) already runs getValues('orderBy'), then orderByAfterRemovingSelectItem(..., defaultSearchConfig.orderBy), then setValue. applySelect now does the same thing in a loop. Move this into one helper, e.g. orderByAfterRemovingSelectItems(items, orderBy, default) in utils.ts next to orderByAfterRemovingSelectItem, and call it from both places so the rule can't drift.
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
| wrap="nowrap" | ||
| // 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.
🔵 minor — The SQL-mode footer sits above the completion list and hides suggestions under Reset/Cancel/Apply
With zIndex: var(--mantine-z-index-max) on the footer, completion items that spill past the editor go underneath the footer's transparent row. Users see them overlap the button labels and cannot click them. Fix the list staying open after blur, which is the case the e2e applyClause works around. Or give the editor area room or a max height for the list, rather than layering the footer over it.
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
| ); | ||
| }; | ||
| const applySelect = useCallback( | ||
| (select: string, removedItems: string[]) => { |
There was a problem hiding this comment.
🔵 minor — No test covers the new Columns-apply wiring that drops removed columns from the sort
The PR description says removing a column drops it from the sort, but nothing tests the applySelect path. The e2e tests only set SELECT/ORDER BY through SQL, and DBSearchPage.directTrace.test mocks ColumnsPopover out. Add a test that removes an aliased column used in ORDER BY via Apply, and assert the resulting orderBy in the form or URL (including the fallback to the default sort).
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
| orderBy = orderByAfterRemovingSelectItem( | ||
| item, | ||
| orderBy, | ||
| defaultSearchConfig.orderBy ?? '', | ||
| ); |
There was a problem hiding this comment.
Removed columns leave broken sorts
Select upper(Body) AS message, set Sort to message DESC, then remove that column through Columns and Apply. applySelect calls orderByAfterRemovingSelectItem, but that helper only matches "message", not message. The search then fails because the removed alias no longer exists. Match valid quoted and unquoted alias references when dropping sort fields.
| onRelativeSearch={onTimePickerRelativeSearch} | ||
| showLive={analysisMode === 'results'} | ||
| isLiveMode={isLive} | ||
| // Default to relative time mode if the user has made changes to interval and reloaded. |
There was a problem hiding this comment.
My only major feedback is this works, but the page has 5 rows of elements before the search results appear. We should in the future consider how we can save vertical space. it looks very off with the amount of empty space is in the source/save column.. i feel like we could compact/rearrange further.
| } | ||
| : undefined | ||
| } | ||
| > |
There was a problem hiding this comment.
Feedback on this form: I got bit by this twice (I thought it was broken) so worth considering:
I added SeverityNumber but did NOT hit apply, it felt like clicking 'add' was saving. Then I clicked outside the popover and lost all my work. At the very least, we should confirm when closing without saving
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