Skip to content

fix(gui): shadow-call selects save the canonical namespaced model id (#1075) - #1087

Merged
lidge-jun merged 3 commits into
devfrom
codex/1075-shadow-call-namespaced
Aug 6, 2026
Merged

lidge-jun merged 3 commits into
devfrom
codex/1075-shadow-call-namespaced

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Aug 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Fixes the dashboard's Shadow Call Intercept "Replacement model" select saving the bare model id (gpt-5.6-sol) instead of the canonical namespaced id (subapi/gpt-5.6-sol), which silently routed shadow calls to the built-in openai provider 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.
  • Both selects that edit shadowCallIntercept.model now share one helper, shadowCallModelOptions in gui/src/pages/dashboard-shared.ts, which emits the API's canonical namespaced value 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).
  • Legacy saved values that no longer match any option are appended as a visible fallback option instead of the select silently jumping to index zero. Honest limitation, also recorded on the issue: a previously saved bare id that collides with a native slug is indistinguishable from an intentional native pick and cannot be auto-repaired; the fix prevents new corruption.
  • ModelInfo in the dashboard gains the namespaced field /api/models already 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+"/"+id case, legacy fallback appended, empty current appends nothing; plus a source contract asserting both dashboard-overview-sections.tsx and Models.tsx use the helper).
  • Red ablation recorded: with the overview .tsx change reverted, the contract test fails (3 pass, 1 fail).
  • Full gui suite: 610 pass, 0 fail.
  • bun run privacy:scan — passed.
  • Live GUI QA on this branch (Vite dev against a running proxy): the dashboard replacement-model dropdown now lists canonical ids (bare native slugs, routed provider/model entries):

dashboard shadow-call select

Closes #1075.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (No user-facing docs describe this select; devlog unit records the plan and audit.)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (GUI-only value semantics; no credential surface.)

Summary by CodeRabbit

  • Bug Fixes
    • Improved shadow-call model selection to show only currently available models.
    • Preserved existing selections when a model is no longer available.
    • Standardized model identifiers across shadow-call selectors.
  • Tests
    • Added coverage for available options, empty selections, and legacy values.
    • Verified consistent behavior across dashboard shadow-call selectors.

…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.
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 6, 2026
@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

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

Changes

Shadow-call model selection

Layer / File(s) Summary
Canonical option contract
gui/src/pages/dashboard-shared.ts
ModelInfo now requires namespaced. shadowCallModelOptions creates an empty option, uses canonical identifiers, and preserves unmatched current values.
Models selector integration
gui/src/pages/Models.tsx
The Models page derives options from active models and uses the shared options in its selector.
Dashboard integration and validation
gui/src/pages/dashboard-overview-sections.tsx, gui/tests/shadow-call-model-options.test.ts
The dashboard uses the shared helper. Tests cover native, routed, and encoded identifiers, unmatched values, empty values, and both selectors.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers: ingwannu, wibias

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main GUI fix: saving the canonical namespaced model ID in shadow-call selectors.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/1075-shadow-call-namespaced

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between ad38b5f and 4acc2d3.

⛔ Files ignored due to path filters (1)
  • devlog/_plan/260806_overnight_triage_round2/evidence/shadow-call-select-namespaced.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • gui/src/pages/Models.tsx
  • gui/src/pages/dashboard-overview-sections.tsx
  • gui/src/pages/dashboard-shared.ts
  • gui/tests/shadow-call-model-options.test.ts

Comment on lines +164 to +169
/** 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;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 win

Reconcile the selector with the PUT response.

Line 920 updates shadowCall.model before saveShadowCall completes. In this file, saveShadowCall at Lines 473-485 does not check response.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 fetch calls.

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 win

Format the canonical namespaced value.

Line 116 uses m.namespaced as the option value but reconstructs ${m.provider}/${m.model} for the label. For provider-specific encoded IDs, m.model can contain a <vendor>/<model> path while m.namespaced contains 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4acc2d3 and d53253b.

📒 Files selected for processing (2)
  • gui/src/pages/Models.tsx
  • gui/src/pages/dashboard-overview-sections.tsx

@lidge-jun
lidge-jun merged commit bfbc9a4 into dev Aug 6, 2026
26 checks passed
@lidge-jun
lidge-jun deleted the codex/1075-shadow-call-namespaced branch August 8, 2026 00:49
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
…ll-namespaced

fix(gui): shadow-call selects save the canonical namespaced model id (lidge-jun#1075)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant