-
Notifications
You must be signed in to change notification settings - Fork 5.8k
fix: pass adapter command from UI form for model discovery #1920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -199,10 +199,12 @@ export function OnboardingWizard() { | |
| isFetching: adapterModelsFetching | ||
| } = useQuery({ | ||
| queryKey: createdCompanyId | ||
| ? queryKeys.agents.adapterModels(createdCompanyId, adapterType) | ||
| : ["agents", "none", "adapter-models", adapterType], | ||
| queryFn: () => agentsApi.adapterModels(createdCompanyId!, adapterType), | ||
| enabled: Boolean(createdCompanyId) && effectiveOnboardingOpen && step === 2 | ||
| ? queryKeys.agents.adapterModels(createdCompanyId, adapterType, command || undefined) | ||
| : ["agents", "none", "adapter-models", adapterType, command || ""], | ||
| queryFn: () => | ||
| agentsApi.adapterModels(createdCompanyId!, adapterType, command ? { command } : undefined), | ||
| enabled: Boolean(createdCompanyId) && effectiveOnboardingOpen && step === 2, | ||
| staleTime: 60_000, | ||
| }); | ||
|
Comment on lines
200
to
208
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Like A Prompt To Fix With AIThis is a comment left during a code review.
Path: ui/src/components/OnboardingWizard.tsx
Line: 200-208
Comment:
**No debounce on `command` — per-keystroke subprocess spawning**
Like `NewAgent.tsx`, this query uses the raw `command` state value directly. Each character the user types changes the query key, triggering a new HTTP request and a new server-side `opencode models` subprocess immediately. The 800 ms debounce added in `AgentConfigForm.tsx` has no effect here because this component manages its own `command` state and query independently.
A `debouncedCommand` local state (same 800 ms pattern) should be introduced for the query key and queryFn to prevent the subprocess storm on each keystroke.
How can I resolve this? If you propose a fix, please make it concise. |
||
| const isLocalAdapter = | ||
| adapterType === "claude_local" || | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,10 +87,12 @@ export function NewAgent() { | |
| isFetching: adapterModelsFetching, | ||
| } = useQuery({ | ||
| queryKey: selectedCompanyId | ||
| ? queryKeys.agents.adapterModels(selectedCompanyId, configValues.adapterType) | ||
| : ["agents", "none", "adapter-models", configValues.adapterType], | ||
| queryFn: () => agentsApi.adapterModels(selectedCompanyId!, configValues.adapterType), | ||
| ? queryKeys.agents.adapterModels(selectedCompanyId, configValues.adapterType, configValues.command || undefined) | ||
| : ["agents", "none", "adapter-models", configValues.adapterType, configValues.command || ""], | ||
| queryFn: () => | ||
| agentsApi.adapterModels(selectedCompanyId!, configValues.adapterType, configValues.command ? { command: configValues.command } : undefined), | ||
| enabled: Boolean(selectedCompanyId), | ||
| staleTime: 60_000, | ||
| }); | ||
|
Comment on lines
89
to
96
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Since the two queries share a key only once Fix: introduce a locally debounced command value in Prompt To Fix With AIThis is a comment left during a code review.
Path: ui/src/pages/NewAgent.tsx
Line: 89-96
Comment:
**Debounce bypassed — subprocess storm still possible**
`NewAgent.tsx` uses `configValues.command` directly in both the `queryKey` and `queryFn`, with no debouncing. `AgentConfigForm.tsx` (also rendered on this page) has its own debounced query using `debouncedCommand`, but that only gates `AgentConfigForm.tsx`'s own fetch. Because `NewAgent.tsx`'s query fires immediately on every `configValues.command` change, each keystroke in the command field produces a new query key → new HTTP request → new server-side subprocess.
Since the two queries share a key only once `debouncedCommand` has caught up (after 800 ms of no typing), the debounce protection added in `AgentConfigForm.tsx` provides no benefit for the `NewAgent.tsx` create flow. `OnboardingWizard.tsx` has the same problem since its `command` state is also used directly without a debounce.
**Fix**: introduce a locally debounced command value in `NewAgent.tsx` (matching the 800 ms `useEffect` timer pattern already used in `AgentConfigForm.tsx`), and use that debounced value in the `queryKey` and `queryFn` instead of `configValues.command` directly.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| const { data: companySkills } = useQuery({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\(backslash) and..(path traversal) not rejectedThe current regex blocks common shell metacharacters but does not block
\(Windows path separator) or relative path traversal sequences like../../tmp/malicious. Withshell: falsenone of these characters enable command injection, and the PR correctly acknowledges that reaching an arbitrary binary still requires pre-existing filesystem write access. However, if the goal is defense-in-depth, consider also rejecting\and possibly enforcing that the value is an absolute path.Prompt To Fix With AI
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!