Skip to content

feat: search term highlighting within log entry (fixes #189) #305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

AVMatthews
Copy link
Contributor

@AVMatthews AVMatthews commented May 29, 2025

Description

Fixes #189

Search term highlighting enabled within a log event. Syncs the built in monaco editor find actions with the results from the log viewers search.

  • Basic search highlighting working
  • Regex search result highlighting working
  • **Case sensitive Searches not working
    ->find action in monaco editor can take two arguments related to case sensitivity (matchCase and preserveCase). Both arguments take a boolean value. Setting either or both of them doesn't seem to trigger the case sensitivity in the monaco editor.

Checklist

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

Validation performed

Loaded logs into the log viewer and attempt various searches to see that the correct terms were being highlighted in the log events with a match value.

Summary by CodeRabbit

  • New Features
    • Enhanced search experience by synchronizing search panel and editor search widget, allowing for more responsive and consistent search updates.
  • Bug Fixes
    • Improved state management to ensure search interactions reset relevant flags, preventing unexpected behaviour when switching between search actions.
  • Chores
    • Introduced a new internal state management store to support improved search functionality.

Copy link

coderabbitai bot commented May 29, 2025

Walkthrough

A new Zustand store (useResultsStore) is introduced to manage a buttonClicked state. Event handlers in search-related components are updated to set or reset this flag based on user interactions. The editor component now synchronizes its find widget with the query and results store state, enabling reactive updates when search actions occur.

Changes

File(s) Change Summary
src/stores/resultsStore.ts Added new Zustand store for buttonClicked state with setter and initial value.
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/QueryInputBox.tsx Imported useResultsStore; updated event handlers to reset buttonClicked to false after query actions.
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/Result.tsx Imported useResultsStore; set buttonClicked to true on result button click.
src/components/Editor/index.tsx Imported both Zustand stores; synchronized editor find widget with store state; added logic for widget control.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant QueryInputBox
    participant useResultsStore
    participant Editor

    User->>QueryInputBox: Change query input / toggle search options
    QueryInputBox->>useResultsStore: setButtonClicked(false)
    QueryInputBox->>Editor: Update query state

    User->>Result: Click result button
    Result->>useResultsStore: setButtonClicked(true)
    useResultsStore->>Editor: Notify via subscription
    Editor->>Editor: Update find widget with current query params
Loading

Assessment against linked issues

Objective Addressed Explanation
Highlight search matching parts (#189) The changes synchronize search state but do not implement inline highlighting of matches.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Introduction of buttonClicked state and related logic (src/stores/resultsStore.ts, other) Managing a buttonClicked flag is not directly related to the objective of highlighting matching parts.
Synchronization of editor find widget with query/results store (src/components/Editor/index.tsx) These changes enable reactive search UI but do not address inline highlighting as described in the issue.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-09T21_43_25_633Z-debug-0.log


📜 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 4ae9716 and 38b9d71.

📒 Files selected for processing (3)
  • src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/QueryInputBox.tsx (4 hunks)
  • src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/Result.tsx (2 hunks)
  • src/components/Editor/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>.

  • src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/Result.tsx
  • src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/QueryInputBox.tsx
  • src/components/Editor/index.tsx
🔇 Additional comments (7)
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/QueryInputBox.tsx (2)

10-10: LGTM! Helper function properly addresses past review feedback.

The addition of useResultsStore import and the resetButtonClicked helper function effectively addresses the past review comment about extracting the common pattern for better maintainability.

Also applies to: 33-36


44-44: LGTM! Consistent usage of helper function.

The resetButtonClicked() calls are properly placed in all three event handlers, ensuring consistent state management across the component.

Also applies to: 53-53, 62-62

src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/Result.tsx (1)

8-8: LGTM! Proper integration of results store state.

The import and usage of useResultsStore to set buttonClicked to true before the existing logic ensures proper coordination with the editor's find widget functionality.

Also applies to: 45-46

src/components/Editor/index.tsx (4)

1-3: LGTM! ESLint rule adjustments accommodate the new functionality.

The increased limits for max-lines, max-lines-per-function, and max-statements are reasonable given the added search integration functionality.


14-15: LGTM! Store imports support the search highlighting feature.

The addition of useQueryStore and useResultsStore imports enables the editor to reactively synchronize with search state changes.


239-247: LGTM! Improved type safety for Monaco contribution access.

The type assertion and null checking for the find controller contribution is now more robust and type-safe, addressing the previous review feedback.


249-263: LGTM! Memory leaks properly addressed with cleanup functions.

The Zustand store subscriptions now properly return cleanup functions that are called when the component unmounts, resolving the memory leak concern from previous reviews.

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

@AVMatthews AVMatthews marked this pull request as ready for review June 6, 2025 19:41
@AVMatthews AVMatthews requested a review from a team as a code owner June 6, 2025 19:41
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1a53e09 and 4ae9716.

📒 Files selected for processing (4)
  • src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/QueryInputBox.tsx (2 hunks)
  • src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/Result.tsx (2 hunks)
  • src/components/Editor/index.tsx (3 hunks)
  • src/stores/resultsStore.ts (1 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>.

  • src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/QueryInputBox.tsx
  • src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/Result.tsx
  • src/stores/resultsStore.ts
  • src/components/Editor/index.tsx
🔇 Additional comments (7)
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/QueryInputBox.tsx (1)

10-10: LGTM - Clean import addition.

The import for the new results store follows the existing patterns in the file.

src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/Result.tsx (2)

7-7: LGTM - Consistent import pattern.

The import follows the same pattern established in other components.


41-42: LGTM - Clear intent and proper ordering.

The code correctly sets the button clicked state before updating the URL, ensuring the state change happens first for any subscribers to react to.

src/stores/resultsStore.ts (2)

4-12: Well-structured interface design.

The separation of values and actions into distinct interfaces and their combination into a single state type follows TypeScript best practices and makes the store's API clear.


18-23: Clean and straightforward Zustand store implementation.

The store implementation correctly uses the spread operator for defaults and provides a simple setter function. The implementation is focused and follows Zustand patterns well.

src/components/Editor/index.tsx (2)

1-3: Verify if ESLint rule relaxation is necessary.

The ESLint rules for maximum lines, lines-per-function, and statements were significantly relaxed. Ensure this increase is truly necessary and consider if the code can be refactored to reduce complexity instead.


19-20: LGTM - Store imports follow established patterns.

The new store imports are consistent with the existing codebase patterns.

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.

overall looks cool

can we change the behaviour a bit to make things more intuitive for the users?

  1. to make the indices in Monaco's find box accurate, on result button clicks, we can programmatically select the whole log event (before programmatically popping up the find box)
  2. To keep the matching parts always highlighted, we can run an useEffect hook on any changes of queryString, queryIsCaseSensitive, queryIsRegex

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.

Highlight search matching parts.
3 participants