@omercnet/paseo-pr-radar 3.2.3 → 3.3.0

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.
@@ -0,0 +1,691 @@
1
+ import { type PluginSurfaceProps, useRpc } from "@getpaseo/plugin/client";
2
+ import { Icon, Modal, TextInput } from "@getpaseo/plugin/client/ui";
3
+ import { useQuery } from "@tanstack/react-query";
4
+ import { useEffect, useMemo, useRef, useState } from "react";
5
+ import { Pressable, ScrollView, Text, View } from "react-native";
6
+ import type { CwdMode, PrRadarSettings } from "../shared/settings";
7
+ import { listLocalDirs, type RoutingScriptResult, runRoutingScript } from "../shared/viewer-scope";
8
+ import { ComboSelect, useAgentLaunchOptions } from "./agent-launch-options";
9
+ import {
10
+ type AgentLaunchOverrides,
11
+ automaticRoutingLaunchState,
12
+ initialLaunchTarget,
13
+ type RadarRow,
14
+ type RoutingLaunchState,
15
+ restrictRoutedLaunch,
16
+ routedProviderModel,
17
+ vetRoutedProfile,
18
+ } from "./radar";
19
+
20
+ export interface StartAgentLaunchRequest {
21
+ row: RadarRow;
22
+ targetDir: string | null;
23
+ allowClone?: boolean;
24
+ cwdMode: CwdMode;
25
+ worktreeName: string | null;
26
+ overrides: AgentLaunchOverrides;
27
+ profileName: string;
28
+ routingWarning?: string;
29
+ }
30
+
31
+ function defaultHumanWorktreeName(row: RadarRow): string {
32
+ const repoName = row.repository.split("/")[1] || "repo";
33
+ const slug = row.headRefName
34
+ .toLowerCase()
35
+ .replace(/[^a-z0-9]+/g, "-")
36
+ .replace(/^-+|-+$/g, "")
37
+ .slice(0, 32);
38
+ const kindPrefix = row.itemKind === "issue" ? "issue" : "pr";
39
+ const num = row.number ?? kindPrefix;
40
+ return slug ? `${repoName}-${kindPrefix}-${num}-${slug}` : `${repoName}-${kindPrefix}-${num}`;
41
+ }
42
+
43
+ export function StartAgentModal({
44
+ row,
45
+ settings,
46
+ theme,
47
+ pending,
48
+ error,
49
+ onClose,
50
+ onStart,
51
+ }: {
52
+ row: RadarRow | null;
53
+ settings: PrRadarSettings;
54
+ theme: PluginSurfaceProps["theme"];
55
+ pending: boolean;
56
+ error: string | null;
57
+ onClose: () => void;
58
+ onStart: (request: StartAgentLaunchRequest) => void;
59
+ }) {
60
+ const fetchDirs = useRpc(listLocalDirs);
61
+ const invokeRouter = useRpc(runRoutingScript);
62
+ const {
63
+ profiles,
64
+ profileOptions,
65
+ providerOptions,
66
+ modelOptions,
67
+ modeOptions,
68
+ contextModeOptions,
69
+ effortOptions,
70
+ } = useAgentLaunchOptions(Boolean(row));
71
+
72
+ const [dirFilter, setDirFilter] = useState("");
73
+ const [selectedDir, setSelectedDir] = useState<string | null>(null);
74
+ const [allowClone, setAllowClone] = useState(false);
75
+ const [cwdMode, setCwdMode] = useState<CwdMode>(settings.defaultCwdMode);
76
+ const [worktreeName, setWorktreeName] = useState("");
77
+ const [profileName, setProfileName] = useState(settings.defaultProfile);
78
+ const [provider, setProvider] = useState(settings.defaultProvider);
79
+ const [model, setModel] = useState(settings.defaultModel);
80
+ const [effort, setEffort] = useState(settings.defaultEffort);
81
+ const [modeId, setModeId] = useState(settings.defaultModeId);
82
+ const [contextMode, setContextMode] = useState(settings.defaultContextMode);
83
+ const [routedOptions, setRoutedOptions] = useState<Record<string, unknown> | undefined>(
84
+ undefined,
85
+ );
86
+ const [routeReason, setRouteReason] = useState<string | null>(null);
87
+ const [routeError, setRouteError] = useState<string | null>(null);
88
+ const [routingBusy, setRoutingBusy] = useState(false);
89
+ const activeRowIdRef = useRef<string | null>(null);
90
+ const editedFieldsRef = useRef<Set<string>>(new Set());
91
+ const providerRef = useRef(provider);
92
+
93
+ useEffect(() => {
94
+ providerRef.current = provider;
95
+ }, [provider]);
96
+
97
+ useEffect(() => {
98
+ activeRowIdRef.current = row?.id ?? null;
99
+ if (!row) return;
100
+ editedFieldsRef.current.clear();
101
+ setDirFilter("");
102
+ const target = initialLaunchTarget(row);
103
+ setSelectedDir(target.selectedDir);
104
+ setAllowClone(target.allowClone);
105
+ setCwdMode(settings.defaultCwdMode);
106
+ setWorktreeName(defaultHumanWorktreeName(row));
107
+ setProfileName(settings.defaultProfile);
108
+ setProvider(settings.defaultProvider);
109
+ setModel(settings.defaultModel);
110
+ setEffort(settings.defaultEffort);
111
+ setModeId(settings.defaultModeId);
112
+ setContextMode(settings.defaultContextMode);
113
+ setRoutedOptions(undefined);
114
+ setRouteReason(null);
115
+ setRouteError(null);
116
+ setRoutingBusy(false);
117
+ }, [row?.id]);
118
+
119
+ const dirQuery = useQuery({
120
+ queryKey: ["pr-radar-dirs", settings.sourceCodeDir, dirFilter, row?.repository ?? ""],
121
+ queryFn: () =>
122
+ fetchDirs({
123
+ query: dirFilter,
124
+ repository: row?.repository ?? "",
125
+ }),
126
+ enabled: Boolean(row),
127
+ staleTime: 10_000,
128
+ });
129
+
130
+ const routingSeqRef = useRef(0);
131
+
132
+ async function handleRunRouter(
133
+ targetRow: RadarRow,
134
+ launchState: RoutingLaunchState = { selectedDir, cwdMode, provider },
135
+ ) {
136
+ if (!settings.routingScriptPath.trim()) return;
137
+ const invocationSeq = ++routingSeqRef.current;
138
+ setRoutingBusy(true);
139
+ setRouteError(null);
140
+ try {
141
+ const result: RoutingScriptResult = await invokeRouter({
142
+ payload: {
143
+ pr: {
144
+ id: targetRow.id,
145
+ number: targetRow.number,
146
+ url: targetRow.url,
147
+ title: targetRow.title,
148
+ repository: targetRow.repository,
149
+ baseRefName: targetRow.baseRefName,
150
+ headRefName: targetRow.headRefName,
151
+ isDraft: targetRow.isDraft,
152
+ author: targetRow.author,
153
+ authorKind: targetRow.authorKind,
154
+ isSecurity: targetRow.isSecurity,
155
+ comments: targetRow.comments,
156
+ labels: targetRow.labels,
157
+ bucket: targetRow.bucket,
158
+ reason: targetRow.reason,
159
+ reviewRequestedFromMe: targetRow.reviewRequestedFromMe,
160
+ ownership: targetRow.ownership,
161
+ checksStatus: targetRow.checksStatus,
162
+ reviewDecision: targetRow.reviewDecision,
163
+ mergeable: targetRow.mergeable,
164
+ linkedIssues: targetRow.linkedIssues,
165
+ },
166
+ workspace: {
167
+ targetDir: launchState.selectedDir,
168
+ cwdMode: launchState.cwdMode,
169
+ localProjectRoot: targetRow.localProjectRoot,
170
+ workspaceIds: targetRow.workspaceIds,
171
+ },
172
+ defaults: {
173
+ profile: settings.defaultProfile,
174
+ provider: settings.defaultProvider,
175
+ model: settings.defaultModel,
176
+ effort: settings.defaultEffort,
177
+ modeId: settings.defaultModeId,
178
+ contextMode: settings.defaultContextMode,
179
+ },
180
+ },
181
+ });
182
+ if (activeRowIdRef.current !== targetRow.id || routingSeqRef.current !== invocationSeq) {
183
+ return;
184
+ }
185
+ const vetted = vetRoutedProfile(profiles, result.profile);
186
+ // Resolve the accepted profile locally (the profiles state has not updated inside this
187
+ // handler yet), falling back the same way the launch mutation does for an empty profile name.
188
+ const acceptedProfileName =
189
+ vetted.profileName && !editedFieldsRef.current.has("profile")
190
+ ? vetted.profileName
191
+ : profileName;
192
+ if (vetted.profileName && !editedFieldsRef.current.has("profile")) {
193
+ setProfileName(vetted.profileName);
194
+ }
195
+ const wantedProfile = acceptedProfileName.trim().toLowerCase();
196
+ const selectedProfile =
197
+ (wantedProfile
198
+ ? profiles.find((candidate) => candidate.name.toLowerCase() === wantedProfile)
199
+ : undefined) ??
200
+ profiles.find((candidate) => candidate.name.toLowerCase() === "model router") ??
201
+ profiles[0];
202
+ const canApplyProvider = !editedFieldsRef.current.has("provider");
203
+ const currentProvider =
204
+ (canApplyProvider ? launchState.provider : providerRef.current)?.trim() ||
205
+ selectedProfile?.provider ||
206
+ "claude";
207
+ const routedPick = routedProviderModel({ provider: currentProvider }, result, {
208
+ applyProvider: canApplyProvider,
209
+ });
210
+ if (routedPick.provider !== undefined && canApplyProvider) {
211
+ // If the user hand-picked a model, a cross-provider switch would orphan it; leave the
212
+ // provider alone then.
213
+ const crossProvider = routedPick.provider !== currentProvider;
214
+ if (!crossProvider || !editedFieldsRef.current.has("model")) {
215
+ setProvider(routedPick.provider);
216
+ }
217
+ }
218
+ if (routedPick.model !== undefined && !editedFieldsRef.current.has("model")) {
219
+ setModel(routedPick.model);
220
+ }
221
+ if (result.thinkingOptionId && !editedFieldsRef.current.has("effort")) {
222
+ setEffort(result.thinkingOptionId);
223
+ }
224
+ const restricted = restrictRoutedLaunch(result);
225
+ restricted.ignored.push(...vetted.ignored);
226
+ if (restricted.modeId && !editedFieldsRef.current.has("modeId")) setModeId(restricted.modeId);
227
+ if (result.contextMode && !editedFieldsRef.current.has("contextMode")) {
228
+ setContextMode(result.contextMode);
229
+ }
230
+ setRoutedOptions(restricted.options);
231
+ const ignoredNote =
232
+ restricted.ignored.length > 0
233
+ ? ` Ignored (not allowed): ${restricted.ignored.join(", ")}.`
234
+ : "";
235
+ setRouteReason(`${result.reason ?? "Routing script applied."}${ignoredNote}`);
236
+ } catch (err) {
237
+ if (activeRowIdRef.current !== targetRow.id || routingSeqRef.current !== invocationSeq) {
238
+ return;
239
+ }
240
+ setRouteError(err instanceof Error ? err.message : "Routing script failed.");
241
+ } finally {
242
+ if (activeRowIdRef.current === targetRow.id && routingSeqRef.current === invocationSeq) {
243
+ setRoutingBusy(false);
244
+ }
245
+ }
246
+ }
247
+
248
+ const autoRoutingRowIdRef = useRef<string | null>(null);
249
+
250
+ useEffect(() => {
251
+ if (!row) {
252
+ autoRoutingRowIdRef.current = null;
253
+ // Drop any in-flight result: with no row it must not be applied.
254
+ routingSeqRef.current += 1;
255
+ setRoutingBusy(false);
256
+ return;
257
+ }
258
+ const isNewRow = autoRoutingRowIdRef.current !== row.id;
259
+ autoRoutingRowIdRef.current = row.id;
260
+ if (!settings.routingScriptPath.trim()) {
261
+ // Drop any in-flight result: with no script configured it must not be applied.
262
+ routingSeqRef.current += 1;
263
+ setRoutingBusy(false);
264
+ return;
265
+ }
266
+ void handleRunRouter(
267
+ row,
268
+ automaticRoutingLaunchState(
269
+ row,
270
+ { selectedDir, cwdMode, provider },
271
+ { cwdMode: settings.defaultCwdMode, provider: settings.defaultProvider },
272
+ isNewRow,
273
+ ),
274
+ );
275
+ }, [row?.id, settings.routingScriptPath]);
276
+
277
+ const styles = useMemo(
278
+ () => ({
279
+ sectionLabel: {
280
+ color: theme.colors.foreground,
281
+ fontSize: 12,
282
+ fontWeight: "600" as const,
283
+ },
284
+ hint: {
285
+ color: theme.colors.foregroundMuted,
286
+ fontSize: 12,
287
+ lineHeight: 16,
288
+ },
289
+ input: {
290
+ color: theme.colors.foreground,
291
+ backgroundColor: theme.colors.surface1,
292
+ borderWidth: 1,
293
+ borderColor: theme.colors.border,
294
+ borderRadius: 8,
295
+ paddingHorizontal: 12,
296
+ paddingVertical: 9,
297
+ fontSize: 13,
298
+ },
299
+ listBox: {
300
+ borderWidth: 1,
301
+ borderColor: theme.colors.border,
302
+ borderRadius: 8,
303
+ backgroundColor: theme.colors.surface1,
304
+ maxHeight: 190,
305
+ overflow: "hidden" as const,
306
+ },
307
+ listRow: {
308
+ flexDirection: "row" as const,
309
+ alignItems: "center" as const,
310
+ justifyContent: "space-between" as const,
311
+ gap: 8,
312
+ paddingHorizontal: 12,
313
+ paddingVertical: 9,
314
+ borderBottomWidth: 1,
315
+ borderBottomColor: theme.colors.border,
316
+ },
317
+ listRowSelected: {
318
+ backgroundColor: theme.colors.surface2,
319
+ },
320
+ listRowTitle: {
321
+ color: theme.colors.foreground,
322
+ fontSize: 13,
323
+ fontWeight: "500" as const,
324
+ },
325
+ listRowSub: {
326
+ color: theme.colors.foregroundMuted,
327
+ fontSize: 11,
328
+ },
329
+ pillRow: {
330
+ flexDirection: "row" as const,
331
+ flexWrap: "wrap" as const,
332
+ gap: 8,
333
+ },
334
+ pill: {
335
+ borderWidth: 1,
336
+ borderColor: theme.colors.border,
337
+ backgroundColor: theme.colors.surface1,
338
+ borderRadius: 999,
339
+ paddingHorizontal: 12,
340
+ paddingVertical: 6,
341
+ },
342
+ pillActive: {
343
+ borderColor: theme.colors.accent,
344
+ backgroundColor: theme.colors.accent,
345
+ },
346
+ pillText: {
347
+ color: theme.colors.foregroundMuted,
348
+ fontSize: 12,
349
+ fontWeight: "600" as const,
350
+ },
351
+ pillTextActive: {
352
+ color: theme.colors.accentForeground,
353
+ },
354
+ gridRow: {
355
+ flexDirection: "row" as const,
356
+ gap: 10,
357
+ },
358
+ gridCell: {
359
+ flex: 1,
360
+ gap: 4,
361
+ },
362
+ footer: {
363
+ flexDirection: "row" as const,
364
+ justifyContent: "flex-end" as const,
365
+ gap: 10,
366
+ paddingTop: 6,
367
+ },
368
+ cancelButton: {
369
+ borderWidth: 1,
370
+ borderColor: theme.colors.border,
371
+ backgroundColor: theme.colors.surface2,
372
+ borderRadius: 999,
373
+ paddingHorizontal: 14,
374
+ paddingVertical: 8,
375
+ },
376
+ cancelText: {
377
+ color: theme.colors.foreground,
378
+ fontSize: 13,
379
+ fontWeight: "600" as const,
380
+ },
381
+ primaryButton: {
382
+ backgroundColor: theme.colors.accent,
383
+ borderRadius: 999,
384
+ paddingHorizontal: 16,
385
+ paddingVertical: 8,
386
+ },
387
+ primaryText: {
388
+ color: theme.colors.accentForeground,
389
+ fontSize: 13,
390
+ fontWeight: "600" as const,
391
+ },
392
+ }),
393
+ [theme],
394
+ );
395
+
396
+ if (!row) return null;
397
+
398
+ const entries = dirQuery.data?.entries ?? [];
399
+ const suggestedClonePath =
400
+ dirQuery.data?.suggestedClonePath ??
401
+ `${settings.sourceCodeDir}/${row.repository.split("/")[1] || "repo"}`;
402
+
403
+ return (
404
+ <Modal
405
+ open={Boolean(row)}
406
+ onOpenChange={(open) => {
407
+ if (!open) onClose();
408
+ }}
409
+ title={`Start New Agent · ${row.repository}${row.number ? ` #${row.number}` : ""}`}
410
+ icon={<Icon name="Terminal" size={16} color={theme.colors.foreground} />}
411
+ >
412
+ <Modal.Content>
413
+ <View style={{ gap: 14 }}>
414
+ <View style={{ gap: 6 }}>
415
+ <Text style={styles.sectionLabel}>
416
+ Local directory or clone target (selected:{" "}
417
+ {allowClone ? `Clone to ${suggestedClonePath}` : (selectedDir ?? "none yet")})
418
+ </Text>
419
+ <TextInput
420
+ value={dirFilter}
421
+ onChangeText={(next) => {
422
+ setDirFilter(next);
423
+ const trimmed = next.trim();
424
+ if (trimmed.startsWith("/") || trimmed.startsWith("~/")) {
425
+ setSelectedDir(trimmed);
426
+ setAllowClone(false);
427
+ }
428
+ }}
429
+ placeholder={`Filter directories in ${settings.sourceCodeDir} or enter existing ~/... path`}
430
+ placeholderTextColor={theme.colors.foregroundMuted}
431
+ autoCapitalize="none"
432
+ autoCorrect={false}
433
+ style={styles.input}
434
+ />
435
+ <ScrollView style={styles.listBox} nestedScrollEnabled>
436
+ <Pressable
437
+ onPress={() => {
438
+ setSelectedDir(suggestedClonePath);
439
+ setAllowClone(true);
440
+ setDirFilter("");
441
+ }}
442
+ style={[styles.listRow, allowClone && styles.listRowSelected]}
443
+ >
444
+ <View style={{ flex: 1, gap: 2 }}>
445
+ <Text style={styles.listRowTitle} numberOfLines={1}>
446
+ Clone {row.repository} → {suggestedClonePath}
447
+ </Text>
448
+ <Text style={styles.listRowSub}>
449
+ Clones repo if missing and creates {cwdMode}
450
+ </Text>
451
+ </View>
452
+ <Icon name="Download" size={14} color={theme.colors.accent} />
453
+ </Pressable>
454
+ {entries.slice(0, 8).map((entry) => (
455
+ <Pressable
456
+ key={entry.path}
457
+ onPress={() => {
458
+ setSelectedDir(entry.path);
459
+ setAllowClone(false);
460
+ }}
461
+ style={[
462
+ styles.listRow,
463
+ !allowClone && selectedDir === entry.path && styles.listRowSelected,
464
+ ]}
465
+ >
466
+ <View style={{ flex: 1, gap: 2 }}>
467
+ <Text style={styles.listRowTitle} numberOfLines={1}>
468
+ {entry.label}
469
+ {entry.isMatch ? " (match)" : ""}
470
+ </Text>
471
+ <Text style={styles.listRowSub} numberOfLines={1}>
472
+ {entry.path}
473
+ {entry.branch ? ` · ${entry.branch}` : ""}
474
+ </Text>
475
+ </View>
476
+ <Icon
477
+ name={
478
+ entry.kind === "worktree"
479
+ ? "GitBranch"
480
+ : entry.kind === "repo"
481
+ ? "FolderGit2"
482
+ : "Folder"
483
+ }
484
+ size={14}
485
+ color={theme.colors.foregroundMuted}
486
+ />
487
+ </Pressable>
488
+ ))}
489
+ </ScrollView>
490
+ </View>
491
+
492
+ <View style={{ gap: 6 }}>
493
+ <Text style={styles.sectionLabel}>Workspace mode</Text>
494
+ <View style={styles.pillRow}>
495
+ {(["CWD-WORKTREE", "CWD-BASE"] as const).map((mode) => (
496
+ <Pressable
497
+ key={mode}
498
+ onPress={() => setCwdMode(mode)}
499
+ style={[styles.pill, cwdMode === mode && styles.pillActive]}
500
+ >
501
+ <Text style={[styles.pillText, cwdMode === mode && styles.pillTextActive]}>
502
+ {mode === "CWD-WORKTREE"
503
+ ? "CWD-WORKTREE (PR worktree)"
504
+ : "CWD-BASE (base checkout)"}
505
+ </Text>
506
+ </Pressable>
507
+ ))}
508
+ </View>
509
+ </View>
510
+
511
+ {cwdMode === "CWD-BASE" ? (
512
+ <Text style={styles.hint}>
513
+ CWD-BASE switches {selectedDir ?? "the selected checkout"} to the task branch before
514
+ the agent starts.
515
+ </Text>
516
+ ) : null}
517
+
518
+ {cwdMode === "CWD-WORKTREE" ? (
519
+ <View style={{ gap: 4 }}>
520
+ <Text style={styles.sectionLabel}>Worktree name</Text>
521
+ <TextInput
522
+ value={worktreeName}
523
+ onChangeText={setWorktreeName}
524
+ placeholder={defaultHumanWorktreeName(row)}
525
+ placeholderTextColor={theme.colors.foregroundMuted}
526
+ autoCapitalize="none"
527
+ autoCorrect={false}
528
+ style={styles.input}
529
+ />
530
+ </View>
531
+ ) : null}
532
+
533
+ <View style={{ gap: 8 }}>
534
+ <View
535
+ style={{
536
+ flexDirection: "row",
537
+ justifyContent: "space-between",
538
+ alignItems: "center",
539
+ }}
540
+ >
541
+ <Text style={styles.sectionLabel}>Agent launch options</Text>
542
+ {settings.routingScriptPath.trim() ? (
543
+ <Pressable
544
+ disabled={routingBusy}
545
+ onPress={() => void handleRunRouter(row)}
546
+ style={styles.pill}
547
+ >
548
+ <Text style={styles.pillText}>
549
+ {routingBusy ? "Routing..." : "Re-run routing script"}
550
+ </Text>
551
+ </Pressable>
552
+ ) : null}
553
+ </View>
554
+ {routeReason ? <Text style={styles.hint}>{routeReason}</Text> : null}
555
+ {routeError ? (
556
+ <Text style={{ color: theme.colors.statusDanger, fontSize: 12 }}>{routeError}</Text>
557
+ ) : null}
558
+
559
+ <View style={styles.gridRow}>
560
+ <View style={styles.gridCell}>
561
+ <ComboSelect
562
+ compact
563
+ label="Profile"
564
+ value={profileName}
565
+ placeholder="Model Router"
566
+ options={profileOptions}
567
+ theme={theme}
568
+ onSelect={(next) => {
569
+ editedFieldsRef.current.add("profile");
570
+ setProfileName(next);
571
+ }}
572
+ />
573
+ </View>
574
+ <View style={styles.gridCell}>
575
+ <ComboSelect
576
+ compact
577
+ label="Vendor / provider"
578
+ value={provider}
579
+ placeholder="Profile default"
580
+ options={providerOptions}
581
+ theme={theme}
582
+ onSelect={(next) => {
583
+ editedFieldsRef.current.add("provider");
584
+ providerRef.current = next;
585
+ setProvider(next);
586
+ }}
587
+ />
588
+ </View>
589
+ </View>
590
+
591
+ <View style={styles.gridRow}>
592
+ <View style={styles.gridCell}>
593
+ <ComboSelect
594
+ compact
595
+ label="Model"
596
+ value={model}
597
+ placeholder="Provider default"
598
+ options={modelOptions}
599
+ theme={theme}
600
+ onSelect={(next) => {
601
+ editedFieldsRef.current.add("model");
602
+ setModel(next);
603
+ }}
604
+ />
605
+ </View>
606
+ <View style={styles.gridCell}>
607
+ <ComboSelect
608
+ compact
609
+ label="Effort (thinking)"
610
+ value={effort}
611
+ placeholder="low / medium / high"
612
+ options={effortOptions}
613
+ theme={theme}
614
+ onSelect={(next) => {
615
+ editedFieldsRef.current.add("effort");
616
+ setEffort(next);
617
+ }}
618
+ />
619
+ </View>
620
+ </View>
621
+
622
+ <View style={styles.gridRow}>
623
+ <View style={styles.gridCell}>
624
+ <ComboSelect
625
+ compact
626
+ label="Mode"
627
+ value={modeId}
628
+ placeholder="default / bypassPermissions"
629
+ options={modeOptions}
630
+ theme={theme}
631
+ onSelect={(next) => {
632
+ editedFieldsRef.current.add("modeId");
633
+ setModeId(next);
634
+ }}
635
+ />
636
+ </View>
637
+ <View style={styles.gridCell}>
638
+ <ComboSelect
639
+ compact
640
+ label="Context mode"
641
+ value={contextMode}
642
+ placeholder="Optional"
643
+ options={contextModeOptions}
644
+ theme={theme}
645
+ onSelect={(next) => {
646
+ editedFieldsRef.current.add("contextMode");
647
+ setContextMode(next);
648
+ }}
649
+ />
650
+ </View>
651
+ </View>
652
+ </View>
653
+
654
+ {error ? (
655
+ <Text style={{ color: theme.colors.statusDanger, fontSize: 12 }}>{error}</Text>
656
+ ) : null}
657
+
658
+ <View style={styles.footer}>
659
+ <Pressable disabled={pending} onPress={onClose} style={styles.cancelButton}>
660
+ <Text style={styles.cancelText}>Cancel</Text>
661
+ </Pressable>
662
+ <Pressable
663
+ disabled={pending || routingBusy}
664
+ onPress={() =>
665
+ onStart({
666
+ row,
667
+ targetDir: selectedDir,
668
+ allowClone,
669
+ cwdMode,
670
+ worktreeName: worktreeName.trim() || null,
671
+ profileName: profileName.trim(),
672
+ overrides: {
673
+ provider,
674
+ model,
675
+ thinkingOptionId: effort,
676
+ modeId,
677
+ contextMode,
678
+ ...(routedOptions ? { options: routedOptions } : {}),
679
+ },
680
+ })
681
+ }
682
+ style={styles.primaryButton}
683
+ >
684
+ <Text style={styles.primaryText}>{pending ? "Starting..." : "Start New Agent"}</Text>
685
+ </Pressable>
686
+ </View>
687
+ </View>
688
+ </Modal.Content>
689
+ </Modal>
690
+ );
691
+ }