Skip to content

refactor: Extract isPrettified from loadPage's parameters into a variable in LogFileManager (fixes #354).#362

Merged
hoophalab merged 5 commits intoy-scope:mainfrom
Henry8192:LogFileManagerProxy-refactor
Aug 11, 2025
Merged

refactor: Extract isPrettified from loadPage's parameters into a variable in LogFileManager (fixes #354).#362
hoophalab merged 5 commits intoy-scope:mainfrom
Henry8192:LogFileManagerProxy-refactor

Conversation

@Henry8192
Copy link
Contributor

@Henry8192 Henry8192 commented Aug 7, 2025

Description

This pull request refactors how the "prettified" (pretty-printed) state for log messages is managed across the log viewer application. Instead of passing the isPrettified flag through multiple method calls, the state is now managed internally within the LogFileManager class. This simplifies method signatures and centralizes the state management for prettified logs.

Refactoring and State Management:

  • Added a private #isPrettified property and a setIsPrettified method to the LogFileManager class to manage prettified state internally, removing the need to pass isPrettified as a parameter to methods like loadPage.

  • In urlHash.ts, fixes isPrettified URL hash parameter gets cleared regardless of value #354.

  • Updated LogFileManagerProxy to provide a setIsPrettified method, and refactored its loadPage and setFilter methods to no longer require the isPrettified argument, forwarding the prettified state to LogFileManager as needed.

Store and View Logic Updates:

  • Refactored store slices (logFileStore, viewStore/createViewPageSlice.ts, and viewStore/createViewFilterSlice.ts) to remove the need to pass the isPrettified parameter when loading pages or setting filters.
    URL and View Synchronization:

  • Updated URL utility logic to synchronize the prettified state via dedicated setter methods, ensuring the view and log manager are updated when the prettified state changes, instead of passing the flag through page load calls.

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

Open log viewer with link: calhost:3010/?filePath=https://yscope.s3.us-east-2.amazonaws.com/sample-logs/yarn-ubuntu-resourcemanager-ip-172-31-17-135.log.1.clp.zst

  • Toggle prettify button works
  • set isPrettified from URL hash parameters works
  • set log level filter with isPrettified toggling works.

Summary by CodeRabbit

  • New Features

    • Added a dedicated control to enable or disable prettified log message formatting.
  • Refactor

    • Centralized the prettification setting, removing the need to pass the prettification flag to individual methods.
    • Updated related methods and UI logic to use the new centralized prettification control.

@Henry8192 Henry8192 requested a review from a team as a code owner August 7, 2025 16:54
@coderabbitai
Copy link

coderabbitai bot commented Aug 7, 2025

Walkthrough

The changes refactor how the prettification state (isPrettified) is managed when loading log pages. The flag is now stored internally within LogFileManager and set via a new setter method, rather than being passed as a parameter to loadPage and related methods. All affected method signatures and calls are updated accordingly.

Changes

Cohort / File(s) Change Summary
LogFileManager internal refactor
src/services/LogFileManager/index.ts
Introduced private #isPrettified field and public setIsPrettified method. Updated loadPage to use the internal flag instead of a parameter. Changed loadPage signature to remove isPrettified argument.
Proxy and method signature updates
src/services/LogFileManagerProxy.ts
Updated loadPage and setFilter signatures to remove isPrettified parameter. Added setIsPrettified method to control prettification state. Adjusted internal calls to match new signatures and logic.
Store usage updates
src/stores/logFileStore.ts,
src/stores/viewStore/createViewPageSlice.ts
Removed retrieval and passing of isPrettified to loadPage, calling it with only the cursor argument.
Filter logic update
src/stores/viewStore/createViewFilterSlice.ts
Removed use and passing of isPrettified to setFilter. Now only uses cursor and log level filter.
URL hash/state synchronisation
src/utils/url/urlHash.ts
Refactored logic so isPrettified state is updated and synchronised with the proxy via setIsPrettified before loading page data. Removed passing isPrettified to loadPage.

Sequence Diagram(s)

sequenceDiagram
    participant UI
    participant ViewStore
    participant LogFileManagerProxy
    participant LogFileManager

    UI->>ViewStore: User toggles prettification
    ViewStore->>LogFileManagerProxy: setIsPrettified(isPrettified)
    LogFileManagerProxy->>LogFileManager: setIsPrettified(isPrettified)

    UI->>ViewStore: Request page (loadPage)
    ViewStore->>LogFileManagerProxy: loadPage(cursor)
    LogFileManagerProxy->>LogFileManager: loadPage(cursor)
    LogFileManager->>LogFileManager: Uses internal #isPrettified
    LogFileManager-->>LogFileManagerProxy: PageData
    LogFileManagerProxy-->>ViewStore: PageData
    ViewStore-->>UI: Rendered page
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • junhaoliao
  • kirkrodrigues

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

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

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 621638d and fa7c6ac.

📒 Files selected for processing (6)
  • src/services/LogFileManager/index.ts (4 hunks)
  • src/services/LogFileManagerProxy.ts (1 hunks)
  • src/stores/logFileStore.ts (1 hunks)
  • src/stores/viewStore/createViewFilterSlice.ts (1 hunks)
  • src/stores/viewStore/createViewPageSlice.ts (1 hunks)
  • src/utils/url/urlHash.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
  • src/stores/viewStore/createViewPageSlice.ts
  • src/stores/viewStore/createViewFilterSlice.ts
  • src/services/LogFileManager/index.ts
  • src/services/LogFileManagerProxy.ts
  • src/utils/url/urlHash.ts
🧠 Learnings (11)
📓 Common learnings
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.
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#347
File: src/utils/math.ts:47-56
Timestamp: 2025-07-24T21:28:56.838Z
Learning: In the y-scope/yscope-log-viewer codebase, Henry8192 prefers not to introduce local variables to avoid parameter reassignment in binary search implementations, considering the additional constants unnecessary.
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#107
File: src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/Result.tsx:1-7
Timestamp: 2024-10-28T18:40:29.816Z
Learning: In the y-scope/yscope-log-viewer project, importing components via destructuring from 'mui/joy' is acceptable, as the package size impact has been analyzed and found acceptable.
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#101
File: docs/dev-guide/building.md:18-18
Timestamp: 2024-10-24T01:18:27.752Z
Learning: In `docs/dev-guide/building.md` of the `yscope-log-viewer` project, it's acceptable to include bare URLs to keep them clickable, instead of wrapping them in backticks or converting them to Markdown links.
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#84
File: new-log-viewer/src/components/modals/SettingsModal/SettingsDialog.tsx:99-114
Timestamp: 2024-10-08T15:52:50.753Z
Learning: When suggesting to add validation for form inputs in `SettingsDialog.tsx`, the user considered it not related to the PR. In future reviews, ensure suggestions align with the PR's scope.
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#84
File: new-log-viewer/src/components/modals/SettingsModal/SettingsDialog.tsx:99-114
Timestamp: 2024-09-30T20:49:32.508Z
Learning: When suggesting to add validation for form inputs in `SettingsDialog.tsx`, the user considered it not related to the PR. In future reviews, ensure suggestions align with the PR's scope.
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#265
File: src/stores/logFileStore.ts:125-125
Timestamp: 2025-05-17T05:13:39.947Z
Learning: When refactoring Zustand state imports to prevent circular dependencies in the yscope-log-viewer project, the preferred pattern is to move state retrievals closest to where they're actually used rather than retrieving them at the beginning of the function.
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#196
File: src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/QueryInputBox.tsx:55-58
Timestamp: 2025-03-03T18:10:02.451Z
Learning: In the y-scope/yscope-log-viewer repository, the team prefers using the `!` operator to flip boolean values (e.g., `!isRegex`) rather than the pattern `false == <expression>` that's mentioned in the coding guidelines.
📚 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
  • src/stores/viewStore/createViewPageSlice.ts
  • src/stores/viewStore/createViewFilterSlice.ts
  • src/utils/url/urlHash.ts
