fix(frontend): correctly handle modelIDs containing slashes#186
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes frontend request payload construction so model IDs containing additional slashes (e.g., provider/namespace/model) are not truncated when sending prompts.
Changes:
- Update
useSendPromptmodel parsing to split on the first slash and preserve the remainder asmodelID.
| const [providerID, ...rest] = model.split("/"); | ||
| if (providerID && rest.length > 0) { | ||
| requestData.model = { | ||
| providerID, | ||
| modelID, | ||
| modelID: rest.join("/"), | ||
| }; |
There was a problem hiding this comment.
Current validation only checks rest.length > 0, which allows inputs like "provider/" to send modelID: "" (and differs from existing parsing that checks !modelID). Consider computing const modelID = rest.join('/') and requiring providerID && modelID before setting requestData.model (to avoid empty/trailing-slash cases).
| const [providerID, ...rest] = model.split("/"); | ||
| if (providerID && rest.length > 0) { | ||
| requestData.model = { | ||
| providerID, | ||
| modelID, | ||
| modelID: rest.join("/"), | ||
| }; |
There was a problem hiding this comment.
PR description checklist says tests were added/updated, but this PR only changes useOpenCode.ts and doesn't include any test changes. Please either add/adjust tests for the model parsing behavior or update the PR description/checklist to match what was actually changed.
dad1a60
into
chriswritescode-dev:main
Summary
Problem
Model IDs that contain slashes (
provider/namespace/modele.g.,ollama/my-models/gemma4) were being truncated when sent in the request payload. This happened because the splitting logic inuseSendPromptused a limit of2when splitting theprovider/modelstring, causing any secondary slashes to be discarded.Changes
frontend/src/hooks/useOpenCode.ts: UpdateduseSendPromptto correctly parse model strings with multiple slashes.Type of Change
Checklist
pnpm lintpasses locallypnpm typecheckpasses locally