Skip to content

feat: configurable custom env vars in settings panel - #119

Merged
aterrylu merged 1 commit into
mainfrom
terry/env-settings
Apr 10, 2026
Merged

feat: configurable custom env vars in settings panel#119
aterrylu merged 1 commit into
mainfrom
terry/env-settings

Conversation

@aterrylu

Copy link
Copy Markdown
Owner

Summary

  • Adds a Custom Environment Variables section to the dashboard settings panel
  • Users can define arbitrary key-value pairs (e.g. NO_FLICKER=1, OPENAI_API_KEY=sk-...) that get injected into every newly spawned session
  • Integrates with existing settings persistence (~/.autonomos/settings.json) and save flow

Changes

Server

  • settings.ts: Added customEnvVars: Record<string, string> to AppSettings interface
  • sessions.ts: buildEnv() spreads custom vars into session environment, with a RESERVED_ENV_KEYS blocklist (PATH, CLAUDECODE, PORT, HOME, AUTONOMOS_SERVER, AUTONOMOS_SESSION_ID) to prevent overriding internal vars
  • routes/settings.ts: API validation — accepts only valid POSIX env var names (/^[A-Za-z_][A-Za-z0-9_]*$/), string values only

Dashboard

  • SettingsStatusBarItem.tsx: New EnvVarSection and EnvVarRow components — key-value pair list with add/remove buttons, integrated into existing batch-save flow. Uses useMemo for stable React keys across re-renders.

Design decisions

  • Custom vars applied last in buildEnv() so they can override ANTHROPIC_BASE_URL etc., but reserved internal keys are blocklisted
  • POSIX name validation on server side silently drops invalid keys (spaces, =, etc.)
  • No secret redaction for custom env var values in GET response — unlike anthropicAuthToken, these values need to be visible for editing. Tradeoff documented.

Test plan

  • Add a custom env var (e.g. NO_FLICKER=1) in settings, save
  • Spawn a new session, verify env var is present (echo $NO_FLICKER)
  • Verify settings persist across server restart
  • Verify reserved keys (PATH, CLAUDECODE) are blocked
  • Verify invalid key names are rejected (try MY VAR, 123KEY)
  • Verify add/remove/edit flow works in the UI
  • Verify existing settings (API override, channels, auto-trust) still work

🤖 Generated with Claude Code

Add a "Custom Environment Variables" section to the dashboard settings
panel. Users can define arbitrary key-value pairs that get injected into
every spawned session's environment via buildEnv().

- Add customEnvVars field to AppSettings schema (Record<string, string>)
- Spread custom vars into buildEnv() with a reserved-keys blocklist
  (PATH, CLAUDECODE, AUTONOMOS_SESSION_ID, etc. cannot be overridden)
- Server-side validation: POSIX env var name format, string values only
- Settings panel UI: key-value rows with add/remove, integrated into
  existing save flow with memoized React state for stable rendering

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aterrylu
aterrylu marked this pull request as ready for review April 10, 2026 10:05
@aterrylu
aterrylu merged commit e31434b into main Apr 10, 2026
1 check passed
@aterrylu
aterrylu deleted the terry/env-settings branch April 10, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant