feat(6.33): auto-refresh ollama models on boot + manual "Refresh" button#38
Merged
fstamatelopoulos merged 2 commits intomainfrom May 9, 2026
Merged
Conversation
`availableOllamaModels` was previously captured ONCE at `cfcf init` and
never re-detected by the server or web UI. Newly-pulled ollama models
were invisible to the role-picker dropdowns until the user re-ran
`cfcf init --force`.
Three pieces:
1. New `refreshOllamaModelsInConfig()` helper in `@cfcf/core`. Detects
ollama, lists models, compares against saved (order-insensitive
since `ollama list` reorders by mtime), persists if different.
Best-effort: never throws; missing-ollama is reported via the
`error` field, not a thrown exception.
2. Boot-time auto-refresh in `start.ts`, runs after the orphan reaper.
Single log line if the list changed; silent otherwise. Failures
log + continue, never block boot. Solves "I pulled a model + did
`cfcf server stop && cfcf server start` but the dropdown is stale".
3. `POST /api/agents/refresh-ollama-models` endpoint + a "Refresh
ollama models" button in the Agent roles section of both web
Settings (`ServerInfo.tsx`) and workspace Config (`ConfigDisplay.tsx`).
Solves "I pulled a model and don't want to bounce the server".
Button shows in-flight + result message ("✓ N models detected —
list updated" / "list already current" / error hint when ollama
isn't installed). Bumps a `modelsRev` counter to trigger a
re-fetch of `/api/agents/models` so dropdowns pick up the change.
Tests: 4 new unit tests in `ollama-detection.test.ts` (response
shape, no-config-no-write, list-equality persistence guard, ordering
insensitivity); 2 new endpoint tests in `agent-models.test.ts`
(documented shape, no-500-on-missing-ollama defence-in-depth).
Pre-existing `app.test.ts` config-merge failure on main is NOT
caused by this work (verified earlier via `git stash`).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… ollama-routed adapters The "(adapter default)" empty-value option in the model picker means "let the CLI pick" — works for `claude-code` (claude has its own default) and `codex` (codex picks gpt-5-codex), but is broken for `claude-code-ollama` / `opencode-ollama`: `ollama launch <agent>` requires an explicit `--model <name>` to know which local model to hand off, and our adapters skip the flag entirely when `model` is falsy. Saving `model=""` for an ollama-routed adapter produces a silent misconfiguration at spawn time. Hide the "(adapter default)" option in `AgentModelSelect` for the two ollama-routed adapters via a small `OLLAMA_ROUTED_ADAPTERS` set (hardcoded in the web tree per the existing convention — web is Vite-built and doesn't import @cfcf/core directly; same pattern as HarnessPolicyWarning). For the empty-list case (no ollama models pulled yet, or the boot refresh hasn't run), surface a disabled placeholder option: `(no ollama models — pull one or click Refresh)`. The dropdown isn't visually empty + the user gets a hint about the Refresh button or `ollama pull`. Behavior unchanged for seed-sourced adapters. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes a UX gap surfaced during dogfood: the user pulled a new ollama model, restarted the cfcf server, and the model didn't appear in the role-picker dropdowns. Root cause:
listOllamaModels()was only called atcfcf init(interactive setup) andcfcf doctor(read-only display) — neither the server nor the web UI ever re-detected.Adds three pieces (boot-time refresh + manual button + helper) and fixes a related model-picker UX bug for ollama-routed adapters that surfaced while implementing the button.
What's new
refreshOllamaModelsInConfig()core helper — detects ollama, lists models, persists toavailableOllamaModelsif the live list differs (order-insensitive comparison sinceollama listreorders by mtime). Best-effort, never throws.cfcf server start— runs after the orphan reaper. Single log line on change, silent otherwise. Solves the "stop + start to pick up the new model" expectation.POST /api/agents/refresh-ollama-models+ "Refresh ollama models" button in both web Settings and workspace Config Agent-roles sections. Solves the "I just pulled a model and don't want to bounce the server" path. Button shows in-flight state + result message ("✓ N models detected — list updated" / "list already current" / hint when ollama isn't installed) and triggers a re-fetch of/api/agents/modelsso the*-ollamadropdowns update without a page reload.Test plan
bun run typecheck— cleanbun test packages/core packages/cli— 778/778 pass (4 new unit + 2 new endpoint)cd packages/web && bun run build— cleanollama pull <new-model>→ restart cfcf server → confirm log line[server] Refreshed availableOllamaModels (N models detected)→ open web Settings → new model appears inclaude-code-ollama/opencode-ollamadropdownsollama pull <another-new-model>→ click "Refresh ollama models" in Settings → confirm status message + new model appears in dropdowns without server restart