Skip to content

fix: simplify default models revert flow (KHA-272)#39

Draft
KHAEntertainment wants to merge 1 commit intomainfrom
fix/kha-272-default-models-revert
Draft

fix: simplify default models revert flow (KHA-272)#39
KHAEntertainment wants to merge 1 commit intomainfrom
fix/kha-272-default-models-revert

Conversation

@KHAEntertainment
Copy link
Copy Markdown
Owner

@KHAEntertainment KHAEntertainment commented Apr 12, 2026

Summary

  • Simplify revertApply to null-out all ThroneKeeper overrides instead of calling the Anthropic API during proxy stop
  • Update hardcoded model fallbacks from outdated 4.5 family to current 4.6 -latest aliases
  • Claude Code uses its own built-in defaults when overrides are absent — no need to fetch specific model IDs

Context

fetchAnthropicDefaults() was called on every proxy stop to get current model names for restoring .claude/settings.json. This failed for OAuth (Pro/Max) users and returned outdated model names (4.5 era when 4.6 is current).

The CLI flow already uses the simpler null-out approach successfully.

Changes

  • revertApply simplified — Removed fetchAnthropicDefaults() API call, cache-age check, and cache update. Single atomic null-out of all ThroneKeeper env vars.
  • Hardcoded fallbacks updatedclaude-opus-4-6-latest, claude-sonnet-4-6-latest, claude-haiku-4-5-latest
  • Success message updated — Reflects new null-out behavior

Test plan

  • npm run compile — TypeScript compiles clean
  • Start proxy → select models → start → verify settings.json has models set
  • Stop proxy → verify all ThroneKeeper keys removed from settings.json
  • Verify Claude Code still works (uses built-in defaults)
  • Verify webview Advanced Settings still shows cached Anthropic defaults

Closes: KHA-272

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added commands for managing Kimi and Minimax API keys
  • Refactor

    • Updated default Anthropic model versions (Opus, Sonnet, Haiku)
    • Simplified settings revert behavior to clear environment variable overrides
    • Enhanced messaging when reverting to default configuration

…nthropic defaults

On proxy stop, remove all ThroneKeeper env vars from .claude/settings.json
and let Claude Code use its built-in defaults. This eliminates the
fetchAnthropicDefaults() API call during revert, which failed for OAuth
(Pro/Max) users and returned outdated 4.5-era model names.

Also updates hardcoded fallbacks to current 4.6 -latest aliases.

Closes: KHA-272

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 12, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a30f6a9e-6009-4f9b-a0ec-35fbc030d108

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/kha-272-default-models-revert

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 and usage tips.

@github-actions
Copy link
Copy Markdown

🤖 Hi @KHAEntertainment, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@github-actions
Copy link
Copy Markdown

🤖 I'm sorry @KHAEntertainment, but I was unable to process your request. Please see the logs for more details.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
extensions/thronekeeper/src/extension.ts (1)

499-503: ⚠️ Potential issue | 🟡 Minor

Add claudeThrone.storeKimiKey to the extension's command contributions.

