Skip to content

feat(new-webui): Add a case sensitivity toggle to QueryBox.#949

Merged
hoophalab merged 3 commits into
y-scope:mainfrom
hoophalab:case-sensitive
May 30, 2025
Merged

feat(new-webui): Add a case sensitivity toggle to QueryBox.#949
hoophalab merged 3 commits into
y-scope:mainfrom
hoophalab:case-sensitive

Conversation

@hoophalab

@hoophalab hoophalab commented May 30, 2025

Copy link
Copy Markdown
Contributor

Description

Add a case sensitivity toggle to QueryBox.

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

The ui looks good.

Summary by CodeRabbit

  • New Features

    • Added a toggle button to the query input for enabling or disabling case sensitivity when searching.
    • The case sensitivity setting is now visually integrated into the search UI and can be easily changed by users.
  • Enhancements

    • The search feature now remembers and manages the case sensitivity state for a more customizable search experience.

@hoophalab hoophalab requested a review from a team as a code owner May 30, 2025 17:32
@coderabbitai

coderabbitai Bot commented May 30, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A case sensitivity toggle feature was added to the query input in the log viewer web UI. This includes a new reusable toggle component, updates to the query box to accept and display the toggle, integration with the search state using Zustand, and state management for case sensitivity throughout the search UI.

Changes

File(s) Change Summary
components/log-viewer-webui/client/src/components/QueryBox/index.tsx Added CaseSensitiveToggle component, extended QueryBoxProps with case sensitivity props, and rendered the toggle.
components/log-viewer-webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx Passed case sensitivity state and updater from search store to QueryBox via new props and event handlers.
components/log-viewer-webui/client/src/pages/SearchPage/SearchState/index.tsx Added queryIsCaseSensitive boolean state and updateQueryIsCaseSensitive updater method to the Zustand search store.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant QueryBox
    participant CaseSensitiveToggle
    participant SearchStore

    User->>CaseSensitiveToggle: Click toggle button
    CaseSensitiveToggle->>QueryBox: onCaseSensitiveChange(newValue)
    QueryBox->>SearchStore: updateQueryIsCaseSensitive(newValue)
    SearchStore-->>QueryBox: queryIsCaseSensitive (updated)
    QueryBox-->>CaseSensitiveToggle: isCaseSensitive (updated prop)
Loading

📜 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 83dceca and 094cd8d.

📒 Files selected for processing (1)
  • components/log-viewer-webui/client/src/components/QueryBox/index.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • components/log-viewer-webui/client/src/components/QueryBox/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-check (ubuntu-latest)
  • GitHub Check: lint-check (macos-latest)
🔇 Additional comments (10)
components/log-viewer-webui/client/src/components/QueryBox/index.tsx (10)

1-2: LGTM: Proper import addition for performance optimization.

The addition of useCallback import is appropriate for the performance optimization implemented in the component.


4-4: LGTM: Required UI component imports added.

The imports for Button, Tooltip, and Typography from antd are necessary for the new case sensitivity toggle functionality.

Also applies to: 9-10


17-20: LGTM: Well-defined interface for toggle props.

The CaseSensitiveToggleProps interface is properly defined with clear, descriptive property names and appropriate types. Good adherence to the export placement guidelines by declaring the interface without inline export.


22-32: LGTM: Comprehensive JSDoc documentation.

The documentation clearly explains the component's purpose, behavior, and parameters. Well-structured and informative.


37-42: LGTM: Excellent performance optimization with useCallback.

Good implementation of the handleButtonClick function wrapped in useCallback with proper dependencies. This addresses the previous review feedback and prevents unnecessary re-renders.


44-56: LGTM: Well-implemented toggle component UI.

The component renders a clean, intuitive toggle button with proper tooltip, visual state indication through button variants, and text styling. The implementation is solid and user-friendly.


59-59: LGTM: Proper interface extension.

The QueryBoxProps interface correctly extends both InputProps and CaseSensitiveToggleProps to include all necessary functionality.


72-73: LGTM: Updated documentation reflects new functionality.

The JSDoc has been properly updated to document the new case sensitivity parameters.


76-89: LGTM: Clean integration of toggle into QueryBox.

The QueryBox component properly destructures the new props and integrates the CaseSensitiveToggle as a suffix in the input field. The implementation maintains the existing functionality while adding the new feature seamlessly.


