Add /rc to manage remote control from the TUI (#62121)

## What changed

Open `/rc` (or `/remote`) to enable or disable remote control for the
managed local background server. The menu checks whether the preference
was saved for the next restart and reports when saving fails. Once remote
control is enabled, **Add device** displays a manual pairing code.

The command can also manage the local server while viewing a cloud
session. Its actions apply only to local sessions.

## Testing

Add tests for menu states, daemon requests and manual pairing, local
daemon selection from a cloud session, and timeout messages.

GitOrigin-RevId: 888abaec3b041d78a6b35a9e76e28cd7dc5305ca
This commit is contained in:
Eric Traut
2026-11-17 22:45:02 +00:00
committed by copyberry
parent 53cd1894aa
commit 5f775c7f4f
17 changed files with 611 additions and 4 deletions
@@ -538,6 +538,9 @@ impl ChatWidget {
self.add_hooks_output();
}
SlashCommand::Daemon => self.app_event_tx.send(AppEvent::OpenDaemonMenu),
SlashCommand::Rc => self.app_event_tx.send(AppEvent::RemoteControl(
crate::app::remote_control::Action::Menu,
)),
SlashCommand::Warnings => self.app_event_tx.send(AppEvent::OpenWarnings),
SlashCommand::Status => {
if self.should_prefetch_rate_limits() {
@@ -803,6 +806,9 @@ impl ChatWidget {
return;
}
match cmd {
SlashCommand::Rc => self.add_error_message(
"Open /rc and choose Disable to turn off remote control.".into(),
),
SlashCommand::Model if !trimmed.is_empty() => {
self.handle_model_command_args(trimmed);
self.app_event_tx.send(AppEvent::SettingsSelectionClosed);
@@ -1324,6 +1330,7 @@ impl ChatWidget {
SlashCommand::Ide
| SlashCommand::Status
| SlashCommand::Daemon
| SlashCommand::Rc
| SlashCommand::Pwd
| SlashCommand::Usage
| SlashCommand::DebugConfig
@@ -2557,6 +2557,17 @@ async fn slash_keymap_debug_can_inspect_app_shortcuts() {
assert!(op_rx.try_recv().is_err(), "expected no core op to be sent");
}
#[tokio::test]
async fn slash_rc_arguments_direct_user_to_menu() {
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
submit_composer_text(&mut chat, "/rc stop");
let [cell]: [_; 1] = drain_insert_history(&mut rx).try_into().expect("one cell");
insta::assert_snapshot!(lines_to_single_string(&cell), @"■ Open /rc and choose Disable to turn off remote control.");
assert!(op_rx.try_recv().is_err(), "expected no agent turn");
}
#[tokio::test]
async fn slash_keymap_invalid_args_show_usage() {
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;