📚 Learning: 2025-05-09T22:39:04.485Z
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#224
File: src/contexts/states/logFileStore.ts:72-79
Timestamp: 2025-05-09T22:39:04.485Z
Learning: In the log viewer application, silently ignoring calls to `handleExportChunk` when `logExportManager` is null is intentional, as the page is reloaded in this scenario anyway.

Applied to files:

  • src/stores/logFileStore.ts
  • src/stores/viewStore/createViewPageSlice.ts
  • src/stores/viewStore/createViewFilterSlice.ts
  • src/utils/url/urlHash.ts
📚 Learning: 2024-09-25T21:12:28.732Z
Learnt from: davemarco
PR: y-scope/yscope-log-viewer#76
File: new-log-viewer/src/utils/actions.ts:105-133
Timestamp: 2024-09-25T21:12:28.732Z
Learning: In the `actions.ts` file, the `PAGE_TOP` and `PAGE_BOTTOM` actions are not intended to be handled in the `getPageNumCursorArgs` function.

Applied to files:

  • src/stores/logFileStore.ts
  • src/stores/viewStore/createViewPageSlice.ts
  • src/services/LogFileManagerProxy.ts
  • src/utils/url/urlHash.ts
📚 Learning: 2025-06-01T13:40:12.222Z
Learnt from: zzxthehappiest
PR: y-scope/yscope-log-viewer#286
File: src/components/Editor/index.tsx:138-139
Timestamp: 2025-06-01T13:40:12.222Z
Learning: In the yscope-log-viewer codebase, when using Zustand stores in React components, the preferred pattern is to use `getState()` for static setters that never change (like `setLogEventNum`) to avoid unnecessary subscriptions, while using hooks for actions that do more than just setting values. All store state variables should be declared at the beginning of the component for consistency and clear dependency overview.

Applied to files:

  • src/stores/logFileStore.ts
  • src/stores/viewStore/createViewFilterSlice.ts
  • src/utils/url/urlHash.ts
📚 Learning: 2024-10-09T02:08:56.053Z
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#80
File: new-log-viewer/src/services/LogFileManager.ts:297-313
Timestamp: 2024-10-09T02:08:56.053Z
Learning: In the `#searchChunk` method of `LogFileManager.ts`, checking `typeof match.index === "number"` correctly handles matches at index 0, ensuring matches at the beginning of the string are not skipped.

Applied to files:

  • src/stores/logFileStore.ts
  • src/stores/viewStore/createViewFilterSlice.ts
  • src/services/LogFileManager/index.ts
  • src/services/LogFileManagerProxy.ts
📚 Learning: 2025-05-17T05:13:39.947Z
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#265
File: src/stores/logFileStore.ts:125-125
Timestamp: 2025-05-17T05:13:39.947Z
Learning: When refactoring Zustand state imports to prevent circular dependencies in the yscope-log-viewer project, the preferred pattern is to move state retrievals closest to where they're actually used rather than retrieving them at the beginning of the function.

Applied to files:

  • src/stores/logFileStore.ts
  • src/stores/viewStore/createViewFilterSlice.ts
  • src/utils/url/urlHash.ts
📚 Learning: 2024-09-25T21:13:37.250Z
Learnt from: davemarco
PR: y-scope/yscope-log-viewer#76
File: new-log-viewer/src/utils/actions.ts:84-139
Timestamp: 2024-09-25T21:13:37.250Z
Learning: In the `getPageNumCursorArgs` function, variables `newPageNum` and `anchor` are always initialized when handling valid actions, so there is no risk of them being uninitialized.

Applied to files:

  • src/stores/viewStore/createViewPageSlice.ts
  • src/utils/url/urlHash.ts
