@omercnet/paseo-pr-radar 3.2.3 → 3.3.0-next.528.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.
@@ -1,7 +1,12 @@
1
- import { openExternalUrl, type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
1
+ import {
2
+ openExternalUrl,
3
+ type PluginSurfaceProps,
4
+ useRpc,
5
+ useSettings,
6
+ } from "@getpaseo/plugin/client";
2
7
  import { copyText } from "@getpaseo/plugin/client/react-native";
3
8
  import { useMutation, useQueryClient } from "@tanstack/react-query";
4
- import { useCallback, useEffect, useMemo, useState } from "react";
9
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
5
10
  import {
6
11
  ActivityIndicator,
7
12
  FlatList,
@@ -11,22 +16,36 @@ import {
11
16
  TextInput,
12
17
  View,
13
18
  } from "react-native";
14
- import { acknowledgeViewerScope } from "../shared/viewer-scope";
19
+ import { DEFAULT_PR_RADAR_SETTINGS, prRadarSettings } from "../shared/settings";
20
+ import {
21
+ acknowledgeViewerScope,
22
+ prepareWorkspaceCwd,
23
+ runRoutingScript,
24
+ } from "../shared/viewer-scope";
25
+ import { HighlightedText } from "./highlighted-text";
15
26
  import {
27
+ type AgentLaunchOverrides,
16
28
  agentActionFor,
29
+ autoLaunchRequiresModal,
17
30
  BUCKET_TITLES,
18
31
  BUCKETS,
32
+ buildAgentConfig,
19
33
  buildAgentPrompt,
20
34
  checkSummary,
21
35
  formatAge,
22
36
  hasActiveAgent,
37
+ labelWorkspaceCwd,
23
38
  matchesRow,
24
39
  openPullRequestUrl,
25
40
  profileAgentConfig,
26
41
  type RadarBucket,
27
42
  type RadarRow,
43
+ restrictRoutedLaunch,
44
+ routedProviderModel,
28
45
  type SortKey,
29
46
  sortRows,
47
+ splitDraftRows,
48
+ vetRoutedProfile,
30
49
  } from "./radar";
31
50
  import {
32
51
  DIRECTORY_PARTIAL,
@@ -34,8 +53,10 @@ import {
34
53
  parseRadarParams,
35
54
  type RadarFilter,
36
55
  VIEWER_URL_LIMIT,
56
+ viewerCoverage,
37
57
  } from "./screen-state";
38
58
  import { SortControls } from "./sort-controls";
59
+ import { type StartAgentLaunchRequest, StartAgentModal } from "./start-agent-modal";
39
60
  import { useRadar } from "./use-radar";
40
61
  import { revealFocusedChip } from "./web";
41
62
 
@@ -79,16 +100,25 @@ export function PrRadar({
79
100
  host,
80
101
  navigation,
81
102
  params = {},
82
- }: PluginSurfaceProps & { params?: Record<string, string> }) {
103
+ onOpenSettings,
104
+ }: PluginSurfaceProps & { params?: Record<string, string>; onOpenSettings?: () => void }) {
83
105
  const queryClient = useQueryClient();
84
106
  const acknowledgeUpdates = useRpc(acknowledgeViewerScope);
107
+ const prepareCwd = useRpc(prepareWorkspaceCwd);
108
+ const invokeRouter = useRpc(runRoutingScript);
109
+ const settingsState = useSettings(prRadarSettings);
110
+ const settings =
111
+ settingsState.status === "ready" ? settingsState.values : DEFAULT_PR_RADAR_SETTINGS;
85
112
  const parsed = parseRadarParams(params);
86
113
  // The host's compact flag follows the window, so a pane narrower than the window (the screen
87
114
  // sits beside a sidebar) kept the wide card. Measure the radar's own width as well.
88
115
  const [narrow, setNarrow] = useState(false);
89
116
  const layout = { ...hostLayout, compact: hostLayout.compact || narrow };
90
117
  const [filter, setFilterState] = useState<RadarFilter | null>(parsed.filter);
118
+ const [activeTab, setActiveTab] = useState<"prs" | "issues">("prs");
91
119
  const [focusedPr, setFocusedPr] = useState<string | null>(parsed.pr);
120
+ const [modalRow, setModalRow] = useState<RadarRow | null>(null);
121
+ const [dprCollapsed, setDprCollapsed] = useState(false);
92
122
  // Chips are local state: openScreen would push a new screen per tap. A chip press also ends PR focus.
93
123
  const setFilter = (value: RadarFilter | null) => {
94
124
  setFilterState(value);
@@ -123,11 +153,16 @@ export function PrRadar({
123
153
  refetch,
124
154
  rawRows,
125
155
  rows,
156
+ issues,
126
157
  viewerData,
127
158
  viewerError,
128
- isFetching,
129
159
  refetchViewer,
130
160
  } = useRadar(host.id, windowDays);
161
+ // Only a press shows "Scanning": agent updates and the poll refetch in the background, and keying
162
+ // the label on those flashed it every second or two while agents ran.
163
+ const refreshMutation = useMutation({
164
+ mutationFn: () => Promise.all([refetch(), refetchViewer()]),
165
+ });
131
166
 
132
167
  useEffect(() => {
133
168
  const clock = setInterval(() => setNow(Date.now()), CLOCK_TICK_MS);
@@ -207,6 +242,186 @@ export function PrRadar({
207
242
  },
208
243
  onSettled: () => queryClient.invalidateQueries({ queryKey }),
209
244
  });
245
+
246
+ const startNewAgentMutation = useMutation({
247
+ mutationFn: async (request: StartAgentLaunchRequest) => {
248
+ const { row } = request;
249
+ if (!row.number) {
250
+ throw new Error("An issue or pull request number is required to start a new agent.");
251
+ }
252
+ const prepared = await prepareCwd({
253
+ repository: row.repository,
254
+ prNumber: row.number,
255
+ itemKind: row.itemKind ?? "pr",
256
+ headRefName: row.headRefName,
257
+ baseRefName: row.baseRefName,
258
+ targetDir: request.targetDir,
259
+ allowClone: request.allowClone ?? false,
260
+ cwdMode: request.cwdMode,
261
+ worktreeName: request.worktreeName,
262
+ });
263
+
264
+ const targetWorkspace = await paseo.workspaces.open(prepared.cwd);
265
+ await labelWorkspaceCwd(targetWorkspace, prepared.cwdTag);
266
+
267
+ const { config } = await paseo.config.get();
268
+ const profiles = config.agentProfiles ?? [];
269
+ const wantedProfile = request.profileName.trim().toLowerCase();
270
+ const profile =
271
+ (wantedProfile
272
+ ? profiles.find((candidate) => candidate.name.toLowerCase() === wantedProfile)
273
+ : undefined) ??
274
+ profiles.find((candidate) => candidate.name.toLowerCase() === "model router") ??
275
+ profiles[0];
276
+
277
+ const agentConfig = buildAgentConfig(profile, request.overrides);
278
+ const prompt = buildAgentPrompt(row);
279
+ const created = await targetWorkspace.agents.create({
280
+ config: agentConfig,
281
+ title: `PR Radar: ${row.repository}#${row.number}`,
282
+ prompt,
283
+ labels: { "pr-radar.cwd": prepared.cwdTag },
284
+ });
285
+
286
+ if (navigation) {
287
+ navigation.openAgent({ agentId: created.id, serverId: host.id });
288
+ }
289
+ const baseMsg = `Started new agent in ${prepared.cwdTag} (${prepared.cwd}) for ${row.repository}#${row.number}.`;
290
+ const warnings = [request.routingWarning, prepared.warning].filter(Boolean);
291
+ return warnings.length > 0 ? `${warnings.join(" ")} ${baseMsg}` : baseMsg;
292
+ },
293
+ onMutate: (request) => {
294
+ setOpenError(null);
295
+ setActionNotice(request.routingWarning ?? null);
296
+ },
297
+ onSuccess: (message) => {
298
+ setModalRow(null);
299
+ setActionNotice(message);
300
+ },
301
+ onError: (mutationError) => {
302
+ setOpenError(
303
+ mutationError instanceof Error ? mutationError.message : "Could not start new agent.",
304
+ );
305
+ },
306
+ onSettled: () => queryClient.invalidateQueries({ queryKey }),
307
+ });
308
+
309
+ const autoLaunchingRef = useRef(false);
310
+
311
+ const handleStartNewAgentPress = useCallback(
312
+ async (row: RadarRow) => {
313
+ if (autoLaunchingRef.current || startNewAgentMutation.isPending) return;
314
+ setOpenError(null);
315
+ if (autoLaunchRequiresModal(settings, row)) {
316
+ if (settings.defaultCwdMode === "CWD-BASE") {
317
+ setActionNotice("CWD-BASE will switch the selected checkout before the agent starts.");
318
+ }
319
+ setModalRow(row);
320
+ return;
321
+ }
322
+
323
+ autoLaunchingRef.current = true;
324
+ try {
325
+ let overrides: AgentLaunchOverrides = {
326
+ provider: settings.defaultProvider,
327
+ model: settings.defaultModel,
328
+ thinkingOptionId: settings.defaultEffort,
329
+ modeId: settings.defaultModeId,
330
+ contextMode: settings.defaultContextMode,
331
+ };
332
+ let profileName = settings.defaultProfile;
333
+ let routingWarning: string | undefined;
334
+
335
+ if (settings.routingScriptPath.trim()) {
336
+ try {
337
+ const routed = await invokeRouter({
338
+ payload: {
339
+ pr: {
340
+ id: row.id,
341
+ number: row.number,
342
+ url: row.url,
343
+ title: row.title,
344
+ repository: row.repository,
345
+ baseRefName: row.baseRefName,
346
+ headRefName: row.headRefName,
347
+ isDraft: row.isDraft,
348
+ author: row.author,
349
+ authorKind: row.authorKind,
350
+ isSecurity: row.isSecurity,
351
+ comments: row.comments,
352
+ labels: row.labels,
353
+ bucket: row.bucket,
354
+ reason: row.reason,
355
+ reviewRequestedFromMe: row.reviewRequestedFromMe,
356
+ ownership: row.ownership,
357
+ checksStatus: row.checksStatus,
358
+ reviewDecision: row.reviewDecision,
359
+ mergeable: row.mergeable,
360
+ linkedIssues: row.linkedIssues,
361
+ },
362
+ workspace: {
363
+ targetDir: row.localProjectRoot ?? null,
364
+ cwdMode: settings.defaultCwdMode,
365
+ localProjectRoot: row.localProjectRoot,
366
+ workspaceIds: row.workspaceIds,
367
+ },
368
+ defaults: {
369
+ profile: settings.defaultProfile,
370
+ provider: settings.defaultProvider,
371
+ model: settings.defaultModel,
372
+ effort: settings.defaultEffort,
373
+ modeId: settings.defaultModeId,
374
+ contextMode: settings.defaultContextMode,
375
+ },
376
+ },
377
+ });
378
+ const vetted = routed.profile
379
+ ? vetRoutedProfile(
380
+ (await paseo.config.get()).config.agentProfiles ?? [],
381
+ routed.profile,
382
+ )
383
+ : { ignored: [] as string[] };
384
+ if (vetted.profileName) profileName = vetted.profileName;
385
+ overrides = { ...overrides, ...routedProviderModel(overrides, routed) };
386
+ if (routed.thinkingOptionId) {
387
+ overrides = { ...overrides, thinkingOptionId: routed.thinkingOptionId };
388
+ }
389
+ const restricted = restrictRoutedLaunch(routed);
390
+ restricted.ignored.push(...vetted.ignored);
391
+ if (restricted.modeId) overrides = { ...overrides, modeId: restricted.modeId };
392
+ if (routed.contextMode) overrides = { ...overrides, contextMode: routed.contextMode };
393
+ if (restricted.options) overrides = { ...overrides, options: restricted.options };
394
+ if (restricted.ignored.length > 0) {
395
+ routingWarning = `Routing script values ignored (${restricted.ignored.join(", ")}).`;
396
+ setActionNotice(routingWarning);
397
+ }
398
+ } catch (routerError) {
399
+ const reason =
400
+ routerError instanceof Error ? routerError.message : "Routing script failed.";
401
+ routingWarning = `Routing script failed (${reason}); using PR Radar defaults.`;
402
+ setActionNotice(routingWarning);
403
+ }
404
+ }
405
+
406
+ // onError reports the failure; the guard stays held until the mutation has settled.
407
+ await startNewAgentMutation
408
+ .mutateAsync({
409
+ row,
410
+ targetDir: row.localProjectRoot ?? null,
411
+ allowClone: settings.autoLaunchMode === "existing_or_clone",
412
+ cwdMode: settings.defaultCwdMode,
413
+ worktreeName: null,
414
+ profileName,
415
+ overrides,
416
+ routingWarning,
417
+ })
418
+ .catch(() => undefined);
419
+ } finally {
420
+ autoLaunchingRef.current = false;
421
+ }
422
+ },
423
+ [invokeRouter, settings, startNewAgentMutation],
424
+ );
210
425
  const counts = useMemo(() => {
211
426
  const result: Record<RadarBucket, number> = {
212
427
  "needs-you": 0,
@@ -253,6 +468,18 @@ export function PrRadar({
253
468
  [activeOnly, now, rows, savedView, search, selected, focusedPr],
254
469
  );
255
470
  const sortedRows = useMemo(() => sortRows(visibleRows, sortKey), [visibleRows, sortKey]);
471
+ const { pullRequests, draftPullRequests } = useMemo(
472
+ () => splitDraftRows(sortedRows),
473
+ [sortedRows],
474
+ );
475
+ const sortedIssues = useMemo(
476
+ () =>
477
+ sortRows(
478
+ issues.filter((row) => matchesRow(row, search)),
479
+ sortKey,
480
+ ),
481
+ [issues, search, sortKey],
482
+ );
256
483
 
257
484
  const styles = useMemo(() => {
258
485
  const gutter = layout.compact ? 14 : 24;
@@ -266,18 +493,31 @@ export function PrRadar({
266
493
  paddingBottom: 48,
267
494
  },
268
495
  header: {
496
+ width: "100%" as const,
269
497
  paddingHorizontal: gutter,
270
498
  paddingTop: layout.compact ? 18 : 28,
271
499
  paddingBottom: 18,
272
500
  gap: 14,
273
501
  },
274
502
  signalLine: {
503
+ width: "100%" as const,
275
504
  flexDirection: "row" as const,
276
505
  alignItems: "center" as const,
277
506
  justifyContent: "space-between" as const,
278
507
  gap: 12,
279
508
  },
280
- signalLabel: { flexDirection: "row" as const, alignItems: "center" as const, gap: 8 },
509
+ signalLabel: {
510
+ flexDirection: "row" as const,
511
+ alignItems: "center" as const,
512
+ gap: 8,
513
+ flexShrink: 1,
514
+ },
515
+ headerActions: {
516
+ flexDirection: "row" as const,
517
+ alignItems: "center" as const,
518
+ gap: 8,
519
+ flexShrink: 0,
520
+ },
281
521
  signalDot: {
282
522
  width: 7,
283
523
  height: 7,
@@ -332,12 +572,16 @@ export function PrRadar({
332
572
  refresh: {
333
573
  minHeight: 36,
334
574
  justifyContent: "center" as const,
575
+ alignItems: "center" as const,
335
576
  paddingHorizontal: 12,
336
577
  borderWidth: 1,
337
578
  borderColor: theme.colors.accent,
338
579
  borderRadius: 8,
339
580
  backgroundColor: theme.colors.accent,
340
581
  },
582
+ refreshButton: {
583
+ minWidth: 92,
584
+ },
341
585
  refreshPressed: { opacity: 0.72 },
342
586
  refreshText: {
343
587
  color: theme.colors.accentForeground,
@@ -361,16 +605,28 @@ export function PrRadar({
361
605
  },
362
606
  chipText: { color: theme.colors.foregroundMuted, fontSize: 12, fontWeight: "600" as const },
363
607
  chipTextActive: { color: theme.colors.surface0 },
608
+ tabBar: {
609
+ flexDirection: "row" as const,
610
+ flexWrap: "wrap" as const,
611
+ alignItems: "center" as const,
612
+ gap: 7,
613
+ },
614
+ highlight: {
615
+ backgroundColor: theme.colors.accent,
616
+ color: theme.colors.accentForeground,
617
+ },
364
618
  search: {
365
- minHeight: 40,
619
+ flexGrow: 1,
620
+ flexBasis: 140,
621
+ minHeight: 32,
366
622
  color: theme.colors.foreground,
367
623
  backgroundColor: theme.colors.surface1,
368
624
  borderWidth: 1,
369
625
  borderColor: theme.colors.border,
370
626
  borderRadius: 8,
371
627
  paddingHorizontal: 12,
372
- paddingVertical: 8,
373
- fontSize: 14,
628
+ paddingVertical: 4,
629
+ fontSize: 13,
374
630
  },
375
631
  warning: {
376
632
  marginHorizontal: gutter,
@@ -442,7 +698,9 @@ export function PrRadar({
442
698
  metadata: { color: theme.colors.foregroundMuted, fontSize: 12, lineHeight: 17 },
443
699
  actions: {
444
700
  flexDirection: "row" as const,
701
+ flexWrap: "wrap" as const,
445
702
  alignItems: "center" as const,
703
+ justifyContent: layout.compact ? ("flex-start" as const) : ("flex-end" as const),
446
704
  gap: 8,
447
705
  paddingLeft: layout.compact ? 0 : 12,
448
706
  paddingTop: layout.compact ? 4 : 0,
@@ -461,10 +719,42 @@ export function PrRadar({
461
719
  borderColor: theme.colors.accent,
462
720
  backgroundColor: theme.colors.accent,
463
721
  },
722
+ actionStartOrange: {
723
+ borderColor: "#ea7a33",
724
+ backgroundColor: "#c2591a",
725
+ },
726
+ actionStartBrown: {
727
+ borderColor: "#9a5f3b",
728
+ backgroundColor: "#7c4a2d",
729
+ },
730
+ actionStartText: { color: "#ffffff" },
464
731
  actionAgentText: { color: theme.colors.accentForeground },
465
732
  actionDisabled: { opacity: 0.55 },
466
733
  actionText: { color: theme.colors.foreground, fontSize: 12, fontWeight: "600" as const },
467
734
  actionPrimaryText: { color: theme.colors.accent },
735
+ dprHeader: {
736
+ marginTop: 24,
737
+ marginHorizontal: gutter,
738
+ paddingVertical: 12,
739
+ paddingHorizontal: 14,
740
+ borderWidth: 1,
741
+ borderColor: theme.colors.border,
742
+ borderRadius: 10,
743
+ backgroundColor: theme.colors.surface1,
744
+ flexDirection: "row" as const,
745
+ alignItems: "center" as const,
746
+ justifyContent: "space-between" as const,
747
+ },
748
+ dprHeaderTitle: {
749
+ color: theme.colors.foreground,
750
+ fontSize: 14,
751
+ fontWeight: "700" as const,
752
+ },
753
+ dprHeaderToggle: {
754
+ color: theme.colors.foregroundMuted,
755
+ fontSize: 12,
756
+ fontWeight: "600" as const,
757
+ },
468
758
  empty: {
469
759
  paddingHorizontal: gutter,
470
760
  paddingVertical: 52,
@@ -494,6 +784,17 @@ export function PrRadar({
494
784
  }
495
785
  }, []);
496
786
 
787
+ const openIssues = useCallback(async (row: RadarRow) => {
788
+ setOpenError(null);
789
+ try {
790
+ for (const issueUrl of row.linkedIssues) {
791
+ await openPullRequestUrl(issueUrl, openExternalUrl);
792
+ }
793
+ } catch {
794
+ setOpenError(`Could not open linked issues for ${row.repository}#${row.number ?? "PR"}.`);
795
+ }
796
+ }, []);
797
+
497
798
  const copyPrLink = useCallback(async (row: RadarRow) => {
498
799
  setOpenError(null);
499
800
  setCopied(null);
@@ -515,19 +816,55 @@ export function PrRadar({
515
816
  const primaryAgent = item.agents[0];
516
817
  const agentAction = agentActionFor(item);
517
818
  const actionPending = agentMutation.isPending && agentMutation.variables?.id === item.id;
518
- const ownershipLabel = item.reviewRequestedFromMe
519
- ? "REVIEW"
520
- : item.ownership === "mine"
521
- ? "YOURS"
522
- : item.ownership === "external"
523
- ? "EXTERNAL"
524
- : "SCOPE UNKNOWN";
819
+ const startPending =
820
+ startNewAgentMutation.isPending && startNewAgentMutation.variables?.row.id === item.id;
821
+ const ownershipLabel =
822
+ item.itemKind === "issue"
823
+ ? item.issueRole === "assignee"
824
+ ? "ASSIGNED"
825
+ : item.issueRole === "owner"
826
+ ? "OWNER"
827
+ : "AUTHOR"
828
+ : item.reviewRequestedFromMe
829
+ ? "REVIEW"
830
+ : item.ownership === "mine"
831
+ ? "YOURS"
832
+ : item.ownership === "external"
833
+ ? "EXTERNAL"
834
+ : "SCOPE UNKNOWN";
525
835
  const actions = (
526
836
  <View style={styles.actions}>
527
- {agentAction ? (
837
+ {item.linkedIssues.length > 0 ? (
838
+ <Pressable
839
+ accessibilityRole="link"
840
+ accessibilityLabel={`Open ${item.linkedIssues.length} linked issues for ${item.repository} ${item.number ?? ""}`}
841
+ onPress={() => void openIssues(item)}
842
+ style={({ pressed }) => [styles.action, pressed && styles.refreshPressed]}
843
+ >
844
+ <Text style={styles.actionText}>Open issues ({item.linkedIssues.length})</Text>
845
+ </Pressable>
846
+ ) : null}
847
+ <Pressable
848
+ accessibilityRole="button"
849
+ accessibilityLabel={`Start New Agent for ${item.repository} ${item.number ?? ""}`}
850
+ accessibilityState={{ busy: startPending, disabled: startNewAgentMutation.isPending }}
851
+ disabled={startNewAgentMutation.isPending}
852
+ onPress={() => void handleStartNewAgentPress(item)}
853
+ style={({ pressed }) => [
854
+ styles.action,
855
+ item.hasLocalPlace ? styles.actionStartOrange : styles.actionStartBrown,
856
+ (pressed || startPending) && styles.refreshPressed,
857
+ startNewAgentMutation.isPending && styles.actionDisabled,
858
+ ]}
859
+ >
860
+ <Text style={[styles.actionText, styles.actionStartText]}>
861
+ {startPending ? "Starting…" : "Start New Agent"}
862
+ </Text>
863
+ </Pressable>
864
+ {agentAction?.kind === "ask" ? (
528
865
  <Pressable
529
866
  accessibilityRole="button"
530
- accessibilityLabel={`${agentAction.kind === "ask" ? "Ask an agent to handle" : "Start an agent for"} ${item.repository} ${item.number ?? ""}`}
867
+ accessibilityLabel={`Ask an agent to handle ${item.repository} ${item.number ?? ""}`}
531
868
  accessibilityState={{ busy: actionPending, disabled: agentMutation.isPending }}
532
869
  disabled={agentMutation.isPending}
533
870
  onPress={() => agentMutation.mutate(item)}
@@ -539,27 +876,21 @@ export function PrRadar({
539
876
  ]}
540
877
  >
541
878
  <Text style={[styles.actionText, styles.actionAgentText]}>
542
- {actionPending
543
- ? agentAction.kind === "ask"
544
- ? "Sending…"
545
- : "Starting…"
546
- : agentAction.kind === "ask"
547
- ? "Ask agent"
548
- : "Start agent"}
879
+ {actionPending ? "Sending…" : "Ask agent"}
549
880
  </Text>
550
881
  </Pressable>
551
882
  ) : null}
552
883
  {navigation && primaryAgent ? (
553
884
  <Pressable
554
885
  accessibilityRole="button"
555
- accessibilityLabel={`Open agent ${primaryAgent.title}`}
886
+ accessibilityLabel={`Open Existing Agent ${primaryAgent.title}`}
556
887
  onPress={() => {
557
888
  const target = { agentId: primaryAgent.id, serverId: host.id };
558
889
  navigation.openAgent(target);
559
890
  }}
560
891
  style={({ pressed }) => [styles.action, pressed && styles.refreshPressed]}
561
892
  >
562
- <Text style={styles.actionText}>Open agent</Text>
893
+ <Text style={styles.actionText}>Open Existing Agent</Text>
563
894
  </Pressable>
564
895
  ) : null}
565
896
  {navigation && !primaryAgent && item.workspaceIds[0] ? (
@@ -575,9 +906,19 @@ export function PrRadar({
575
906
  <Text style={styles.actionText}>Open workspace</Text>
576
907
  </Pressable>
577
908
  ) : null}
909
+ <Pressable
910
+ accessibilityRole="button"
911
+ accessibilityLabel={`Copy link to pull request ${item.repository} ${item.number ?? ""}`}
912
+ onPress={() => void copyPrLink(item)}
913
+ style={({ pressed }) => [styles.action, pressed && styles.refreshPressed]}
914
+ >
915
+ <Text style={styles.actionText} accessibilityLiveRegion="polite">
916
+ {copied?.id === item.id ? "Copied" : "Copy link"}
917
+ </Text>
918
+ </Pressable>
578
919
  <Pressable
579
920
  accessibilityRole="link"
580
- accessibilityLabel={`Open pull request ${item.repository} ${item.number ?? ""}`}
921
+ accessibilityLabel={`Open ${item.itemKind === "issue" ? "issue" : "pull request"} ${item.repository} ${item.number ?? ""}`}
581
922
  onPress={() => void openPr(item)}
582
923
  style={({ pressed }) => [
583
924
  styles.action,
@@ -585,7 +926,9 @@ export function PrRadar({
585
926
  pressed && styles.refreshPressed,
586
927
  ]}
587
928
  >
588
- <Text style={[styles.actionText, styles.actionPrimaryText]}>Open PR</Text>
929
+ <Text style={[styles.actionText, styles.actionPrimaryText]}>
930
+ {item.itemKind === "issue" ? "Open Issue" : "Open PR"}
931
+ </Text>
589
932
  </Pressable>
590
933
  </View>
591
934
  );
@@ -596,25 +939,39 @@ export function PrRadar({
596
939
  <View style={styles.rowBody}>
597
940
  <View style={styles.rowTop}>
598
941
  <Text style={styles.identifier} numberOfLines={1}>
599
- {item.repository}
600
- {item.number ? ` #${item.number}` : ""}
942
+ <HighlightedText
943
+ text={`${item.repository}${item.number ? ` #${item.number}` : ""}`}
944
+ query={search}
945
+ highlightStyle={styles.highlight}
946
+ />
601
947
  </Text>
602
948
  <Text style={styles.badge}>{ownershipLabel}</Text>
949
+ <Text style={styles.badge}>{item.cwdTag}</Text>
603
950
  {item.isDraft ? <Text style={styles.badge}>DRAFT</Text> : null}
604
951
  {item.authorKind === "bot" ? <Text style={styles.badge}>BOT</Text> : null}
605
952
  {item.isSecurity ? <Text style={styles.badge}>SECURITY</Text> : null}
606
953
  {isStale ? <Text style={styles.badge}>STALE</Text> : null}
607
954
  </View>
608
955
  <Text style={styles.title} numberOfLines={2} ellipsizeMode="tail">
609
- {item.title}
956
+ <HighlightedText text={item.title} query={search} highlightStyle={styles.highlight} />
610
957
  </Text>
611
958
  <View style={styles.reasonLine}>
612
959
  <View style={[styles.reasonDot, { backgroundColor: color }]} />
613
- <Text style={styles.reason}>{item.reason}</Text>
960
+ <Text style={styles.reason}>
961
+ <HighlightedText
962
+ text={item.reason}
963
+ query={search}
964
+ highlightStyle={styles.highlight}
965
+ />
966
+ </Text>
614
967
  </View>
615
968
  <Text style={styles.metadata} numberOfLines={1} ellipsizeMode="middle">
616
- {checkSummary(item)}
617
- {branchSummary}
969
+ {item.itemKind === "issue" ? "Open issue" : checkSummary(item)}
970
+ <HighlightedText
971
+ text={branchSummary}
972
+ query={search}
973
+ highlightStyle={styles.highlight}
974
+ />
618
975
  </Text>
619
976
  <Text style={styles.metadata} numberOfLines={1} ellipsizeMode="tail">
620
977
  {item.author ? `${item.author} · ` : ""}
@@ -630,32 +987,30 @@ export function PrRadar({
630
987
  {layout.compact ? actions : null}
631
988
  </View>
632
989
  {layout.compact ? null : actions}
633
- <Pressable
634
- accessibilityRole="button"
635
- accessibilityLabel={`Copy link to pull request ${item.repository} ${item.number ?? ""}`}
636
- onPress={() => void copyPrLink(item)}
637
- style={({ pressed }) => [styles.copyButton, pressed && styles.refreshPressed]}
638
- >
639
- <Text style={styles.copyText} accessibilityLiveRegion="polite">
640
- {copied?.id === item.id ? "Copied" : "Copy link"}
641
- </Text>
642
- </Pressable>
643
990
  </View>
644
991
  );
645
992
  };
646
993
 
647
- const totalCopy = `${rows.length} open ${rows.length === 1 ? "pull request" : "pull requests"}; ${rawRows.length} linked to ${data?.workspaceCount ?? 0} workspaces`;
648
- const emptyCopy = focusedPr
649
- ? "This pull request is not in the current queue."
650
- : search
651
- ? "No pull requests match this search."
652
- : activeOnly
653
- ? "No pull requests have a running or initializing agent."
654
- : savedView
655
- ? `No pull requests match the ${SAVED_VIEW_TITLES[savedView].toLowerCase()} view.`
656
- : selected
657
- ? "No pull requests are in this queue."
658
- : "No open pull requests are visible to GitHub or linked to a Paseo workspace.";
994
+ const totalCopy =
995
+ activeTab === "issues"
996
+ ? `${issues.length} open ${issues.length === 1 ? "issue" : "issues"}`
997
+ : `${rows.length} open ${rows.length === 1 ? "pull request" : "pull requests"}; ${rawRows.length} linked to ${data?.workspaceCount ?? 0} workspaces`;
998
+ const emptyCopy =
999
+ activeTab === "issues"
1000
+ ? search
1001
+ ? "No issues match this search."
1002
+ : "No open issues authored by or assigned to you were found."
1003
+ : focusedPr
1004
+ ? "This pull request is not in the current queue."
1005
+ : search
1006
+ ? "No pull requests match this search."
1007
+ : activeOnly
1008
+ ? "No pull requests have a running or initializing agent."
1009
+ : savedView
1010
+ ? `No pull requests match the ${SAVED_VIEW_TITLES[savedView].toLowerCase()} view.`
1011
+ : selected
1012
+ ? "No pull requests are in this queue."
1013
+ : "No open pull requests are visible to GitHub or linked to a Paseo workspace.";
659
1014
  const summaryMetrics = [
660
1015
  { label: "Action now", value: counts["needs-you"] },
661
1016
  { label: "Ready", value: counts.ready },
@@ -665,6 +1020,7 @@ export function PrRadar({
665
1020
  { label: "Agent PRs", value: activeCount },
666
1021
  ];
667
1022
 
1023
+ const coverage = viewerCoverage(activeTab, viewerData);
668
1024
  const header = (
669
1025
  <View style={styles.header}>
670
1026
  <View style={styles.signalLine}>
@@ -672,134 +1028,185 @@ export function PrRadar({
672
1028
  <View style={styles.signalDot} />
673
1029
  <Text style={styles.eyebrow}>PR RADAR · {viewerData?.viewer ?? "GITHUB"}</Text>
674
1030
  </View>
675
- <Pressable
676
- accessibilityRole="button"
677
- accessibilityLabel="Refresh pull request status"
678
- accessibilityState={{ busy: isFetching }}
679
- disabled={isFetching}
680
- onPress={() => void Promise.all([refetch(), refetchViewer()])}
681
- style={({ pressed }) => [styles.refresh, pressed && styles.refreshPressed]}
682
- >
683
- <Text style={styles.refreshText}>{isFetching ? "Scanning" : "Refresh"}</Text>
684
- </Pressable>
1031
+ <View style={styles.headerActions}>
1032
+ {onOpenSettings ? (
1033
+ <Pressable
1034
+ accessibilityRole="button"
1035
+ accessibilityLabel="Open PR Radar settings"
1036
+ onPress={onOpenSettings}
1037
+ style={({ pressed }) => [styles.refresh, pressed && styles.refreshPressed]}
1038
+ >
1039
+ <Text style={styles.refreshText}>Settings</Text>
1040
+ </Pressable>
1041
+ ) : null}
1042
+ <Pressable
1043
+ accessibilityRole="button"
1044
+ accessibilityLabel="Refresh pull request status"
1045
+ accessibilityState={{ busy: refreshMutation.isPending }}
1046
+ disabled={refreshMutation.isPending}
1047
+ onPress={() => refreshMutation.mutate()}
1048
+ style={({ pressed }) => [
1049
+ styles.refresh,
1050
+ styles.refreshButton,
1051
+ pressed && styles.refreshPressed,
1052
+ ]}
1053
+ >
1054
+ <Text style={styles.refreshText}>
1055
+ {refreshMutation.isPending ? "Scanning" : "Refresh"}
1056
+ </Text>
1057
+ </Pressable>
1058
+ </View>
685
1059
  </View>
686
1060
  <Text style={styles.heroTitle}>Know what moves next.</Text>
687
1061
  <Text style={styles.heroDetail}>{totalCopy}</Text>
688
- {focusedPr ? <Text style={styles.heroDetail}>Focused PR: {focusedPr}</Text> : null}
689
- {data?.truncated ? <Text style={styles.warningText}>{DIRECTORY_PARTIAL}</Text> : null}
690
- {rawRows.length > VIEWER_URL_LIMIT ? (
691
- <Text style={styles.warningText}>{LOOKUP_CAPPED}</Text>
692
- ) : null}
693
- <View accessibilityRole="summary" style={styles.summary}>
694
- {summaryMetrics.map(({ label, value }) => (
695
- <View key={label} style={styles.metric}>
696
- <Text style={styles.metricValue}>{value}</Text>
697
- <Text style={styles.metricLabel}>{label}</Text>
698
- </View>
699
- ))}
700
- </View>
701
- <ScrollView
702
- accessibilityRole="tablist"
703
- horizontal
704
- onFocus={revealFocusedChip}
705
- showsHorizontalScrollIndicator={false}
706
- style={styles.chipScroller}
707
- contentContainerStyle={styles.chipRow}
708
- >
709
- <Pressable
710
- accessibilityRole="tab"
711
- accessibilityState={{
712
- selected: selected === null && !activeOnly && !savedView && !focusedPr,
713
- }}
714
- onPress={() => setFilter(null)}
715
- style={[
716
- styles.chip,
717
- selected === null && !activeOnly && !savedView && !focusedPr && styles.chipActive,
718
- ]}
719
- >
720
- <Text
721
- style={[
722
- styles.chipText,
723
- selected === null && !activeOnly && !savedView && !focusedPr && styles.chipTextActive,
724
- ]}
725
- >
726
- All {rows.length}
727
- </Text>
728
- </Pressable>
729
- {BUCKETS.map((bucket) => (
1062
+ <View style={styles.tabBar}>
1063
+ <View accessibilityRole="tablist" style={styles.chipRow}>
730
1064
  <Pressable
731
1065
  accessibilityRole="tab"
732
- accessibilityState={{ selected: selected === bucket }}
733
- key={bucket}
734
- onPress={() => setFilter(bucket)}
735
- style={[styles.chip, selected === bucket && styles.chipActive]}
1066
+ accessibilityState={{ selected: activeTab === "prs" }}
1067
+ onPress={() => setActiveTab("prs")}
1068
+ style={[styles.chip, activeTab === "prs" && styles.chipActive]}
736
1069
  >
737
- <Text style={[styles.chipText, selected === bucket && styles.chipTextActive]}>
738
- {BUCKET_TITLES[bucket]} {counts[bucket]}
1070
+ <Text style={[styles.chipText, activeTab === "prs" && styles.chipTextActive]}>
1071
+ Pull Requests {rows.length}
739
1072
  </Text>
740
1073
  </Pressable>
741
- ))}
742
- <Pressable
743
- accessibilityRole="tab"
744
- accessibilityState={{ selected: activeOnly }}
745
- onPress={() => setFilter("active")}
746
- style={[styles.chip, activeOnly && styles.chipActive]}
747
- >
748
- <Text style={[styles.chipText, activeOnly && styles.chipTextActive]}>
749
- Active agents {activeCount}
750
- </Text>
751
- </Pressable>
752
- {(Object.keys(SAVED_VIEW_TITLES) as SavedView[]).map((view) => (
753
1074
  <Pressable
754
1075
  accessibilityRole="tab"
755
- accessibilityState={{ selected: savedView === view }}
756
- key={view}
757
- onPress={() => setFilter(view)}
758
- style={[styles.chip, savedView === view && styles.chipActive]}
1076
+ accessibilityState={{ selected: activeTab === "issues" }}
1077
+ onPress={() => setActiveTab("issues")}
1078
+ style={[styles.chip, activeTab === "issues" && styles.chipActive]}
759
1079
  >
760
- <Text style={[styles.chipText, savedView === view && styles.chipTextActive]}>
761
- {SAVED_VIEW_TITLES[view]} {savedViewCounts[view]}
1080
+ <Text style={[styles.chipText, activeTab === "issues" && styles.chipTextActive]}>
1081
+ Issues {issues.length}
762
1082
  </Text>
763
1083
  </Pressable>
764
- ))}
765
- {([7, 30, 90] as const).map((days) => (
766
- <Pressable
767
- accessibilityRole="button"
768
- accessibilityState={{ selected: windowDays === days }}
769
- key={days}
770
- onPress={() => setWindowDays(days)}
771
- style={[styles.chip, windowDays === days && styles.chipActive]}
1084
+ </View>
1085
+ <TextInput
1086
+ accessibilityLabel={activeTab === "issues" ? "Filter issues" : "Filter pull requests"}
1087
+ autoCapitalize="none"
1088
+ autoCorrect={false}
1089
+ onChangeText={setSearch}
1090
+ placeholder="Filter"
1091
+ placeholderTextColor={theme.colors.foregroundMuted}
1092
+ style={styles.search}
1093
+ value={search}
1094
+ />
1095
+ </View>
1096
+ {activeTab === "prs" && focusedPr ? (
1097
+ <Text style={styles.heroDetail}>Focused PR: {focusedPr}</Text>
1098
+ ) : null}
1099
+ {activeTab === "prs" && data?.truncated ? (
1100
+ <Text style={styles.warningText}>{DIRECTORY_PARTIAL}</Text>
1101
+ ) : null}
1102
+ {activeTab === "prs" && rawRows.length > VIEWER_URL_LIMIT ? (
1103
+ <Text style={styles.warningText}>{LOOKUP_CAPPED}</Text>
1104
+ ) : null}
1105
+ {activeTab === "prs" ? (
1106
+ <>
1107
+ <View accessibilityRole="summary" style={styles.summary}>
1108
+ {summaryMetrics.map(({ label, value }) => (
1109
+ <View key={label} style={styles.metric}>
1110
+ <Text style={styles.metricValue}>{value}</Text>
1111
+ <Text style={styles.metricLabel}>{label}</Text>
1112
+ </View>
1113
+ ))}
1114
+ </View>
1115
+ <ScrollView
1116
+ accessibilityRole="tablist"
1117
+ horizontal
1118
+ onFocus={revealFocusedChip}
1119
+ showsHorizontalScrollIndicator={false}
1120
+ style={styles.chipScroller}
1121
+ contentContainerStyle={styles.chipRow}
772
1122
  >
773
- <Text style={[styles.chipText, windowDays === days && styles.chipTextActive]}>
774
- {days}d
775
- </Text>
776
- </Pressable>
777
- ))}
778
- </ScrollView>
779
- <TextInput
780
- accessibilityLabel="Filter pull requests"
781
- autoCapitalize="none"
782
- autoCorrect={false}
783
- onChangeText={setSearch}
784
- placeholder="Filter by PR, branch, workspace, or agent"
785
- placeholderTextColor={theme.colors.foregroundMuted}
786
- style={styles.search}
787
- value={search}
788
- />
1123
+ <Pressable
1124
+ accessibilityRole="tab"
1125
+ accessibilityState={{
1126
+ selected: selected === null && !activeOnly && !savedView && !focusedPr,
1127
+ }}
1128
+ onPress={() => setFilter(null)}
1129
+ style={[
1130
+ styles.chip,
1131
+ selected === null && !activeOnly && !savedView && !focusedPr && styles.chipActive,
1132
+ ]}
1133
+ >
1134
+ <Text
1135
+ style={[
1136
+ styles.chipText,
1137
+ selected === null &&
1138
+ !activeOnly &&
1139
+ !savedView &&
1140
+ !focusedPr &&
1141
+ styles.chipTextActive,
1142
+ ]}
1143
+ >
1144
+ All {rows.length}
1145
+ </Text>
1146
+ </Pressable>
1147
+ {BUCKETS.map((bucket) => (
1148
+ <Pressable
1149
+ accessibilityRole="tab"
1150
+ accessibilityState={{ selected: selected === bucket }}
1151
+ key={bucket}
1152
+ onPress={() => setFilter(bucket)}
1153
+ style={[styles.chip, selected === bucket && styles.chipActive]}
1154
+ >
1155
+ <Text style={[styles.chipText, selected === bucket && styles.chipTextActive]}>
1156
+ {BUCKET_TITLES[bucket]} {counts[bucket]}
1157
+ </Text>
1158
+ </Pressable>
1159
+ ))}
1160
+ <Pressable
1161
+ accessibilityRole="tab"
1162
+ accessibilityState={{ selected: activeOnly }}
1163
+ onPress={() => setFilter("active")}
1164
+ style={[styles.chip, activeOnly && styles.chipActive]}
1165
+ >
1166
+ <Text style={[styles.chipText, activeOnly && styles.chipTextActive]}>
1167
+ Active agents {activeCount}
1168
+ </Text>
1169
+ </Pressable>
1170
+ {(Object.keys(SAVED_VIEW_TITLES) as SavedView[]).map((view) => (
1171
+ <Pressable
1172
+ accessibilityRole="tab"
1173
+ accessibilityState={{ selected: savedView === view }}
1174
+ key={view}
1175
+ onPress={() => setFilter(view)}
1176
+ style={[styles.chip, savedView === view && styles.chipActive]}
1177
+ >
1178
+ <Text style={[styles.chipText, savedView === view && styles.chipTextActive]}>
1179
+ {SAVED_VIEW_TITLES[view]} {savedViewCounts[view]}
1180
+ </Text>
1181
+ </Pressable>
1182
+ ))}
1183
+ {([7, 30, 90] as const).map((days) => (
1184
+ <Pressable
1185
+ accessibilityRole="button"
1186
+ accessibilityState={{ selected: windowDays === days }}
1187
+ key={days}
1188
+ onPress={() => setWindowDays(days)}
1189
+ style={[styles.chip, windowDays === days && styles.chipActive]}
1190
+ >
1191
+ <Text style={[styles.chipText, windowDays === days && styles.chipTextActive]}>
1192
+ {days}d
1193
+ </Text>
1194
+ </Pressable>
1195
+ ))}
1196
+ </ScrollView>
1197
+ </>
1198
+ ) : null}
789
1199
  <SortControls sortKey={sortKey} onSort={setSortKey} styles={styles} />
790
- {viewerData ? (
1200
+ {coverage ? (
791
1201
  <View style={{ gap: 7 }}>
792
- <Text style={styles.heroDetail}>
793
- {viewerData.coverageNote}
794
- {viewerData.truncated ? " Results reached the 100-item inbox cap." : ""}
795
- </Text>
796
- {viewerData.updates > 0 ? (
1202
+ <Text style={styles.heroDetail}>{coverage.text}</Text>
1203
+ {coverage.showUpdates && viewerData ? (
797
1204
  <Text style={styles.heroDetail}>
798
1205
  These are PR state changes detected in the {windowDays}-day view. Marking them seen
799
1206
  only clears PR Radar badges; it does not change GitHub notifications or pull requests.
800
1207
  </Text>
801
1208
  ) : null}
802
- {viewerData.updates > 0 ? (
1209
+ {coverage.showUpdates && viewerData ? (
803
1210
  <Pressable
804
1211
  accessibilityRole="button"
805
1212
  accessibilityLabel={`Mark ${viewerData.updates} detected pull request updates as seen`}
@@ -839,23 +1246,58 @@ export function PrRadar({
839
1246
  >
840
1247
  <FlatList
841
1248
  contentContainerStyle={styles.content}
842
- data={sortedRows}
1249
+ data={activeTab === "issues" ? sortedIssues : pullRequests}
843
1250
  keyExtractor={(item) => item.id}
844
1251
  ListHeaderComponent={header}
845
1252
  ListEmptyComponent={
846
1253
  isPending ? (
847
1254
  <ActivityIndicator color={theme.colors.accent} style={styles.spinner} />
848
- ) : (
1255
+ ) : activeTab === "prs" && draftPullRequests.length > 0 ? null : (
849
1256
  <View style={styles.empty}>
850
1257
  <Text style={styles.emptyTitle}>
851
- {rows.length === 0 ? "Clear runway" : "Nothing here"}
1258
+ {(activeTab === "issues" ? issues.length : rows.length) === 0
1259
+ ? "Clear runway"
1260
+ : "Nothing here"}
852
1261
  </Text>
853
1262
  <Text style={styles.emptyDetail}>{emptyCopy}</Text>
854
1263
  </View>
855
1264
  )
856
1265
  }
1266
+ ListFooterComponent={
1267
+ activeTab === "prs" && draftPullRequests.length > 0 ? (
1268
+ <View>
1269
+ <Pressable
1270
+ accessibilityRole="button"
1271
+ accessibilityState={{ expanded: !dprCollapsed }}
1272
+ onPress={() => setDprCollapsed((prev) => !prev)}
1273
+ style={styles.dprHeader}
1274
+ >
1275
+ <Text style={styles.dprHeaderTitle}>
1276
+ Draft PRs (DPRs) · {draftPullRequests.length}
1277
+ </Text>
1278
+ <Text style={styles.dprHeaderToggle}>{dprCollapsed ? "Show" : "Hide"}</Text>
1279
+ </Pressable>
1280
+ {!dprCollapsed ? (
1281
+ <View>
1282
+ {draftPullRequests.map((item) => (
1283
+ <View key={item.id}>{renderRow({ item })}</View>
1284
+ ))}
1285
+ </View>
1286
+ ) : null}
1287
+ </View>
1288
+ ) : null
1289
+ }
857
1290
  renderItem={renderRow}
858
1291
  />
1292
+ <StartAgentModal
1293
+ row={modalRow}
1294
+ settings={settings}
1295
+ theme={theme}
1296
+ pending={startNewAgentMutation.isPending}
1297
+ error={openError}
1298
+ onClose={() => setModalRow(null)}
1299
+ onStart={(request) => startNewAgentMutation.mutate(request)}
1300
+ />
859
1301
  {data?.warnings.length ? (
860
1302
  <View style={styles.warning}>
861
1303
  <Text style={styles.warningText} numberOfLines={2}>