From db88290b9110ba78f484d707ae3e64521db4e622 Mon Sep 17 00:00:00 2001 From: Carlos Umanzor Date: Fri, 6 Feb 2026 13:10:46 -0600 Subject: [PATCH] fix(teams): propagate CLAUDE_CONFIG_DIR to tmux session for agent teammates When CCS launches Claude with CLAUDE_CONFIG_DIR pointing to the isolated instance path, agent team teammates spawned via tmux split-window don't inherit it because tmux creates new panes from its own session environment. This causes teammates to use ~/.claude/ instead of ~/.ccs/instances/{profile}/, creating a split-brain in shared state (tasks, teams, mailbox). Sets key CCS env vars in the tmux session environment via `tmux setenv` so all new panes inherit the correct config directory. --- src/utils/shell-executor.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/utils/shell-executor.ts b/src/utils/shell-executor.ts index e8bb02d9..77135399 100644 --- a/src/utils/shell-executor.ts +++ b/src/utils/shell-executor.ts @@ -4,7 +4,7 @@ * Cross-platform shell execution utilities for CCS. */ -import { spawn, ChildProcess } from 'child_process'; +import { spawn, ChildProcess, execSync } from 'child_process'; import { ErrorManager } from './error-manager'; import { getWebSearchHookEnv } from './websearch-manager'; @@ -82,6 +82,21 @@ export function execClaude( ? { ...baseEnv, ...envVars, ...webSearchEnv } : { ...baseEnv, ...webSearchEnv }; + // propagate key env vars to tmux session so agent team teammates + // (spawned via tmux split-window) inherit the correct config dir + if (process.env.TMUX && envVars) { + const tmuxPropagateVars = ['CLAUDE_CONFIG_DIR', 'CCS_PROFILE_TYPE', 'CCS_WEBSEARCH_SKIP']; + for (const key of tmuxPropagateVars) { + if (envVars[key]) { + try { + execSync(`tmux setenv ${key} ${JSON.stringify(envVars[key])}`, { stdio: 'ignore' }); + } catch { + // tmux setenv can fail if not in a tmux session; safe to ignore + } + } + } + } + let child: ChildProcess; if (needsShell) { // When shell needed: concatenate into string to avoid DEP0190 warning