Skip to content

fix(frontend): correctly handle modelIDs containing slashes#186

Merged
chriswritescode-dev merged 1 commit intochriswritescode-dev:mainfrom
LazuliKao:fix/model-id-with-slashes
Apr 16, 2026
Merged

fix(frontend): correctly handle modelIDs containing slashes#186
chriswritescode-dev merged 1 commit intochriswritescode-dev:mainfrom
LazuliKao:fix/model-id-with-slashes

Conversation

@LazuliKao
Copy link
Copy Markdown
Contributor

Summary

Problem

Model IDs that contain slashes (provider/namespace/model e.g., ollama/my-models/gemma4) were being truncated when sent in the request payload. This happened because the splitting logic in useSendPrompt used a limit of 2 when splitting the provider/model string, causing any secondary slashes to be discarded.

Changes

  • Modified frontend/src/hooks/useOpenCode.ts: Updated useSendPrompt to correctly parse model strings with multiple slashes.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation

Checklist

  • Code follows project style (no comments, named imports)
  • TypeScript types are properly defined
  • Tests added/updated (80% coverage target)
  • pnpm lint passes locally
  • pnpm typecheck passes locally

@LazuliKao LazuliKao marked this pull request as ready for review April 16, 2026 09:15
Copilot AI review requested due to automatic review settings April 16, 2026 09:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 useSendPrompt model parsing to split on the first slash and preserve the remainder as modelID.

Comment on lines +347 to 352
const [providerID, ...rest] = model.split("/");
if (providerID && rest.length > 0) {
requestData.model = {
providerID,
modelID,
modelID: rest.join("/"),
};
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +347 to 352
const [providerID, ...rest] = model.split("/");
if (providerID && rest.length > 0) {
requestData.model = {
providerID,
modelID,
modelID: rest.join("/"),
};
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@chriswritescode-dev chriswritescode-dev merged commit dad1a60 into chriswritescode-dev:main Apr 16, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants