Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@davemarco
Copy link
Contributor

@davemarco davemarco commented Jun 2, 2025

Description

PR adds ability to sort by timestamp.

I took a look at old webui, and It implemented server side sorting. I thought the idea of this is that it would requery, and you could get either the earliest or latest 1000 results.

After looking at it further, the server side sorting is only in the results cache, and not actually in clp, or clp-s. Like it dosent requery. As a results, the server side sorting dosent actually change the available results, and the same functionality can be achieved with client-side sorting.

To simplify until we have fancier queries, that can be resubmitted, I simply implemented client side sorting to achieve the same functionality, which is simpler. It's not that it would be hard, but this is simpler.

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

Results can be sorted

Summary by CodeRabbit

  • New Features
    • Improved sorting behaviour for the "timestamp" column in the search results table, including a default ascending order and updated sort direction cycling.
  • Style
    • Adjusted user interaction by removing the option to clear sorting on the "timestamp" column.

@davemarco davemarco requested a review from a team as a code owner June 2, 2025 17:35
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 2, 2025

"""

Walkthrough

The sorting logic for the "timestamp" column in the search results table was updated from a basic boolean sorter to a custom comparator function. Default sort order was set to ascending, and the sort directions were modified to prevent users from cancelling sorting by cycling through a third state.

Changes

File(s) Change Summary
components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx Updated "timestamp" column configuration: added custom comparator, set default sort order, and restricted sort directions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SearchResultsTable

    User->>SearchResultsTable: Clicks "timestamp" column header
    SearchResultsTable->>SearchResultsTable: Sorts rows using custom comparator (a.timestamp - b.timestamp)
    SearchResultsTable-->>User: Displays sorted results (ascending or descending)
    Note over SearchResultsTable: Sort cycles only between 'ascend' and 'descend'
Loading

Possibly related PRs

Suggested reviewers

  • junhaoliao
    """

📜 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 b2b108a and 9719ed1.

