Repository navigation
Description
Problem / motivation
Tag migration needs a model that works without a live session, so isOpencodeTagMigrationConfigured() in src/services/api-handlers.ts deliberately rejects "opencodeModel": "inherit":
// "inherit" needs a live session model; tag migration has none.
return Boolean(CONFIG.opencodeProvider && CONFIG.opencodeModel && CONFIG.opencodeModel !== "inherit");"inherit" is what the README recommends for auto-capture, and it works there now (thanks to #453 / #508). But the moment you open the Web UI and let it migrate tags, every batch fails with
No tag-migration provider configured. Set opencodeProvider/opencodeModel or memoryModel/memoryApiUrl/memoryApiKey.
The UI cannot tell you that before you click, and cannot fix it: no /api/* route reads or writes config, so the only option is to open ~/.config/opencode/opencode-mem.jsonc by hand, replace "inherit" with a concrete model id, and restart OpenCode. That is exactly the hand-editing this plugin is supposed to spare people from.
Proposed solution
Already implemented locally on a branch; no new dependencies.
Backend:
GET /api/config/model-provider— returns the configuredproviderID/modelID, whether the migration path would accept them, and the provider/model directory, including which providers are connected. On v2 hosts the directory comes fromctx.provider.list()+ctx.model.list()(the legacy client only exposesconnected), with the v1provider.list()shape as fallback. Reportsavailable: falseplus a reason when no directory is reachable.PUT /api/config/model-provider— validates both ids, rewrites onlyopencodeProvider/opencodeModelin the config file that already supplied them (project file if it sets either key, else the first existing global file), preserving comments, trailing commas and CRLF, re-parsing the result before an atomic rename. On success the plugin reloads config in-process through areloadConfigcallback, so no restart is needed.
Web UI:
- The tag-migration dialog gets a provider → model pair of selects and a save button; "Start migration" stays disabled until a concrete model is configured.
- The same picker is a shared component, also reachable any time from a new sidebar entry Model (
/model-settings), with a note that these two keys are shared with auto-capture. - Sim mode (
OPENCODE_MEM_SIM=1) answers the new endpoints from a fixture, so the picker is demoable offline.
Screenshots (attached): blocked dialog with inherit, saved state, the new Model page.
Alternatives considered
- Treat
inheritas configured for migration and fail at runtime. Same dead end, just later. - Add UI for the manual API channel too (
memoryModel/memoryApiUrl/memoryApiKey). Would also solve it, but means accepting an API key in the browser UI — bigger surface, separate concern. - Write the config but require a restart. Simpler, but the UI then reports "saved" while still refusing to migrate.
- Only extend
/api/migration/tags/detect. It reportscount, not whether a provider exists, so the UI still could not explain the failure before it happens. - Parse the JSONC with a library. Not needed for two known keys; the writer does line-level replacement and self-checks with the existing
stripJsoncComments.
Additional context
- Branch
feat/web-model-selector, 9 commits: config writer + 12 unit tests, catalog/route, dialog picker, three fixes found by real use (model ids containing/, a config comment mentioning/api/*confusing the writer's comment tracking, and the in-process reload needing the plugin's own config instance), the Model page, and sim support. - Verified against a real OpenCode v2 host on Windows: catalog lists the connected providers, saving takes effect without a restart, and the config file keeps its comments and a single copy of each key.
bun run checkandbun run web:buildpass.bun test: new tests pass; remaining failures reproduce onmainhere (profile runtime timeouts, onnxruntime shim, the 500-memory portability test under load).- Questions before I open a PR:
- Does a writable Web UI fit the direction you want, or would you rather keep it read-only and solve this in config/
inherithandling? - Writing back to the project config file when it already sets these keys, vs always the global file — any preference?
- Is in-process reload acceptable, or should the UI ask for a restart?
- Should
getAutoCaptureProviderStatus()also flaginheritas not migration-ready? Today it reports ready, which is why the mismatch is invisible until a batch fails. (I left it alone.)
- Does a writable Web UI fit the direction you want, or would you rather keep it read-only and solve this in config/

Activity