Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src-tauri/src/acp/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ use crate::acp::file_system_runtime::{FileSystemRuntime, FileSystemRuntimeError,
use crate::acp::registry::{self, AgentDistribution};
use crate::acp::session_state::SessionState;
use crate::acp::stderr_tail::{summarize_parser_error, StderrTail, TailScope};
use crate::acp::terminal_runtime::{TerminalRuntime, TerminalRuntimeError};
use crate::acp::terminal_runtime::{
TerminalRuntime, TerminalRuntimeError, TerminalShellRuntimeConfig,
};
use crate::acp::types::{
AcpEvent, AvailableCommandInfo, ConnectionInfo, ConnectionStatus, GrokModelSpec,
PermissionOptionInfo, PlanEntryInfo, PromptCapabilitiesInfo, PromptInputBlock,
Expand Down Expand Up @@ -1154,6 +1156,7 @@ pub async fn spawn_agent_connection(
preferred_mode_id: Option<String>,
preferred_config_values: BTreeMap<String, String>,
delegation_injection: Option<DelegationInjection>,
terminal_shell_config: TerminalShellRuntimeConfig,
) -> Result<tokio::sync::oneshot::Receiver<()>, AcpError> {
// Create the authoritative session state up front. Subsequent emit_with_state
// calls write through this state and increment its seq counter so the first
Expand Down Expand Up @@ -1317,6 +1320,7 @@ pub async fn spawn_agent_connection(
emitter_clone.clone(),
Arc::clone(&state_clone),
terminal_base_env,
terminal_shell_config,
preferred_mode_id,
preferred_config_values,
delegation_injection,
Expand Down Expand Up @@ -3282,6 +3286,7 @@ async fn run_connection(
emitter: EventEmitter,
state: Arc<RwLock<SessionState>>,
terminal_base_env: BTreeMap<String, String>,
terminal_shell_config: TerminalShellRuntimeConfig,
preferred_mode_id: Option<String>,
preferred_config_values: BTreeMap<String, String>,
delegation_injection: Option<DelegationInjection>,
Expand All @@ -3300,7 +3305,9 @@ async fn run_connection(
// `terminal/create` without a `cwd` (e.g. CodeBuddy) runs in the folder the
// conversation runs in rather than codeg's own process cwd.
let terminal_runtime = Arc::new(
TerminalRuntime::with_base_env(terminal_base_env).with_default_cwd(Some(cwd.clone())),
TerminalRuntime::with_base_env(terminal_base_env)
.with_default_cwd(Some(cwd.clone()))
.with_default_shell_config(terminal_shell_config),
);
let cwd_string = cwd.to_string_lossy().to_string();
tracing::info!("[ACP] fs policy {}", fs_policy.describe());
Expand Down
16 changes: 16 additions & 0 deletions src-tauri/src/acp/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::acp::question::{
build_outcome, QuestionAnswer, QuestionOutcome, QuestionSpec, RegisteredQuestion,
SessionQuestionAccess,
};
use crate::acp::terminal_runtime::TerminalShellRuntimeConfig;
use crate::acp::types::{
AcpEvent, AgentOptionsSnapshot, ConfigStaleKind, ConnectionInfo, ConnectionStatus,
ForkResultInfo, PromptCapabilitiesInfo, PromptInputBlock,
Expand Down Expand Up @@ -201,6 +202,10 @@ pub struct ConnectionManager {
/// tests; in production initialized from env via
/// `spawn_handshake_timeout_from_env`.
spawn_handshake_timeout: Duration,
/// Shared General Settings shell used by ACP terminal fallbacks. Cloned
/// into each connection runtime so a setting update applies to existing
/// model sessions as well as newly spawned ones.
terminal_shell_config: TerminalShellRuntimeConfig,
/// Delegation broker + token registry + UDS path installed during app
/// bootstrap (`install_delegation`). When present, `spawn_agent` propagates
/// the injection to `spawn_agent_connection`, which makes
Expand Down Expand Up @@ -262,6 +267,7 @@ impl ConnectionManager {
connections: Arc::new(Mutex::new(HashMap::new())),
spawn_locks: Arc::new(Mutex::new(HashMap::new())),
spawn_handshake_timeout: spawn_handshake_timeout_from_env(),
terminal_shell_config: TerminalShellRuntimeConfig::new(),
delegation_injection: Arc::new(std::sync::OnceLock::new()),
probe_locks: Arc::new(Mutex::new(HashMap::new())),
pending_questions: Arc::new(Mutex::new(HashMap::new())),
Expand All @@ -275,6 +281,7 @@ impl ConnectionManager {
connections: self.connections.clone(),
spawn_locks: self.spawn_locks.clone(),
spawn_handshake_timeout: self.spawn_handshake_timeout,
terminal_shell_config: self.terminal_shell_config.clone(),
delegation_injection: self.delegation_injection.clone(),
probe_locks: self.probe_locks.clone(),
pending_questions: self.pending_questions.clone(),
Expand All @@ -293,6 +300,13 @@ impl ConnectionManager {
self.delegation_injection.get().cloned()
}

/// Returns the shared terminal-shell setting consumed by ACP terminal
/// runtimes. Keeping the handle shared makes saves apply immediately to
/// connections that are already running.
pub fn terminal_shell_config(&self) -> TerminalShellRuntimeConfig {
self.terminal_shell_config.clone()
}

/// Test-only constructor that overrides the spawn-handshake timeout.
/// Production code should use `new()`.
#[cfg(test)]
Expand All @@ -301,6 +315,7 @@ impl ConnectionManager {
connections: Arc::new(Mutex::new(HashMap::new())),
spawn_locks: Arc::new(Mutex::new(HashMap::new())),
spawn_handshake_timeout: timeout,
terminal_shell_config: TerminalShellRuntimeConfig::new(),
delegation_injection: Arc::new(std::sync::OnceLock::new()),
probe_locks: Arc::new(Mutex::new(HashMap::new())),
pending_questions: Arc::new(Mutex::new(HashMap::new())),
Expand Down Expand Up @@ -478,6 +493,7 @@ impl ConnectionManager {
preferred_mode_id,
preferred_config_values,
self.delegation_snapshot(),
self.terminal_shell_config.clone(),
)
.await?;

Expand Down
Loading
Loading