Skip to content

feat(webui): Provide improved calculation of time range for queries:#1336

Merged
hoophalab merged 16 commits into
y-scope:mainfrom
hoophalab:alltime
Oct 2, 2025
Merged

feat(webui): Provide improved calculation of time range for queries:#1336
hoophalab merged 16 commits into
y-scope:mainfrom
hoophalab:alltime

Conversation

@hoophalab

@hoophalab hoophalab commented Sep 25, 2025

Copy link
Copy Markdown
Contributor
  • Treat the "All Time" time range as spanning the time range of existing archives.
  • Determine the time range when the submit button is clicked.
  • Include logs compressed without a timestamp key.

Description

From the issue page:
Currently, the "All Time" time range in the search UI defaults to [UNIX epoch, current time + 1 year]. Thus, when a user enters a query and the results are displayed, they are usually shown as a single graph near the end of the timeline.
Instead, it would be better to treat "All Time" as spanning the time range of the existing archives.

When a query is run for "All Time", this PR fetches the time range of the existing archives in clp-database; translates that into a query for the time range of the existing archives.

clpsalltime

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

Search for * on the search page with the "all time" range option selected:

  1. clp-text: The timeline's time range is the range of all logs.
  2. clp-json: The timeline's time range is the range of all logs in the dataset.
  3. clp-json: Different datasets have different time ranges.
  4. logs w/o timestamp key are shown

Summary by CodeRabbit

  • New Features

    • “All time” now auto-detects earliest/latest logs via a backend fetch; user-visible warnings appear if dataset is missing or fetch fails.
    • Submit button now computes and submits time-range bounds (or nulls for All time) and shows inline message feedback on errors.
  • Bug Fixes

    • Improved submit flow resilience with explicit error handling and fallback to a default time range.
  • Refactor

    • Preset selections no longer auto-update the visible range (CUSTOM still opens the picker); time-range defaults consolidated.

@hoophalab hoophalab requested a review from a team as a code owner September 25, 2025 21:33
@coderabbitai

coderabbitai Bot commented Sep 25, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds async time-range resolution (including ALL_TIME via SQL), updates submit to accept null timestamps and await async range resolution, stops auto-updating presets in the TimeRange UI, introduces default time-range constants and Dayjs typing across the search state, and relaxes schema to allow null timestamps.

Changes

Cohort / File(s) Summary
Time range computation & defaults
components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/utils.tsx, components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/sql.ts
Converts preset mapping to async handlers (handlers now return Promise<[Dayjs, Dayjs]>); adds DEFAULT_TIME_RANGE and DEFAULT_TIME_RANGE_OPTION; implements fetchAllTimeRange(selectDataset): Promise<[Dayjs, Dayjs]> which queries archives for ALL_TIME bounds and returns a UTC Dayjs range, falling back to default on error.
Time range UI behaviour
components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.tsx
Removes automatic update of timeRange when selecting non-CUSTOM presets; CUSTOM still triggers range picker; removed import of the synchronous TIME_RANGE_OPTION_DAYJS_MAP.
Search submission flow
components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/SubmitButton/index.tsx
Makes submit handler async and awaits preset resolution; when non-CUSTOM, resolves new range via async map and may call fetchAllTimeRange; on fetch failure shows Ant Design warning and aborts submit; updates timeline config and updateTimeRange; submits with timestampBegin/timestampEnd derived from resolved range or null for ALL_TIME; adds message.useMessage contextHolder and includes messageApi in deps.
Search state defaults & types
components/webui/client/src/pages/SearchPage/SearchState/index.tsx
Replaces default dayjs import with named Dayjs type; uses DEFAULT_TIME_RANGE and DEFAULT_TIME_RANGE_OPTION for defaults; changes timeRange type to [Dayjs, Dayjs] and updateTimeRange signature accordingly; computes timeline config from DEFAULT_TIME_RANGE.
Schema validation
components/webui/common/src/schemas/search.ts
QueryJobCreationSchema updated: timestampBegin and timestampEnd now allow null via Type.Union([Type.Null(), Type.Integer()]).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Submit as SubmitButton
  participant Store as SearchStore
  participant Map as TIME_RANGE_OPTION_DAYJS_MAP
  participant SQL as fetchAllTimeRange
  participant API as Query API
  Note right of Submit #DDEBF7: submit handler is async and uses messageApi

  User->>Submit: Click
  Submit->>Store: read timeRangeOption, timeRange, selectDataset, storageEngine
  alt timeRangeOption == CUSTOM
    Submit->>Submit: newTimeRange = timeRange
  else
    Submit->>Map: await preset handler (async)
    alt preset == ALL_TIME
      Map->>SQL: fetchAllTimeRange(selectDataset)
      SQL-->>Map: [begin,end] or error
    end
    Map-->>Submit: [begin,end] or error
    alt error
      Submit->>Submit: newTimeRange = DEFAULT_TIME_RANGE
      Submit->>User: show warning (messageApi)
    end
    Submit->>Store: updateTimeRange(newTimeRange)
  end

  alt storageEngine == CLP_S and selectDataset missing
    Submit->>User: log error & abort
  else
    Submit->>Submit: build payload (timestamps null when ALL_TIME)
    Submit->>API: submit query job
    API-->>Submit: response
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title accurately and succinctly describes the main enhancement—improved calculation of query time ranges in the web UI—and follows the established “feat(scope): description” convention used in this codebase. It clearly conveys the feature’s purpose without extraneous detail. The trailing colon is a minor formatting quirk but does not hinder comprehension.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 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 f305931 and c5fb425.

