Skip to content

Conversation

hoophalab
Copy link
Contributor

@hoophalab hoophalab commented Aug 7, 2025

Description

This PR adds support for cancelling Presto SQL queries.

  1. adds a new endpoint to webui server
  2. adds a cancel button
  3. put searchJobId in zustand store

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

  1. Run a big query in webui client: SELECT * FROM tpch.sf100000.orders
  2. Click cancel
  3. The query is cancelled in presto webui
cancel

Summary by CodeRabbit

  • New Features

    • Added a Cancel button to allow users to cancel ongoing Presto queries from the UI.
    • Introduced a dynamic search button that switches between "Run" and "Cancel" based on query state.
  • Enhancements

    • Prevents duplicate submissions by gating the Run action based on query lifecycle state.
    • Updated button styling for a more consistent, full-width layout.
  • Bug Fixes

    • Improved state handling and logging during query submission and cancellation.

@hoophalab hoophalab requested a review from a team as a code owner August 7, 2025 19:55
@hoophalab hoophalab requested a review from davemarco August 7, 2025 19:55
Copy link
Contributor

coderabbitai bot commented Aug 7, 2025

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

📥 Commits

Reviewing files that changed from the base of the PR and between 4171efa and b7a4a01.

📒 Files selected for processing (8)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/CancelButton/index.module.css (1 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/CancelButton/index.tsx (1 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/RunButton/index.module.css (1 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/RunButton/index.tsx (3 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/index.module.css (1 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlSearchButton/index.tsx (1 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/index.tsx (2 hunks)
  • components/webui/server/src/routes/api/presto-search/index.ts (2 hunks)
 _________________________________________________________________________________________________________
< If a system is to serve the creative spirit, it must be entirely comprehensible to a single individual. >
 ---------------------------------------------------------------------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).

Walkthrough

Adds Presto query cancellation: server POST /cancel route, client API call, request handlers integrating search UI state, a Cancel button and composite PrestoSearchButton component, and related CSS and minor RunButton updates.

Changes

Cohort / File(s) Change Summary
Server: Presto search route
components/webui/server/src/routes/api/presto-search/index.ts
New POST /cancel route that accepts PrestoQueryJobSchema, invokes Presto.client.kill(searchJobId, ...), and returns 204 on success or 500 on error; imports Type for response schema.
Client API: Presto search
components/webui/client/src/api/presto-search/index.ts
Adds cancelQuery(payload: PrestoQueryJobSchema): Promise<AxiosResponse<null>>, logs payload, posts to /api/presto-search/cancel, and exports it alongside submitQuery.
Request handlers / store integration
components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts
handlePrestoQuerySubmit now checks/updates searchUiState (uses useSearchStore) and sets QUERY_ID_PENDING then QUERYING; new handlePrestoQueryCancel checks state, sets DONE, and calls cancelQuery.
UI: PrestoSearchButton and subcomponents
components/webui/client/src/pages/SearchPage/SearchControls/Presto/PrestoSearchButton/index.tsx,
.../CancelButton/index.tsx,
.../RunButton/index.tsx
Adds PrestoSearchButton that renders CancelButton when state is QUERYING otherwise RunButton. CancelButton reads searchJobId and triggers cancel flow. RunButton import paths adjusted, reads searchUiState, applies styles, and disables when QUERY_ID_PENDING.
Styles: button and container CSS modules
components/webui/client/src/pages/SearchPage/SearchControls/Presto/PrestoSearchButton/index.module.css,
.../RunButton/index.module.css,
.../CancelButton/index.module.css
New CSS modules/ classes: .runButtonContainer (120px), .runButton (width:100%), .cancelButton (width:100%).
Integration: search controls
components/webui/client/src/pages/SearchPage/SearchControls/index.tsx
Replaces direct <RunButton/> usage with <PrestoSearchButton/> for the Presto branch.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant PrestoSearchButton
    participant RunButton
    participant CancelButton
    participant SearchStore
    participant ClientAPI
    participant Server

    User->>PrestoSearchButton: Click
    PrestoSearchButton->>SearchStore: read searchUiState
    alt state == QUERYING
        PrestoSearchButton->>CancelButton: render
        User->>CancelButton: Click Cancel
        CancelButton->>SearchStore: read searchJobId
        alt jobId present
            CancelButton->>SearchStore: set searchUiState = DONE
            CancelButton->>ClientAPI: cancelQuery(jobId)
            ClientAPI->>Server: POST /api/presto-search/cancel
            Server-->>ClientAPI: 204 No Content
            ClientAPI-->>CancelButton: success
        else jobId missing
            CancelButton-->>User: log error
        end
    else
        PrestoSearchButton->>RunButton: render
        User->>RunButton: Click Run
        RunButton->>SearchStore: read searchUiState
        alt state in [DEFAULT, DONE]
            RunButton->>ClientAPI: submitQuery(payload)
            ClientAPI->>Server: POST /api/presto-search/submit
            Server-->>ClientAPI: 200 (jobId)
            ClientAPI-->>RunButton: jobId
            RunButton->>SearchStore: set searchJobId, set searchUiState = QUERYING
        else
            RunButton-->>User: disabled / no-op
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • junhaoliao
  • kirkrodrigues

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Add the reviews.auto_title_instructions setting in your project's settings in CodeRabbit to generate a title for your PR based on the changes in the PR with custom instructions.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Copy link
Contributor

@davemarco davemarco left a comment

Choose a reason for hiding this comment

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

Looks good - have some style changes

@hoophalab hoophalab requested a review from davemarco August 8, 2025 23:09
coderabbitai[bot]

This comment was marked as resolved.

Copy link
Contributor

@davemarco davemarco left a comment

Choose a reason for hiding this comment

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

Small comments

coderabbitai[bot]

This comment was marked as resolved.

@hoophalab hoophalab requested a review from davemarco August 11, 2025 17:25
@davemarco
Copy link
Contributor

title looks good

Copy link
Member

@kirkrodrigues kirkrodrigues left a comment

Choose a reason for hiding this comment

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

Deferring to @davemarco's review.

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