Skip to content

feat(cli-rs): bring the Rust client up to v2.4.0, and fix finished subagents - #65825

Merged
simonklee merged 7 commits into
devfrom
native-fixes
Nov 23, 2026
Merged

simonklee merged 7 commits into
devfrom
native-fixes

Conversation

@simonklee

@simonklee simonklee commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

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 dev today, 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_sources and
models::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 entry
in the model and free-model pickers. It is now a speed of its standard model.

  • /speed (alias /fast) and speed.cycle switch speeds. They exist only
    while the current model has speeds.
  • The dialog lists speeds slowest first, each with its price against the
    standard speed.
  • model.json remembers each model's speed, as TypeScript's does. A recent
    or favorite saved at a speed stands for its model.
  • The prompt shows the speed after the variant, and lays out that row at its
    measured width.

New parity checks: the P-COMP fixture E.16/speed (the dialog) and the
P-APP scenario E.16/speed-prompt (/speed, the dialog, then Fast). The
model.json interop oracle gained a speed op, and TypeScript and Rust now
take 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 had
queued 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 and plugin.luau now include
model speeds, ungated video generation and the opencode_api flag that
Code 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. So
a 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
completed event that newer servers send afterwards changes nothing. This
was not a regression: the job logic had always been like this.

bun run perf could measure the wrong binary. script/perf.ts took the
first executable artifact cargo listed. For opencode-tui --test all, that
can 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 whole cli_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 experimental map allocates, and
users' cli.json files have one. Both now borrow the config. The perf
scenarios now mount with an experimental key, so a per-frame config copy
would show up in their counts again.

bun run perf, 3 runs before → after
stream allocations, with an experimental key 160,561 → 157,170 (−2.1%)
stream allocations, without one 157,170 = 157,170
resize / open_long / scroll −0.26% / −0.12% / =

Instructions are flat.

Guards and risks

  • Subagents: composer::a_finished_subagent_leaves_the_active_count_each_time_it_goes_idle
    lists 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.
  • Config copy: the stream perf scenario.
  • Speeds: models::a_speed_switches_the_model_and_shows_beside_its_name
    and the parity checks above.
  • Riskiest change: the prompt's metadata row, now measured, which the
    P-PTY prompt rows exercise. Every P-APP scenario matches with it.
  • Not covered: on a v2.3.2 server, shell and Code Mode jobs have the
    same gap as subagents. A listed job that ends is never removed. They have
    no execution end to hook this fix onto.

Commits:

  • bfe0cc6c8e chore(cli-rs): regenerate the API for v2.4.0
  • eaba060c4d feat(cli-rs): offer a model's service tiers as a speed
  • fd3097a1a3 fix(cli-rs): end a cancelled plugin RPC event subscription at once
  • a48554655b fix(cli-rs): drop finished subagents from the active list
  • 99d269146d fix(cli-rs): measure the test binary, not the first executable
  • f17cac1d0a test(cli-rs): run the perf scenarios with an experimental key
  • 854c4414eb fix(cli-rs): stop copying the config on every frame

Added by the opencode bot (AI-generated).

Public API: adds a speed map to model.json, the speed.cycle/speed.list keybinds and /speed (/fast); cancelled plugin RPC subscriptions end at once (backwards compatible)

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.
@simonklee
simonklee merged commit b51482f into dev Nov 23, 2026
11 checks passed
@simonklee
simonklee deleted the native-fixes branch November 23, 2026 14:25

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json gains a speed map (model key → speed ID), shared with the TypeScript client. Older files without it decode as empty.
  • New keybind names speed.cycle and speed.list (both default none), and the slash command /speed with 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.luau and API types only add fields: model speeds, video generation and the opencode_api flag.

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