Skip to content

feat: configurable embedding/description models via TUI settings menu#9

Merged
MrDoe merged 6 commits into
mainfrom
feat/tui-model-config
Jun 12, 2026
Merged

feat: configurable embedding/description models via TUI settings menu#9
MrDoe merged 6 commits into
mainfrom
feat/tui-model-config

Conversation

@MrDoe

@MrDoe MrDoe commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Summary

Embedding and description models can now be configured via the OpenCode TUI settings dialog (Ctrl+Shift+R), without editing opencode-rag.json.

Changes

TUI settings (src/tui.ts)

  • New Embedding category with model picker (provider/model)
  • LLM Descriptions category extended with model picker
  • Model picker populated from OpenCode's configured providers (api.state.provider), grouped by provider name — matching native look and feel
  • "Custom..." option for manual entry (e.g. local models not in provider config)
  • Re-index warning toaster when embedding model changes
  • SettingEntry type extended with "string" type and options field for select-style dialogs

Runtime overrides (src/core/runtime-overrides.ts)

  • RuntimeOverrides now includes embedding: { provider, model, baseUrl } and description: { provider, model, baseUrl }
  • saveRuntimeOverride() accepts string values in addition to boolean | number
  • applyRuntimeOverrides() merges the 6 new fields onto RagConfig

Plugin startup (src/plugin.ts)

  • Runtime overrides are now applied before creating embedder/description provider, so previously saved TUI settings take effect on plugin reload
  • resolveApiKeyFromProviderConfig() reads the OpenCode config to extract the API key for OpenAI providers — no manual key re-entry

Tests

  • 13 new tests covering string values, embedding/description override fields
  • All 589 tests pass

- Extend runtime overrides with embedding.provider/model/baseUrl
  and description.provider/model/baseUrl fields
- Add string value support to saveRuntimeOverride()
- Add Embedding category and extend LLM Descriptions category
  in the TUI settings dialog (Ctrl+Shift+R)
- Model picker populates from api.state.provider (OpenCode providers),
  grouped by provider name matching native look & feel
- Include 'Custom...' option for manual model entry
- Show re-index warning when embedding model changes
- Apply runtime overrides at plugin startup so saved settings
  take effect on next plugin reload
- Resolve OpenAI API keys from OpenCode provider config
- 13 new tests for runtime-override fields
Copilot AI review requested due to automatic review settings June 12, 2026 16:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds TUI-driven configuration of embedding and description LLM models by storing runtime overrides in the workspace vectorstore directory, and ensures those overrides are applied during plugin startup so changes take effect on reload.

Changes:

  • Extended the TUI settings dialog with select-style entries (including a model picker and custom entry) for embedding and description models.
  • Expanded runtime overrides to support embedding/description provider, model, and baseUrl, including string-valued overrides.
  • Updated plugin startup to apply runtime overrides earlier and attempt to resolve missing OpenAI API keys from OpenCode provider config files.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/tui.ts Adds model-picker UI and string-based settings entries for embedding and description model selection.
src/plugin.ts Applies runtime overrides before service construction and adds OpenCode config API-key resolution helper.
src/core/runtime-overrides.ts Extends override schema and merge logic to include embedding/description provider/model/baseUrl and string values.
src/tests/core/runtime-overrides.test.ts Adds unit tests for string overrides and new embedding/description override merge behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/plugin.ts Outdated
Comment on lines +675 to +677
function stripJsoncComments(text: string): string {
return text.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
}
Comment thread src/tui.ts
Comment on lines +225 to +226
for (const provider of providers) {
if (!provider.models) continue;
Comment thread src/tui.ts
Comment on lines +310 to +314
function displayModel(roProvider: unknown, roModel: unknown, cfgProvider: unknown, cfgModel: unknown, defaultProvider: string, defaultModel: string): string {
const p = (roProvider as string) ?? (cfgProvider as string) ?? defaultProvider;
const m = (roModel as string) ?? (cfgModel as string) ?? defaultModel;
return `${p}/${m}`;
}
Comment thread src/plugin.ts Outdated
Comment on lines +665 to +669
/**
* Resolve missing API keys from OpenCode provider config files.
* Reads the workspace and global OpenCode config to find the provider
* and extract its apiKey. Falls back to env vars.
*/
Comment thread src/plugin.ts
Comment on lines +746 to +752
// Apply runtime overrides before creating services
const overrides = loadRuntimeOverrides(storePath);
const effectiveCfg = applyRuntimeOverrides(cfg, overrides);

// Resolve API keys from OpenCode provider config if not set in opencode-rag.json
resolveApiKeyFromProviderConfig(effectiveCfg, input.directory, logFilePath);

@MrDoe

MrDoe commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

Still needs some more testing before merging it...

@MrDoe MrDoe merged commit 6faa197 into main Jun 12, 2026
3 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.

2 participants