add per-column sort controls#32
Open
AntonNiklasson wants to merge 3 commits into
Open
Conversation
Each dashboard column gets a row of clickable dimensions in its header. Active dimension shows an arrow; clicking it toggles asc/desc, clicking another switches to it (defaulting to desc). State per column persists in localStorage via atomWithStorage. Defaults: My PRs by created desc (stable, doesn't jump on activity), Review Requests / Notifications by updated desc.
There was a problem hiding this comment.
Pull request overview
Adds per-column sorting to the web dashboard, with clickable header sort controls and keyboard shortcuts, persisting preferences via Jotai localStorage-backed atoms.
Changes:
- Introduces shared sort state/types, per-section sort field lists, and comparators for PRs, reviews, and notifications.
- Adds a reusable
SortControlheader component and wires it into each dashboard column, includings/Shift+Sshortcuts. - Updates UI copy (“opened” → “created”) and documents new shortcuts in the help overlay.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/web/src/sort.ts | Defines sort state, persisted atoms, and comparator functions for each column. |
| packages/web/src/components/SortControl.tsx | New UI control to select/toggle sort field + direction in column headers. |
| packages/web/src/components/ShortcutHelp.tsx | Documents the new sort keyboard shortcuts. |
| packages/web/src/components/SectionHeader.tsx | Adds support for rendering right-side header content (sort controls + fetching indicator). |
| packages/web/src/components/PrCard.tsx | Renames label text to “created” to align with sort terminology. |
| packages/web/src/App.tsx | Applies sorting in each column, persists state, adds header controls, and implements s/Shift+S handling. |
Comments suppressed due to low confidence (1)
packages/web/src/App.tsx:984
e.key === "S"is case-sensitive and depends on Caps Lock / keyboard layout. If you intend this to mean “Shift+S”, usee.shiftKey(and typicallye.code === "KeyS") instead of matching the capital letter. This will make the shortcut work consistently and avoid conflicting with the lower-caseshandler.
} else if (e.key === "S") {
const flip = (d: "asc" | "desc") => (d === "asc" ? "desc" : "asc");
if (activeSection === "prs") {
setPrSort((cur) => ({ ...cur, dir: flip(cur.dir) }));
} else if (activeSection === "reviews") {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+55
to
+56
| const aT = a ? new Date(a).getTime() : 0; | ||
| const bT = b ? new Date(b).getTime() : 0; |
Comment on lines
+64
to
+76
| export function comparePrs(a: PR, b: PR, sort: SortState<PrSortField>) { | ||
| const sign = sort.dir === "asc" ? 1 : -1; | ||
| switch (sort.field) { | ||
| case "created": | ||
| return sign * cmpDate(a.createdAt, b.createdAt); | ||
| case "updated": | ||
| return sign * cmpDate(a.updatedAt, b.updatedAt); | ||
| case "title": | ||
| return sign * cmpString(a.title, b.title); | ||
| case "size": | ||
| return sign * (a.additions + a.deletions - (b.additions + b.deletions)); | ||
| } | ||
| } |
Comment on lines
+951
to
+955
| } else if (e.key === "s") { | ||
| if (activeSection === "prs") { | ||
| setPrSort((cur) => { | ||
| const i = PR_SORT_FIELDS.findIndex((f) => f.field === cur.field); | ||
| const next = PR_SORT_FIELDS[(i + 1) % PR_SORT_FIELDS.length]; |
Comment on lines
+20
to
+25
| <button | ||
| key={opt.field} | ||
| type="button" | ||
| className={cn( | ||
| "text-[10px] uppercase tracking-tight tabular-nums", | ||
| active |
Comment on lines
+64
to
+69
| export function comparePrs(a: PR, b: PR, sort: SortState<PrSortField>) { | ||
| const sign = sort.dir === "asc" ? 1 : -1; | ||
| switch (sort.field) { | ||
| case "created": | ||
| return sign * cmpDate(a.createdAt, b.createdAt); | ||
| case "updated": |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scycles dimension on the active column,Shift+Stoggles direction. Documented in the?help.atomWithStorage(prSort/reviewSort/notificationSort).Test plan
pnpm typecheck,pnpm lint,pnpm fmt:check,pnpm testclean1/2/3, presssrepeatedly — wraps through dimensionsShift+S— direction flips on active dimension