Repository navigation
feat(cli): add future session set to change an existing session's parent/title/cwd/model/thinking - #773
Merged
Conversation
`future session new` (#771) creates a session; this adds the command that actually changes an existing one: future session set <id> [--parent <id>] [--title <name>] [--cwd <dir>] [--model <id>] [--thinking <level>] [--json] Agent: new `set_parent_session` command — the one setting the wire contract lacked. It updates the live session and persists `parent_session_id` into session_info, because the run-end snapshot re-reads the parent from disk: an in-memory-only change would be reverted by the next run. It rejects a self-parent and a parent that is neither live nor stored (a live session with no entries yet is a valid parent), and is registered in `command_policy`, which is also the dispatcher's command registry. CLI: the options are applied one at a time and reported. A per-field failure (a model the agent refuses, say) does not roll back the others — it prints `Failed to set <field>: …` and exits 1. `--parent` is applied first and aborts the rest, since a typo there makes the rest of the update meaningless. An empty `--parent` detaches in `set` and now means "unset" in `new` too. `session new` and `session set` share one options struct + parser. The session golden-help test and docs/wiki/{en,zh}/CLI.md are updated.
huichen
enabled auto-merge (squash)
September 22, 2026 06:29
huichen
added a commit
that referenced
this pull request
Sep 22, 2026
`future session new` (#771) turned out to be a solution to a problem nobody had: it only created a session (`new_session` + print the id) without running anything, while the actual request was to change an existing one — which is `future session set` (#773). Keeping both meant two commands with overlapping option surfaces and a create path whose result no command consumes (`future run --session <id>` also creates the session it is given). Removed: the `new` subcommand, `SESSION_NEW_HELP`, `RunClient::new_session_with` and `NewSessionOptions` (the plain `new_session(cwd)` used by the run orchestration is untouched, and the session options parser now serves `set` alone). The agent-side `set_parent_session` stays — `session set` needs it. A session can still be created without a token: it just isn't a CLI command, matching how every other client does it (they create on first prompt).
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.
What
future session new(#771) creates a session. This adds the command the original request asked for — changing settings on a session that already exists:Only the options passed are touched; nothing else is changed.
Agent: new
set_parent_sessioncommandParent was the one setting the wire contract had no way to change on an existing session (
fork/new_sessiononly set it at creation). The new command:parent_session_idinto session_info — the run-end snapshot re-reads the parent from disk, so an in-memory-only change would be silently reverted by the next run (this is whyset_cwd/set_session_namepersist too);forksees lineage);parent_session_idcolumn isnullif(…,''), so it reads back as no parent);packages/rpc/src/command_policy.rs— which doubles as the dispatcher's command registry, so without it the command would be rejected asunknown command.No proto change:
parent_session(field 20) and the stringlytypealready exist. No event is emitted — no client renders a live session's parent today (the desktop builds its thread tree from its own store), and the change is durable in the session record.CLI behaviour
get_state), so a bad id reports the CLI's ownSession not found: <id>instead of the agent'snew_session-flavoured "pass a valid session_id" text.--parentis applied first and aborts the rest: a parent is a reference to another session, so a typo there makes the rest of the update meaningless.Failed to set <field>: …, and the command exits 1.--jsonreportsupdated/failedper field.session newandsession setnow share oneSessionOptions+ parser;--parent ""means "unset" innewas well (previously it probed for a session named""and failed withSession not found:).future session --help,future session set --help,help.rsgroup line,docs/wiki/{en,zh}/CLI.md.Honest notes on the two-level semantics
set --title/--parent/--thinking+ one run,session list --jsonshows the new title/parentSessionIdandsession infothe new thinking level.future runapplies its own--cwd(current directory by default) at the start of every run, so a cwd set here holds only until that run — pre-existingrunbehaviour, now documented in the help text.set_modelaccepts an id the registry doesn't know (existing agent behaviour: a model selector click must not fail); such a model fails loudly at the next run instead.Verification
cargo test -p future-agent— 1824 lib + integration tests pass (new: parent persists to disk / detaches, self-parent and unknown-parent rejected, live-without-entries parent accepted).cargo test -p future-cli— 753 lib + 15 integration (new: full option round-trip on the wire, only-given-options-touched,--jsonupdated/failed, parent detach, usage errors, help without an agent, unknown target, bad/self parent aborting the rest, empty--parentinnew).cargo test -p future-rpc— 121 pass.cargo fmt --all --checkclean.future agent --home /tmp/… --grpc-addr 127.0.0.1:49191): every option lands (get_stateshows name/cwd/thinking/parent), errors report as expected (self, unknown parent, unknown target, no options, partial failure).Local
clippy -D warningson this machine reports a pre-existingnonminimal_boolinagent/src/session/compaction_ops.rsandchannels/under Homebrew's clippy 0.1.96 (the known 1.96-vs-1.97 false report; both files are untouched here) — CI runs clippy on the pinned toolchain. One lint on the new handler was real and is fixed.Follow-ups (not in this PR)
--jsonis onsetfor symmetry withnew/list; a futuresession editcould reuse the same parser.session newshould stay is a product call — it is the "create without spending a token" counterpart.