Skip to content

feat(zerocode): add mid-session agent switching (Ctrl+G)#6

Open
JordanTheJet wants to merge 2 commits into
masterfrom
zerocode-switch-agent
Open

feat(zerocode): add mid-session agent switching (Ctrl+G)#6
JordanTheJet wants to merge 2 commits into
masterfrom
zerocode-switch-agent

Conversation

@JordanTheJet

Copy link
Copy Markdown
Owner

Summary

  • Base branch: master
  • What changed and why: In the zerocode TUI the agent was chosen once at session start and could not be changed without quitting and relaunching β€” Ctrl+N restarts the same agent and Ctrl+S only switches between existing sessions, so there was no path back to the agent picker from a live session. This adds a SwitchAgent action (default Ctrl+G) that opens an agent-picker overlay from an active session, mirroring the existing session-switch overlay; Enter starts a fresh session against the chosen agent, Esc returns to the current session untouched.
  • Restart and switch now share start_fresh_session, which commits agent_alias only after the daemon confirms the new session β€” a failed create no longer strands the alias on an agent the live session isn't running.
  • agent_overlay is mirrored into wants_text_input() so global keys (?, Ctrl+R) treat the new picker the same as the session picker regardless of any leftover draft; switching also warns via the info bar when a draft or queued messages are cleared instead of dropping them silently.
  • Scope boundary: Does NOT change the startup agent picker, session switching (Ctrl+S), the Ctrl+N restart semantics, or any daemon/RPC surface. No copy/paste changes (tracked separately).
  • Blast radius: Confined to apps/zerocode (TUI client). The shared restart_session_for_state was refactored to delegate to start_fresh_session; behavior for the existing Ctrl+N restart path is unchanged (it passes the current alias and the same "New session started." notice).
  • Linked issue(s): None β€” addresses a direct user QOL request ("can't change agents easily").
  • Labels: expect auto path/scope labels for apps/zerocode; suggest enhancement, size: S, risk: medium (touches apps/zerocode/src/**).

Validation Evidence (required)

cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo test
  • Commands run and tail output:
    • cargo fmt --all -- --check β†’ clean, no diff (exit 0).
    • cargo clippy --all-targets -- -D warnings β†’ Finished \dev` profile [unoptimized + debuginfo] target(s) in 4m 03s`; no warnings.
    • cargo test β†’ all suites pass (exit 0). The zerocode package: test result: ok. 348 passed; 0 failed; 0 ignored. Full-workspace run green (e.g. system::full_stack ok. 9 passed; 0 failed).
  • Beyond CI β€” what did you manually verify? Traced the new key path end-to-end: input bar does not consume Ctrl+G (control chords return NotHandled, input_bar.rs:1052), so the chat handler opens the overlay; overlay captures keys (nav/Enter/Esc), Enter on the current agent is a no-op, click only moves selection (Enter confirms) so a stray click cannot discard the session. Confirmed start_fresh_session commits agent_alias only on the success branch and the WSS-ACP CWD-picker path carries the new alias without mutating live state. NOT verified: live WSS-ACP remote daemon switch and a real daemon session_new failure (the error-path rollback is covered by reasoning + the alias-on-success structure, not an integration test).
  • If any command was intentionally skipped, why: None skipped.

Security & Privacy Impact (required)

  • New permissions, capabilities, or file system access scope? No
  • New external network calls? No
  • Secrets / tokens / credentials handling changed? No
  • PII, real identities, or personal data in diff, tests, fixtures, or docs? No
  • If any Yes, describe the risk and mitigation: N/A.

Compatibility (required)

  • Backward compatible? Yes
  • Config / env / CLI surface changed? Yes β€” adds a new rebindable keymap action chat.switch_agent (default Ctrl+G) and two new info-bar strings. No migration required; existing configs and keybinding overrides are unaffected, and Ctrl+G was previously unbound.
  • If No or Yes to either: exact upgrade steps for existing users: None β€” the new binding is additive and active by default.

Rollback (required for risk: medium and risk: high)

Low blast radius (single TUI binary). git revert <sha> cleanly removes the action, overlay, and the start_fresh_session refactor (the refactor is behavior-preserving for the existing restart path, so reverting restores the prior inline restart_session_for_state).

* ci(clawpatch): review every PR with zeroclaw as the brain

Adds a GitHub Actions workflow that, on each PR, installs the prebuilt zeroclaw
binary + acpx, points acpx at `zeroclaw acp` (stdio ACP), and runs `clawpatch ci`
with provider=acpx so changed code is reviewed by ZeroClaw's own coding agent
(Claude-backed). Non-blocking; findings post to the job summary + an artifact.
Requires the ANTHROPIC_OAUTH_TOKEN repo secret.

* ci: daily auto-sync fork master with upstream zeroclaw-labs/zeroclaw
The agent was chosen once at session start; the only way to change it was
to quit and relaunch. Ctrl+N restarts with the same agent and Ctrl+S only
switches between existing sessions, so there was no path back to the agent
picker from a live session.

Add a SwitchAgent action (Ctrl+G) that opens an agent-picker overlay from
an active session, mirroring the existing session-switch overlay. Enter
starts a fresh session against the chosen agent; Esc returns to the current
session untouched; re-picking the current agent is a no-op so a stray
confirm never discards the live session. A click only moves the selection
(Enter confirms) for the same reason.

Details:
- restart/switch share start_fresh_session, which commits agent_alias only
  after the daemon confirms the new session β€” a failed create no longer
  strands the alias on an agent the live session isn't running.
- agent_overlay is mirrored into wants_text_input() so global keys (?,
  Ctrl+R) treat the picker the same as the session picker regardless of any
  leftover draft.
- Switching warns via the info bar when a draft or queued messages are
  cleared, instead of dropping them silently.

The agent list is a transient on-demand snapshot of agents_status β€” the
live agent of record remains ChatState::agent_alias; nothing is cached.
@JordanTheJet JordanTheJet added the enhancement New feature or request label Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant