Repository navigation
Mount Columns and Sort on the search page - #3432
elizabetdev wants to merge 26 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
3 finding(s): 🔴 0 P0/P1 · 🟡 2 P2 · 🔵 1 P3 Already reported on an earlier push — no new comments. 3 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 • 1133s
Tests ran across 4 shards in parallel. |
Deep ReviewScope: PR #3432 — mounts the SELECT (Columns) and ORDER BY (Sort) clause editors as popovers on the results-table toolbar (results mode only), refactors the alias-stripping/sort-fallback helpers in Intent (author-stated, advisory): move clause editing off the query form onto the results table without regressing saved-search behavior or sort cleanup when columns are removed. ✅ No critical issues found. The core 🟡 P2 — recommended
🔵 P3 nitpicks (2)
Reviewers (3): correctness (orchestrator trace of Testing gaps: No automated coverage asserts the Escape-passthrough behavior survives a Mantine/CodeMirror DOM change; the in-place-edit blur-vs-Enter-vs-Escape single-commit path is exercised only indirectly. 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: 2d920b5 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>
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>
Picking a suggestion in the Columns popover only filled the input, so adding a column took a second click on Add. It now adds the column right away, the same way the Sort popover does. Add stays for typed expressions. Rows in the column list can now be edited in place, so an alias such as tz can be renamed without switching to the SQL tab. Escape in the edit field cancels the edit without discarding the popover draft.
|
Re this comment: fixed in 2f7bd71. Picking a suggestion in the Columns popover now adds the column right away, like Sort does. Map keys still get their alias. Add stays for typed expressions such as |
|
Re this comment: fixed in 2f7bd71. Columns in the list can now be edited in place. Click a column, or its pencil icon, change the expression (for example the |
| // Lets ClausePopover pass Escape through instead of discarding. | ||
| data-handles-escape | ||
| data-testid="search-columns-edit-input" | ||
| /> |
There was a problem hiding this comment.
🟡 P2 — An unfinished inline column edit is lost without a prompt when the user clicks outside the popover
The inline edit is only written to ColumnsPopover's draft on blur. Mantine's click-outside handler runs on mousedown, which fires before the input loses focus, so requestClose sees dirty === false and closes the popover. The blur-time onEdit then runs on a closed popover, and the next onOpen overwrites the draft. To fix it, report the in-progress edit up to ClausePopover so it counts toward dirty (for example an onEditingChange(dirty) callback), or commit the edit on pointerdown/mousedown outside the row before ClausePopover reads dirty.
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
| if (aliases.length === 0) return undefined; | ||
| // An alias can be written bare, double-quoted, or backtick-quoted in ORDER BY | ||
| const aliasKeys = new Set( | ||
| aliases.flatMap(alias => [alias, `"${alias}"`, `\`${alias}\``]), |
There was a problem hiding this comment.
🟡 P2 — Matching bare aliases now drops sorts on real table columns
orderByWithoutAliases now also matches the unquoted alias. This affects both the header toggle (toggleColumn → orderByAfterRemovingSelectItem) and Columns Apply. Example: SELECT Timestamp, lower(ServiceName) AS ServiceName with sort ServiceName ASC. Removing that item resets the sort to the default, even though ServiceName is still a real column ClickHouse can sort by. Fix: skip the bare form when the alias is in knownColumns, or only strip the bare form when it is not a source column.
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
Conflicts were in three test files: - searchFilters.test.ts and filterSources.test.ts: both sides fixed the same lint warnings. Took main's version, so this PR no longer touches them. - utils.test.ts: kept this PR's imports and dropped orderByStringToSortingState and sortingStateToOrderByString, which main removed from utils.ts in #3746. Committed with --no-verify: the pre-commit oxlint check counts every line merged from main as new and flagged 5 warnings in code this PR does not touch.
The inline edit field was a single-line input, so a long expression such as a map key with an alias scrolled sideways and was hard to edit. Use an auto-growing textarea in the same monospace font and wrapping as the row, and place the caret at the end. Pasted line breaks are collapsed to spaces because a column is a single expression.
Long column names such as LogAttributes['browser.resource_timing...'] were clipped in the suggestion list, and the clipped part is the part that tells similar names apart. Let options wrap and widen the dropdown, capped to stay inside the popover.
The inline column edit only reached the popover draft on blur, but the click-outside check runs on mousedown, before blur. A click outside the popover during an edit therefore closed it with no prompt. Unadded search text had the same gap. The edit now lives in ColumnsPopover, so an edit with a changed value and search text not yet added count as unsaved. Escape in the edit field still cancels only that edit, as before. Escape while the suggestion list is open also prompted once search text counted as unsaved. The list is a sibling of its input, so the Escape check missed it. The check now also looks for an open listbox in the same popover.
|
LGTM - Ideally we should get a second review (cc @teeohhem) plus - can we make sure product is aligned (Mike or Alex) if not already? |
|
Thanks, @brandon-pereira. Yes, @alex-fedotyev is aligned on this, and I’ve already shown it to Mike. I’ll wait for @teeohhem’s review. |


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