Skip to content

Conversation

Henry8192
Copy link
Contributor

@Henry8192 Henry8192 commented Aug 11, 2025

Description

Resolves #331.

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. Open log viewer, make sure side bar tab is not in Search tab.
  2. Load http://localhost:3010/?filePath=https://yscope.s3.us-east-2.amazonaws.com/sample-logs/yarn-ubuntu-resourcemanager-ip-172-31-17-135.log.1.clp.zst#queryString=123 in the log viewer, notice side bar switches to search tab automatically.
  3. Change query parameters, such as queryIsCaseSensitive=true and queryIsRegex=true, side bar also switches.

Summary by CodeRabbit

  • New Features
    • App now automatically switches to the Search tab and starts the search whenever query parameters are present or updated, including after loading a file, surfacing results faster.
    • Existing navigation behaviour is preserved; only detected queries trigger the tab switch and auto-run.
    • No user action required; works transparently with links or workflows that include query parameters.

@Henry8192 Henry8192 requested a review from a team as a code owner August 11, 2025 17:38
Copy link

coderabbitai bot commented Aug 11, 2025

Walkthrough

Adds calls to the UI store to set the active sidebar tab to SEARCH when query-related hash parameters are detected or updated, invoked in AppController.handleHashChange and in logFileStore.loadFile before starting a query; also adds an ESLint disable in logFileStore.

Changes

Cohort / File(s) Summary
Search tab auto-switch integration
src/components/AppController.tsx, src/stores/logFileStore.ts
When updateQueryHashParams() returns true, retrieve setActiveTabName from useUiStore.getState() and call setActiveTabName(TAB_NAME.SEARCH) immediately before invoking startQuery(). Added TAB_NAME import in AppController and UI store usage in both locations.
Lint directive
src/stores/logFileStore.ts
Added // eslint-disable-next-line max-lines-per-function above the useLogFileStore declaration (non-functional lint suppression).

Sequence Diagram(s)

sequenceDiagram
  participant App as AppController
  participant Hash as Hash Params
  participant UI as UI Store
  participant Q as Query Store

  App->>Hash: updateViewHashParams()
  App->>Hash: updateQueryHashParams()
  alt query params updated
    App->>UI: setActiveTabName(SEARCH)
    App->>Q: startQuery()
  else
    Note right of App: No query start
  end
