Skip to content

Repo-versioned workflow definitions (WORKFLOW.md) (#164) - #1577

Merged
currentbits merged 2 commits into
mainfrom
coder/repo-versioned-workflow-definitions-work-382880
Oct 10, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/repo-versioned-workflow-definitions-work-382880

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #164.

What

  • Run: when the selected template is the default (standard), startWorkflowRun reads WORKFLOW.md (then .solenta/workflow.md) from the thread's own checkout, so the workflow versions with the branch. Explicitly picked store templates still win. The kickoff event notes from WORKFLOW.md.
  • Validation: the file goes through the same validateWorkflowTemplate as store templates; an invalid file fails the start with the file name prefixed (WORKFLOW.md: Phase "build": agentCount …), never a silent fallback.
  • Export: the workflows editor gains Export to repo (workflows:exportToRepo, files web scope). It refuses to clobber an existing file until a second Overwrite click; disabled while the draft has unsaved edits.

Format (electron/repoWorkflow.js)

# Plan and Verify

Free prose here is ignored.

## seed
provider: claude
model: claude-opus-5-5
agents: 1

Produce a concise plan plus key questions.

Unknown keys error; an instruction cannot contain its own ## line.

Not in scope

  • The Composer picker still labels the default as "Plan and Verify" when a repo file overrides it; only the kickoff line shows the source.
  • Remote (SSH) / WSL projects neither read nor export the repo file.

Tests

  • electron/test/repo-workflow.test.js: round trip, file precedence, export + overwrite guard.
  • electron/test/workflow.test.js: repo file beats default, explicit pick beats repo file, invalid file rejects.
  • test/workflowsModal.test.tsx: export + overwrite confirm, hidden without a target.
  • Full test:electron: 4506/4507; the one failure (webScopes classification of the new channel) is fixed in this commit and its file passes 10/10. vite build OK.
  • tsc reports one error in src/mermaidEngine.ts (trustedTypes typing), which this PR doesn't touch.

🤖 Generated with Claude Code

A committed WORKFLOW.md (or .solenta/workflow.md) in the thread's checkout
replaces the default template on workflow runs, validated with the store
template rules; an invalid file fails the start instead of falling back.
Explicitly picked store templates still win. The workflows editor gains
Export to repo (workflows:exportToRepo, files web scope).

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

chatgpt-codex-connector Bot commented Oct 10, 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-10T08:16:20.564741Z 4566f3b 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.

@currentbits
currentbits merged commit 96cdaa3 into main Oct 10, 2026

@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: 4566f3b188

ℹ️ 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".

if (project.remoteHost || require("./wsl.js").wslTarget(project)) {
throw new Error("Export to repo is not supported for remote projects");
}
const dir = thread.worktreePath || project.path;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Materialize pending worktrees before exporting

When the selected thread has pendingWorktree: true but no worktreePath (the normal state before its first run), this falls back to project.path and writes the workflow into the shared checkout. The first run then creates a separate worktree from committed Git state, so the exported uncommitted WORKFLOW.md is absent or stale there and the workflow is not used, while the project checkout is dirtied unexpectedly. Materialize the pending worktree before selecting the destination, or reject the export until it exists.

Useful? React with 👍 / 👎.

if (fs.existsSync(file) && !(input && input.overwrite)) {
return { written: false, path: file };
}
fs.mkdirSync(path.dirname(file), { recursive: true });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Do not recreate a missing worktree as an empty directory

If a thread's worktree directory was deleted externally, exporting reaches this recursive mkdirSync and recreates only the directory, without restoring its Git worktree. Subsequent run setup sees that worktreePath exists, skips the existing missing-worktree recovery, and launches agents in an empty non-Git directory containing only the exported file. Check and rematerialize the worktree before writing rather than recreating a stale path.

Useful? React with 👍 / 👎.

return { written: false, path: file };
}
fs.mkdirSync(path.dirname(file), { recursive: true });
fs.writeFileSync(file, repoWorkflow.serializeRepoWorkflow(template));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Refuse to overwrite workflow symlinks

When an existing WORKFLOW.md or .solenta/workflow.md is a symbolic link, the confirmation reports the in-repo path, but this write follows the link and truncates its target. A checked-out repository can therefore point the workflow file outside the checkout and cause the second “Overwrite” click to destroy an arbitrary user file. Inspect the destination with lstat and refuse symlinks or open it with no-follow semantics.

Useful? React with 👍 / 👎.

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.

Repo-versioned workflow definitions (WORKFLOW.md)

1 participant