📒 Files selected for processing (1)
  • components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx (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>.

  • components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx
🧬 Code Graph Analysis (1)
components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx (1)
components/log-viewer-webui/client/src/typings/datetime.ts (1)
  • DATETIME_FORMAT_TEMPLATE (3-3)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-check (ubuntu-latest)
  • GitHub Check: lint-check (macos-latest)
🔇 Additional comments (2)
components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx (2)

29-29: Appropriate default ascending sort.

Setting defaultSortOrder: "ascend" provides a clear initial state for chronological data.


34-39: Intentional removal of unsorted state through explicit sort cycle.

The ["ascend", "descend", "ascend"] sequence correctly prevents users from reaching an unsorted state, which aligns with the UX intent. The inline comment also clarifies this behaviour.

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

@davemarco davemarco requested a review from junhaoliao June 2, 2025 17:36
Copy link
Contributor

@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 6d114b9 and 5a4bb7e.

📒 Files selected for processing (1)
  • components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx (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>.

  • components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: lint-check (macos-latest)

Comment on lines 29 to 32
sorter: (a, b) => a.timestamp - b.timestamp,
defaultSortOrder: "ascend",
// Specifying a third sort direction removes ability for user to cancel sorting.
sortDirections: ['ascend', 'descend', 'ascend'],
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

LGTM! Proper numeric sorting implementation with intentional UX behaviour.

The changes correctly implement client-side numeric sorting for timestamps:

  • The custom sorter function (a, b) => a.timestamp - b.timestamp is appropriate for numeric timestamps and more accurate than the previous boolean sorter
  • Default ascending order provides a sensible starting state for chronological data
  • The sort directions configuration intentionally removes the ability to cancel sorting, which aligns with the comment's explanation

Consider adding null/undefined handling in the sorter if timestamps could potentially be missing:

-        sorter: (a, b) => a.timestamp - b.timestamp,
+        sorter: (a, b) => (a.timestamp || 0) - (b.timestamp || 0),
📝 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
sorter: (a, b) => a.timestamp - b.timestamp,
defaultSortOrder: "ascend",
// Specifying a third sort direction removes ability for user to cancel sorting.
sortDirections: ['ascend', 'descend', 'ascend'],
sorter: (a, b) => (a.timestamp || 0) - (b.timestamp || 0),
defaultSortOrder: "ascend",
// Specifying a third sort direction removes ability for user to cancel sorting.
sortDirections: ['ascend', 'descend', 'ascend'],
🤖 Prompt for AI Agents
In
components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx
around lines 29 to 32, the sorter function currently assumes timestamps are
always present. To handle cases where timestamps might be null or undefined,
update the sorter to check for these values before subtracting. Implement logic
to treat missing timestamps consistently, such as placing them at the start or
end of the sorted list, ensuring the sorter does not throw errors or produce
incorrect order when encountering missing data.

@davemarco davemarco requested a review from hoophalab June 2, 2025 17:39
Copy link
Contributor

@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

♻️ Duplicate comments (1)
components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx (1)

30-30: 🧹 Nitpick (assertive)

Handle missing timestamps to avoid NaN.

The current sorter a.timestamp - b.timestamp will yield NaN if either timestamp is null or undefined. Consider a nullish fallback to maintain stable ordering:

-sorter: (a, b) => a.timestamp - b.timestamp,
+sorter: (a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0),

This ensures records with missing timestamps sort predictably.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5a4bb7e and e306488.

📒 Files selected for processing (1)
  • components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx (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>.

  • components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx
🧬 Code Graph Analysis (1)
components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx (1)
components/log-viewer-webui/client/src/typings/datetime.ts (1)
  • DATETIME_FORMAT_TEMPLATE (3-3)
🔇 Additional comments (1)
components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx (1)

27-27: Default ascending sort order is set appropriately.

Setting defaultSortOrder: "ascend" ensures the timestamp column is initially sorted chronologically from oldest to newest, which aligns with expected UX for time‐based data.

Comment on lines 32 to 34
sortDirections: ["ascend",
"descend",
"ascend"],
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Simplify sortDirections or remove redundancy.

Explicitly setting ["ascend", "descend", "ascend"] mirrors AntD’s default cycle. To restrict toggling to just ascend↔descend, you can simplify:

-sortDirections: ["ascend", "descend", "ascend"],
+sortDirections: ["ascend", "descend"],

Or omit sortDirections entirely if the default behaviour already meets requirements.

📝 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
sortDirections: ["ascend",
"descend",
"ascend"],
sortDirections: ["ascend", "descend"],
🤖 Prompt for AI Agents
In
components/log-viewer-webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/typings.tsx
around lines 32 to 34, the sortDirections array includes a redundant third
"ascend" value. Simplify this by either removing the last "ascend" to have
["ascend", "descend"] or omit the sortDirections property entirely if the
default AntD behavior suffices, to avoid unnecessary redundancy.

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.

for the PR title, how about:

feat(new-webui): Sort search results by timestamp.

Comment on lines 25 to 40
{
dataIndex: "timestamp",
defaultSortOrder: "ascend",
key: "timestamp",
render: (timestamp: number) => dayjs(timestamp).format(DATETIME_FORMAT_TEMPLATE),
sorter: true,
sorter: (a, b) => a.timestamp - b.timestamp,

// Specifying a third sort direction removes ability for user to cancel sorting.
sortDirections: [
"ascend",
"descend",
"ascend",
],
title: "Timestamp",
width: 15,
},
Copy link
Member

Choose a reason for hiding this comment

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

(optional: utterly nit-picking) since there're many fields already, i'd probably group the fields:

Suggested change
{
dataIndex: "timestamp",
defaultSortOrder: "ascend",
key: "timestamp",
render: (timestamp: number) => dayjs(timestamp).format(DATETIME_FORMAT_TEMPLATE),
sorter: true,
sorter: (a, b) => a.timestamp - b.timestamp,
// Specifying a third sort direction removes ability for user to cancel sorting.
sortDirections: [
"ascend",
"descend",
"ascend",
],
title: "Timestamp",
width: 15,
},
{
dataIndex: "timestamp",
key: "timestamp",
title: "Timestamp",
render: (timestamp: number) => dayjs(timestamp).format(DATETIME_FORMAT_TEMPLATE),
width: 15,
// Specifying a third sort direction removes ability for user to cancel sorting.
defaultSortOrder: "ascend",
sortDirections: [
"ascend",
"descend",
"ascend",
],
sorter: (a, b) => a.timestamp - b.timestamp,
},

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would be happy to do this, but the linter will complain about sort keys

@davemarco davemarco changed the title feat(new-webui): Add support for sorting by timestamp in search results. feat(new-webui): Sort search results by timestamp. Jun 3, 2025
@davemarco davemarco merged commit 98acf70 into y-scope:main Jun 3, 2025
6 checks passed
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.

2 participants