Repository navigation
feat(cli-rs): bring the Rust client up to v2.4.0, and fix finished subagents - #65825
Conversation
dev ungated video generation, added model speeds, and added the opencode_api experimental flag for Code Mode's opencode:// fetch.
Port of #65749. A model the server marks as another model served faster or slower (experimental.speed) is no longer an entry of its own in the model and free model pickers: it is a speed of its standard model. /speed (alias /fast) and speed.cycle switch speeds, only while the current model has some; the dialog lists them slowest first with their price against the standard speed. model.json remembers each model's speed, and recents and favorites saved at a speed stand for the model. The prompt shows the speed after the variant, lays the row out at its measured width, and a switch between speeds reads "Switched speed to ...". Adds the E.16 speed dialog fixture and the E.16/speed-prompt P-APP scenario, and the speed ops to the F.5 model.json interop oracle.
Port of #65441, which makes the TS client's event subscriptions honor an aborted signal before handing out queued events. The JS host's client.rpc(...).events.subscribe() returned the events queued before the abort; it now ends as the TS client's does.
A subagent counts as active while its session runs or while a job in its tree runs. The store added jobs from the job list and removed them only on `experimental.job.updated`. Servers before f15ed39, such as the installed v2.3.2, list jobs but never send that event. So a subagent job that a mount or reconnect listed stayed running until the client restarted, and its child stayed in the footer's count and the Subagents tab after it went idle. A child that was resumed while such a read ran got stuck this way. A subagent job runs one busy period of its child: the server settles it when the child's execution ends. The store now ends the child's subagent jobs when that execution ends, except on a shutdown, which keeps the job for the restart. Current servers announce the same end right after, and that event then changes nothing.
`bun run perf` took the first executable that cargo reported for each test build. For the TUI, `--test all` also builds its `plugin-launch-witness` binary. When cargo reported that binary first, the script listed scenarios from it, so it found no TUI scenarios and the regression check skipped them. The binary also wrote a file named `--list` into the package directory. Cargo reports artifacts in the order they finish. With free job slots, the small binary finishes before the test binary. With one free slot, from a low CARGO_BUILD_JOBS or a busy machine, cargo builds the test binary first. So some runs today found the TUI scenarios and others did not. The script now takes the artifact that cargo built as a test (`profile.test`).
Users' cli.json files carry experimental keys, and a copy of the config then allocates. The scenarios ran with none, so a per-frame copy of the config cost them nothing and went unseen.
The session sidebar read its setting through Live::info(), which clones the whole cli_config::Info, and it does so on every sync. The clone costs nothing for an empty config, but an experimental map allocates, so any experimental key added about one copy of it per frame: 2.1% of the allocations of a streaming reply. The sidebar and the title's setting now borrow the config instead.
There was a problem hiding this comment.
I found no blocking problems. I read the speed logic in local.rs side by side with packages/tui/src/context/local.tsx, and they match: speeds share the standard model's variant, recents and favorites are deduplicated, and set_speed/cycle_speed behave the same. The subagent fix also fits core: a subagent job's ID is the child session ID and the job runs one execution.resume(child), so ending it on a non-shutdown execution end is right. Clearing it from in-flight list reads keeps a reconnect from adding it back.
I couldn't run any Rust code here: there's no Rust toolchain, and a single core was too slow to build the TUI in time. So the Rust tests, the parity checks and before/after screenshots are still unchecked. I did run compat.test.ts (76 pass) and typecheck:tsc (clean) in packages/cli-rs. Since the prompt row is visibly new, a before/after screenshot of the prompt with a speed selected would help reviewers.
Public API impact (all backwards compatible):
model.jsongains aspeedmap (model key → speed ID), shared with the TypeScript client. Older files without it decode as empty.- New keybind names
speed.cycleandspeed.list(both defaultnone), and the slash command/speedwith alias/fast. These only appear while the current model has speeds. - Plugin host:
client.rpc(...).events.subscribe()now ends immediately when aborted or returned, instead of first handing out events it had already queued. This matches the TS client. - The regenerated
plugin.luauand API types only add fields: model speeds, video generation and theopencode_apiflag.
This brings the Rust client up to v2.4.0 (model speeds, the plugin
subscription fix, the regenerated API) and adds four small fixes on top.
On
devtoday, three Rust parity tests fail against v2.4.0's TypeScript.They pass with this PR:
app::tests::the_first_layer_follows_app_tsx,complete::slash_names_and_aliases_match_the_typescript_sourcesandmodels::model_json_is_shared_with_the_typescript_client.Up to v2.4.0
Model speeds (#65749). A model that the server marks as another model
served faster or slower (
experimental.speed) is no longer a separate entryin the model and free-model pickers. It is now a speed of its standard model.
/speed(alias/fast) andspeed.cycleswitch speeds. They exist onlywhile the current model has speeds.
standard speed.
model.jsonremembers each model's speed, as TypeScript's does. A recentor favorite saved at a speed stands for its model.
measured width.
New parity checks: the P-COMP fixture
E.16/speed(the dialog) and theP-APP scenario
E.16/speed-prompt(/speed, the dialog, then Fast). Themodel.jsoninterop oracle gained a speed op, and TypeScript and Rust nowtake turns writing speeds. All 89 P-APP scenarios were re-recorded from
TypeScript, and none changed because of this range.
Plugin RPC subscriptions end when cancelled (#65441). In the JS host,
client.rpc(...).events.subscribe()kept handing out the events it hadqueued before the abort. Now it ends at once, as the TS client's does. Rust's
own event connection has no shared fan-out, so it needs no change.
API regenerated from
dev. The API types andplugin.luaunow includemodel speeds, ungated video generation and the
opencode_apiflag thatCode Mode's
opencode://fetch uses. The commit holds only the writers'output. Nothing else in v2.4.0 reaches the Rust client: server plugins'
automations run in core, and the rest is core, app, AI and release changes.
Fixes
Finished subagents stayed active. The footer's subagent count and the
Subagents tab come from the store's job list. The store added jobs from the
job list read on mount and after each reconnect, and removed them only on
experimental.job.updated. Servers up to v2.3.2 never send that event. Soa subagent job that a list read saw running stayed until restart: resume a
finished child, and the footer said "2 subagents" when one was running. Now
a child's execution end ends its running subagent jobs, unless the end is a
shutdown, which keeps the job for the restart. A subagent job covers exactly
one busy period of its child, and the server settles it then, so the
completedevent that newer servers send afterwards changes nothing. Thiswas not a regression: the job logic had always been like this.
bun run perfcould measure the wrong binary.script/perf.tstook thefirst executable artifact cargo listed. For
opencode-tui --test all, thatcan be a bin, which has no TUI scenarios. It now requires the test profile's
artifact.
The config was copied on every frame. The session sidebar read its
setting through
Live::info(), which clones the wholecli_config::Info,on every sync. The title's setting did the same on every session-info sync.
An empty config clones for free, but an
experimentalmap allocates, andusers'
cli.jsonfiles have one. Both now borrow the config. The perfscenarios now mount with an
experimentalkey, so a per-frame config copywould show up in their counts again.
bun run perf, 3 runsstreamallocations, with an experimental keystreamallocations, without oneresize/open_long/scrollInstructions are flat.
Guards and risks
composer::a_finished_subagent_leaves_the_active_count_each_time_it_goes_idlelists two running subagent jobs and sends no job events. One child goes
idle, is resumed with a reconnect that lists its job again, and goes idle
again, and the footer must read 1 each time. It failed with "2 subagents"
before the fix.
streamperf scenario.models::a_speed_switches_the_model_and_shows_beside_its_nameand the parity checks above.
P-PTY prompt rows exercise. Every P-APP scenario matches with it.
same gap as subagents. A listed job that ends is never removed. They have
no execution end to hook this fix onto.
Commits:
bfe0cc6c8echore(cli-rs): regenerate the API for v2.4.0eaba060c4dfeat(cli-rs): offer a model's service tiers as a speedfd3097a1a3fix(cli-rs): end a cancelled plugin RPC event subscription at oncea48554655bfix(cli-rs): drop finished subagents from the active list99d269146dfix(cli-rs): measure the test binary, not the first executablef17cac1d0atest(cli-rs): run the perf scenarios with an experimental key854c4414ebfix(cli-rs): stop copying the config on every frameAdded by the opencode bot (AI-generated).
Public API: adds a
speedmap to model.json, thespeed.cycle/speed.listkeybinds and/speed(/fast); cancelled plugin RPC subscriptions end at once (backwards compatible)