Repository navigation
fix(gui): shadow-call selects save the canonical namespaced model id (#1075) - #1087
Conversation
…1075) The dashboard overview selector saved bare model ids, allowing provider collisions to route shadow calls to the wrong model and making the selection jump on reload. Use canonical namespaced ids in both selectors and retain an unmatched saved legacy value as a fallback option so existing configurations remain visible without changing their value.
|
✅ Deterministic PR hygiene checks passed. |
📝 WalkthroughWalkthroughThe GUI now generates shadow-call model options from canonical namespaced identifiers. The shared helper preserves unmatched configured values and handles empty selections. Both shadow-call selectors use the helper, with tests covering identifier formats and selector integration. ChangesShadow-call model selection
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@gui/src/pages/dashboard-shared.ts`:
- Around line 164-169: Update shadowCallModelOptions to accept an
empty-selection label parameter and use it instead of the hardcoded "—" text.
Add the corresponding translation key to each locale file, then pass t(...) for
that key from both selector components that call shadowCallModelOptions.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 0771a67b-b5a9-4a8c-a438-bd1b6c2d2ce5
⛔ Files ignored due to path filters (1)
devlog/_plan/260806_overnight_triage_round2/evidence/shadow-call-select-namespaced.pngis excluded by!**/*.png
📒 Files selected for processing (4)
gui/src/pages/Models.tsxgui/src/pages/dashboard-overview-sections.tsxgui/src/pages/dashboard-shared.tsgui/tests/shadow-call-model-options.test.ts
| /** Options for shadow-call replacement models use the proxy's canonical routing id. */ | ||
| export function shadowCallModelOptions(models: ModelInfo[], current: string | undefined) { | ||
| const out = [{ value: "", label: "—" }, ...models.map(model => ({ value: model.namespaced, label: model.namespaced }))]; | ||
| if (current && !out.some(option => option.value === current)) out.push({ value: current, label: current }); | ||
| return out; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Move the empty-selection label to the locale files.
Line 166 adds "—" as a user-visible option label. This prevents a locale from defining the empty-selection text.
Pass a localized empty label into shadowCallModelOptions, and add the corresponding key to the locale files. Supply that key through t(...) from both selector components.
As per path instructions, user-visible strings must go through the i18n locale files rather than hardcoded text.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@gui/src/pages/dashboard-shared.ts` around lines 164 - 169, Update
shadowCallModelOptions to accept an empty-selection label parameter and use it
instead of the hardcoded "—" text. Add the corresponding translation key to each
locale file, then pass t(...) for that key from both selector components that
call shadowCallModelOptions.
Source: Path instructions
…-namespaced # Conflicts: # gui/src/pages/dashboard-overview-sections.tsx
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
gui/src/pages/Models.tsx (1)
920-920: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winReconcile the selector with the PUT response.
Line 920 updates
shadowCall.modelbeforesaveShadowCallcompletes. In this file,saveShadowCallat Lines 473-485 does not checkresponse.ok, catch network failures, or restore the previous value. A failed request leaves the selector showing a value that the management API did not save. The next reload changes the value again.Check the response and restore the previous value or reload the server state on failure. Also catch rejected
fetchcalls.Proposed fix
+ const previous = shadowCall; setShadowCall({ ...shadowCall, ...patch }); try { - await fetch(`${apiBase}/api/shadow-call-settings`, { + const response = await fetch(`${apiBase}/api/shadow-call-settings`, { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify(patch), }); + if (!response.ok) throw new Error("shadow-call save failed"); + } catch { + setShadowCall(previous); } finally { setShadowCallSaving(false); }As per path instructions, the selector state must stay consistent with the management API response.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@gui/src/pages/Models.tsx` at line 920, Update the saveShadowCall flow to handle non-OK responses and rejected fetch calls, then restore the previous shadowCall.model or reload the server state when saving fails. In the Select onChange handler, retain the prior value so the selector remains consistent with the management API after saveShadowCall completes.Source: Path instructions
gui/src/pages/dashboard-overview-sections.tsx (1)
116-116: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winFormat the canonical namespaced value.
Line 116 uses
m.namespacedas the option value but reconstructs${m.provider}/${m.model}for the label. For provider-specific encoded IDs,m.modelcan contain a<vendor>/<model>path whilem.namespacedcontains the canonical encoded identifier. The formatter can then receive an extra slash and display a label that does not match the saved value.- ...injectionAvailable.map(m => ({ value: m.namespaced, label: formatNamespacedModelId(`${m.provider}/${m.model}`, t) })), + ...injectionAvailable.map(m => ({ value: m.namespaced, label: formatNamespacedModelId(m.namespaced, t) })),🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@gui/src/pages/dashboard-overview-sections.tsx` at line 116, Update the option mapping around injectionAvailable.map to pass the canonical namespaced identifier m.namespaced through formatNamespacedModelId for the label, instead of reconstructing it from m.provider and m.model. Keep m.namespaced as the option value so the displayed label and saved value use the same canonical identifier.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@gui/src/pages/dashboard-overview-sections.tsx`:
- Line 116: Update the option mapping around injectionAvailable.map to pass the
canonical namespaced identifier m.namespaced through formatNamespacedModelId for
the label, instead of reconstructing it from m.provider and m.model. Keep
m.namespaced as the option value so the displayed label and saved value use the
same canonical identifier.
In `@gui/src/pages/Models.tsx`:
- Line 920: Update the saveShadowCall flow to handle non-OK responses and
rejected fetch calls, then restore the previous shadowCall.model or reload the
server state when saving fails. In the Select onChange handler, retain the prior
value so the selector remains consistent with the management API after
saveShadowCall completes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 7088cdea-09c8-44e9-94db-d0b3e3b63040
📒 Files selected for processing (2)
gui/src/pages/Models.tsxgui/src/pages/dashboard-overview-sections.tsx
…ll-namespaced fix(gui): shadow-call selects save the canonical namespaced model id (lidge-jun#1075)
Summary
gpt-5.6-sol) instead of the canonical namespaced id (subapi/gpt-5.6-sol), which silently routed shadow calls to the built-inopenaiprovider for users of custom/namespaced providers, and made the selection jump to the native model with the same id on reload. Reported in [Bug] Shadow call intercept model dropdown saves bare id for namespaced providers, silently breaking interception #1075 (dup [Bug] Shadow call intercept model dropdown saves bare id for namespaced providers, silently breaking interception #1078) with an exact root cause in the bundled gui.shadowCallIntercept.modelnow share one helper,shadowCallModelOptionsingui/src/pages/dashboard-shared.ts, which emits the API's canonicalnamespacedvalue per row (native rows stay bare slugs; routed rows keep their slug-codec form — no${provider}/${id}string reconstruction, which would mint noncanonical ids and bypass encoded aliases).ModelInfoin the dashboard gains thenamespacedfield/api/modelsalready serves (src/server/management/model-rows.ts).Verification
bun run typecheck— clean.bun run lint:gui— clean.cd gui && bun test tests/shadow-call-model-options.test.ts— 4 pass, 0 fail (covers: native bare id preserved, routed id preserved,namespaced !== provider+"/"+idcase, legacy fallback appended, empty current appends nothing; plus a source contract asserting bothdashboard-overview-sections.tsxandModels.tsxuse the helper)..tsxchange reverted, the contract test fails (3 pass, 1 fail).bun run privacy:scan— passed.provider/modelentries):Closes #1075.
Checklist
Summary by CodeRabbit