feat: add per-workspace environment variables with terminal/agent injection#167
Merged
DeadWaveWave merged 6 commits intoDeadWaveWave:mainfrom Apr 15, 2026
Conversation
9c47b74 to
708f4e7
Compare
Owner
|
感谢这个 PR!整体思路很棒:把 workspace 级 environmentVariables 持久化,并透传到 pty.spawn / agent.launch,IPC 也做了 normalize(trim / string-only / 100-entry cap)。 我这边看下来有几个点建议尽快修一下,避免出现“workspace 潜在毛病/隐性抖动/变量丢失”:
另外:CI 现在有一个 check 没过,也麻烦一并修一下再继续 review/merge。 |
Add an "Environment Variables" section to each project's settings page, placed below the Workspace Worktree section. Users can configure key-value environment variable pairs that will be injected into terminals and agents launched within the workspace. - Two-column UI (Key + Value) with Add/Remove controls - Data persisted as JSON in SQLite with safe migration - Full i18n support (English + Chinese) - Consistent styling with existing settings panel components Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Thread per-workspace environment variables from settings UI through IPC to the PTY and agent spawn paths, so variables configured in Settings > Projects > Environment Variables are actually applied to every terminal and agent launched within that workspace. - Add env field to SpawnTerminalInput and LaunchAgentInput DTOs - Validate and normalize env in IPC handlers (100-entry cap, string-only) - Merge workspace env into process.env in TerminalProfileResolver and agent launch handler (internal session vars take precedence) - Thread environmentVariables through all renderer callsites: terminal creation, keyboard shortcuts, context menu, agent launcher, agent node lifecycle, and task agent actions - Add environmentVariables to workerSync merge module - Install missing ws dependency required by controlSurface from main Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…r sync, guardrails - Extract normalizeEnvPayload to shared ipc/normalize.ts (was duplicated in terminal and agent validate files) - Add env key regex, key/value length limits, and OPENCOVE_* prefix filter - Include environmentVariables in worker sync merge with deep-equal reuse and equality check to prevent env loss and refresh jitter - Fix oxlint curly violations (braceless if statements) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
708f4e7 to
2bf3e0a
Compare
# Conflicts: # src/contexts/workspace/presentation/renderer/components/workspaceCanvas/hooks/useAgentLauncher.ts # src/contexts/workspace/presentation/renderer/components/workspaceCanvas/hooks/useAgentNodeLifecycle.ts # src/contexts/workspace/presentation/renderer/components/workspaceCanvas/hooks/useCanvasAgentSupport.ts # src/contexts/workspace/presentation/renderer/components/workspaceCanvas/hooks/useInteractions.paneNodeCreation.ts # src/contexts/workspace/presentation/renderer/components/workspaceCanvas/hooks/useTaskActions.agentSession.resume.ts # src/contexts/workspace/presentation/renderer/components/workspaceCanvas/hooks/useTaskActions.agentSession.run.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
environment_variables_json) with safe migrationChanges
Storage & UI (commit 1)
environmentVariables?: Record<string, string>onWorkspaceState/PersistedWorkspaceStateWorkspaceSectionwith env var list, key/value inputs, add/remove actionsAppShell→SettingsPanel→WorkspaceSectionInjection (commit 2)
env?: Record<string, string>toSpawnTerminalInputandLaunchAgentInputnormalizeEnvPayload()with 100-entry cap, string-only values, trimmed keysTerminalProfileResolver.resolveTerminalSpawn()mergesinput.envintoprocess.env;spawnSessionfallback path also mergessessionEnv(internal vars like opencode server hostname take precedence)environmentVariablesthreaded through all terminal creation paths (shortcut, context menu, terminal creation hook) and all agent paths (launcher, node lifecycle, task run/resume actions)toShellWorkspaceStateForSyncincludesenvironmentVariablesin merge + equality checkTest plan
pnpm check— zero type errorspnpm vitest run— 132/132 test files, 515/515 tests passpnpm build— builds successfullyNODE_ENV=development, close and reopen settings, verify it persistsecho $NODE_ENV→ verifydevelopment🤖 Generated with Claude Code