📚 Learning: 2024-10-19T03:33:29.578Z
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#94
File: new-log-viewer/src/components/CentralContainer/Sidebar/index.tsx:99-118
Timestamp: 2024-10-19T03:33:29.578Z
Learning: In `new-log-viewer/src/components/CentralContainer/Sidebar/index.tsx`, when using `useEffect` to register window resize event handlers, it's acceptable to have an empty dependency array because the variables and functions used within the effect (`getPanelWidth`, `PANEL_CLIP_THRESHOLD_IN_PIXELS`, and `tabListRef`) are constants or refs declared outside the functional component and do not change.

Applied to files:

  • src/stores/viewStore/createViewFilterSlice.ts
  • src/utils/url/urlHash.ts
📚 Learning: 2025-06-01T13:41:12.938Z
Learnt from: zzxthehappiest
PR: y-scope/yscope-log-viewer#286
File: src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/QueryInputBox.tsx:37-40
Timestamp: 2025-06-01T13:41:12.938Z
Learning: The `updateWindowUrlHashParams` function in `src/utils/url.ts` doesn't throw errors, so error handling is not needed when calling this function.

Applied to files:

  • src/utils/url/urlHash.ts
📚 Learning: 2025-06-01T13:44:05.278Z
Learnt from: zzxthehappiest
PR: y-scope/yscope-log-viewer#286
File: src/components/AppController.tsx:40-43
Timestamp: 2025-06-01T13:44:05.278Z
Learning: In the y-scope/yscope-log-viewer codebase, when functions return invalid or default log event numbers, they should use 0 as this aligns with URL_HASH_PARAMS_DEFAULT.LOG_EVENT_NUM which is set to 0. This maintains consistency with the established default hash parameter pattern.

Applied to files:

  • src/utils/url/urlHash.ts
🧬 Code Graph Analysis (3)
src/stores/logFileStore.ts (1)
src/services/LogFileManager/index.ts (1)
  • cursor (443-477)
src/services/LogFileManagerProxy.ts (4)
src/services/LogFileManager/index.ts (1)
  • cursor (443-477)
src/typings/worker.ts (2)
  • CursorType (108-108)
  • PageData (111-111)
src/services/decoders/JsonlDecoder/index.ts (1)
  • logLevelFilter (244-258)
src/typings/logs.ts (1)
  • LogLevelFilter (51-51)
src/utils/url/urlHash.ts (2)
src/services/LogFileManagerProxy.ts (1)
  • setIsPrettified (60-63)
src/services/LogFileManager/index.ts (2)
  • setIsPrettified (199-201)
  • cursor (443-477)
🔇 Additional comments (10)
src/stores/viewStore/createViewPageSlice.ts (1)

142-142: LGTM! Parameter removal aligns with refactoring objective.

The removal of the isPrettified parameter from loadPage correctly reflects the new architecture where prettification state is managed internally within LogFileManager.

src/stores/logFileStore.ts (1)

148-148: LGTM! Consistent parameter removal.

The removal of the isPrettified parameter from loadPage is consistent with the refactoring to centralize prettification state management within LogFileManager.

src/stores/viewStore/createViewFilterSlice.ts (1)

31-31: LGTM! Consistent with filter method signature change.

The removal of isPrettified from the destructured state correctly reflects the updated setFilter method signature where prettification is now managed internally.

src/services/LogFileManager/index.ts (4)

65-65: LGTM! Appropriate default value for prettification state.

The private field initialization with false provides a sensible default for the prettification state.


199-201: LGTM! Clean setter implementation.

The setIsPrettified method provides a clean interface for updating the internal prettification state.


242-242: LGTM! Method signature correctly updated.

The removal of the isPrettified parameter from loadPage correctly implements the refactoring to use internal state management.


272-274: LGTM! Correct usage of internal state.

The change from parameter to this.#isPrettified correctly utilizes the internal state for prettification logic.

src/services/LogFileManagerProxy.ts (3)

45-48: LGTM: Method signature correctly updated to remove prettification parameter.