Loading
sequenceDiagram
  participant Loader as logFileStore.loadFile
  participant Hash as Hash Params
  participant UI as UI Store
  participant Q as Query Store

  Loader->>Hash: updateQueryHashParams()
  alt query params updated
    Loader->>UI: setActiveTabName(SEARCH)
    Loader->>Q: startQuery()
  else
    Note right of Loader: Continue normal load flow
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Auto-switch to Search tab when query-related params present/updated in URL during app init and file load (#331)
Check for queryString, queryIsRegex, queryIsCaseSensitive via updateQueryHashParams path (#331)

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
ESLint disable for max-lines-per-function (src/stores/logFileStore.ts) Lint rule suppression is unrelated to the feature requirement of auto-switching the Search tab.

Possibly related PRs

Suggested reviewers

  • junhaoliao
  • kirkrodrigues

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the "Integrations" page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 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 3bcaaea and ae20cb8.

📒 Files selected for processing (1)
  • src/stores/logFileStore.ts (2 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:

  • src/stores/logFileStore.ts
🧠 Learnings (2)
📚 Learning: 2025-05-09T01:07:32.803Z
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#224
File: src/contexts/states/viewStore.ts:108-109
Timestamp: 2025-05-09T01:07:32.803Z
Learning: For the viewStore in the yscope-log-viewer project, it's more appropriate to suppress the max-lines-per-function ESLint rule than to split the store into slices due to the tight coupling and cohesive nature of its functions.

Applied to files:

  • src/stores/logFileStore.ts
📚 Learning: 2025-05-27T18:09:40.038Z
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#173
File: src/contexts/UrlContextProvider.tsx:1-1
Timestamp: 2025-05-27T18:09:40.038Z
Learning: The UrlContextProvider in src/contexts/UrlContextProvider.tsx is planned to be eventually replaced and deleted, so refactoring efforts to reduce its file size should be avoided despite it being large enough to require eslint-disable max-lines.

Applied to files:

  • src/stores/logFileStore.ts
🧬 Code Graph Analysis (1)
src/stores/logFileStore.ts (1)
src/typings/tab.ts (1)
  • TAB_NAME (22-22)
✨ 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.
    • 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.
  • 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 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/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

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: 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 4871fcc and e43f4dc.

📒 Files selected for processing (2)
  • src/components/AppController.tsx (2 hunks)
  • src/stores/logFileStore.ts (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:

  • src/components/AppController.tsx
  • src/stores/logFileStore.ts
🧬 Code Graph Analysis (2)
src/components/AppController.tsx (1)
src/typings/tab.ts (1)
  • TAB_NAME (22-22)
src/stores/logFileStore.ts (1)
src/typings/tab.ts (1)
  • TAB_NAME (22-22)
🪛 GitHub Check: lint-check
src/stores/logFileStore.ts

[failure] 101-101:
Unused eslint-disable directive (no problems were reported from

🪛 GitHub Actions: lint
src/stores/logFileStore.ts

[error] 101-101: ESLint: Unused eslint-disable directive (no problems were reported from 'max-lines-per-function')

🔇 Additional comments (4)
src/components/AppController.tsx (2)

8-10: New UI imports for tab switching — LGTM

Imports of useUiStore and TAB_NAME are appropriate for the new behaviour and keep concerns local. No issues spotted.


34-36: Auto-switch to Search tab before starting query — aligns with #331

Order is correct: setActiveTabName(TAB_NAME.SEARCH) prior to startQuery() ensures users land on the Search tab as the query runs. This matches the feature’s intent.

src/stores/logFileStore.ts (2)

17-17: TAB_NAME import — LGTM

Importing TAB_NAME for consistent tab identifiers is correct and keeps types centralised.


156-160: Switch to Search tab when query hash params are applied — LGTM

Setting the active tab before startQuery() aligns with the UX goal. This mirrors the AppController change and preserves existing query-start flow.

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

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e43f4dc and ed3560b.

📒 Files selected for processing (1)
  • src/stores/logFileStore.ts (2 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:

  • src/stores/logFileStore.ts
🧠 Learnings (2)
📚 Learning: 2025-05-09T01:07:32.803Z
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#224
File: src/contexts/states/viewStore.ts:108-109
Timestamp: 2025-05-09T01:07:32.803Z
Learning: For the viewStore in the yscope-log-viewer project, it's more appropriate to suppress the max-lines-per-function ESLint rule than to split the store into slices due to the tight coupling and cohesive nature of its functions.

Applied to files:

  • src/stores/logFileStore.ts
📚 Learning: 2025-05-27T18:09:40.038Z
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#173
File: src/contexts/UrlContextProvider.tsx:1-1
Timestamp: 2025-05-27T18:09:40.038Z
Learning: The UrlContextProvider in src/contexts/UrlContextProvider.tsx is planned to be eventually replaced and deleted, so refactoring efforts to reduce its file size should be avoided despite it being large enough to require eslint-disable max-lines.

Applied to files:

  • src/stores/logFileStore.ts
🧬 Code Graph Analysis (1)
src/stores/logFileStore.ts (1)
src/typings/tab.ts (1)
  • TAB_NAME (22-22)
🔇 Additional comments (2)
src/stores/logFileStore.ts (2)

17-17: Add TAB_NAME import — required for new tab-switch logic

Import is correct and used below for switching the active tab.


154-159: Auto-switch to Search tab before starting the query — correct placement and behaviour

This aligns with the objective: users land on the Search tab before the query kicks off. Good addition.

Comment on lines 154 to 159
if (updateQueryHashParams()) {
const {setActiveTabName} = useUiStore.getState();
setActiveTabName(TAB_NAME.SEARCH);
const {startQuery} = useQueryStore.getState();
startQuery();
}
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify no duplicate startQuery/tab-switch triggers across handlers

The AI summary notes AppController.tsx also switches to SEARCH and calls startQuery() when query hash params are present. Ensure we don’t trigger startQuery twice (once here and once in AppController) for the same navigation, which could cause duplicate work.

Consider centralising the “hash-param detected → switch to SEARCH → startQuery” flow in a single place (either AppController or this store) to avoid duplication.

Run this script to locate all call sites:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== updateQueryHashParams call sites ==="
rg -n -A 3 -B 3 $'updateQueryHashParams\\('

echo -e "\n=== startQuery call sites ==="
rg -n -A 3 -B 3 $'startQuery\\('

echo -e "\n=== setActiveTabName call sites ==="
rg -n -A 3 -B 3 $'setActiveTabName\\('

Length of output: 9733


Centralize hash-param handling to avoid duplicate searches

Both logFileStore.ts and AppController.tsx detect updateQueryHashParams(), switch to the SEARCH tab, and call startQuery(). This duplication can fire two identical queries on load.

Please consolidate this flow in one place or add a guard to prevent back-to-back triggers:

• src/stores/logFileStore.ts (lines 154–159)
• src/components/AppController.tsx (lines 33–38)

Consider moving the hash-param → tab switch → startQuery() logic entirely into AppController, or vice versa, and remove the redundant block.

🤖 Prompt for AI Agents
In src/stores/logFileStore.ts around lines 154–159, the code duplicates the
hash-param handling already implemented in src/components/AppController.tsx
(lines 33–38), causing two identical queries on load; remove or disable the
block in logFileStore.ts and centralize the hash-param →
setActiveTabName(TAB_NAME.SEARCH) → startQuery() flow in a single location
(preferably AppController), or add a guard (e.g., a boolean flag in a shared
store or check if the SEARCH tab is already active or query already started) to
prevent back-to-back triggers so only one startQuery() executes when
updateQueryHashParams() is true.

🧹 Nitpick (assertive)

Guard against redundant tab updates to avoid unnecessary re-renders

If the UI is already on the Search tab, skip dispatching setActiveTabName to reduce churn.

Apply this diff:

-                const {setActiveTabName} = useUiStore.getState();
-                setActiveTabName(TAB_NAME.SEARCH);
+                const {activeTabName, setActiveTabName} = useUiStore.getState();
+                if (TAB_NAME.SEARCH !== activeTabName) {
+                    setActiveTabName(TAB_NAME.SEARCH);
+                }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (updateQueryHashParams()) {
const {setActiveTabName} = useUiStore.getState();
setActiveTabName(TAB_NAME.SEARCH);
const {startQuery} = useQueryStore.getState();
startQuery();
}
if (updateQueryHashParams()) {
const {activeTabName, setActiveTabName} = useUiStore.getState();
if (TAB_NAME.SEARCH !== activeTabName) {
setActiveTabName(TAB_NAME.SEARCH);
}
const {startQuery} = useQueryStore.getState();
startQuery();
}
🤖 Prompt for AI Agents
In src/stores/logFileStore.ts around lines 154 to 159, guard against redundant
tab updates by reading the current active tab from useUiStore.getState() (e.g.,
const { activeTabName, setActiveTabName } = useUiStore.getState()), compare
activeTabName to TAB_NAME.SEARCH, and only call
setActiveTabName(TAB_NAME.SEARCH) when they differ; keep calling startQuery() as
before if updateQueryHashParams() returns true. Ensure you use the store's
getState() accessor without introducing side effects and preserve existing
typing.

@kirkrodrigues
Copy link
Member

@quinntaylormitchell, can you take a shot at reviewing this?

Copy link
Contributor

@quinntaylormitchell quinntaylormitchell left a comment

Choose a reason for hiding this comment

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

LGTM.

nit comment about the “Validation” section: you could include three test links, one testing each of the parameters mentioned in issue #331 (queryString, queryIsRegex, and queryIsCaseSensitive), to demonstrate that this fixes issue #331 in its entirety (not just for the queryString parameter).

…upon-query

# Conflicts:
#	src/components/AppController.tsx
@Henry8192 Henry8192 merged commit dc90027 into y-scope:main Aug 18, 2025
6 checks passed
@Henry8192 Henry8192 deleted the switch-to-search-tab-upon-query branch August 18, 2025 20:09
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.

feat: Auto-switch to Search tab when query parameters are present in URL

3 participants