diff --git a/src/apps/cli/src/modes/chat/session_lineage.rs b/src/apps/cli/src/modes/chat/session_lineage.rs index 1ae48da598..05f3868d29 100644 --- a/src/apps/cli/src/modes/chat/session_lineage.rs +++ b/src/apps/cli/src/modes/chat/session_lineage.rs @@ -1239,6 +1239,7 @@ mod session_lineage_tests { user_input: "continue".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }, ); assert_eq!( @@ -1290,6 +1291,7 @@ mod session_lineage_tests { user_input: "continue".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }, AgenticEvent::TextChunk { session_id: "first".to_string(), @@ -1525,6 +1527,7 @@ mod session_lineage_tests { user_input: "question".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }, false, ); diff --git a/src/crates/assembly/core/src/agentic/coordination/coordinator.rs b/src/crates/assembly/core/src/agentic/coordination/coordinator.rs index 3fea02cadf..80b3d4a5fa 100644 --- a/src/crates/assembly/core/src/agentic/coordination/coordinator.rs +++ b/src/crates/assembly/core/src/agentic/coordination/coordinator.rs @@ -4657,6 +4657,9 @@ Update the persona files and delete BOOTSTRAP.md as soon as bootstrap is complet user_input: prompt.clone(), original_user_input: (display_input != prompt).then_some(display_input), user_message_metadata: Some(user_message_metadata.clone()), + session_workspace: self + .session_manager + .get_session_workspace_facts(&session_id), }) .await; self.emit_event(AgenticEvent::ModelRoundStarted { @@ -6178,6 +6181,9 @@ Update the persona files and delete BOOTSTRAP.md as soon as bootstrap is complet user_input: MANUAL_COMPACTION_COMMAND.to_string(), original_user_input: None, user_message_metadata: user_message_metadata.clone(), + session_workspace: self + .session_manager + .get_session_workspace_facts(&session_id), }) .await; @@ -7414,6 +7420,9 @@ Update the persona files and delete BOOTSTRAP.md as soon as bootstrap is complet None }, user_message_metadata: user_message_metadata.clone(), + session_workspace: self + .session_manager + .get_session_workspace_facts(&session_id), }) .await; @@ -11252,6 +11261,9 @@ Update the persona files and delete BOOTSTRAP.md as soon as bootstrap is complet user_input: user_input_text.clone(), original_user_input: None, user_message_metadata: None, + session_workspace: self + .session_manager + .get_session_workspace_facts(&session_id), }) .await; } @@ -16005,6 +16017,9 @@ impl openbitfun_runtime_ports::AgentUserShellCommandPort for ConversationCoordin user_input: format!("!{}", request.command), original_user_input: None, user_message_metadata: None, + session_workspace: self + .session_manager + .get_session_workspace_facts(&request.session_id), }; let session_manager = Arc::clone(&self.session_manager); @@ -21706,10 +21721,27 @@ pub(crate) mod tests { .expect("load turns"); let turn = turns.last().expect("shell turn"); let events = coordinator.event_queue.dequeue_batch(100).await; - assert!(events.iter().any(|envelope| matches!( - &envelope.event, - AgenticEvent::DialogTurnStarted { turn_id, .. } if turn_id == "turn-shell" - ))); + let started_workspace = events + .iter() + .find_map(|envelope| match &envelope.event { + AgenticEvent::DialogTurnStarted { + turn_id, + session_workspace, + .. + } if turn_id == "turn-shell" => Some(session_workspace.clone()), + _ => None, + }) + .expect("shell turn started event"); + let announced_path = started_workspace + .and_then(|binding| binding.workspace_path) + .expect("turn-started event carries the session workspace"); + assert_eq!( + Some(announced_path), + session_manager + .get_session(&session.session_id) + .and_then(|session| session.config.workspace_path), + "turn-started event must announce the session's own workspace binding", + ); assert!(!events.iter().any(|envelope| matches!( &envelope.event, AgenticEvent::DialogTurnFailed { turn_id, .. } if turn_id == "turn-shell" diff --git a/src/crates/assembly/core/src/agentic/session/session_manager.rs b/src/crates/assembly/core/src/agentic/session/session_manager.rs index e119ecac0c..9555a4a7d8 100644 --- a/src/crates/assembly/core/src/agentic/session/session_manager.rs +++ b/src/crates/assembly/core/src/agentic/session/session_manager.rs @@ -2971,6 +2971,25 @@ impl SessionManager { .map(|session| session.state.clone()) } + /// Workspace binding announced on turn events; reads only config fields. + pub fn get_session_workspace_facts( + &self, + session_id: &str, + ) -> Option { + self.sessions.get(session_id).map(|session| { + let config = &session.config; + openbitfun_events::SessionWorkspaceFacts { + workspace_path: config.workspace_path.clone(), + project_workspace_path: config.project_workspace_path.clone(), + execution_target: config.execution_target.clone(), + workspace_id: config.workspace_id.clone(), + project_workspace_id: config.project_workspace_id.clone(), + remote_connection_id: config.remote_connection_id.clone(), + remote_ssh_host: config.remote_ssh_host.clone(), + } + }) + } + pub async fn cached_system_prompt( &self, session_id: &str, diff --git a/src/crates/contracts/events/src/agentic.rs b/src/crates/contracts/events/src/agentic.rs index eb4488bc0b..6b39e29019 100644 --- a/src/crates/contracts/events/src/agentic.rs +++ b/src/crates/contracts/events/src/agentic.rs @@ -94,6 +94,29 @@ pub struct DeepReviewQueueState { pub session_concurrency_high: bool, } +/// Workspace binding of the session a turn event belongs to. +/// +/// A consumer that has not loaded the session yet (for example, a scheduled +/// job running in a workspace the UI has not opened) places the session from +/// these facts instead of guessing from its own foreground workspace. +#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)] +pub struct SessionWorkspaceFacts { + #[serde(default, skip_serializing_if = "Option::is_none")] + pub workspace_path: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub project_workspace_path: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub execution_target: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub workspace_id: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub project_workspace_id: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub remote_connection_id: Option, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub remote_ssh_host: Option, +} + #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(tag = "type")] pub enum AgenticEvent { @@ -182,6 +205,10 @@ pub enum AgenticEvent { original_user_input: Option, /// Image metadata JSON for UI rendering (id, name, data_url, mime_type, image_path) user_message_metadata: Option, + /// Workspace the session is bound to. Absent in events written by + /// older hosts and in emitters that do not know the binding. + #[serde(default, skip_serializing_if = "Option::is_none")] + session_workspace: Option, }, /// Low-frequency linking event that associates a hidden subagent session diff --git a/src/crates/contracts/events/src/frontend_projection.rs b/src/crates/contracts/events/src/frontend_projection.rs index d9ad0c6442..6564f7eb1a 100644 --- a/src/crates/contracts/events/src/frontend_projection.rs +++ b/src/crates/contracts/events/src/frontend_projection.rs @@ -85,17 +85,53 @@ pub fn project_agentic_frontend_event(event: AgenticEvent) -> Option Some(AgenticFrontendEvent::new( - "agentic://dialog-turn-started", - json!({ + session_workspace, + } => { + let mut payload = json!({ "sessionId": session_id, "turnId": turn_id, "turnIndex": turn_index, "userInput": user_input, "originalUserInput": original_user_input, "userMessageMetadata": user_message_metadata, - }), - )), + }); + if let (Some(workspace), Some(fields)) = (session_workspace, payload.as_object_mut()) { + // Same flat keys as `agentic://session-created`, so the UI can + // place a session it has not loaded with one resolver. + let entries = [ + ("workspacePath", workspace.workspace_path.map(Value::from)), + ( + "projectWorkspacePath", + workspace.project_workspace_path.map(Value::from), + ), + ( + "executionTarget", + workspace + .execution_target + .and_then(|target| serde_json::to_value(target).ok()), + ), + ("workspaceId", workspace.workspace_id.map(Value::from)), + ( + "projectWorkspaceId", + workspace.project_workspace_id.map(Value::from), + ), + ( + "remoteConnectionId", + workspace.remote_connection_id.map(Value::from), + ), + ("remoteSshHost", workspace.remote_ssh_host.map(Value::from)), + ]; + for (key, value) in entries { + if let Some(value) = value { + fields.insert(key.to_string(), value); + } + } + } + Some(AgenticFrontendEvent::new( + "agentic://dialog-turn-started", + payload, + )) + } AgenticEvent::SubagentSessionLinked { session_id, subagent_dialog_turn_id, @@ -546,7 +582,7 @@ mod tests { use super::*; use crate::{ DeepReviewQueueReason, DeepReviewQueueState, DeepReviewQueueStatus, - ModelRoundAttemptDiagnostic, + ModelRoundAttemptDiagnostic, SessionWorkspaceFacts, }; use openbitfun_core_types::{ ReasoningContentKind, SessionExecutionTarget, SessionExecutionTargetKind, WorktreeLifecycle, @@ -607,6 +643,73 @@ mod tests { assert_eq!(projected.payload["workspaceId"], "workspace-wt-1"); } + #[test] + fn dialog_turn_started_projects_session_workspace_binding() { + let projected = project_agentic_frontend_event(AgenticEvent::DialogTurnStarted { + session_id: "session-1".to_string(), + turn_id: "turn-1".to_string(), + turn_index: 3, + user_input: "check".to_string(), + original_user_input: None, + user_message_metadata: None, + session_workspace: Some(SessionWorkspaceFacts { + workspace_path: Some("/assistants/pdf".to_string()), + project_workspace_path: Some("/assistants/pdf".to_string()), + execution_target: Some(SessionExecutionTarget { + kind: SessionExecutionTargetKind::Local, + worktree_id: None, + root_path: "/assistants/pdf".to_string(), + base_ref: None, + base_commit: None, + branch: None, + lifecycle: None, + }), + workspace_id: Some("workspace-pdf".to_string()), + project_workspace_id: Some("workspace-pdf".to_string()), + remote_connection_id: None, + remote_ssh_host: None, + }), + }) + .expect("projected"); + + assert_eq!(projected.event_name, "agentic://dialog-turn-started"); + assert_eq!(projected.payload["workspacePath"], "/assistants/pdf"); + assert_eq!(projected.payload["projectWorkspacePath"], "/assistants/pdf"); + assert_eq!(projected.payload["workspaceId"], "workspace-pdf"); + assert_eq!(projected.payload["projectWorkspaceId"], "workspace-pdf"); + assert_eq!( + projected.payload["executionTarget"]["rootPath"], + "/assistants/pdf" + ); + assert!(projected.payload.get("remoteConnectionId").is_none()); + } + + #[test] + fn legacy_dialog_turn_started_without_workspace_still_round_trips() { + let legacy = serde_json::json!({ + "type": "DialogTurnStarted", + "session_id": "session-1", + "turn_id": "turn-1", + "turn_index": 0, + "user_input": "hello", + "original_user_input": null, + "user_message_metadata": null, + }); + let event: AgenticEvent = serde_json::from_value(legacy.clone()).expect("legacy event"); + let AgenticEvent::DialogTurnStarted { + session_workspace, .. + } = &event + else { + panic!("expected DialogTurnStarted"); + }; + assert!(session_workspace.is_none()); + assert_eq!(serde_json::to_value(&event).expect("serialize"), legacy); + + let projected = project_agentic_frontend_event(event).expect("projected"); + assert!(projected.payload.get("workspaceId").is_none()); + assert!(projected.payload.get("workspacePath").is_none()); + } + #[test] fn thinking_chunk_projects_to_text_chunk_event() { let projected = project_agentic_frontend_event(AgenticEvent::ThinkingChunk { diff --git a/src/crates/contracts/events/src/lib.rs b/src/crates/contracts/events/src/lib.rs index b6b2ca13ee..22449829a9 100644 --- a/src/crates/contracts/events/src/lib.rs +++ b/src/crates/contracts/events/src/lib.rs @@ -15,7 +15,8 @@ pub mod types; pub use agentic::{ AgenticEvent, AgenticEventEnvelope, AgenticEventPriority, DeepReviewQueueReason, DeepReviewQueueState, DeepReviewQueueStatus, ModelRoundAttemptDiagnostic, - ModelRoundAttemptToolDiagnostic, SubagentParentInfo, ToolEventData, ToolEventIdentity, + ModelRoundAttemptToolDiagnostic, SessionWorkspaceFacts, SubagentParentInfo, ToolEventData, + ToolEventIdentity, }; pub use backend::{ BackgroundCommandLifecycleInfo, ToolExecutionCompletedInfo, ToolExecutionErrorInfo, diff --git a/src/crates/execution/agent-runtime/src/session_event_journal.rs b/src/crates/execution/agent-runtime/src/session_event_journal.rs index 1ea6264bad..d8ecf7acc3 100644 --- a/src/crates/execution/agent-runtime/src/session_event_journal.rs +++ b/src/crates/execution/agent-runtime/src/session_event_journal.rs @@ -733,6 +733,7 @@ mod tests { user_input: "prompt".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, } } diff --git a/src/crates/services/services-integrations/src/remote_connect.rs b/src/crates/services/services-integrations/src/remote_connect.rs index 374fe0a517..92814eb2c7 100644 --- a/src/crates/services/services-integrations/src/remote_connect.rs +++ b/src/crates/services/services-integrations/src/remote_connect.rs @@ -6281,6 +6281,7 @@ mod tests { user_input: "hidden".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.mark_persistence_clean(); let previous_version = tracker.version(); @@ -6371,6 +6372,7 @@ mod tests { user_input: "hello".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.handle_agentic_event(&AgenticEvent::DialogTurnCompleted { session_id: "session-a".to_string(), @@ -6439,6 +6441,7 @@ mod tests { user_input: "hello".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.handle_agentic_event(&AgenticEvent::DialogTurnCompleted { session_id: "session-a".to_string(), @@ -6529,6 +6532,7 @@ mod tests { user_input: "hello".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.handle_agentic_event(&AgenticEvent::DialogTurnFailed { session_id: "session-a".to_string(), @@ -6558,6 +6562,7 @@ mod tests { user_input: "queued follow-up".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.handle_agentic_event(&AgenticEvent::TextChunk { session_id: "session-a".to_string(), diff --git a/src/crates/services/services-integrations/tests/remote_connect_contracts.rs b/src/crates/services/services-integrations/tests/remote_connect_contracts.rs index 52ba3d88f0..259ea3adc8 100644 --- a/src/crates/services/services-integrations/tests/remote_connect_contracts.rs +++ b/src/crates/services/services-integrations/tests/remote_connect_contracts.rs @@ -3302,6 +3302,7 @@ fn remote_connect_tracker_preserves_streaming_snapshot_contract() { user_input: "hello".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.handle_agentic_event(&AgenticEvent::ModelRoundStarted { session_id: "session-1".to_string(), @@ -3360,6 +3361,7 @@ fn remote_connect_tracker_keeps_steering_between_assistant_text_segments() { user_input: "hello".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.handle_agentic_event(&AgenticEvent::TextChunk { session_id: "session-1".to_string(), @@ -3446,6 +3448,7 @@ async fn remote_connect_tracker_broadcasts_tool_and_turn_events() { user_input: "hello".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.handle_agentic_event(&AgenticEvent::ToolEvent { session_id: "session-1".to_string(), @@ -3500,6 +3503,7 @@ fn remote_connect_tracker_keeps_finished_turn_snapshot_until_persistence_finaliz user_input: "hello".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.handle_agentic_event(&AgenticEvent::TextChunk { session_id: "session-1".to_string(), @@ -3646,6 +3650,7 @@ fn remote_connect_poll_helpers_preserve_delta_and_completion_policy() { user_input: "hello".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.handle_agentic_event(&AgenticEvent::TextChunk { session_id: "session-1".to_string(), @@ -3741,6 +3746,7 @@ fn remote_connect_tracker_ignores_unrelated_direct_session_events() { user_input: "hello".to_string(), original_user_input: None, user_message_metadata: None, + session_workspace: None, }); tracker.handle_agentic_event(&AgenticEvent::TextChunk { session_id: "session-2".to_string(), diff --git a/src/web-ui/src/flow_chat/services/flow-chat-manager/EventHandlerModule.test.ts b/src/web-ui/src/flow_chat/services/flow-chat-manager/EventHandlerModule.test.ts index 02d159db2a..c1a25bf122 100644 --- a/src/web-ui/src/flow_chat/services/flow-chat-manager/EventHandlerModule.test.ts +++ b/src/web-ui/src/flow_chat/services/flow-chat-manager/EventHandlerModule.test.ts @@ -113,6 +113,51 @@ describe('external BTW turn projection', () => { }); }); +describe('background turn in a workspace this surface has not loaded', () => { + beforeEach(() => { resetFlowChatStore(); stateMachineManager.clear(); }); + afterEach(() => { resetFlowChatStore(); stateMachineManager.clear(); }); + + function foregroundContext(): FlowChatContext { + return { + ...createFlowChatContext(), + currentWorkspaceId: 'workspace-secretary', + currentWorkspacePath: '/assistants/secretary', + } as FlowChatContext; + } + + it('places the session in the workspace the host announces, not the foreground one', () => { + __test_only__.handleDialogTurnStarted(foregroundContext(), { + sessionId: 'scheduled-session', turnId: 'cronjob_1', turnIndex: 7, userInput: 'check', + workspaceId: 'workspace-pdf', + workspacePath: '/assistants/pdf', + projectWorkspacePath: '/assistants/pdf', + projectWorkspaceId: 'workspace-pdf', + executionTarget: { kind: 'local', rootPath: '/assistants/pdf' }, + userMessageMetadata: { backgroundDelivery: { source: 'scheduled_job' } }, + }); + + const session = FlowChatStore.getInstance().getState().sessions.get('scheduled-session'); + expect(session).toMatchObject({ + workspaceId: 'workspace-pdf', + workspacePath: '/assistants/pdf', + projectWorkspacePath: '/assistants/pdf', + projectWorkspaceId: 'workspace-pdf', + }); + expect(session?.config.executionTarget).toMatchObject({ rootPath: '/assistants/pdf' }); + }); + + it('keeps the legacy foreground fallback for events from hosts that omit the binding', () => { + __test_only__.handleDialogTurnStarted(foregroundContext(), { + sessionId: 'legacy-session', turnId: 'turn-1', turnIndex: 0, userInput: 'hello', + }); + + expect(FlowChatStore.getInstance().getState().sessions.get('legacy-session')).toMatchObject({ + workspaceId: 'workspace-secretary', + workspacePath: '/assistants/secretary', + }); + }); +}); + describe('Claw bootstrap cancellation', () => { beforeEach(() => { resetFlowChatStore(); diff --git a/src/web-ui/src/flow_chat/services/flow-chat-manager/EventHandlerModule.ts b/src/web-ui/src/flow_chat/services/flow-chat-manager/EventHandlerModule.ts index 34ea27aa73..9875e20ed8 100644 --- a/src/web-ui/src/flow_chat/services/flow-chat-manager/EventHandlerModule.ts +++ b/src/web-ui/src/flow_chat/services/flow-chat-manager/EventHandlerModule.ts @@ -1048,17 +1048,7 @@ function handleSessionCreated(context: FlowChatContext, event: any): void { const store = FlowChatStore.getInstance(); const existing = store.getState().sessions.get(sessionId); - const { workspaceId, workspacePath } = resolveExternalSessionWorkspace(context, event); - const projectWorkspacePath = - (typeof event.projectWorkspacePath === 'string' && event.projectWorkspacePath) - || (typeof event.project_workspace_path === 'string' && event.project_workspace_path) - || workspacePath; - const executionTarget = - event.executionTarget && typeof event.executionTarget === 'object' - ? event.executionTarget - : event.execution_target && typeof event.execution_target === 'object' - ? event.execution_target - : undefined; + const binding = resolveExternalSessionBinding(context, event); const remoteConnectionId = extractEventRemoteConnectionId(event); const remoteSshHost = extractEventRemoteSshHost(event); @@ -1068,11 +1058,12 @@ function handleSessionCreated(context: FlowChatContext, event: any): void { sessionId, sessionName || 'Remote Session', agentType || 'Standard', - workspacePath, + binding.workspacePath, { - projectWorkspacePath, - executionTarget, - workspaceId, + projectWorkspacePath: binding.projectWorkspacePath, + projectWorkspaceId: binding.projectWorkspaceId, + executionTarget: binding.executionTarget, + workspaceId: binding.workspaceId, }, remoteConnectionId, remoteSshHost @@ -1096,9 +1087,10 @@ interface ExternalSessionWorkspace { * through the compatibility resolver. A path that names no opened record * is kept as an IO projection only; it never silently becomes the current * workspace. - * 3. No workspace facts at all: the event belongs to the workspace this - * manager is initialized for (the host only forwards events for the - * workspaces this surface subscribed to). + * 3. No workspace facts at all: legacy fallback to the workspace this + * manager is initialized for. Current hosts announce the binding on both + * `session-created` and `dialog-turn-started`, because a scheduled or + * delegated turn can start in a workspace this surface has not loaded. */ function resolveExternalSessionWorkspace( context: FlowChatContext, @@ -1139,6 +1131,33 @@ function resolveExternalSessionWorkspace( }; } +interface ExternalSessionBinding extends ExternalSessionWorkspace { + projectWorkspacePath?: string; + projectWorkspaceId?: string; + executionTarget?: Session['config']['executionTarget']; +} + +/** Workspace attribution plus the project/execution facts an event carries. */ +function resolveExternalSessionBinding( + context: FlowChatContext, + event?: Record | null, +): ExternalSessionBinding { + const workspace = resolveExternalSessionWorkspace(context, event); + const projectWorkspacePath = + (typeof event?.projectWorkspacePath === 'string' && event.projectWorkspacePath) + || (typeof event?.project_workspace_path === 'string' && event.project_workspace_path) + || workspace.workspacePath; + const projectWorkspaceId = + (typeof event?.projectWorkspaceId === 'string' && event.projectWorkspaceId.trim()) + || (typeof event?.project_workspace_id === 'string' && event.project_workspace_id.trim()) + || undefined; + const rawExecutionTarget = event?.executionTarget ?? event?.execution_target; + const executionTarget = rawExecutionTarget && typeof rawExecutionTarget === 'object' + ? rawExecutionTarget as Session['config']['executionTarget'] + : undefined; + return { ...workspace, projectWorkspacePath, projectWorkspaceId, executionTarget }; +} + function extractEventRemoteConnectionId(event?: Record | null): string | undefined { if (!event) return undefined; const id = @@ -1913,18 +1932,24 @@ function handleDialogTurnStarted(context: FlowChatContext, event: any): void { ? userMessageMetadata.appId : undefined; log.warn('DialogTurnStarted: session not in store, creating placeholder', { sessionId, sessionsCount: state.sessions.size, isMiniAppAgentRun }); - const workspace = resolveExternalSessionWorkspace(context, event); + const workspace = resolveExternalSessionBinding(context, event); + const binding = { + workspaceId: workspace.workspaceId, + projectWorkspacePath: workspace.projectWorkspacePath, + projectWorkspaceId: workspace.projectWorkspaceId, + executionTarget: workspace.executionTarget, + }; store.addExternalSession( sessionId, isMiniAppAgentRun ? (miniAppId ? `MiniApp: ${miniAppId}` : 'MiniApp Agent') : isBtwRun ? 'Side thread' : 'Remote Session', 'Standard', workspace.workspacePath, isMiniAppAgentRun - ? { sessionKind: 'miniapp', isTransient: true, agentBackedTransient: true, workspaceId: workspace.workspaceId } + ? { sessionKind: 'miniapp', isTransient: true, agentBackedTransient: true, ...binding } : isBtwRun ? { sessionKind: 'btw', isTransient: true, agentBackedTransient: true, - parentSessionId: userMessageMetadata.parentSessionId, workspaceId: workspace.workspaceId } - : { workspaceId: workspace.workspaceId }, + parentSessionId: userMessageMetadata.parentSessionId, ...binding } + : binding, extractEventRemoteConnectionId(event), extractEventRemoteSshHost(event) );