The removal of the isPrettified parameter aligns with the refactoring objective to centralize prettification state management within the LogFileManager.


50-58: LGTM: Filter method correctly updated to match new architecture.

The setFilter method properly delegates to the updated loadPage method without passing the isPrettified parameter, maintaining consistency with the refactored design.


60-63: LGTM: New setter method properly encapsulates prettification state management.

The setIsPrettified method follows the established patterns in the class by using #getLogFileManager() for error handling and properly delegates to the underlying LogFileManager.

@kirkrodrigues kirkrodrigues requested a review from hoophalab August 7, 2025 21:12
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.

The change looks clean and nice, but I noticed a bug which probably isn't caused by this PR.

  1. Open any file
  2. Click isPrettified button
  • Notice that the url isn't updated
  1. After the file is prettified, click any line in the text editor
  • The output becomes "un-prettifed" because the url isn't updated

This is probably due to incorrect logic in updateViewHashParams and getCursorFromHashParams. Since we are already updating the isPrettifed logic in those two function, can we find a fix for this?

@Henry8192
Copy link
Contributor Author

Henry8192 commented Aug 8, 2025

The change looks clean and nice, but I noticed a bug which probably isn't caused by this PR.

  1. Open any file
  2. Click isPrettified button
  • Notice that the url isn't updated
  1. After the file is prettified, click any line in the text editor
  • The output becomes "un-prettifed" because the url isn't updated

This is probably due to incorrect logic in updateViewHashParams and getCursorFromHashParams. Since we are already updating the isPrettifed logic in those two function, can we find a fix for this?

that was the bug I talked about yesterday, and I plan to fix it once this is merged.

Still, if ypu think this is within the scope, I actually prefer to fix it here

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 49070d6 and c3d81b4.

📒 Files selected for processing (1)
  • src/utils/url/urlHash.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/utils/url/urlHash.ts
🧠 Learnings (14)
📓 Common learnings
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.
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#84
File: new-log-viewer/src/components/modals/SettingsModal/SettingsDialog.tsx:99-114
Timestamp: 2024-10-08T15:52:50.753Z
Learning: When suggesting to add validation for form inputs in `SettingsDialog.tsx`, the user considered it not related to the PR. In future reviews, ensure suggestions align with the PR's scope.
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#84
File: new-log-viewer/src/components/modals/SettingsModal/SettingsDialog.tsx:99-114
Timestamp: 2024-09-30T20:49:32.508Z
Learning: When suggesting to add validation for form inputs in `SettingsDialog.tsx`, the user considered it not related to the PR. In future reviews, ensure suggestions align with the PR's scope.
Learnt from: davemarco
PR: y-scope/yscope-log-viewer#76
File: new-log-viewer/src/services/fileManager/utils.ts:43-59
Timestamp: 2024-09-25T21:11:48.621Z
Learning: Avoid commenting on code that is only being moved and not modified in the PR.
Learnt from: davemarco
PR: y-scope/yscope-log-viewer#76
File: new-log-viewer/src/services/fileManager/utils.ts:43-59
Timestamp: 2024-10-08T15:52:50.753Z
Learning: Avoid commenting on code that is only being moved and not modified in the PR.
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#74
File: new-log-viewer/src/components/CentralContainer/Sidebar/ResizeHandle.tsx:77-82
Timestamp: 2024-10-08T15:52:50.753Z
Learning: Accessibility improvements, such as adding ARIA attributes to components like `ResizeHandle`, require broader discussion and are considered out of scope for small PRs.
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#74
File: new-log-viewer/src/components/CentralContainer/Sidebar/ResizeHandle.tsx:77-82
Timestamp: 2024-09-28T02:32:08.882Z
Learning: Accessibility improvements, such as adding ARIA attributes to components like `ResizeHandle`, require broader discussion and are considered out of scope for small PRs.
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#347
File: src/utils/math.ts:47-56
Timestamp: 2025-07-24T21:28:56.838Z
Learning: In the y-scope/yscope-log-viewer codebase, Henry8192 prefers not to introduce local variables to avoid parameter reassignment in binary search implementations, considering the additional constants unnecessary.
📚 Learning: 2025-06-01T13:41:12.938Z
Learnt from: zzxthehappiest
PR: y-scope/yscope-log-viewer#286
File: src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/QueryInputBox.tsx:37-40
Timestamp: 2025-06-01T13:41:12.938Z
Learning: The `updateWindowUrlHashParams` function in `src/utils/url.ts` doesn't throw errors, so error handling is not needed when calling this function.

