Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: honor disabled CoS review loop

[._.]/ Adam Eivy3ca7216d2673
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index e37e898389..a28bc70386 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -942,7 +942,7 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet
reviewers: lightReviewers, reviewStopMode: lightReviewStopMode, reviewerApplies: lightReviewerApplies
}));
} else {
- sections.push(buildCliCompletionSection({ worktreeInfo, willOpenPR, hasSlashdo, simplifyEnabled, reviewers: lightReviewers, reviewStopMode: lightReviewStopMode, reviewerApplies: lightReviewerApplies }));
+ sections.push(buildCliCompletionSection({ worktreeInfo, willOpenPR, willReviewLoop, hasSlashdo, simplifyEnabled, reviewers: lightReviewers, reviewStopMode: lightReviewStopMode, reviewerApplies: lightReviewerApplies }));
}
return { taskSections, contractSections };
@@ -1022,14 +1022,19 @@ function buildTuiCompletionSection({ willOpenPR, willReviewLoop, simplifyEnabled
return buildManualTuiCompletionSection({ willOpenPR, simplifyEnabled, sentinelPath, branchName, baseBranch });
}
const cmd = willOpenPR ? '/do:pr' : '/do:push';
- const reviewArgs = willOpenPR && willReviewLoop ? buildReviewWithArgs(reviewers, reviewStopMode, reviewerApplies) : '';
+ // `/do:pr` may inherit a saved `review-with` default. Explicitly opt out
+ // when the task's Review Loop control is off so that default cannot start a
+ // Copilot (or other external) review unexpectedly.
+ const reviewArgs = willOpenPR
+ ? (willReviewLoop ? buildReviewWithArgs(reviewers, reviewStopMode, reviewerApplies) : '--review-with none')
+ : '';
const reviewerArg = reviewArgs ? ` ${reviewArgs}` : '';
const copilotOnly = reviewers.length === 1 && reviewers[0] === DEFAULT_REVIEWER;
const reviewSuffix = willOpenPR && willReviewLoop
? (copilotOnly
? ' — `/do:pr` runs the Copilot review loop after the PR opens.'
: ` — \`/do:pr\` runs the review loop for ${reviewers.join(', ')} in order after the PR opens.`)
- : '';
+ : (willOpenPR ? ' — external review is disabled for this task.' : '');
// `/simplify` is a Claude Code TUI built-in. Non-Claude TUI providers
// (codex-tui, antigravity-tui) can't run it, so give them the inline equivalent.
// Default (no providerId) stays Claude-shaped for backward compatibility.
@@ -1038,7 +1043,9 @@ function buildTuiCompletionSection({ willOpenPR, willReviewLoop, simplifyEnabled
? (canRunSimplifyCommand ? '1. `/simplify`' : `1. Before committing, ${SIMPLIFY_INLINE_REVIEW} and fix any findings.`)
: '1. (simplify disabled — skip)';
const sentinelTail = willOpenPR ? ' ## PR\n <PR URL>' : ' ## Branch\n <branch name>';
- const merge = willOpenPR ? buildPostPRMergeSteps(3, { reviewers, reviewStopMode }) : { lines: [], nextStep: 3 };
+ const merge = willOpenPR && willReviewLoop
+ ? buildPostPRMergeSteps(3, { reviewers, reviewStopMode })
+ : { lines: [], nextStep: 3 };
const sentinelStep = merge.nextStep;
return [
@@ -1150,20 +1157,26 @@ function buildManualTuiCompletionSection({ willOpenPR, simplifyEnabled, sentinel
* CLI providers fall through to the legacy commit-only block where PortOS
* handles push+PR on exit.
*/
-function buildCliCompletionSection({ worktreeInfo, willOpenPR, hasSlashdo = false, simplifyEnabled = false, reviewers = DEFAULT_REVIEWERS, reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false }) {
+function buildCliCompletionSection({ worktreeInfo, willOpenPR, willReviewLoop = false, hasSlashdo = false, simplifyEnabled = false, reviewers = DEFAULT_REVIEWERS, reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false }) {
if (hasSlashdo && worktreeInfo && willOpenPR) {
const lines = ['## Completion', 'When finished, run these in order:'];
let step = 1;
if (simplifyEnabled) {
lines.push(`${step++}. \`/simplify\` — review the changed code for reuse, quality, and efficiency, and fix any findings.`);
}
- const reviewArgs = buildReviewWithArgs(reviewers, reviewStopMode, reviewerApplies);
+ const reviewArgs = willReviewLoop
+ ? buildReviewWithArgs(reviewers, reviewStopMode, reviewerApplies)
+ : '--review-with none';
const reviewerArg = reviewArgs ? ` ${reviewArgs}` : '';
- const reviewerNote = (reviewers.length === 1 && reviewers[0] === DEFAULT_REVIEWER)
- ? 'Copilot review loop'
- : `review loop for ${reviewers.join(', ')} in order`;
- lines.push(`${step++}. \`/do:pr${reviewerArg}\` — commits your changes, pushes the branch, opens a pull request against the default branch, and drives the ${reviewerNote} until clean.`);
- const merge = buildPostPRMergeSteps(step, { reviewers, reviewStopMode });
+ const completionNote = willReviewLoop
+ ? ((reviewers.length === 1 && reviewers[0] === DEFAULT_REVIEWER)
+ ? 'and drives the Copilot review loop until clean.'
+ : `and drives the review loop for ${reviewers.join(', ')} in order until clean.`)
+ : 'with external review disabled.';
+ lines.push(`${step++}. \`/do:pr${reviewerArg}\` — commits your changes, pushes the branch, and opens a pull request against the default branch ${completionNote}`);
+ const merge = willReviewLoop
+ ? buildPostPRMergeSteps(step, { reviewers, reviewStopMode })
+ : { lines: [], nextStep: step };
lines.push(...merge.lines);
step = merge.nextStep;
return lines.join('\n');
diff --git a/server/services/agentPromptBuilder.test.js b/server/services/agentPromptBuilder.test.js
index 38e353b933..c8a41328d7 100644
--- a/server/services/agentPromptBuilder.test.js
+++ b/server/services/agentPromptBuilder.test.js
@@ -174,7 +174,7 @@ describe('buildLightContextPrompt', () => {
expect(prompt).toMatch(/`jira\/proj-123`/);
});
- it('renders the Completion Workflow with /do:pr for TUI + openPR', () => {
+ it('disables external review when a TUI task opens a PR without a Review Loop', () => {
const prompt = buildLightContextPrompt(
makeTask({ metadata: { simplify: true, openPR: true } }),
'/r',
@@ -183,19 +183,19 @@ describe('buildLightContextPrompt', () => {
{ isTui: true });
expect(prompt).toMatch(/## Completion Workflow/);
expect(prompt).toMatch(/`\/simplify`/);
- expect(prompt).toMatch(/`\/do:pr`/);
+ expect(prompt).toMatch(/`\/do:pr --review-with none`/);
+ expect(prompt).toMatch(/external review is disabled/i);
+ expect(prompt).not.toMatch(/Copilot review loop/i);
expect(prompt).toMatch(/\.agent-done/);
// The sentinel is the done signal — the agent must NOT be told to RUN
// /quit (it's a UI command it can't invoke; PortOS closes the session on
// poll). The prompt only mentions /quit to tell the agent NOT to run it.
expect(prompt).not.toMatch(/^\s*\d+\.\s*`\/quit`/m);
expect(prompt).toMatch(/NOT run `\/quit`/);
- // After /do:pr drives the Copilot review loop clean, the agent must
- // merge and verify — otherwise the PR sits open after the agent exits.
- expect(prompt).toMatch(/gh pr merge "<PR_URL>" --merge --delete-branch/);
- expect(prompt).not.toMatch(/gh pr merge[^\n]*--auto/);
- expect(prompt).toMatch(/gh pr view "<PR_URL>" --json state -q \.state/);
- expect(prompt).toMatch(/MERGED/);
+ // Without a Review Loop the task opens the PR for human follow-up and
+ // must not be told to auto-merge based on a review outcome.
+ expect(prompt).not.toMatch(/gh pr merge/);
+ expect(prompt).not.toMatch(/gh pr view "<PR_URL>" --json state/);
});
it('TUI simplify step is provider-aware — non-Claude TUI (codex-tui) gets the inline equivalent, not /simplify', () => {
@@ -327,7 +327,7 @@ describe('buildLightContextPrompt', () => {
it('emits a slashdo Completion block (/simplify + /do:pr) for Claude Code CLI + openPR', () => {
const prompt = buildLightContextPrompt(
- makeTask({ metadata: { openPR: true, simplify: true } }),
+ makeTask({ metadata: { openPR: true, reviewLoop: true, simplify: true } }),
'/r',
{ branchName: 'b', worktreePath: '/tmp/wt' },
isTruthyMeta,
@@ -346,13 +346,27 @@ describe('buildLightContextPrompt', () => {
expect(prompt).toMatch(/MERGED/);
});
- it('skips /simplify in the slashdo Completion block when simplify is disabled', () => {
+ it('disables external review and omits merge guidance for Claude Code CLI when Review Loop is off', () => {
const prompt = buildLightContextPrompt(
makeTask({ metadata: { openPR: true, simplify: false } }),
'/r',
{ branchName: 'b', worktreePath: '/tmp/wt' },
isTruthyMeta,
{ isTui: false, providerId: 'claude-code' });
+ expect(prompt).toMatch(/`\/do:pr --review-with none`/);
+ expect(prompt).toMatch(/external review disabled/i);
+ expect(prompt).not.toMatch(/Copilot review loop/i);
+ expect(prompt).not.toMatch(/gh pr merge/);
+ expect(prompt).not.toMatch(/gh pr view "<PR_URL>" --json state/);
+ });
+
+ it('skips /simplify in the slashdo Completion block when simplify is disabled', () => {
+ const prompt = buildLightContextPrompt(
+ makeTask({ metadata: { openPR: true, reviewLoop: true, simplify: false } }),
+ '/r',
+ { branchName: 'b', worktreePath: '/tmp/wt' },
+ isTruthyMeta,
+ { isTui: false, providerId: 'claude-code' });
expect(prompt).toMatch(/`\/do:pr`/);
expect(prompt).not.toMatch(/`\/simplify`/);
// Merge guidance still applies when /simplify is skipped.