Skip to content

refactor(new-webui): Add Nullable typing for cachedDataset to support null dataset option for clp-text.#1079

Merged
hoophalab merged 6 commits into
y-scope:mainfrom
hoophalab:dataset-null
Jul 8, 2025
Merged

refactor(new-webui): Add Nullable typing for cachedDataset to support null dataset option for clp-text.#1079
hoophalab merged 6 commits into
y-scope:mainfrom
hoophalab:dataset-null

Conversation

@hoophalab

@hoophalab hoophalab commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

Description

Currently, the WebUI client sends a /query/extract-stream request with the dataset field set to an empty string "". This doesn't cause any issues since DbManager ignores the dataset field when jobType is EXTRACT_IR.
However, for consistency with other APIs, it's better to use null instead.

This PR updates the default value of cachedDataset and modifies the request logic accordingly.

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 for both clp-text and clp-json:

  1. run the packge
  2. compress one file
  3. do a search on the search page
  4. log viewer link still works.

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of nullable dataset values across search and job submission features, ensuring empty strings are treated as null where appropriate.
    • Updated user interface logic to properly manage and display cases where the dataset may be null.
  • Refactor

    • Standardized the use of nullable types for dataset-related properties throughout the application for consistency and clarity.
    • Enhanced URL parameter construction for log viewer links to improve reliability and maintainability.
    • Updated linting rules to better handle specific capitalized function exceptions.

@hoophalab hoophalab requested a review from a team as a code owner July 8, 2025 03:58
@coderabbitai

coderabbitai Bot commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes update the handling of the dataset parameter throughout the codebase to consistently support null values instead of empty strings. This includes type adjustments, default value changes, and logic to convert undefined to null where necessary. ESLint configuration was also updated for rule exceptions. Additionally, URL parameter construction was refactored to use URLSearchParams.

Changes

File(s) Change Summary
components/webui/client/eslint.config.mjs Updated "new-cap" rule exceptions list to add "Type.Literal" and "Type.Optional" earlier, reordered entries.
components/webui/client/src/api/query.ts Changed SubmitExtractStreamJobProps.dataset type from string to Nullable<string>; imported Nullable.
components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Message/LogViewerLink.tsx Refactored URL parameter construction to use URLSearchParams, conditionally appending dataset if not null.
components/webui/client/src/pages/SearchPage/SearchState/index.tsx Changed cachedDataset type and default from string/"" to Nullable<string>/null; imported Nullable.
components/webui/client/src/typings/query.ts Changed ExtractJobSearchParams.dataset type from Type.String() to Type.Optional(Type.String()).
components/webui/client/src/ui/QueryStatus.tsx Refactored to destructure dataset and pass null if dataset is undefined when calling submitExtractStreamJob.

Sequence Diagram(s)

sequenceDiagram
    participant UI
    participant SearchState
    participant QueryAPI

    UI->>SearchState: Retrieve cachedDataset (Nullable<string>)
    SearchState-->>UI: Returns null or string
    UI->>UI: If cachedDataset is null, set URL param to ""
    UI->>QueryAPI: submitExtractStreamJob({ dataset: cachedDataset || null })
    QueryAPI-->>UI: Job submission response
Loading
sequenceDiagram
    participant UI
    participant QueryAPI

    UI->>QueryAPI: submitExtractStreamJob({ dataset: dataset === undefined ? null : dataset })
    QueryAPI-->>UI: Job submission response
Loading

Suggested reviewers

  • davemarco

📜 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 4c8c025 and 3c444ba.

📒 Files selected for processing (1)
  • components/webui/client/eslint.config.mjs (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
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.
Learnt from: Bill-hbrhbr
PR: y-scope/clp#1036
File: components/clp-py-utils/clp_py_utils/clp_metadata_db_utils.py:204-211
Timestamp: 2025-07-03T12:58:18.407Z
Learning: In the CLP codebase, the validate_and_cache_dataset function in components/clp-py-utils/clp_py_utils/clp_metadata_db_utils.py uses in-place updates of the existing_datasets set parameter rather than returning a new set, as preferred by the development team.
components/webui/client/eslint.config.mjs (1)
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.
⏰ 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). (2)
  • GitHub Check: lint-check (macos-latest)
  • GitHub Check: lint-check (ubuntu-latest)
🔇 Additional comments (1)
components/webui/client/eslint.config.mjs (1)

38-39: LGTM! Necessary ESLint configuration update for TypeBox schema changes.

The addition of "Type.Literal" and "Type.Optional" to the capIsNewExceptions array is appropriate. These TypeBox schema builders are factory functions, not constructors, so they should be exempt from the "new-cap" rule that enforces constructor functions to be called with new.

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

@hoophalab hoophalab requested a review from davemarco July 8, 2025 04:03
@hoophalab

Copy link
Copy Markdown
Contributor Author

@davemarco the cachedDataset change requested in this comment

I don’t have much context on WebUI, so feel free to point out anything that looks off or unusual in the code. Also, do you have any suggestions for the PR title?

const cachedDataset = useSearchStore((state) => state.cachedDataset);
const nullableCachedDataset = useSearchStore((state) => state.cachedDataset);
// eslint-disable-next-line no-warning-comments
// TODO: URL search parameters can't be null, so we need a way to

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.

I think this change and the one in QueryStatus.ts make the code less readable. Do u think its possible to just omit the dataset in the path completely? Then in QueryStatus if parsedResult.dataset is undefined, we can submit null? If not i think we should close this PR.

@davemarco

Copy link
Copy Markdown
Contributor

okay i tested the latest version and looks good

Comment thread components/webui/client/eslint.config.mjs Outdated
davemarco
davemarco previously approved these changes Jul 8, 2025

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

small nit above but i approve

@davemarco davemarco self-requested a review July 8, 2025 22:11

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

title
refactor(webui): Add Nullable typing to cachedDataset to support null dataset option for clp-text flavor

@hoophalab hoophalab changed the title fix(webui): Submit the dataset parameter as null when extracting stream in clp-text flavor. refactor(webui): Add Nullable typing to cachedDataset to support null dataset option for clp-text flavor. Jul 8, 2025

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

Deferring to @davemarco's review.

For the PR title, how about:

refactor(new-webui): Add `Nullable` typing for `cachedDataset` to support null dataset option for clp-text.
  • We've been using new-webui for all new-webui commits. For consistency, can we switch to webui after the release?
  • Switched the first "to" to "for" since it's slightly confusing to read "... to x ... to y ...".
  • I think the backticks help to clarify what are symbols in the code.
  • clp-text is a known name for the clp-text-flavored package, so I don't think we need the word "flavor".

@hoophalab hoophalab changed the title refactor(webui): Add Nullable typing to cachedDataset to support null dataset option for clp-text flavor. refactor(new-webui): Add Nullable typing for cachedDataset to support null dataset option for clp-text. Jul 8, 2025
@hoophalab hoophalab merged commit 5b5fd79 into y-scope:main Jul 8, 2025
9 checks passed
@hoophalab hoophalab deleted the dataset-null branch July 10, 2025 16:33
junhaoliao pushed a commit to junhaoliao/clp that referenced this pull request May 17, 2026
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.

3 participants