📒 Files selected for processing (1)
  • components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/SubmitButton/index.tsx (5 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:

  • components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/SubmitButton/index.tsx
🧬 Code graph analysis (1)
components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/SubmitButton/index.tsx (3)
components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/utils.tsx (2)
  • TIME_RANGE_OPTION (130-130)
  • TIME_RANGE_OPTION_DAYJS_MAP (131-131)
components/webui/client/src/config/index.ts (2)
  • CLP_STORAGE_ENGINES (26-26)
  • SETTINGS_STORAGE_ENGINE (28-28)
components/webui/client/src/pages/SearchPage/SearchState/typings.ts (1)
  • SEARCH_UI_STATE (31-31)
⏰ 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). (4)
  • GitHub Check: package-image
  • GitHub Check: lint-check (ubuntu-24.04)
  • GitHub Check: rust-checks (ubuntu-24.04)
  • GitHub Check: rust-checks (ubuntu-22.04)
🔇 Additional comments (9)
components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/SubmitButton/index.tsx (9)

1-9: LGTM!

The new imports (message, Dayjs, TIME_RANGE_OPTION, TIME_RANGE_OPTION_DAYJS_MAP) are correctly added to support the async time-range handling and user feedback features.

Also applies to: 19-22


32-44: LGTM!

The additional state selections (timeRangeOption, updateTimeRange) and the message API hook are correctly integrated to support the new time-range handling and user feedback functionality.


49-64: LGTM!

The async time-range handling correctly:

  • Fetches the time range dynamically for non-CUSTOM options via TIME_RANGE_OPTION_DAYJS_MAP
  • Updates the state with the new range
  • Provides user feedback via messageApi.warning on fetch failure
  • Aborts submission gracefully on error

This approach aligns with the discussion in past review comments about using the message API for error feedback.


66-81: LGTM!

The timeline configuration correctly uses newTimeRange, and the dataset validation error message is clear and informative.


88-98: LGTM!

The conditional timestamp handling correctly:

  • Passes null for both timestampBegin and timestampEnd when timeRangeOption === TIME_RANGE_OPTION.ALL_TIME
  • Passes computed timestamps from newTimeRange for other options

This enables including logs compressed without a timestamp key, as per the PR objectives.


100-109: LGTM!

The useCallback dependency array is complete and includes all values referenced within the callback: queryString, queryIsCaseSensitive, timeRange, timeRangeOption, updateTimeRange, messageApi, selectDataset, and updateCachedDataset.


115-116: LGTM!

The disabled logic is correctly expanded for readability and checks all necessary conditions to prevent invalid submissions.

Also applies to: 134-136


137-141: LGTM!

The onClick handler correctly wraps the async handleSubmitButtonClick call with a catch block that rethrows errors, preventing unhandled promise rejections while preserving error propagation semantics.


127-127: LGTM!

The contextHolder is correctly rendered to enable the Ant Design message API functionality.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

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

the code structure lgtm. will validate before approving on the posted comments are addressed

@hoophalab hoophalab changed the title feat(webui): Treat the "All Time" time range as spanning the time range of existing archives (resolves #970). feat(webui): Improve "All Time" time range handling (resolves #970): Sep 25, 2025
@junhaoliao junhaoliao changed the title feat(webui): Improve "All Time" time range handling (resolves #970): feat(webui): Improve "All Time" time range handling (resolves #970).. Sep 29, 2025
@junhaoliao junhaoliao changed the title feat(webui): Improve "All Time" time range handling (resolves #970).. feat(webui): Improve "All Time" time range handling (resolves #970). Sep 29, 2025
@davemarco

Copy link
Copy Markdown
Contributor

Do you think we should update TIME_RANGE_OPTION_DAYJS_MAP in /home/davidmawk/clp/components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/utils.tsx to call the fetch timestamp function? Then we could upgrade the whole UI, so that it calls the function in TIME_RANGE_OPTION_DAYJS_MAP when we submit a query. Right now the timestamps get outdated, but we could potentially fix this for all options, not just allTime

@hoophalab

Copy link
Copy Markdown
Contributor Author

Do you think we should update TIME_RANGE_OPTION_DAYJS_MAP in /home/davidmawk/clp/components/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/utils.tsx to call the fetch timestamp function? Then we could upgrade the whole UI, so that it calls the function in TIME_RANGE_OPTION_DAYJS_MAP when we submit a query. Right now the timestamps get outdated, but we could potentially fix this for all options, not just allTime

sure I'll do that

@hoophalab hoophalab changed the title feat(webui): Improve "All Time" time range handling (resolves #970). feat(webui): Improve time range handling (resolves #970): Oct 1, 2025
@hoophalab hoophalab requested a review from davemarco October 1, 2025 17:06
coderabbitai[bot]

This comment was marked as off-topic.

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

see final comments

Comment thread components/webui/common/src/schemas/search.ts
@hoophalab hoophalab requested a review from davemarco October 2, 2025 17:07
coderabbitai[bot]

This comment was marked as resolved.

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

reponded to ur question

@hoophalab hoophalab requested a review from davemarco October 2, 2025 18:18
@davemarco

Copy link
Copy Markdown
Contributor

feat(webui): Provide improved calculation of time range for queries:

coderabbitai[bot]

This comment was marked as resolved.

@hoophalab hoophalab changed the title feat(webui): Improve time range handling (resolves #970): feat(webui): Provide improved calculation of time range for queries: Oct 2, 2025

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

nice job. deferring to @davemarco 's review

@hoophalab hoophalab merged commit 632eecb into y-scope:main Oct 2, 2025
22 checks passed
@hoophalab hoophalab deleted the alltime branch October 23, 2025 19:06
junhaoliao pushed a commit to junhaoliao/clp that referenced this pull request May 17, 2026
…-scope#1336)

- Treat the "All Time" time range as spanning the time range of existing archives.
- Determine the time range when the submit button is clicked.
- Include logs compressed without a timestamp key.
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