108-108: LGTM: Proper export placement.

Good adherence to the coding guidelines by placing exports at the end of the file rather than inline with declarations.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • @coderabbitai modularize this function.
  • 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 67aea01 and 83dceca.

📒 Files selected for processing (3)
  • components/log-viewer-webui/client/src/components/QueryBox/index.tsx (2 hunks)
  • components/log-viewer-webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx (3 hunks)
  • components/log-viewer-webui/client/src/pages/SearchPage/SearchState/index.tsx (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.

**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Prefer false == <expression> rather than !<expression>.

  • components/log-viewer-webui/client/src/pages/SearchPage/SearchState/index.tsx
  • components/log-viewer-webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx
  • components/log-viewer-webui/client/src/components/QueryBox/index.tsx
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-check (macos-latest)
  • GitHub Check: lint-check (ubuntu-latest)
🔇 Additional comments (4)
components/log-viewer-webui/client/src/pages/SearchPage/SearchState/index.tsx (1)

17-17: LGTM! Well-integrated state management implementation.

The case sensitivity state has been properly integrated into the search store following the established patterns. The default value of false (case insensitive) is a sensible choice for user experience, and the implementation is consistent with other state properties.

Also applies to: 32-35, 63-63, 76-78

components/log-viewer-webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx (1)

24-30: LGTM! Clean integration with the search store.

The integration of case sensitivity state follows the established patterns perfectly. The props are appropriately named and the callback correctly updates the store state.

Also applies to: 64-64, 73-75

components/log-viewer-webui/client/src/components/QueryBox/index.tsx (2)

15-48: Excellent component design with clean separation of concerns.

The CaseSensitiveToggle component is well-designed with:

  • Comprehensive JSDoc documentation
  • Good use of Ant Design components for UI consistency
  • Clear visual feedback with different button variants and disabled text
  • Helpful tooltip for user guidance

51-51: LGTM! Well-integrated QueryBox enhancement.

The QueryBox component has been appropriately extended to include the case sensitivity toggle. The props are properly typed by extending the interface, and the toggle is sensibly positioned as a suffix within the input field.

Also applies to: 68-81

@kirkrodrigues kirkrodrigues requested a review from davemarco May 30, 2025 17:43
Comment thread components/log-viewer-webui/client/src/components/QueryBox/index.tsx Outdated

export interface QueryBoxProps extends InputProps {

export interface CaseSensitiveToggleProps {

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.

not sure why the liner doesn't catch this -

we tend to put all exports towards the end of sources. e.g.,

interface CaseSensitiveToggleProps {...}

...


export {CaseSensitiveToggleProps};

@coderabbitai create an issue to track why linter didn't catch this.

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.

🧩 Analysis chain

@junhaoliao I'll create an issue to track this linter configuration issue.


🏁 Script executed:

#!/bin/bash
# Create a GitHub issue to track why the linter didn't catch the export placement violation
gh issue create \
  --title "Linter not catching export placement style violations" \
  --body "## Issue Description

The linter is not catching violations of the coding style where exports should be placed at the end of source files rather than inline with declarations.

## Expected Behavior
Exports should be grouped at the end of files using the pattern:
\`\`\`typescript
interface SomeInterface {...}

// ... other code ...

export {SomeInterface};
\`\`\`

## Actual Behavior
The linter allows inline exports like:
\`\`\`typescript
export interface SomeInterface {...}
\`\`\`

## Example
Found in PR #949, file \`components/log-viewer-webui/client/src/components/QueryBox/index.tsx\` where \`export interface CaseSensitiveToggleProps\` appears at the top of the file instead of being grouped with other exports at the end.

## Backlinks
- PR: https://github.com/y-scope/clp/pull/949
- Comment: https://github.com/y-scope/clp/pull/949#discussion_r2116610583

## Action Required
Review and update linter configuration to enforce export placement at the end of files." \
  --assignee junhaoliao

Length of output: 1112


Perfect! I've created issue #952 to track this linter configuration problem: #952

The issue documents the specific case where export interface CaseSensitiveToggleProps should have been caught by the linter according to your coding standards, which prefer exports grouped at the end of files rather than inline declarations. This will help investigate and fix the linter configuration to enforce this style rule going forward.


🧬 Code Graph Analysis Results

Possibly relevant snippets from components/log-viewer-webui/client/src/components/QueryBox/index.tsx (lines 1-74)

import {
    Button,
    Input,
    InputProps,
    Progress,
    theme,
    Tooltip,
    Typography,
} from "antd";
import {Nullable} from "src/typings/common";

import styles from "./index.module.css";


export interface CaseSensitiveToggleProps {
    isCaseSensitive: boolean;
    onCaseSensitiveChange: (newValue: boolean) => void;
}

/**
 * A toggle button component that switches between case-sensitive and case-insensitive modes.
 *
 * This component displays a button labeled "Aa". When clicked, it toggles the `isCaseSensitive`
 * state and invokes the `onCaseSensitiveChange` callback with the new value.
 *
 * @param props
 * @param props.isCaseSensitive
 * @param props.onCaseSensitiveChange
 * @return
 */
const CaseSensitiveToggle = ({
    isCaseSensitive,
    onCaseSensitiveChange,
}: CaseSensitiveToggleProps) => {
    return (
        <Tooltip title={"Match case"}>
            <Button
                color={"default"}
                icon={<Typography.Text disabled={!isCaseSensitive}>Aa</Typography.Text>}
                variant={isCaseSensitive ?
                    "filled" :
                    "text"}
                onClick={() => {
                    onCaseSensitiveChange(!isCaseSensitive);
                }}/>
        </Tooltip>
    );
};


export interface QueryBoxProps extends InputProps, CaseSensitiveToggleProps {
    /**
     * The progress of the progress bar from `0` to `100`. Hides the bar if `null`.
     */
    progress: Nullable<number>;
}

/**
 * Renders an Input with a progress bar.
 *
 * @param props
 * @param props.progress
 * @param props.inputProps
 * @param props.onCaseSensitiveChange
 * @param props.isCaseSensitive
 * @return
 */
const QueryBox = ({
    progress,
    isCaseSensitive,
    onCaseSensitiveChange,
    ...inputProps
}: QueryBoxProps) => {
    const {token} = theme.useToken();
    return (
        <div className={styles["queryBox"]}>
            <Input
                {...inputProps}
                suffix={<CaseSensitiveToggle
                    isCaseSensitive={isCaseSensitive}
                    onCaseSensitiveChange={onCaseSensitiveChange}/>}/>
            <div
                className={styles["progressBarMask"]}
                style={{borderRadius: token.borderRadiusLG}}
            >
                {null !== progress && (
                    <Progress
                        className={styles["progressBar"] || ""}
                        percent={progress}
                        showInfo={false}
                        size={"small"}
                        status={"active"}
                        strokeLinecap={"butt"}/>
                )}
            </div>
        </div>
    );
};
export default QueryBox;

Possibly relevant snippet from components/webui/imports/ui/SearchView/SearchStatus.jsx (line 36)

const [progress, setProgress] = useState(0);

This snippet shows a React state hook for managing a progress value, which may relate to the progress prop used in QueryBoxProps in the main file.


✏️ Learnings added
Learnt from: junhaoliao
PR: y-scope/clp#949
File: components/log-viewer-webui/client/src/components/QueryBox/index.tsx:15-15
Timestamp: 2025-05-30T20:43:38.291Z
Learning: In TypeScript/JavaScript files, exports should be placed at the end of the source file rather than inline with declarations. Prefer pattern like `interface SomeInterface {...}` followed by `export {SomeInterface};` at the end rather than `export interface SomeInterface {...}` at the declaration site.

Learnt from: junhaoliao
PR: y-scope/clp#949
File: components/log-viewer-webui/client/src/components/QueryBox/index.tsx:15-15
Timestamp: 2025-05-30T20:43:38.291Z
Learning: In TypeScript/JavaScript files, exports should be placed at the end of the source file rather than inline with declarations. Prefer pattern like `interface SomeInterface {...}` followed by `export {SomeInterface};` at the end rather than `export interface SomeInterface {...}` at the declaration site.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

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.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

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

for the title, how about

feat(new-webui): Add a case sensitivity toggle to QueryBox.

@hoophalab hoophalab changed the title feat: Add a case sensitivity toggle to QueryBox. feat(new-webui): Add a case sensitivity toggle to QueryBox. May 30, 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.

2 participants