Repository navigation
feat(cli): add \uture models refresh\ to pull the Future catalogue - #1342
Merged
Merged
Conversation
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.
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.
future models refresh:从终端拉取 Future 平台目录,等同于桌面端「设置 → 服务商 → 更新模型列表」那个按钮。解决「平台新上架的模型,已装的应用看不到,得重启或等 24 小时维护」这件事的终端侧入口(界面侧的自动刷新已在 #1341 合入)。两条路径,都不阻塞
Agent 在跑 —— 走 Agent 的
sync_future_models:同步抓平台目录、重建 registry、发布provider_config_changed。桌面端的配置观察者已把该事件转成providers-changed,模型列表会自己重拉,已打开的菜单/设置页就地刷新,不用重启。没有 Agent 应答(桌面端关着,或 CLI 与运行中的 Agent 构建版本对不上)—— CLI 自己在进程内抓一次,写进
~/.future/agent/.future-models-cache.json,即下次 Agent 启动会读的缓存。输出会说明没走 Agent 的原因,而不是静默降级:没有 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-cli1296 项全过,含新增 4 项:Agent 同步成功 / 同步失败、无 Agent 且无凭据、无 Agent 但有凭据时用本地 mock 平台真实抓取并落到磁盘缓存;注意
已装的
future.exe还没有这个命令,需要一次make install(且要make install而非裸cargo build --release,否则版本号会退化成0.0.0而撞上版本守卫)。