Skip to content

feat(webui): Disable guided inputs while query running; Replace redundant "from" state with "dataset" state from native UI.#1465

Merged
davemarco merged 4 commits into
y-scope:mainfrom
davemarco:mode
Oct 23, 2025
Merged

Conversation

@davemarco

@davemarco davemarco commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Description

Sets disabled states while querying for guided components. Remove from state and use dataset state instead, since the from is not neccesary.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Components become disabled

Summary by CodeRabbit

  • New Features

    • Search controls (Select, Where, Order By, and query buttons) now auto-disable while queries are pending or running to prevent edits during active searches.
  • Refactor

    • Dataset selection state moved to a shared store; several guided controls no longer bind to local state and render as uncontrolled inputs.
    • Layout tweak: select control sizing changed to use flexible growth within its container.

@coderabbitai

coderabbitai Bot commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Migrates the Presto from field out of the Presto-specific zustand store into the global search store, makes DatasetSelect and TimestampKeySelect uncontrolled (removes their local Presto state bindings), and disables multiple Presto inputs/buttons during QUERY_ID_PENDING or QUERYING UI states.

Changes

Cohort / File(s) Summary
Presto State Management
components/webui/client/src/pages/SearchPage/SearchState/Presto/index.tsx
Removed from property from PrestoSearchState, removed from default in PRESTO_SEARCH_STATE_DEFAULT, and deleted updateFrom setter from the zustand store.
Uncontrolled Component Migration
components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/From.tsx, components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/TimestampKey/index.tsx
Removed usePrestoSearchState imports and removed value/onChange props passed to DatasetSelect and TimestampKeySelect, rendering them uncontrolled.
Query UI-state-based Disabling
components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/OrderBy.tsx, .../Select.tsx, .../Where.tsx
Added useSearchStore and SEARCH_UI_STATE usage; replaced static disabled={false} with a computed disabled when search UI state is QUERY_ID_PENDING or QUERYING.
Button Interaction Updates
components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlInterfaceButton/FreeformButton/index.tsx, .../GuidedButton/index.tsx
Added global useSearchStore + SEARCH_UI_STATE checks and applied computed disabled to button components during pending/querying UI states.
Run Button Source Migration
components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/RunButton/GuidedRunButton.tsx
Replaced from lookup from Presto state with useSearchStore.getState().selectDataset (renamed from) for query readiness checks.
Query Builder Update
components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-guided-search-requests.ts
buildPrestoGuidedQueries now retrieves selectDataset from the global search store (used as from) while other Presto fields remain read from Presto state; added null-checks accordingly.
CSS tweak
components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/index.module.css
.widthSelect changed from width: 100% to width: 0 with flex-grow: 1, switching to flexible width within flex layout.

Sequence Diagram(s)

sequenceDiagram
  participant UI as Guided Controls UI
  participant PrestoState as PrestoSearchState (zustand)
  participant GlobalStore as SearchStore (useSearchStore)

  Note over UI,PrestoState: Old flow (before changes)
  UI->>PrestoState: read `from`, `select`, `where`, `orderBy`, `timestampKey`
  PrestoState-->>UI: returns values
  UI->>UI: controlled inputs bind to Presto state
  UI->>PrestoState: update handlers call setters (e.g., updateFrom)

  Note over UI,GlobalStore: New flow (after changes)
  UI->>PrestoState: read `select`, `where`, `orderBy`, `timestampKey`
  UI->>GlobalStore: read `selectDataset` (as `from`) via getState / hooks
  UI-->>UI: DatasetSelect & TimestampKeySelect rendered uncontrolled (no state binding)
  GlobalStore-->>UI: provides `searchUiState` for disabling controls when QUERY_ID_PENDING/QUERYING
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Heterogeneous edits: state-shape change, multiple components updated to use a different store, and UI disabling logic applied consistently; requires checking state migrations, call-sites, and null-handling.

Possibly related PRs

Suggested reviewers

  • hoophalab
  • junhaoliao

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title clearly and accurately summarizes the two main objectives of the changeset. The first part—"Disable guided inputs while query running"—is directly supported by changes to OrderBy.tsx, Select.tsx, Where.tsx, FreeformButton, and GuidedButton, all of which now compute a disabled state based on searchUiState matching QUERY_ID_PENDING or QUERYING. The second part—"Replace redundant 'from' state with 'dataset' state from native UI"—is reflected across multiple files including From.tsx, TimestampKey/index.tsx, GuidedRunButton.tsx, presto-guided-search-requests.ts, and the removal of the from property from PrestoSearchState in Presto/index.tsx. The title is concise, specific, and avoids vague terminology or noise, making the primary changes immediately clear to someone reviewing the commit history.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 327b804 and e2a168b.

