Skip to content

Conversation

davemarco
Copy link
Contributor

@davemarco davemarco commented Aug 4, 2025

Description

PR focuses input box when user enters search page, and when search completes.

Resolves #1068. Not exactly sure what the best way to "return to whatever input the user used before starting the query" mentioned in the issue, so for now it just refocuses on the input when the query completes.

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

Tested it focuses on input on load, and on query success.

Summary by CodeRabbit

  • New Features
    • The query input box now automatically receives focus when the search interface is in its default or completed state, improving usability.

Copy link
Contributor

coderabbitai bot commented Aug 4, 2025

Walkthrough

The changes update the query input box to support React refs, enabling programmatic focus control. A ref is created and attached to the input component on the search page. An effect monitors the search UI state and automatically focuses the input when entering specific states, improving usability for user workflows.

Changes

Cohort / File(s) Change Summary
Input Ref Forwarding Support
components/webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx
Updated InputWithCaseSensitiveProps type to include React.RefAttributes<InputRef>, enabling ref forwarding.
Query Input Focus Management
components/webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx
Introduced inputRef, attached it to the query input, and added effect to focus input on certain UI state changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SearchPage
    participant QueryInput
    participant QueryBox

    User->>SearchPage: Navigates to search page
    SearchPage->>QueryInput: Renders QueryInput
    QueryInput->>QueryBox: Passes inputRef via ref
    QueryInput->>QueryBox: Renders QueryBox
    QueryInput->>QueryBox: inputRef attached
    Note over QueryInput: searchUiState changes to DEFAULT or DONE
    QueryInput->>QueryBox: Calls inputRef.current?.focus()
    QueryBox->>User: Input is focused
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Focus/refocus query input box for ease of use (#1068)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Suggested reviewers

  • hoophalab
  • junhaoliao

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 581bd46 and a4f6cb5.

📒 Files selected for processing (2)
  • components/webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx (2 hunks)
  • components/webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx (3 hunks)
🧰 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/QueryInput/index.tsx
  • components/webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx
🧠 Learnings (4)
📓 Common learnings
Learnt from: haiqi96
PR: y-scope/clp#0
File: :0-0
Timestamp: 2025-07-29T14:04:13.769Z
Learning: User haiqi96 requested creating a GitHub issue to document a bug fix from PR #1136, which addressed MySQL compatibility issues with invalid SQL CAST operations in the WebUI component.
📚 Learning: in components/log-viewer-webui react codebase: return type annotations (like `: jsx.element`) are un...
Learnt from: junhaoliao
PR: y-scope/clp#937
File: components/log-viewer-webui/client/src/AntdApp.tsx:16-24
Timestamp: 2025-05-29T20:33:40.653Z
Learning: In components/log-viewer-webui React codebase: Return type annotations (like `: JSX.Element`) are unnecessary and not preferred for React components in JSX/TSX files.

Applied to files:

  • components/webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx
  • components/webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx
📚 Learning: in the y-scope/clp react webui client codebase, for zustand store usage: use `usestore.getstate().me...
Learnt from: hoophalab
PR: y-scope/clp#1108
File: components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlQueryInput/index.tsx:15-15
Timestamp: 2025-07-18T20:00:50.288Z
Learning: In the y-scope/clp React webui client codebase, for Zustand store usage: use `useStore.getState().method` for callbacks since the output is not reactive and doesn't need state as a dependency in the hook, and use `useStore((state) => state.property)` with proper selectors for reactive components that need to re-render when state changes.

Applied to files:

  • components/webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx
📚 Learning: in `components/log-viewer-webui/client/src/api/query.js`, the `extractjsonresp` type definition is a...
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.

Applied to files:

  • components/webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx
⏰ 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: lint-check (macos-15)
🔇 Additional comments (6)
components/webui/client/src/components/QueryBox/InputWithCaseSensitive/index.tsx (2)

4-4: LGTM: InputRef import added correctly.

The import addition supports the ref forwarding functionality required for the focus behavior.


13-14: LGTM: Type definition properly extended for ref forwarding.

The addition of React.RefAttributes<InputRef> to the type definition correctly enables ref forwarding to the underlying Ant Design Input component, which is essential for the focus functionality.

components/webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx (4)

9-9: LGTM: InputRef type import added correctly.

The import supports the ref typing for the focus functionality.


32-32: LGTM: Input ref created with proper typing.

The ref is correctly typed as InputRef and initialized with null, following React ref patterns.


72-79: LGTM: Focus behavior implementation matches PR objectives.

The useEffect correctly implements the requested focus behavior:

  • Focuses input on page load (DEFAULT state)
  • Refocuses input after search completion (DONE state)
  • Uses optional chaining for safe access to the ref
  • Proper dependency array with searchUiState

This addresses the core requirement from issue #1068 for improved ease of use.


86-86: LGTM: Ref prop correctly passed to QueryBox.

The ref is properly forwarded to the QueryBox component, enabling the focus functionality.

✨ 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.

@davemarco davemarco requested a review from junhaoliao August 4, 2025 19:30
@davemarco davemarco marked this pull request as ready for review August 4, 2025 19:30
@davemarco davemarco requested a review from a team as a code owner August 4, 2025 19:30
@kirkrodrigues kirkrodrigues requested a review from hoophalab August 4, 2025 21:01
@hoophalab hoophalab changed the title feat(webui): Focus/refocus query input box for ease of use (resolves #1068). feat(webui): Focus/refocus query input box for ease of use. Aug 5, 2025
Copy link
Contributor

@hoophalab hoophalab left a comment

Choose a reason for hiding this comment

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

lgtm

Validations:

  1. Focus query input box when switch to the search page.
  2. The query input box is refocused after the query is completed

@davemarco
Copy link
Contributor Author

@junhaoliao can you approve this

Copy link
Member

@junhaoliao junhaoliao 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 @hoophalab ‘s review

@davemarco davemarco merged commit 176104f into y-scope:main Aug 6, 2025
7 checks passed
gibber9809 pushed a commit to gibber9809/clp that referenced this pull request Aug 6, 2025
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.

[new-webui] Focus/refocus query input box for ease of use
3 participants