Repository navigation
mecatui initial session ignores saved global/workspace model default when boot model inventory is stale #41
Description
Summary
mecatui appears to persist and display the selected global/default model correctly, but on a fresh boot it can still create the initial session on the server default (GPT-5) instead of the saved global/workspace default (OpenRouter: GPT-5.5). After manually selecting GPT-5.5 in /models and restarting the session, the header correctly shows OpenAI: GPT-5.5.
Observed local state on the affected machine:
# ~/.local/state/mecatui/models.yaml
version: 1
default:
providerId: openrouter
modelId: openai/gpt-5.5
workspaces:
/var/home/jaosorior/Development/stacklok/mecatl:
providerId: openrouter
modelId: openai/gpt-5.5So the persisted selection is present and correct.
Diagnosis
The likely failure is in the connect-time ListModels reconciliation path clearing the persisted selection before CreateSession runs.
Relevant path:
cmd/mecatui/main.goloads persisted model state:newSelectionStore(...)store.Load(cfg.workspace)store.LoadWorkspace(cfg.workspace)store.LoadGlobalDefault()
cmd/mecatui/state.goload order is per-workspace first, then global default:Load: workspace entry if present, elsedefault, else zero selection.
cmd/mecatui/ui/model.goseedsactiveModelfromDeps.InitialModel.cmd/mecatui/ui/model.goInit()fetchesListModelsbefore creating the session.cmd/mecatui/ui/models.gohandlesModelsMsgand callsreconcileSelection().reconcileSelection()clearsm.models.activeandm.activeModelto zero if the persisted selection is not present in the current model inventory.cmd/mecatui/ui/update.gocreateSessionCmd()then sendsm.activeModeltoCreateSession; if it has been cleared, the server default is used.
This matches the symptom:
- Saved selection is
openrouter/openai/gpt-5.5. - At boot, initial
ListModelslikely does not include that exact(provider_id, model_id)pair yet. reconcileSelection()clears the persisted selection to zero.- Initial
CreateSessionuses server default, which resolves toGPT-5. - Later,
/modelsselection explicitly sendsopenrouter/openai/gpt-5.5through the restart-now path, and the header correctly showsGPT-5.5.
The curated catalog does include bare OpenAI gpt-5.5, but the saved selection is OpenRouter’s namespaced openai/gpt-5.5. The race/mismatch may involve the startup snapshot vs background live model refresh for OpenRouter.
Expected behavior
If a saved global or per-workspace default exists and the provider is configured, boot should create the initial session on that saved selection, or at minimum not silently fall back to server default because an early model inventory snapshot was incomplete/stale.
Actual behavior
Boot header shows GPT-5 even though saved default/workspace selection is openrouter/openai/gpt-5.5. Manual selection/restart immediately fixes the header/session.
Pointers
Relevant files/functions:
cmd/mecatui/main.go— persisted state is loaded and threaded intoui.Deps.cmd/mecatui/state.go—selectionStore.Load,LoadWorkspace,LoadGlobalDefault.cmd/mecatui/ui/model.go—NewseedsactiveModel;InitfetchesListModelsbefore create.cmd/mecatui/ui/models.go—updateModelsMsg,reconcileSelection, restart-now model switch path.cmd/mecatui/ui/update.go—createSessionCmdsendsactiveModel.internal/app/build.go/internal/app/modellister.go— startup model snapshot plus background live model refresh.
Verification already run
go test ./cmd/mecatui ./internal/app ./internal/adapter/serverAll passed locally. No code changes were made during diagnosis.
Activity
feat(prompt): output-economy default tone (ladder + prose scope + saf…
feat(prompt): output-economy default tone (ladder + prose scope + saf…
feat(prompt): output-economy default tone (ladder + prose scope + saf…
feat(prompt): output-economy default tone (ladder + prose scope + saf…