@omercnet/paseo-pr-radar 3.0.1-next.299.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 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.
@@ -2,7 +2,15 @@ import { openExternalUrl, type PluginSurfaceProps, useRpc } from "@getpaseo/plug
2
2
  import { copyText } from "@getpaseo/plugin/client/react-native";
3
3
  import { useMutation, useQueryClient } from "@tanstack/react-query";
4
4
  import { useCallback, useEffect, useMemo, useState } from "react";
5
- import { ActivityIndicator, FlatList, Pressable, Text, TextInput, View } from "react-native";
5
+ import {
6
+ ActivityIndicator,
7
+ FlatList,
8
+ Pressable,
9
+ ScrollView,
10
+ Text,
11
+ TextInput,
12
+ View,
13
+ } from "react-native";
6
14
  import { acknowledgeViewerScope } from "../shared/viewer-scope";
7
15
  import {
8
16
  agentActionFor,
@@ -16,6 +24,8 @@ import {
16
24
  openPullRequestUrl,
17
25
  type RadarBucket,
18
26
  type RadarRow,
27
+ type SortKey,
28
+ sortRows,
19
29
  } from "./radar";
20
30
  import {
21
31
  DIRECTORY_PARTIAL,
@@ -24,7 +34,9 @@ import {
24
34
  type RadarFilter,
25
35
  VIEWER_URL_LIMIT,
26
36
  } from "./screen-state";
37
+ import { SortControls } from "./sort-controls";
27
38
  import { useRadar } from "./use-radar";
39
+ import { revealFocusedChip } from "./web";
28
40
 
29
41
  const CLOCK_TICK_MS = 30_000;
30
42
 
@@ -88,6 +100,7 @@ export function PrRadar({
88
100
  ? (filter as SavedView)
89
101
  : null;
90
102
  const [windowDays, setWindowDays] = useState(30);
103
+ const [sortKey, setSortKey] = useState<SortKey>("attention");
91
104
  const [search, setSearch] = useState("");
92
105
  const [now, setNow] = useState(() => Date.now());
93
106
  const [openError, setOpenError] = useState<string | null>(null);
@@ -244,6 +257,7 @@ export function PrRadar({
244
257
  }),
245
258
  [activeOnly, now, rows, savedView, search, selected, focusedPr],
246
259
  );
260
+ const sortedRows = useMemo(() => sortRows(visibleRows, sortKey), [visibleRows, sortKey]);
247
261
 
248
262
  const styles = useMemo(() => {
249
263
  const gutter = layout.compact ? 14 : 24;
@@ -335,7 +349,9 @@ export function PrRadar({
335
349
  fontSize: 13,
336
350
  fontWeight: "700" as const,
337
351
  },
338
- chips: { flexDirection: "row" as const, flexWrap: "wrap" as const, gap: 7 },
352
+ // Filter chips stay on one line and scroll sideways instead of wrapping.
353
+ chipScroller: { flexGrow: 0 },
354
+ chipRow: { flexDirection: "row" as const, gap: 7, paddingRight: 6 },
339
355
  chip: {
340
356
  minHeight: 32,
341
357
  justifyContent: "center" as const,
@@ -687,7 +703,14 @@ export function PrRadar({
687
703
  </View>
688
704
  ))}
689
705
  </View>
690
- <View accessibilityRole="tablist" style={styles.chips}>
706
+ <ScrollView
707
+ accessibilityRole="tablist"
708
+ horizontal
709
+ onFocus={revealFocusedChip}
710
+ showsHorizontalScrollIndicator={false}
711
+ style={styles.chipScroller}
712
+ contentContainerStyle={styles.chipRow}
713
+ >
691
714
  <Pressable
692
715
  accessibilityRole="tab"
693
716
  accessibilityState={{
@@ -757,7 +780,7 @@ export function PrRadar({
757
780
  </Text>
758
781
  </Pressable>
759
782
  ))}
760
- </View>
783
+ </ScrollView>
761
784
  <TextInput
762
785
  accessibilityLabel="Filter pull requests"
763
786
  autoCapitalize="none"
@@ -768,6 +791,7 @@ export function PrRadar({
768
791
  style={styles.search}
769
792
  value={search}
770
793
  />
794
+ <SortControls sortKey={sortKey} onSort={setSortKey} styles={styles} />
771
795
  {viewerData ? (
772
796
  <View style={{ gap: 7 }}>
773
797
  <Text style={styles.heroDetail}>
@@ -820,7 +844,7 @@ export function PrRadar({
820
844
  >
821
845
  <FlatList
822
846
  contentContainerStyle={styles.content}
823
- data={visibleRows}
847
+ data={sortedRows}
824
848
  keyExtractor={(item) => item.id}
825
849
  ListHeaderComponent={header}
826
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/client/web.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { Platform, type ScrollViewProps } from "react-native";
2
+
3
+ export const revealFocusedChip: NonNullable<ScrollViewProps["onFocus"]> = (event) => {
4
+ if (Platform.OS !== "web") return;
5
+
6
+ const target = event.target as unknown as {
7
+ scrollIntoView(options: { block: "nearest"; inline: "nearest" }): void;
8
+ };
9
+ target.scrollIntoView({ block: "nearest", inline: "nearest" });
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omercnet/paseo-pr-radar",
3
- "version": "3.0.1-next.299.1",
3
+ "version": "3.0.1-next.301.1",
4
4
  "type": "module",
5
5
  "description": "A viewer-aware delivery queue for pull requests linked to Paseo workspaces.",
6
6
  "license": "MIT",