claudeThrone.storeKimiKey is registered in code but missing from package.json's contributes.commands array. Without this declaration, the command won't appear reliably in the Command Palette or menus. (claudeThrone.storeMinimaxKey is already properly declared.)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/thronekeeper/src/extension.ts` around lines 499 - 503, The
extension registers the command storeKimiKey via the function/variable
storeKimiKey (command id 'claudeThrone.storeKimiKey') but that id is missing
from package.json contributes.commands; add an entry for
'claudeThrone.storeKimiKey' to the contributes.commands array (mirror the
existing 'claudeThrone.storeMinimaxKey' entry including a suitable title and
category) so the command is exposed in the Command Palette and menus.
🧹 Nitpick comments (1)
extensions/thronekeeper/src/extension.ts (1)

1144-1153: Consolidate duplicate subscription lists to prevent drift.

This block duplicates disposables already pushed earlier (Line 527 onward). It works, but maintaining two lists is like keeping two source-of-truth ledgers—eventually they diverge. Prefer a single context.subscriptions.push(...) block.

As per coding guidelines "**/*.ts: Event listeners are not duplicated (check cleanup)."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/thronekeeper/src/extension.ts` around lines 1144 - 1153, The
second context.subscriptions.push(...) duplicates disposables already pushed
earlier (openPanel, storeOpenRouterKey, storeOpenAIKey, storeTogetherKey,
storeDeepseekKey, storeGlmKey, storeKimiKey, storeMinimaxKey, storeCustomKey),
so remove this duplicate block and consolidate into a single subscription
registration; either extend the existing push at the original location to
include any missing symbols or centralize all disposables into one array and
call context.subscriptions.push(...thatArray) so there is only one authoritative
subscription list for cleanup.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@extensions/thronekeeper/src/extension.ts`:
- Around line 126-128: The unconditional console.log in fetchAnthropicDefaults
printing models.map((m: any) => m.id) is noisy; wrap this raw model-ID dump
behind the debug flag and use the Fastify logger instead of console. Replace the
direct console.log with a conditional that checks the extension debug setting
(e.g. process.env.DEBUG or the extension's debug config) and call
fastify.log.debug(...) (or the injected logger) to emit the message only when
debug is enabled, referencing the same models variable and the existing
fetchAnthropicDefaults function.

---

Outside diff comments:
In `@extensions/thronekeeper/src/extension.ts`:
- Around line 499-503: The extension registers the command storeKimiKey via the
function/variable storeKimiKey (command id 'claudeThrone.storeKimiKey') but that
id is missing from package.json contributes.commands; add an entry for
'claudeThrone.storeKimiKey' to the contributes.commands array (mirror the
existing 'claudeThrone.storeMinimaxKey' entry including a suitable title and
category) so the command is exposed in the Command Palette and menus.

---

Nitpick comments:
In `@extensions/thronekeeper/src/extension.ts`:
- Around line 1144-1153: The second context.subscriptions.push(...) duplicates
disposables already pushed earlier (openPanel, storeOpenRouterKey,
storeOpenAIKey, storeTogetherKey, storeDeepseekKey, storeGlmKey, storeKimiKey,
storeMinimaxKey, storeCustomKey), so remove this duplicate block and consolidate
into a single subscription registration; either extend the existing push at the
original location to include any missing symbols or centralize all disposables
into one array and call context.subscriptions.push(...thatArray) so there is
only one authoritative subscription list for cleanup.
🪄 Autofix (Beta)

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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 18b3748a-d074-4bc5-adee-fffbc4ebcfb7

📥 Commits

Reviewing files that changed from the base of the PR and between fa1f69e and 548d0c8.

📒 Files selected for processing (1)
  • extensions/thronekeeper/src/extension.ts

Comment on lines +126 to +128
// DEBUG: Log all raw model IDs before filtering
console.log(`[fetchAnthropicDefaults] All ${models.length} models from API:`, models.map((m: any) => m.id));

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.

⚠️ Potential issue | 🟡 Minor

Gate raw model-ID dump behind debug mode.

Line 127 logs the full model-id list unconditionally; that’s noisy in normal runs and can flood extension logs like leaving a faucet open. Please guard it behind the debug setting.

💡 Suggested patch
-    // DEBUG: Log all raw model IDs before filtering
-    console.log(`[fetchAnthropicDefaults] All ${models.length} models from API:`, models.map((m: any) => m.id));
+    const debug = vscode.workspace.getConfiguration('claudeThrone').get<boolean>('proxy.debug', false)
+    if (debug) {
+      console.log(
+        `[fetchAnthropicDefaults] All ${models.length} models from API:`,
+        models.map((m: any) => m.id)
+      )
+    }

As per coding guidelines "Logging: use Fastify's logger; gate verbose output behind DEBUG."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@extensions/thronekeeper/src/extension.ts` around lines 126 - 128, The
unconditional console.log in fetchAnthropicDefaults printing models.map((m: any)
=> m.id) is noisy; wrap this raw model-ID dump behind the debug flag and use the
Fastify logger instead of console. Replace the direct console.log with a
conditional that checks the extension debug setting (e.g. process.env.DEBUG or
the extension's debug config) and call fastify.log.debug(...) (or the injected
logger) to emit the message only when debug is enabled, referencing the same
models variable and the existing fetchAnthropicDefaults function.

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.

1 participant