Applied to files:

  • src/utils/url/urlHash.ts
📚 Learning: 2024-09-25T21:12:28.732Z
Learnt from: davemarco
PR: y-scope/yscope-log-viewer#76
File: new-log-viewer/src/utils/actions.ts:105-133
Timestamp: 2024-09-25T21:12:28.732Z
Learning: In the `actions.ts` file, the `PAGE_TOP` and `PAGE_BOTTOM` actions are not intended to be handled in the `getPageNumCursorArgs` function.

Applied to files:

  • src/utils/url/urlHash.ts
📚 Learning: 2024-09-25T21:13:37.250Z
Learnt from: davemarco
PR: y-scope/yscope-log-viewer#76
File: new-log-viewer/src/utils/actions.ts:84-139
Timestamp: 2024-09-25T21:13:37.250Z
Learning: In the `getPageNumCursorArgs` function, variables `newPageNum` and `anchor` are always initialized when handling valid actions, so there is no risk of them being uninitialized.

Applied to files:

  • src/utils/url/urlHash.ts
📚 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/utils/url/urlHash.ts
📚 Learning: 2024-10-19T03:33:29.578Z
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#94
File: new-log-viewer/src/components/CentralContainer/Sidebar/index.tsx:99-118
Timestamp: 2024-10-19T03:33:29.578Z
Learning: In `new-log-viewer/src/components/CentralContainer/Sidebar/index.tsx`, when using `useEffect` to register window resize event handlers, it's acceptable to have an empty dependency array because the variables and functions used within the effect (`getPanelWidth`, `PANEL_CLIP_THRESHOLD_IN_PIXELS`, and `tabListRef`) are constants or refs declared outside the functional component and do not change.

Applied to files:

  • src/utils/url/urlHash.ts
📚 Learning: 2024-10-18T01:13:02.946Z
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#83
File: new-log-viewer/src/components/theme.tsx:59-61
Timestamp: 2024-10-18T01:13:02.946Z
Learning: In 'new-log-viewer/src/components/theme.tsx', a 1px focus ring is acceptable due to sufficient color contrast as per project preferences.

Applied to files:

  • src/utils/url/urlHash.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/utils/url/urlHash.ts
📚 Learning: 2024-10-09T02:08:56.053Z
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#80
File: new-log-viewer/src/services/LogFileManager.ts:297-313
Timestamp: 2024-10-09T02:08:56.053Z
Learning: In the `#searchChunk` method of `LogFileManager.ts`, checking `typeof match.index === "number"` correctly handles matches at index 0, ensuring matches at the beginning of the string are not skipped.

Applied to files:

  • src/utils/url/urlHash.ts
📚 Learning: 2024-10-08T15:52:50.753Z
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#84
File: new-log-viewer/src/components/modals/SettingsModal/SettingsDialog.tsx:99-114
Timestamp: 2024-10-08T15:52:50.753Z
Learning: When suggesting to add validation for form inputs in `SettingsDialog.tsx`, the user considered it not related to the PR. In future reviews, ensure suggestions align with the PR's scope.

Applied to files:

  • src/utils/url/urlHash.ts
📚 Learning: 2025-06-01T13:40:12.222Z
Learnt from: zzxthehappiest
PR: y-scope/yscope-log-viewer#286
File: src/components/Editor/index.tsx:138-139
Timestamp: 2025-06-01T13:40:12.222Z
Learning: In the yscope-log-viewer codebase, when using Zustand stores in React components, the preferred pattern is to use `getState()` for static setters that never change (like `setLogEventNum`) to avoid unnecessary subscriptions, while using hooks for actions that do more than just setting values. All store state variables should be declared at the beginning of the component for consistency and clear dependency overview.

Applied to files:

  • src/utils/url/urlHash.ts
📚 Learning: 2025-06-01T13:44:05.278Z
Learnt from: zzxthehappiest
PR: y-scope/yscope-log-viewer#286
File: src/components/AppController.tsx:40-43
Timestamp: 2025-06-01T13:44:05.278Z
Learning: In the y-scope/yscope-log-viewer codebase, when functions return invalid or default log event numbers, they should use 0 as this aligns with URL_HASH_PARAMS_DEFAULT.LOG_EVENT_NUM which is set to 0. This maintains consistency with the established default hash parameter pattern.

Applied to files:

  • src/utils/url/urlHash.ts
📚 Learning: 2025-05-17T05:13:39.947Z
Learnt from: junhaoliao
PR: y-scope/yscope-log-viewer#265
File: src/stores/logFileStore.ts:125-125
Timestamp: 2025-05-17T05:13:39.947Z
Learning: When refactoring Zustand state imports to prevent circular dependencies in the yscope-log-viewer project, the preferred pattern is to move state retrievals closest to where they're actually used rather than retrieving them at the beginning of the function.

Applied to files:

  • src/utils/url/urlHash.ts
📚 Learning: 2025-05-09T22:39:04.485Z
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#224
File: src/contexts/states/logFileStore.ts:72-79
Timestamp: 2025-05-09T22:39:04.485Z
Learning: In the log viewer application, silently ignoring calls to `handleExportChunk` when `logExportManager` is null is intentional, as the page is reloaded in this scenario anyway.

Applied to files:

  • src/utils/url/urlHash.ts
🧬 Code Graph Analysis (1)
src/utils/url/urlHash.ts (2)
src/services/LogFileManagerProxy.ts (1)
  • setIsPrettified (60-63)
src/services/LogFileManager/index.ts (2)
  • setIsPrettified (199-201)
  • cursor (443-477)
🔇 Additional comments (1)
src/utils/url/urlHash.ts (1)

41-41: Cursor choice on prettify mismatch looks correct

Using viewStore’s prevIsPrettified to detect a mismatch and emit an EVENT_NUM cursor is consistent with the new internalised prettify state. No issues here.

@Henry8192 Henry8192 requested a review from hoophalab August 8, 2025 20:01
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.

the change is clean.

Validations:
isPrettified button works.
isPrettified url hash parameter is updated correctly.

@Henry8192 Henry8192 changed the title refactor: Extract isPrettified from loadPage parameters as a variable in logFileManager refactor: Extract isPrettified from loadPage parameters as a variable in logFileManager (fixes #354). Aug 11, 2025
@hoophalab hoophalab changed the title refactor: Extract isPrettified from loadPage parameters as a variable in logFileManager (fixes #354). refactor: Extract isPrettified from loadPage parameters as a variable in LogFileManager (fixes #354). Aug 11, 2025
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 @hoophalab's review.

For the PR title, how about:

refactor: Extract `isPrettified` from `loadPage`'s parameters into a variable in `LogFileManager` (fixes #354).

@hoophalab hoophalab changed the title refactor: Extract isPrettified from loadPage parameters as a variable in LogFileManager (fixes #354). refactor: Extract isPrettified from loadPage's parameters into a variable in LogFileManager (fixes #354). Aug 11, 2025
@hoophalab hoophalab merged commit b424a86 into y-scope:main Aug 11, 2025
9 checks passed
@Henry8192 Henry8192 deleted the LogFileManagerProxy-refactor branch August 11, 2025 19:28
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.

isPrettified URL hash parameter gets cleared regardless of value

3 participants