Skip to content

Add task env vars and port isolation#745

Open
rabanspiegel wants to merge 6 commits intomainfrom
emdash/archive-script-4oe
Open

Add task env vars and port isolation#745
rabanspiegel wants to merge 6 commits intomainfrom
emdash/archive-script-4oe

Conversation

@rabanspiegel
Copy link
Contributor

@rabanspiegel rabanspiegel commented Feb 4, 2026

Summary

  • add task env helper and inject EMDASH_* vars into task terminals and direct-spawn agents
  • seed EMDASH_PORT by worktree identity to avoid collisions
  • document task env vars with usage examples

Testing

  • npm run lint
  • npm run type-check
  • npx vitest run
  • create a task and run in the task terminal
  • create a multi-agent task, run in each variant terminal and confirm same task id, different ports
  • open an agent terminal (direct spawn), exit the CLI to shell, run to confirm env vars

Note

Medium Risk
Touches terminal/PTTY spawning paths and IPC boundaries; while env injection is gated to EMDASH_*, regressions could affect agent/terminal startup behavior across single- and multi-agent tasks.

Overview
Adds a shared getTaskEnvVars helper that generates EMDASH_* task context variables (including a deterministic EMDASH_PORT range) and wires it into task terminals across the UI, including multi-agent variants via a portSeed to reduce port collisions.

Extends the direct PTY spawn IPC/API to accept an env payload and updates the main-process direct-spawn path to merge only EMDASH_* keys into the minimal CLI environment. Updates docs to describe the new task env vars and provide port-aware setup and docker-compose examples.

Written by Cursor Bugbot for commit 8b375f1. This will update automatically on new commits. Configure here.

@vercel
Copy link

vercel bot commented Feb 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Feb 4, 2026 7:12am

Request Review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

defaultBranch,
portSeed,
});
}, [task, projectPath, defaultBranch, portSeed]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete useMemo dependencies in TaskTerminalPanel

Medium Severity

The taskEnv memo depends on task.id, task.name, and task.path inside the computation, but the dependency array only includes task as a whole object reference. If the task's properties change while the object reference stays the same, the memo won't recompute and will return stale env vars. In contrast, ChatInterface.tsx correctly uses [task.id, task.name, task.path, ...] as dependencies.

Fix in Cursor Fix in Web

@rabanspiegel
Copy link
Contributor Author

Addressed Cursor Bugbot findings:

  • fixed TaskTerminalPanel taskEnv memo dependencies
  • memoized per-variant env map in MultiAgentTask to avoid terminal reattach
  • passed env through startPty fallback in pty:startDirect

Pushed in 8b375f1.

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