feat: restore API key command and route usage - #161
Conversation
|
Hey @buhagee, thanks for this. I checked the routing change against the code and it holds up. Usage sync now reads One thing I want to settle before merge. This restores the command-palette API-key entry we deliberately pulled a few days ago, when we went BYOK-only in Is it the environment where the native Manage Models panel isn't available? Or a specific flow where BYOK doesn't work for you? The answer decides whether this stays a documented fallback or gets wired deeper, say into the multi-profile flow from issue #63. |
📝 What does this change?
Restores optional command-palette API-key entry for OpenCode Go and OpenCode Zen. Keys are stored securely in VS Code SecretStorage, native VS Code BYOK remains supported, and models refresh after saving.
Also routes model, test-connection, and Go usage requests through the configured
apiBaseUrl, including safe usage-sync diagnostics without exposing credentials.Why is this change needed?
The extension supports configurable OpenCode-compatible API gateways, but not all traffic was consistently routed through the configured base URL. Chat/model requests used
opencodego.apiBaseUrl, while Go usage synchronization still used the hardcoded OpenCode endpoint. As a result, users running a compatible gateway could receive valid model responses while their usage dashboard incorrectly showed zero.This change makes the configured API base URL authoritative for model discovery, connection testing, chat requests, and usage synchronization.
It also restores an optional command-palette API-key entry path. Native VS Code BYOK remains supported and is still the preferred flow, but the fallback is useful when the BYOK panel is unavailable or when users are testing a custom OpenCode-compatible gateway. Keys remain in VS Code SecretStorage, and models refresh immediately after a key is saved.
🧪 How did you test it?
gpt-5.6-lunathrough the configured custom gateway./usageendpoint.npm run compilepassed.npm testpassed.npm run test-retrypassed: 7/7 tests.npm run packagepassed and produced the VSIX.npm run lintwas also run, but the repository-wide check reports pre-existing line-ending and formatting issues across unrelated files. ESLint passed for the changed files.✅ Checklist
npm run compilepassesnpm run lintpasses — existing repository-wide Editorconfig/Prettier issues remainnpm testpassesnpm run packageproduces a VSIX