Skip to content

feat(cli): add \uture models refresh\ to pull the Future catalogue - #1342

Merged
huichen merged 6 commits into
mainfrom
dev-huichen
Oct 24, 2026
Merged

huichen merged 6 commits into
mainfrom
dev-huichen

Conversation

@huichen

@huichen huichen commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

future models refresh:从终端拉取 Future 平台目录,等同于桌面端「设置 → 服务商 → 更新模型列表」那个按钮。解决「平台新上架的模型,已装的应用看不到,得重启或等 24 小时维护」这件事的终端侧入口(界面侧的自动刷新已在 #1341 合入)。

future models refresh          # 拉取 Future 平台目录
future models refresh --json   # {"provider":"future","source":"agent","synced":true,"modelCount":14}

两条路径,都不阻塞

Agent 在跑 —— 走 Agent 的 sync_future_models:同步抓平台目录、重建 registry、发布 provider_config_changed。桌面端的配置观察者已把该事件转成 providers-changed,模型列表会自己重拉,已打开的菜单/设置页就地刷新,不用重启。

没有 Agent 应答(桌面端关着,或 CLI 与运行中的 Agent 构建版本对不上)—— CLI 自己在进程内抓一次,写进 ~/.future/agent/.future-models-cache.json,即下次 Agent 启动会读的缓存。输出会说明没走 Agent 的原因,而不是静默降级:

Refreshed the Future model catalogue on disk: 14 models.
No agent took the refresh (Incompatible Future Agent: … does not match client 0.0.0; local startup is forbidden) — start the Desktop (or `future agent`) to use them.

没有 Future 凭据时不去猜:Agent 对「没凭据」和「平台请求失败」都回 synced: false,所以失败时 CLI 会自己区分这两种情况,分别给 future auth login 与「检查网络 / future doctor」。

一并修的

future models 组之前把第一个位置参数丢掉了(future models <addr> 实际不生效)。现在完整转发:refresh 走到子命令,剩下的裸地址仍是显式 Agent 地址。

验证

  • cargo clippy -p future-cli --all-targets -D warnings、cargo fmt --check、make check-docs 全绿;
  • cargo test -p future-cli 1296 项全过,含新增 4 项:Agent 同步成功 / 同步失败、无 Agent 且无凭据、无 Agent 但有凭据时用本地 mock 平台真实抓取并落到磁盘缓存;
  • 用真实凭据实跑过一次,输出上面那段 fallback 文本,缓存里确实写进了 14 个模型(含 Kimi K3.1 PRO)。

注意

已装的 future.exe 还没有这个命令,需要一次 make install(且要 make install 而非裸 cargo build --release,否则版本号会退化成 0.0.0 而撞上版本守卫)。

A model published on the platform after the agent had already fetched the
catalogue stayed invisible until a restart or the desktop's 24h maintenance
pass: every picker reads the agent's registry, and `list_models` polls that
registry without ever asking the platform again.

Opening a model picker (the composer's picker, the new-conversation screen and
Settings -> Models) is exactly the moment to catch up, so it now asks for a
refresh. The new `request_future_models_refresh` command is the non-blocking
counterpart of `sync_future_models`: it starts the same single-flight,
backoff-guarded fetch `Registry::new()` uses and answers immediately. When the
fetch lands, the agent's sync callback rebuilds the registry and publishes
`provider_config_changed`, which the desktop already turns into
`providers-changed` -> a model-list reload, so an open picker updates in place
without anything waiting on the platform.

The GUI side is fire-and-forget and TTL-gated (10 minutes across all pickers),
so opening the menu repeatedly does not ask the platform each time, and a failed
request is swallowed rather than surfaced at the picker.

Also fixes a latent lock-order inversion in the future-models tests: the
sync-callback test took the refresh gate before its isolated HOME, which
deadlocks any test that holds a HOME and then goes through the gated refresh.
The desktop can refresh the Future catalogue (Settings -> Providers -> "Update
model list"), but a terminal-only user — or a script — had no way to do it, and
`future models` only ever read the agent's registry. So a model published after
the agent fetched the catalogue stayed invisible until a restart or the 24h
maintenance pass.

`future models refresh [--json]` closes that. It asks the agent's
`sync_future_models` command, which fetches the platform catalogue, rebuilds the
registry and publishes `provider_config_changed`; the desktop already turns that
into a model-list reload, so a running Desktop updates in place with no restart.

With no agent answering (the desktop is closed, or the CLI build does not match
the running agent's version) the command refreshes the on-disk catalogue itself
— the cache the next Agent start reads — and says so, including why no agent
took the refresh. Without a Future credential it points at `future auth login`
instead of guessing, because the agent answers `synced: false` for both "no
credential" and "the platform call failed".

The `models` group now forwards its first positional into the command (it used
to drop it), so `refresh` reaches the subcommand while a bare address still
seeds the listing as before.
@huichen
huichen merged commit 9961430 into main Oct 24, 2026
10 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.

1 participant