feat(config): synchronize terminal settings with environment variables

- Added functionality to keep the .env file in sync with terminal configuration settings in config.yaml, ensuring terminal_tool can directly access necessary environment variables.
- Updated setup wizard to save selected backend and associated Docker image to .env for improved consistency and usability.
This commit is contained in:
teknium1 2026-02-26 20:02:46 -08:00
parent 7c1f90045e
commit 0a231c0783
2 changed files with 21 additions and 0 deletions

View file

@ -815,6 +815,19 @@ def set_config_value(key: str, value: str):
with open(config_path, 'w') as f:
yaml.dump(user_config, f, default_flow_style=False, sort_keys=False)
# Keep .env in sync for keys that terminal_tool reads directly from env vars.
# config.yaml is authoritative, but terminal_tool only reads TERMINAL_ENV etc.
_config_to_env_sync = {
"terminal.backend": "TERMINAL_ENV",
"terminal.docker_image": "TERMINAL_DOCKER_IMAGE",
"terminal.singularity_image": "TERMINAL_SINGULARITY_IMAGE",
"terminal.modal_image": "TERMINAL_MODAL_IMAGE",
"terminal.cwd": "TERMINAL_CWD",
"terminal.timeout": "TERMINAL_TIMEOUT",
}
if key in _config_to_env_sync:
save_env_value(_config_to_env_sync[key], str(value))
print(f"✓ Set {key} = {value} in {config_path}")

View file

@ -1015,6 +1015,14 @@ def run_setup_wizard(args):
print_success("Terminal set to SSH")
# else: Keep current (selected_backend is None)
# Sync terminal backend to .env so terminal_tool picks it up directly.
# config.yaml is the source of truth, but terminal_tool reads TERMINAL_ENV.
if selected_backend:
save_env_value("TERMINAL_ENV", selected_backend)
docker_image = config.get('terminal', {}).get('docker_image')
if docker_image:
save_env_value("TERMINAL_DOCKER_IMAGE", docker_image)
# =========================================================================
# Step 5: Agent Settings
# =========================================================================