📒 Files selected for processing (1)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/index.module.css (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: package-image
  • GitHub Check: lint-check (macos-15)
  • GitHub Check: lint-check (ubuntu-24.04)
🔇 Additional comments (1)
components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/index.module.css (1)

33-36: CSS flexbox pattern applied correctly to fix overflow.

The change from width: 100% to width: 0; flex-grow: 1; is a standard and appropriate flexbox technique for handling dynamic content overflow in constrained containers. This allows the .widthSelect element to grow and shrink intelligently based on available space while preventing text overflow issues.

Please verify that:

  1. The dataset name overflow issue reported in review comments is now resolved (no text truncation or wrapping of long dataset names)
  2. The layout appears correct across different dataset name lengths and viewport sizes
  3. No visual regressions occurred in the flex container's child elements or siblings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@davemarco davemarco marked this pull request as ready for review October 22, 2025 18:00
@davemarco davemarco requested a review from a team as a code owner October 22, 2025 18:00
@davemarco davemarco requested a review from hoophalab October 22, 2025 18:01

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/RunButton/GuidedRunButton.tsx (1)

96-97: Appliquer la correction de guideline et corriger l'incohérence d'état désactivé.

Deux problèmes confirmés :

  1. Violation de guideline confirmée : La ligne 96 utilise !isQueryReady au lieu du format requis false == isQueryReady.

  2. Incohérence confirmée : Tous les autres contrôles guidés (Select, Where, OrderBy, FreeformButton, GuidedButton) désactivent pendant les deux états : QUERY_ID_PENDING et QUERYING. GuidedRunButton ne désactive que pendant QUERY_ID_PENDING, créant une incohérence comportementale.

Appliquer les corrections :

-                disabled={!isQueryReady ||
-                    searchUiState === SEARCH_UI_STATE.QUERY_ID_PENDING}
+                disabled={false === isQueryReady ||
+                    searchUiState === SEARCH_UI_STATE.QUERY_ID_PENDING ||
+                    searchUiState === SEARCH_UI_STATE.QUERYING}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8cebaa4 and 327b804.

📒 Files selected for processing (10)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/From.tsx (1 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/OrderBy.tsx (2 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/Select.tsx (2 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/TimestampKey/index.tsx (1 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/Where.tsx (2 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlInterfaceButton/FreeformButton/index.tsx (3 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlInterfaceButton/GuidedButton/index.tsx (3 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/RunButton/GuidedRunButton.tsx (1 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-guided-search-requests.ts (1 hunks)
  • components/webui/client/src/pages/SearchPage/SearchState/Presto/index.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • components/webui/client/src/pages/SearchPage/SearchState/Presto/index.tsx
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}

⚙️ CodeRabbit configuration file

  • Prefer false == <expression> rather than !<expression>.

Files:

  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/RunButton/GuidedRunButton.tsx
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlInterfaceButton/GuidedButton/index.tsx
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/From.tsx
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/Select.tsx
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/Where.tsx
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlInterfaceButton/FreeformButton/index.tsx
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-guided-search-requests.ts
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/OrderBy.tsx
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/TimestampKey/index.tsx
🧬 Code graph analysis (3)
components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlInterfaceButton/GuidedButton/index.tsx (1)
components/webui/client/src/pages/SearchPage/SearchState/typings.ts (1)
  • SEARCH_UI_STATE (31-31)
components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/Select.tsx (1)
components/webui/client/src/pages/SearchPage/SearchState/typings.ts (1)
  • SEARCH_UI_STATE (31-31)
components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlInterfaceButton/FreeformButton/index.tsx (1)
components/webui/client/src/pages/SearchPage/SearchState/typings.ts (1)
  • SEARCH_UI_STATE (31-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: conventional-commits
🔇 Additional comments (8)
components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/Where.tsx (1)

17-26: LGTM! Disabled state correctly applied.

The WHERE input now properly respects the query execution state, preventing user input during pending or active queries.

components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlInterfaceButton/GuidedButton/index.tsx (1)

17-29: LGTM! Guided button correctly disabled during query execution.

The implementation follows the same pattern as FreeformButton and properly prevents interface switching while a query is running.

components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/OrderBy.tsx (1)

17-26: LGTM! ORDER BY input correctly gated by query state.

The implementation is consistent with other guided controls and properly disables the input during query execution.

components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/Select.tsx (1)

17-26: LGTM! SELECT input correctly disabled during queries.

Consistent implementation with other guided controls.

components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/From.tsx (1)

11-22: No action required—DatasetSelect properly synchronizes with the global store.

The verification confirms that DatasetSelect manages its own state through useSearchStore:

  • It retrieves the current value via useSearchStore((state) => state.selectDataset)
  • It updates the store via the handleDatasetChange function, which calls updateDataset(value)
  • The internal Select component is controlled with both value={dataset} and onChange={handleDatasetChange}

From.tsx correctly delegates state management to DatasetSelect by passing only the className prop. When a user selects a dataset, the component immediately synchronizes the selection to the global store, making it available for GuidedRunButton.tsx to read via useSearchStore.getState().selectDataset.

components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/TimestampKey/index.tsx (1)

11-22: Review comment is incorrect.

TimestampKeySelect already properly manages and syncs with Presto state internally—it reads timestampKey and updateTimestampKey from usePrestoSearchState and implements a handleTimestampKeyChange handler that updates state on user selection. The component is controlled internally, not uncontrolled. Rendering it without explicit value/onChange props in the parent is a valid pattern; no changes needed.

Likely an incorrect or invalid review comment.

components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/RunButton/GuidedRunButton.tsx (1)

37-37: Based on my verification of the codebase, I can confirm that DatasetSelect is properly synchronizing its selection to useSearchStore.selectDataset. The component:

  1. Reads the current value from the store (line 22 of DatasetSelect.tsx)
  2. Obtains the updateSelectDataset function from the store (line 23)
  3. Updates the store when the user changes the selection through the handleDatasetChange callback (line 68)
  4. Maintains a controlled Select component with both value and onChange handlers connected to the store

The GuidedRunButton can safely access selectDataset via useSearchStore.getState() at line 37, as the store is kept in sync whenever the DatasetSelect component changes. No issues detected.

components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-guided-search-requests.ts (1)

69-70: Verification confirms null handling is correct; no changes required.

The selectDataset field is typed as string | null (line 85 of SearchState/index.tsx), with a default value of null (line 28). The strict equality check null === from at line 72 properly handles all possible values. Since the type does not include undefined, the current implementation is type-safe and follows TypeScript best practices. The state migration is complete and correct.

Comment on lines +17 to +19
const searchUiState = useSearchStore((state) => state.searchUiState);
const disabled = searchUiState === SEARCH_UI_STATE.QUERY_ID_PENDING ||
searchUiState === SEARCH_UI_STATE.QUERYING;

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.

🧹 Nitpick | 🔵 Trivial

Consider extracting the disabled state computation into a custom hook.

The same disabled state logic appears identically in at least 5 files (FreeformButton, GuidedButton, Where.tsx, OrderBy.tsx, Select.tsx). This code duplication could be eliminated by creating a custom hook like useIsQueryRunning() or useGuidedControlsDisabled().

Example refactor:

Create a new hook file useGuidedControlsDisabled.ts:

import useSearchStore from "../../SearchState/index";
import {SEARCH_UI_STATE} from "../../SearchState/typings";

/**
 * Returns whether guided controls should be disabled based on query execution state.
 */
const useGuidedControlsDisabled = (): boolean => {
    const searchUiState = useSearchStore((state) => state.searchUiState);
    return searchUiState === SEARCH_UI_STATE.QUERY_ID_PENDING ||
        searchUiState === SEARCH_UI_STATE.QUERYING;
};

export default useGuidedControlsDisabled;

Then in each component:

-    const searchUiState = useSearchStore((state) => state.searchUiState);
-    const disabled = searchUiState === SEARCH_UI_STATE.QUERY_ID_PENDING ||
-        searchUiState === SEARCH_UI_STATE.QUERYING;
+    const disabled = useGuidedControlsDisabled();

hoophalab
hoophalab previously approved these changes Oct 23, 2025

@hoophalab hoophalab 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 to me.
Validations: the inputs are disabled before query completes

@hoophalab

hoophalab commented Oct 23, 2025

Copy link
Copy Markdown
Contributor

We probably need to fix the dataset name overflow issue before the release. This feature is required by a user.
overflow

Since we are already modifying guided inputs in this PR, how about patching it quickly?

The following change fixes the issue -- any better ideas?

+++ b/components/webui/client/src/pages/SearchPage/SearchControls/Presto/GuidedControls/index.module.css
@@ -31,7 +31,8 @@
 }
 
 .widthSelect {
-    width: 100%;
+    width: 0;
+    flex-grow: 1;
 }

@davemarco

Copy link
Copy Markdown
Contributor Author

thanks - I made ur change

@hoophalab hoophalab requested a review from junhaoliao October 23, 2025 18:54

@junhaoliao junhaoliao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

deferring to @hoophalab 's review

@davemarco davemarco merged commit cb71d3b into y-scope:main Oct 23, 2025
19 checks passed
junhaoliao pushed a commit to junhaoliao/clp that referenced this pull request May 17, 2026
…dant "from" state with "dataset" state from native UI. (y-scope#1465)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants