@omercnet/paseo-pr-radar 3.2.2 → 3.2.3-next.511.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 +14 -2
- package/client/agent-launch-options.tsx +416 -0
- package/client/directory-load.ts +4 -2
- package/client/directory-observation.ts +73 -7
- package/client/highlight.ts +24 -0
- package/client/highlighted-text.tsx +27 -0
- package/client/pr-radar.tsx +609 -167
- package/client/radar.ts +345 -7
- package/client/screen-state.ts +20 -0
- package/client/settings-screen.tsx +290 -0
- package/client/start-agent-modal.tsx +691 -0
- package/client/use-radar.ts +6 -2
- package/examples/pr-radar-route.py +55 -0
- package/index.client.tsx +13 -2
- package/index.server.ts +26 -1
- package/package.json +6 -5
- package/server/viewer-scope.ts +164 -6
- package/server/workspace-ops.ts +1361 -0
- package/shared/settings.ts +68 -0
- package/shared/viewer-scope.ts +87 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type PluginSurfaceProps,
|
|
3
|
+
type SettingsState,
|
|
4
|
+
useRpc,
|
|
5
|
+
useSettings,
|
|
6
|
+
} from "@getpaseo/plugin/client";
|
|
7
|
+
import {
|
|
8
|
+
Loading,
|
|
9
|
+
SettingsAction,
|
|
10
|
+
SettingsCard,
|
|
11
|
+
SettingsSection,
|
|
12
|
+
SettingsSelect,
|
|
13
|
+
useToast,
|
|
14
|
+
} from "@getpaseo/plugin/client/ui";
|
|
15
|
+
import { useQuery } from "@tanstack/react-query";
|
|
16
|
+
import { useMemo, useRef, useState } from "react";
|
|
17
|
+
import { Text, View } from "react-native";
|
|
18
|
+
import {
|
|
19
|
+
type AutoLaunchMode,
|
|
20
|
+
type CwdMode,
|
|
21
|
+
DEFAULT_PR_RADAR_SETTINGS,
|
|
22
|
+
PrRadarSettingsSchema,
|
|
23
|
+
prRadarSettings,
|
|
24
|
+
} from "../shared/settings";
|
|
25
|
+
import { listLocalDirs } from "../shared/viewer-scope";
|
|
26
|
+
import {
|
|
27
|
+
type ComboOption,
|
|
28
|
+
ComboSelect,
|
|
29
|
+
dedupeOptions,
|
|
30
|
+
EFFORT_OPTIONS,
|
|
31
|
+
useAgentLaunchOptions,
|
|
32
|
+
} from "./agent-launch-options";
|
|
33
|
+
|
|
34
|
+
type ReadySettings = Extract<SettingsState<typeof prRadarSettings.schema>, { status: "ready" }>;
|
|
35
|
+
|
|
36
|
+
const CWD_MODE_OPTIONS: readonly { label: string; value: CwdMode }[] = [
|
|
37
|
+
{ label: "Worktree (CWD-WORKTREE)", value: "CWD-WORKTREE" },
|
|
38
|
+
{ label: "Base checkout (CWD-BASE)", value: "CWD-BASE" },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const AUTO_LAUNCH_OPTIONS: readonly { label: string; value: AutoLaunchMode }[] = [
|
|
42
|
+
{ label: "Always prompt before starting", value: "prompt" },
|
|
43
|
+
{ label: "Auto-launch when local checkout exists", value: "existing_only" },
|
|
44
|
+
{ label: "Auto-launch (clone & create worktree if needed)", value: "existing_or_clone" },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const KNOWN_ROUTING_SCRIPTS: readonly ComboOption[] = [
|
|
48
|
+
{
|
|
49
|
+
label: "None (use static defaults above)",
|
|
50
|
+
value: "",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: "User config example: ~/.config/pr-radar/route.py",
|
|
54
|
+
value: "~/.config/pr-radar/route.py",
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
function ReadyPrRadarSettings({
|
|
59
|
+
settings,
|
|
60
|
+
theme,
|
|
61
|
+
}: {
|
|
62
|
+
settings: ReadySettings;
|
|
63
|
+
theme: PluginSurfaceProps["theme"];
|
|
64
|
+
}) {
|
|
65
|
+
const fetchDirs = useRpc(listLocalDirs);
|
|
66
|
+
const toast = useToast();
|
|
67
|
+
const [dirQueryText, setDirQueryText] = useState(settings.values.sourceCodeDir);
|
|
68
|
+
const [error, setError] = useState<string | null>(null);
|
|
69
|
+
|
|
70
|
+
const { profileOptions, providerOptions, modelOptions, modeOptions, contextModeOptions } =
|
|
71
|
+
useAgentLaunchOptions();
|
|
72
|
+
|
|
73
|
+
const dirsQuery = useQuery({
|
|
74
|
+
queryKey: ["pr-radar-settings-dirs", settings.values.sourceCodeDir, dirQueryText],
|
|
75
|
+
queryFn: () =>
|
|
76
|
+
fetchDirs({
|
|
77
|
+
query: dirQueryText,
|
|
78
|
+
repository: "",
|
|
79
|
+
}),
|
|
80
|
+
staleTime: 10_000,
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const sourceDirOptions = useMemo<ComboOption[]>(() => {
|
|
84
|
+
const suggestions = dirsQuery.data?.entries ?? [];
|
|
85
|
+
return dedupeOptions([
|
|
86
|
+
{ label: "~/src", value: "~/src", detail: "Default" },
|
|
87
|
+
{ label: "~/code", value: "~/code" },
|
|
88
|
+
{ label: "~/projects", value: "~/projects" },
|
|
89
|
+
...suggestions.map((dir) => ({
|
|
90
|
+
label: dir.label,
|
|
91
|
+
value: dir.path,
|
|
92
|
+
detail: dir.kind !== "dir" ? dir.kind : undefined,
|
|
93
|
+
})),
|
|
94
|
+
]);
|
|
95
|
+
}, [dirsQuery.data]);
|
|
96
|
+
|
|
97
|
+
const routingScriptOptions = useMemo<ComboOption[]>(
|
|
98
|
+
() => dedupeOptions([...KNOWN_ROUTING_SCRIPTS]),
|
|
99
|
+
[],
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const latestSettingsRef = useRef({
|
|
103
|
+
values: settings.values,
|
|
104
|
+
revision: settings.revision,
|
|
105
|
+
});
|
|
106
|
+
latestSettingsRef.current = {
|
|
107
|
+
values: settings.values,
|
|
108
|
+
revision: settings.revision,
|
|
109
|
+
};
|
|
110
|
+
const queuedPatchRef = useRef<Partial<typeof settings.values> | null>(null);
|
|
111
|
+
const saveChainRef = useRef<Promise<boolean>>(Promise.resolve(true));
|
|
112
|
+
|
|
113
|
+
async function savePatch(patch: Partial<typeof settings.values>): Promise<boolean> {
|
|
114
|
+
queuedPatchRef.current = { ...(queuedPatchRef.current ?? {}), ...patch };
|
|
115
|
+
const run = saveChainRef.current.then(async () => {
|
|
116
|
+
const nextPatch = queuedPatchRef.current;
|
|
117
|
+
if (!nextPatch) return true;
|
|
118
|
+
queuedPatchRef.current = null;
|
|
119
|
+
setError(null);
|
|
120
|
+
const parsed = PrRadarSettingsSchema.safeParse({
|
|
121
|
+
...latestSettingsRef.current.values,
|
|
122
|
+
...nextPatch,
|
|
123
|
+
});
|
|
124
|
+
if (!parsed.success) {
|
|
125
|
+
setError(parsed.error.issues[0]?.message ?? "Invalid setting value.");
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
try {
|
|
129
|
+
const saved = await settings.save(parsed.data, latestSettingsRef.current.revision);
|
|
130
|
+
if (saved === false) {
|
|
131
|
+
setError("Settings changed concurrently; please retry.");
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
latestSettingsRef.current = {
|
|
135
|
+
values: parsed.data,
|
|
136
|
+
revision: latestSettingsRef.current.revision,
|
|
137
|
+
};
|
|
138
|
+
return true;
|
|
139
|
+
} catch (updateError) {
|
|
140
|
+
setError(updateError instanceof Error ? updateError.message : "Could not save settings.");
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
saveChainRef.current = run.catch(() => false);
|
|
145
|
+
return run;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function handleReset() {
|
|
149
|
+
setDirQueryText(DEFAULT_PR_RADAR_SETTINGS.sourceCodeDir);
|
|
150
|
+
const saved = await savePatch({ ...DEFAULT_PR_RADAR_SETTINGS });
|
|
151
|
+
if (saved) {
|
|
152
|
+
toast.show("PR Radar settings reset to defaults.", { variant: "success" });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<View style={{ gap: 20 }}>
|
|
158
|
+
{error ? (
|
|
159
|
+
<Text style={{ color: theme.colors.statusDanger, fontSize: 13 }}>{error}</Text>
|
|
160
|
+
) : null}
|
|
161
|
+
|
|
162
|
+
<SettingsSection
|
|
163
|
+
title="Workspace and launch"
|
|
164
|
+
info="Configure where PR Radar looks for or clones repositories and whether Start New Agent prompts or launches immediately."
|
|
165
|
+
>
|
|
166
|
+
<SettingsCard>
|
|
167
|
+
<ComboSelect
|
|
168
|
+
label="Source code directory"
|
|
169
|
+
hint="Default base directory for repositories and auto-clones (default: ~/src)"
|
|
170
|
+
value={settings.values.sourceCodeDir}
|
|
171
|
+
placeholder="~/src"
|
|
172
|
+
options={sourceDirOptions}
|
|
173
|
+
allowEmpty={false}
|
|
174
|
+
theme={theme}
|
|
175
|
+
onQueryChange={setDirQueryText}
|
|
176
|
+
onSelect={(next) => {
|
|
177
|
+
if (next.trim()) void savePatch({ sourceCodeDir: next.trim() });
|
|
178
|
+
}}
|
|
179
|
+
/>
|
|
180
|
+
<SettingsSelect
|
|
181
|
+
label="Default workspace mode"
|
|
182
|
+
hint="Start new agents in a dedicated PR worktree or the base checkout"
|
|
183
|
+
value={settings.values.defaultCwdMode}
|
|
184
|
+
options={CWD_MODE_OPTIONS}
|
|
185
|
+
onValueChange={(value) => void savePatch({ defaultCwdMode: value })}
|
|
186
|
+
/>
|
|
187
|
+
<SettingsSelect
|
|
188
|
+
label="Auto-launch behavior"
|
|
189
|
+
hint="Choose when Start New Agent opens immediately without showing the chooser"
|
|
190
|
+
value={settings.values.autoLaunchMode}
|
|
191
|
+
options={AUTO_LAUNCH_OPTIONS}
|
|
192
|
+
onValueChange={(value) => void savePatch({ autoLaunchMode: value })}
|
|
193
|
+
/>
|
|
194
|
+
</SettingsCard>
|
|
195
|
+
</SettingsSection>
|
|
196
|
+
|
|
197
|
+
<SettingsSection
|
|
198
|
+
title="New agent defaults"
|
|
199
|
+
info="Pre-configure any agent launch settings. Type to filter options continuously or pick from the pull-down list."
|
|
200
|
+
>
|
|
201
|
+
<SettingsCard>
|
|
202
|
+
<ComboSelect
|
|
203
|
+
label="Default profile"
|
|
204
|
+
hint="Paseo agent profile name (default: Model Router)"
|
|
205
|
+
value={settings.values.defaultProfile}
|
|
206
|
+
placeholder="Model Router"
|
|
207
|
+
options={profileOptions}
|
|
208
|
+
theme={theme}
|
|
209
|
+
onSelect={(next) => void savePatch({ defaultProfile: next })}
|
|
210
|
+
/>
|
|
211
|
+
<ComboSelect
|
|
212
|
+
label="TUI vendor / provider"
|
|
213
|
+
hint="Optional provider override (e.g. claude, codex, pi)"
|
|
214
|
+
value={settings.values.defaultProvider}
|
|
215
|
+
placeholder="Use profile default"
|
|
216
|
+
options={providerOptions}
|
|
217
|
+
theme={theme}
|
|
218
|
+
onSelect={(next) => void savePatch({ defaultProvider: next })}
|
|
219
|
+
/>
|
|
220
|
+
<ComboSelect
|
|
221
|
+
label="Model"
|
|
222
|
+
hint="Optional model ID or version override (e.g. sonnet, gpt-6.1-sol)"
|
|
223
|
+
value={settings.values.defaultModel}
|
|
224
|
+
placeholder="Use provider default"
|
|
225
|
+
options={modelOptions}
|
|
226
|
+
theme={theme}
|
|
227
|
+
onSelect={(next) => void savePatch({ defaultModel: next })}
|
|
228
|
+
/>
|
|
229
|
+
<SettingsSelect
|
|
230
|
+
label="Reasoning effort"
|
|
231
|
+
hint="Thinking / reasoning effort level"
|
|
232
|
+
value={settings.values.defaultEffort}
|
|
233
|
+
options={EFFORT_OPTIONS}
|
|
234
|
+
onValueChange={(value) => void savePatch({ defaultEffort: value })}
|
|
235
|
+
/>
|
|
236
|
+
<ComboSelect
|
|
237
|
+
label="Permission / mode"
|
|
238
|
+
hint="Optional modeId (e.g. default, bypassPermissions, plan)"
|
|
239
|
+
value={settings.values.defaultModeId}
|
|
240
|
+
placeholder="Use profile default"
|
|
241
|
+
options={modeOptions}
|
|
242
|
+
theme={theme}
|
|
243
|
+
onSelect={(next) => void savePatch({ defaultModeId: next })}
|
|
244
|
+
/>
|
|
245
|
+
<ComboSelect
|
|
246
|
+
label="Context mode"
|
|
247
|
+
hint="Optional contextMode option passed to the provider"
|
|
248
|
+
value={settings.values.defaultContextMode}
|
|
249
|
+
placeholder="Use provider default"
|
|
250
|
+
options={contextModeOptions}
|
|
251
|
+
theme={theme}
|
|
252
|
+
onSelect={(next) => void savePatch({ defaultContextMode: next })}
|
|
253
|
+
/>
|
|
254
|
+
</SettingsCard>
|
|
255
|
+
</SettingsSection>
|
|
256
|
+
|
|
257
|
+
<SettingsSection
|
|
258
|
+
title="Routing script"
|
|
259
|
+
info="Optional executable script that receives PR, repo, and workspace JSON on stdin and returns provider, model, effort, and mode JSON."
|
|
260
|
+
>
|
|
261
|
+
<SettingsCard>
|
|
262
|
+
<ComboSelect
|
|
263
|
+
label="Routing script path"
|
|
264
|
+
hint="Leave empty to use static defaults above (example: ~/.config/pr-radar/route.py)"
|
|
265
|
+
value={settings.values.routingScriptPath}
|
|
266
|
+
placeholder="~/.config/pr-radar/route.py"
|
|
267
|
+
options={routingScriptOptions}
|
|
268
|
+
theme={theme}
|
|
269
|
+
onSelect={(next) => void savePatch({ routingScriptPath: next })}
|
|
270
|
+
/>
|
|
271
|
+
<SettingsAction
|
|
272
|
+
label="Reset settings"
|
|
273
|
+
hint="Restore all PR Radar settings to their defaults"
|
|
274
|
+
actionLabel="Reset defaults"
|
|
275
|
+
onPress={() => void handleReset()}
|
|
276
|
+
/>
|
|
277
|
+
</SettingsCard>
|
|
278
|
+
</SettingsSection>
|
|
279
|
+
</View>
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
export function PrRadarSettingsScreen({ theme }: PluginSurfaceProps) {
|
|
284
|
+
const settings = useSettings(prRadarSettings);
|
|
285
|
+
if (settings.status === "loading") return <Loading />;
|
|
286
|
+
if (settings.status === "error" || settings.status === "invalid") {
|
|
287
|
+
return <Text style={{ color: theme.colors.statusDanger, fontSize: 13 }}>{settings.error}</Text>;
|
|
288
|
+
}
|
|
289
|
+
return <ReadyPrRadarSettings settings={settings} theme={theme} />;
|
|
290
|
+
}
|