Skip to content

feat: sync table sort state to the URL - #2029

Open
mentonin wants to merge 3 commits into
kernelci:mainfrom
profusion:sort-url
Open

feat: sync table sort state to the URL#2029
mentonin wants to merge 3 commits into
kernelci:mainfrom
profusion:sort-url

Conversation

@mentonin

@mentonin mentonin commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Persist sortable table state in the URL via a shared useSortingState hook and root tableSort search param, so sort order is shareable and bookmarkable.
  • Encode a single active table as flat s=…; use keyed params (s|b=…, s|t=…) only on pages with multiple tracked tables (issue details).
  • Clear tableSort when switching tree/hardware details tabs so inactive tables do not keep stale sort.

Test plan

  • Sort tree, hardware, and issue listing tables; confirm the URL updates and reload/share restores the same sort
  • Reset to default sort and confirm the s / tableSort param is omitted
  • On tree and hardware details, sort a tab, switch tabs, and confirm sort resets for the newly active table
  • On issue details, sort builds and tests independently and confirm keyed URL params (s|b, s|t)
  • Confirm unit tests: useSortingState.test.ts, search.test.ts

Related issues

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

Pretty nice


const sortingUpdater: OnChangeFn<SortingState> = useCallback(
updater => {
navigate({

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.

prefer to use replace instead of push here, or we might end up hurting navigation stack

];
};

export function HardwareTable({

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.

This seems to be happening only on hardware listing. But if we select a sorting strategy, and later click in a row, the sorting parameter seems to be carried in the url.

@mentonin mentonin Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the new commit fixes this everywhere now

@mentonin
mentonin requested a review from alanpeixinho July 30, 2026 16:41
@felipebergamin

Copy link
Copy Markdown
Member

code is looking good, I want to test it before approving

@mentonin
mentonin requested review from felipebergamin and a lite review from Copilot and removed request for Copilot August 4, 2026 21:09
Comment thread dashboard/src/hooks/useSortingState.ts Outdated
Comment on lines +93 to +95

export const useSortingState = (
options: UseSortingStateOptions = {},

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.

Suggested change
export const useSortingState = (
options: UseSortingStateOptions = {},
const EMPTY_OBJECT = {};
export const useSortingState = (
options: UseSortingStateOptions = EMPTY_OBJECT,

Comment thread dashboard/src/hooks/useSortingState.ts Outdated
[defaultSorting, sortValue],
);

const sortingUpdater: OnChangeFn<SortingState> = useCallback(

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.

just to follow the convention I'd name it onUpdateSorting or handleSortingUpdate

Comment thread dashboard/src/types/general.ts Outdated
.default(DEFAULT_LISTING_ITEMS);

/** Sentinel for an explicit unsorted state when the table default is not unsorted. */
export const TABLE_SORT_UNSORTED = 'none';

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.

Suggested change
export const TABLE_SORT_UNSORTED = 'none';
export const TABLE_SORT_UNSORTED = 'none' as const;

mentonin and others added 3 commits August 7, 2026 17:05
Make sortable tables shareable via search params: flat s=… for single
tables, keyed s|… when multiple tables share a page. Clear sort when
switching details tabs so inactive tables do not keep stale ordering.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Luiz Georg <luiz.georg@profusion.mobi>
Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Felipe Bergamin <felipebergamin@profusion.mobi>
@felipebergamin

Copy link
Copy Markdown
Member

just rebased the branch

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.

Add non-default table sort to URL for easier sharing

3 participants