Skip to content

Set up new worktrees from the repo's devcontainer.json or copilot-setup-steps.yml - #1709

Merged
currentbits merged 2 commits into
mainfrom
coder/env-spec-396
Oct 24, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/env-spec-396

Conversation

@currentbits

Copy link
Copy Markdown
Owner

New worktrees now set themselves up the way the repo already describes. When neither project settings nor solenta.json define a setup, Solenta reads .devcontainer/devcontainer.json (or .devcontainer.json), or .github/workflows/copilot-setup-steps.yml, and runs that setup in the worktree. Closes the setup and env part of #396.

Changes

  • Setup from the spec. devcontainer: onCreateCommand, updateContentCommand and postCreateCommand run in order on the host, with workspace-folder and ${localEnv:X} variables rewritten for a host shell. copilot-setup-steps: the job's run: steps become one script under set -e, which matches Actions' bash -e. uses: steps, steps in other shells, and ${{ }} env values are skipped. Which setup wins: project settings, then solenta.json, then the spec.
  • Same approval gate. The spec's commands and env join solenta.json's approval hash, so editing the spec re-prompts before anything runs. The approval card names the files it covers and lists the env vars.
  • Env from the spec (containerEnv/remoteEnv, workflow/job env) reaches agents, setup/verify/quick actions, terminals and dev servers, but only once approved: it can carry NODE_OPTIONS or LD_PRELOAD. Env vars set on the project still override it.
  • runVerifyCommand no longer cuts commands at 500 chars. Every caller already caps what it accepts, and a spec's multi-line setup cut short would run half a script. Spec setups are capped at 8000 chars and refused past that.

Verification

  • New electron/test/env-spec.test.js: JSONC, exec-form quoting (round-tripped through sh), YAML block scalars and comments, working-directory, precedence, re-prompt on spec edit, env gating, broken-spec reporting.
  • Full test:electron with a CI-like env: 5029 pass, 0 fail. ThreadView and EditProjectModal renderer tests: 118 pass. npm run typecheck and vite build succeed.
  • Parsed real specs from microsoft/vscode, microsoft/TypeScript, dotnet/runtime, home-assistant/core and vercel/next.js.
  • Not tested: clicking through the approval card in the running app.

Notes for reviewers

  • Commands run on the host, not in a container. Many real specs assume Linux CI (sudo apt-get, $GITHUB_ENV) and will fail at that step on macOS. The failure is logged and the worktree is kept, and the approval card shows the full script first.
  • A spec with env vars but no setup command has no approval button yet, so its env never applies.
  • Left out on purpose: Dockerfile and .flox/ environments (running agents in a container or under flox activate is its own feature; direnv's use flox works today), and reusing setup across threads.
  • A repo with both solenta.json (without a setup) and a devcontainer gets a new hash and is asked to approve once more. That's intended, since there is a new command to approve.

🤖 Generated with Claude Code

…p-steps.yml (#396)

When neither project settings nor solenta.json define a setup, a new
worktree runs the setup the repo already declares: devcontainer lifecycle
commands (onCreate/updateContent/postCreate) or the copilot-setup-steps
job's run steps, on the host. The spec's env (containerEnv/remoteEnv,
workflow/job env) reaches agents, setup/verify, terminals and dev servers
once approved. Both join solenta.json's approval hash, so editing the
spec re-prompts before anything runs.

runVerifyCommand no longer truncates at 500 chars: callers already cap,
and a spec's multi-line setup cut short would run half a script.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-24T11:02:29.037652Z 3bb0940 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3bb0940e0c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread electron/envSpec.js
Comment on lines +305 to +307
if (step.shell && !/^(bash|sh)\b/.test(step.shell)) continue;
const wd = typeof step["working-directory"] === "string" ? step["working-directory"] : "";
cmds.push(wd ? `(\ncd ${shQuote(wd)}\n${step.run.trim()}\n)` : step.run.trim());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Execute Bash workflow steps with Bash

On Linux hosts where /bin/sh is not Bash, accepted workflow steps containing Bash syntax fail because runVerifyCommand executes the generated script with /bin/sh -c. For example, a step explicitly declaring shell: bash with items=(one two) fails with Syntax error: "(" unexpected. Preserve the selected shell when generating or executing each step instead of treating Bash and POSIX sh as interchangeable.

Useful? React with 👍 / 👎.

Comment thread electron/envSpec.js
Comment on lines +303 to +307
for (const step of job.steps) {
if (!step || typeof step.run !== "string" || !step.run.trim()) continue;
if (step.shell && !/^(bash|sh)\b/.test(step.shell)) continue;
const wd = typeof step["working-directory"] === "string" ? step["working-directory"] : "";
cmds.push(wd ? `(\ncd ${shQuote(wd)}\n${step.run.trim()}\n)` : step.run.trim());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Respect conditions before including workflow steps

Workflow steps with if: conditions are currently included unconditionally. A workflow containing if: false and run: echo should-not-run produces a setup script that executes that command; similarly, OS-specific installation steps execute on incompatible hosts. Honor conditions that can be evaluated locally and reject or explicitly skip unsupported conditions rather than silently removing their execution guard.

Useful? React with 👍 / 👎.

Comment thread electron/envSpec.js
if (!step || typeof step.run !== "string" || !step.run.trim()) continue;
if (step.shell && !/^(bash|sh)\b/.test(step.shell)) continue;
const wd = typeof step["working-directory"] === "string" ? step["working-directory"] : "";
cmds.push(wd ? `(\ncd ${shQuote(wd)}\n${step.run.trim()}\n)` : step.run.trim());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve step-scoped environment variables

When a setup step declares its own env, those values are discarded before its command runs: only workflow and job env are collected below, and no step-specific environment is added here. For example, a step with env: { INSTALL_MODE: development } that checks or consumes $INSTALL_MODE runs without that value, causing setup to fail or install the wrong configuration. Apply each step's literal env values within that step's execution scope, including their precedence over job env.

Useful? React with 👍 / 👎.

Comment thread electron/envSpec.js
return { file, error: `${file} must be a JSON object` };
}
const cmds = DEVCONTAINER_STAGES.map((k) => lifecycleCommand(data[k])).filter(Boolean);
return finish(file, cmds.join(" && "), stringEnv(data.containerEnv, data.remoteEnv));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Isolate lifecycle commands before joining them

A valid lifecycle command ending in a shell comment swallows every subsequent stage because the commands are concatenated on the same line. For example, onCreateCommand: "echo created # comment" followed by postCreateCommand: "npm ci" becomes echo created # comment && npm ci, reports success, and never installs dependencies. Delimit each lifecycle command as a separate shell group with newline boundaries; the same issue also affects named commands joined inside lifecycleCommand.

Useful? React with 👍 / 👎.

)

#1708 added solenta.local.json and its own setupSource; both now share
one field. A local or shared solenta.json setup still beats the repo's
env spec.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@currentbits
currentbits merged commit a5a7f18 into main Oct 24, 2026
6 checks passed
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