@omercnet/paseo-pr-radar 3.0.1-next.300.1 → 3.0.1-next.301.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -0
- package/client/pr-radar.tsx +7 -1
- package/client/radar.ts +49 -0
- package/client/sort-controls.tsx +86 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,21 @@ DevTools before capture. Both PNGs come from an isolated Paseo test daemon at 2
|
|
|
33
33
|
|
|
34
34
|
Paseo supplies normalized workspace pull request status. A daemon-side plugin handler uses the authenticated `gh` CLI to distinguish authored pull requests from review requests. If viewer lookup fails, PR Radar falls back conservatively and does not claim that a row needs the user.
|
|
35
35
|
|
|
36
|
+
## Sorting
|
|
37
|
+
|
|
38
|
+
The Sort row applies after the current filters and search. **Needs attention first** is the default:
|
|
39
|
+
bucket order, then oldest activity first. **Mergeable first** puts Ready rows first, newest activity
|
|
40
|
+
first, then the remaining buckets. **Recently updated** and **Oldest first** order by activity, not
|
|
41
|
+
creation time. **Repository** orders by repository name, then PR number.
|
|
42
|
+
|
|
43
|
+
Activity ties use ascending titles; fully tied rows keep their input order. Missing or invalid
|
|
44
|
+
activity times count as the epoch, so they sort first in oldest-first orders and last in newest-first
|
|
45
|
+
orders. Sort selection stays local to the open screen and resets on reload, like search and the
|
|
46
|
+
time window.
|
|
47
|
+
|
|
48
|
+
On web, Tab enters the group at the selected option and Tab or Shift+Tab leaves it. Space selects
|
|
49
|
+
the focused option. Arrow keys select and focus the next or previous option, wrapping at either end.
|
|
50
|
+
|
|
36
51
|
## Sidebar row
|
|
37
52
|
|
|
38
53
|
The sidebar row shows a "needs you" count; pressing the count opens a popover of those pull requests. Pressing one opens PR Radar focused on it (`param.pr`), and the needs-you link filters the queue (`param.filter`), so both survive reload and can be linked. A trailing `+` marks a count that may be incomplete: viewer lookup failed, a pagination or inbox cap was hit, or workspace status was unavailable.
|
package/client/pr-radar.tsx
CHANGED
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
openPullRequestUrl,
|
|
25
25
|
type RadarBucket,
|
|
26
26
|
type RadarRow,
|
|
27
|
+
type SortKey,
|
|
28
|
+
sortRows,
|
|
27
29
|
} from "./radar";
|
|
28
30
|
import {
|
|
29
31
|
DIRECTORY_PARTIAL,
|
|
@@ -32,6 +34,7 @@ import {
|
|
|
32
34
|
type RadarFilter,
|
|
33
35
|
VIEWER_URL_LIMIT,
|
|
34
36
|
} from "./screen-state";
|
|
37
|
+
import { SortControls } from "./sort-controls";
|
|
35
38
|
import { useRadar } from "./use-radar";
|
|
36
39
|
import { revealFocusedChip } from "./web";
|
|
37
40
|
|
|
@@ -97,6 +100,7 @@ export function PrRadar({
|
|
|
97
100
|
? (filter as SavedView)
|
|
98
101
|
: null;
|
|
99
102
|
const [windowDays, setWindowDays] = useState(30);
|
|
103
|
+
const [sortKey, setSortKey] = useState<SortKey>("attention");
|
|
100
104
|
const [search, setSearch] = useState("");
|
|
101
105
|
const [now, setNow] = useState(() => Date.now());
|
|
102
106
|
const [openError, setOpenError] = useState<string | null>(null);
|
|
@@ -253,6 +257,7 @@ export function PrRadar({
|
|
|
253
257
|
}),
|
|
254
258
|
[activeOnly, now, rows, savedView, search, selected, focusedPr],
|
|
255
259
|
);
|
|
260
|
+
const sortedRows = useMemo(() => sortRows(visibleRows, sortKey), [visibleRows, sortKey]);
|
|
256
261
|
|
|
257
262
|
const styles = useMemo(() => {
|
|
258
263
|
const gutter = layout.compact ? 14 : 24;
|
|
@@ -786,6 +791,7 @@ export function PrRadar({
|
|
|
786
791
|
style={styles.search}
|
|
787
792
|
value={search}
|
|
788
793
|
/>
|
|
794
|
+
<SortControls sortKey={sortKey} onSort={setSortKey} styles={styles} />
|
|
789
795
|
{viewerData ? (
|
|
790
796
|
<View style={{ gap: 7 }}>
|
|
791
797
|
<Text style={styles.heroDetail}>
|
|
@@ -838,7 +844,7 @@ export function PrRadar({
|
|
|
838
844
|
>
|
|
839
845
|
<FlatList
|
|
840
846
|
contentContainerStyle={styles.content}
|
|
841
|
-
data={
|
|
847
|
+
data={sortedRows}
|
|
842
848
|
keyExtractor={(item) => item.id}
|
|
843
849
|
ListHeaderComponent={header}
|
|
844
850
|
ListEmptyComponent={
|
package/client/radar.ts
CHANGED
|
@@ -559,6 +559,55 @@ export function applyViewerScope(
|
|
|
559
559
|
return result;
|
|
560
560
|
}
|
|
561
561
|
|
|
562
|
+
export const SORT_KEYS = ["attention", "mergeable", "recent", "oldest", "repository"] as const;
|
|
563
|
+
export type SortKey = (typeof SORT_KEYS)[number];
|
|
564
|
+
|
|
565
|
+
export const SORT_TITLES: Record<SortKey, string> = {
|
|
566
|
+
mergeable: "Mergeable first",
|
|
567
|
+
attention: "Needs attention first",
|
|
568
|
+
recent: "Recently updated",
|
|
569
|
+
oldest: "Oldest first",
|
|
570
|
+
repository: "Repository",
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
// Unknown or unparsable activity counts as the epoch (the oldest), which keeps the order total.
|
|
574
|
+
const activityOf = (row: RadarRow) => Date.parse(row.activityAt ?? "") || 0;
|
|
575
|
+
const oldestFirst = (left: RadarRow, right: RadarRow) =>
|
|
576
|
+
activityOf(left) - activityOf(right) || left.title.localeCompare(right.title);
|
|
577
|
+
const newestFirst = (left: RadarRow, right: RadarRow) =>
|
|
578
|
+
activityOf(right) - activityOf(left) || left.title.localeCompare(right.title);
|
|
579
|
+
|
|
580
|
+
/** Orders rows for display. Returns a new array; the input order is the bucket order. */
|
|
581
|
+
export function sortRows(rows: readonly RadarRow[], key: SortKey): RadarRow[] {
|
|
582
|
+
const sorted = [...rows];
|
|
583
|
+
switch (key) {
|
|
584
|
+
case "mergeable":
|
|
585
|
+
// classifyRow only yields "ready" for the viewer's own, non-draft, mergeable PRs.
|
|
586
|
+
return sorted.sort(
|
|
587
|
+
(left, right) =>
|
|
588
|
+
Number(right.bucket === "ready") - Number(left.bucket === "ready") ||
|
|
589
|
+
BUCKET_ORDER[left.bucket] - BUCKET_ORDER[right.bucket] ||
|
|
590
|
+
newestFirst(left, right),
|
|
591
|
+
);
|
|
592
|
+
case "attention":
|
|
593
|
+
// The default: the order applyViewerScope produces, longest waiting first within a bucket.
|
|
594
|
+
return sorted.sort(
|
|
595
|
+
(left, right) =>
|
|
596
|
+
BUCKET_ORDER[left.bucket] - BUCKET_ORDER[right.bucket] || oldestFirst(left, right),
|
|
597
|
+
);
|
|
598
|
+
case "recent":
|
|
599
|
+
return sorted.sort(newestFirst);
|
|
600
|
+
case "oldest":
|
|
601
|
+
return sorted.sort(oldestFirst);
|
|
602
|
+
case "repository":
|
|
603
|
+
return sorted.sort(
|
|
604
|
+
(left, right) =>
|
|
605
|
+
left.repository.localeCompare(right.repository) ||
|
|
606
|
+
(left.number ?? 0) - (right.number ?? 0),
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
562
611
|
export function matchesRow(row: RadarRow, needle: string): boolean {
|
|
563
612
|
const query = needle.trim().toLowerCase();
|
|
564
613
|
if (!query) return true;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Platform,
|
|
3
|
+
Pressable,
|
|
4
|
+
type StyleProp,
|
|
5
|
+
Text,
|
|
6
|
+
type TextStyle,
|
|
7
|
+
View,
|
|
8
|
+
type ViewStyle,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
import { SORT_KEYS, SORT_TITLES, type SortKey } from "./radar";
|
|
11
|
+
|
|
12
|
+
interface SortControlsProps {
|
|
13
|
+
sortKey: SortKey;
|
|
14
|
+
onSort: (key: SortKey) => void;
|
|
15
|
+
styles: {
|
|
16
|
+
chip: StyleProp<ViewStyle>;
|
|
17
|
+
chipActive: StyleProp<ViewStyle>;
|
|
18
|
+
chipText: StyleProp<TextStyle>;
|
|
19
|
+
chipTextActive: StyleProp<TextStyle>;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// The host's React Native Web forwards this DOM event; native RN does not declare it.
|
|
24
|
+
export interface RadioKeyEvent {
|
|
25
|
+
key: string;
|
|
26
|
+
target: unknown;
|
|
27
|
+
currentTarget: {
|
|
28
|
+
parentElement: { querySelectorAll(selector: string): ArrayLike<{ focus(): void }> } | null;
|
|
29
|
+
};
|
|
30
|
+
preventDefault(): void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const rowStyle: ViewStyle = { flexDirection: "row", flexWrap: "wrap", gap: 7 };
|
|
34
|
+
|
|
35
|
+
export function SortControls({ sortKey, onSort, styles }: SortControlsProps) {
|
|
36
|
+
const isWeb = Platform.OS === "web";
|
|
37
|
+
return (
|
|
38
|
+
<View accessibilityRole="radiogroup" accessibilityLabel="Sort pull requests" style={rowStyle}>
|
|
39
|
+
<Text style={[styles.chipText, { alignSelf: "center" }]}>Sort</Text>
|
|
40
|
+
{SORT_KEYS.map((key, index) => (
|
|
41
|
+
<Pressable
|
|
42
|
+
accessibilityRole="radio"
|
|
43
|
+
accessibilityState={{ checked: sortKey === key }}
|
|
44
|
+
aria-checked={sortKey === key}
|
|
45
|
+
key={key}
|
|
46
|
+
tabIndex={isWeb ? (sortKey === key ? 0 : -1) : undefined}
|
|
47
|
+
{...(isWeb
|
|
48
|
+
? {
|
|
49
|
+
onKeyDown: (event: RadioKeyEvent) => {
|
|
50
|
+
if (event.target !== event.currentTarget) return;
|
|
51
|
+
let next = index;
|
|
52
|
+
switch (event.key) {
|
|
53
|
+
case " ":
|
|
54
|
+
break;
|
|
55
|
+
case "ArrowRight":
|
|
56
|
+
case "ArrowDown":
|
|
57
|
+
next = (index + 1) % SORT_KEYS.length;
|
|
58
|
+
break;
|
|
59
|
+
case "ArrowLeft":
|
|
60
|
+
case "ArrowUp":
|
|
61
|
+
next = (index + SORT_KEYS.length - 1) % SORT_KEYS.length;
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
if (SORT_KEYS[next] !== sortKey) onSort(SORT_KEYS[next]);
|
|
68
|
+
if (next !== index) {
|
|
69
|
+
event.currentTarget.parentElement
|
|
70
|
+
?.querySelectorAll('[role="radio"]')
|
|
71
|
+
[next]?.focus();
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
: {})}
|
|
76
|
+
onPress={() => onSort(key)}
|
|
77
|
+
style={[styles.chip, sortKey === key && styles.chipActive]}
|
|
78
|
+
>
|
|
79
|
+
<Text style={[styles.chipText, sortKey === key && styles.chipTextActive]}>
|
|
80
|
+
{SORT_TITLES[key]}
|
|
81
|
+
</Text>
|
|
82
|
+
</Pressable>
|
|
83
|
+
))}
|
|
84
|
+
</View>
|
|
85
|
+
);
|
|
86
|
+
}
|
package/package.json
CHANGED