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

feat: give every reviewer-picker surface a per-reviewer Provider/Model/Optional/Max table (#3133)

[._.]/ Adam Eivybb68fa3ec8b9
diff --git a/client/src/components/apps/SlashDoRunDrawer.jsx b/client/src/components/apps/SlashDoRunDrawer.jsx
index c716eaf9a0..7f524fc69d 100644
--- a/client/src/components/apps/SlashDoRunDrawer.jsx
+++ b/client/src/components/apps/SlashDoRunDrawer.jsx
@@ -1,10 +1,12 @@
-import { useState, useCallback } from 'react';
+import { useState, useCallback, useMemo } from 'react';
import { Loader2, Terminal, Wand2 } from 'lucide-react';
import Drawer from '../Drawer';
import ProviderModelSelector from '../ProviderModelSelector';
import ReviewerPicker from '../cos/ReviewerPicker';
import EffortSelect from '../cos/EffortSelect';
import useProviderModels from '../../hooks/useProviderModels';
+import useReviewerModelOptions from '../../hooks/useReviewerModelOptions';
+import { reviewerModelsFromDefaults } from '../../lib/reviewerModels';
import { CodeReviewDefaultsProvider, useCodeReviewDefaults } from '../../hooks/useCodeReviewDefaults';
import { isProcessProvider } from '../../utils/providers';
import WorkItemPicker from './WorkItemPicker';
@@ -31,6 +33,9 @@ const SELECT_CLASS = 'w-full px-3 py-2 bg-port-bg border border-port-border roun
*/
function SlashDoRunDrawerBody({ open, command, label, appId, appName, onClose, onQueued }) {
const codeReviewDefaults = useCodeReviewDefaults();
+ // Resolved model lists for the reviewer table's Model column (the picker never
+ // fetches — see its `modelOptions` prop).
+ const reviewerModelOptions = useReviewerModelOptions();
const {
providers, selectedProviderId, selectedModel, availableModels, selectedProvider,
setSelectedProviderId, setSelectedModel
@@ -41,7 +46,13 @@ function SlashDoRunDrawerBody({ open, command, label, appId, appName, onClose, o
// Seeded from the install's Code Review Defaults for display. `reviewDirty`
// gates whether they're SENT — see the component doc.
const [review, setReview] = useState(null);
- const reviewValue = review ?? codeReviewDefaults;
+ // The defaults carry per-reviewer models as `<reviewer>Model` scalars; the picker
+ // takes the token-keyed map, so fold them in for the seeded (untouched) display.
+ const seededReview = useMemo(
+ () => ({ ...codeReviewDefaults, reviewerModels: reviewerModelsFromDefaults(codeReviewDefaults) }),
+ [codeReviewDefaults]
+ );
+ const reviewValue = review ?? seededReview;
const [work, setWork] = useState({ mode: 'auto', target: '', issueAuthorFilter: '' });
const [submitting, setSubmitting] = useState(false);
@@ -71,7 +82,8 @@ function SlashDoRunDrawerBody({ open, command, label, appId, appName, onClose, o
reviewers: review.reviewers,
usernames: review.usernames,
optionalReviewers: review.optionalReviewers,
- reviewerMaxRounds: review.reviewerMaxRounds
+ reviewerMaxRounds: review.reviewerMaxRounds,
+ reviewerModels: review.reviewerModels
} : {})
}, { silent: true }).catch((err) => {
setSubmitError(err.message || 'Failed to queue the task');
@@ -135,11 +147,13 @@ function SlashDoRunDrawerBody({ open, command, label, appId, appName, onClose, o
usernames={reviewValue.usernames}
optionalReviewers={reviewValue.optionalReviewers}
reviewerMaxRounds={reviewValue.reviewerMaxRounds}
+ reviewerModels={reviewValue.reviewerModels}
+ modelOptions={reviewerModelOptions}
// The claim flows substitute a reviewer CSV into their prompt and have
// no slashdo flag string, so stop-mode / reviewer-applies can't be honored.
showRunFlags={false}
- onChange={({ reviewers, usernames, optionalReviewers, reviewerMaxRounds }) =>
- setReview({ reviewers, usernames, optionalReviewers, reviewerMaxRounds })}
+ onChange={({ reviewers, usernames, optionalReviewers, reviewerMaxRounds, reviewerModels }) =>
+ setReview({ reviewers, usernames, optionalReviewers, reviewerMaxRounds, reviewerModels })}
/>
<p className="text-xs text-gray-500">
The claim flow opens and merges its own PR, so these reviewers gate that merge (slashdo <code>--review-with</code>).
diff --git a/client/src/components/apps/SlashDoRunDrawer.test.jsx b/client/src/components/apps/SlashDoRunDrawer.test.jsx
index bdb6ab0e34..9115a85607 100644
--- a/client/src/components/apps/SlashDoRunDrawer.test.jsx
+++ b/client/src/components/apps/SlashDoRunDrawer.test.jsx
@@ -6,6 +6,8 @@ import SlashDoRunDrawer from './SlashDoRunDrawer';
const api = vi.hoisted(() => ({
getCodeReviewDefaults: vi.fn(),
getProviders: vi.fn(),
+ // Backs the reviewer table's Model column (useReviewerModelOptions).
+ getLocalLlmStatus: vi.fn(),
getAppWorkItems: vi.fn(),
createSlashdoTask: vi.fn()
}));
@@ -30,6 +32,7 @@ describe('SlashDoRunDrawer', () => {
vi.clearAllMocks();
api.getCodeReviewDefaults.mockResolvedValue({ reviewers: ['copilot'], usernames: [], optionalReviewers: [] });
api.getProviders.mockResolvedValue({ providers: [] });
+ api.getLocalLlmStatus.mockResolvedValue({ ollama: { models: [] }, lmstudio: { models: [] } });
api.getAppWorkItems.mockResolvedValue({
tracker: 'github',
issueAuthorFilter: 'self',
diff --git a/client/src/components/cos/ReviewerPicker.jsx b/client/src/components/cos/ReviewerPicker.jsx
index 6ad404c938..70792d14cd 100644
--- a/client/src/components/cos/ReviewerPicker.jsx
+++ b/client/src/components/cos/ReviewerPicker.jsx
@@ -6,6 +6,8 @@ import {
DEFAULT_REVIEW_STOP_MODE,
MAX_REVIEW_USERNAMES,
MAX_REVIEWER_MAX_ROUNDS,
+ MAX_REVIEWER_MODEL_LENGTH,
+ MODEL_SELECTABLE_REVIEWERS,
cleanReviewUsername,
normalizeReviewUsernames
} from './constants';
@@ -14,21 +16,38 @@ const labelFor = (value) => REVIEWER_OPTIONS.find(o => o.value === value)?.label
const normalizeReviewerValue = (value) => value === 'gemini' ? 'antigravity' : value;
/**
- * Ordered multi-reviewer picker. Click a reviewer to append it (run order =
+ * Ordered multi-reviewer picker, rendered as one row per reviewer with the four
+ * per-reviewer controls as columns: **Provider | Model | Optional | Max
+ * Iterations** (#3133). Click a reviewer in the Add row to append it (run order =
* click order), reorder with the arrows, remove with ✕. Maps to slashdo's
* `--review-with a,b,c` plus the stop-mode / `--reviewer-applies` flags.
*
- * A second "GitHub reviewers" row collects arbitrary usernames (e.g.
+ * A second "GitHub reviewers" table collects arbitrary usernames (e.g.
* `@CodeReviewbot`) requested as PR reviewers to gate the merge — appended to
- * `--review-with` as `@user` tokens after the keyed reviewers.
+ * `--review-with` as `@user` tokens after the keyed reviewers. Those rows have no
+ * Model cell: a username reviewer is a human or a GitHub App, not a model-taking
+ * backend (slashdo rejects `@login[…]` for the same reason).
*
- * Each chip carries two per-entry slashdo suffix controls: the `~opt`
- * non-blocking badge and a numeric `~max=<n>` round cap (blank = slashdo's
- * built-in default, `0` = loop until clean).
+ * Per-row controls, each mapping to one slashdo per-entry token feature:
+ * - **Model** → the `[<model>]` selector (or, for a CLI reviewer the follow-up
+ * agent invokes directly, `<reviewer> --model <id>`). Only rendered for
+ * MODEL_SELECTABLE_REVIEWERS. The option lists are OWNED BY THE CALLER (see
+ * `modelOptions`) so this component does no fetching.
+ * - **Optional** → the `~opt` non-blocking marker.
+ * - **Max Iterations** → the numeric `~max=<n>` round cap (blank = slashdo's
+ * built-in default, `0` = loop until clean).
*
* Controlled: emits the full next shape via onChange so the parent can store
- * `reviewers` / `usernames` / `reviewerMaxRounds` / `reviewStopMode` /
- * `reviewerApplies` however it persists them.
+ * `reviewers` / `usernames` / `optionalReviewers` / `reviewerModels` /
+ * `reviewerMaxRounds` / `reviewStopMode` / `reviewerApplies` however it persists
+ * them.
+ *
+ * `modelOptions` is the resolved model-picker data, shaped like
+ * `useReviewerModelOptions()`'s return: `{ optionsByReviewer, freeText,
+ * unavailable, loaded }`. Callers keep owning their own
+ * `api.getLocalLlmStatus` / `api.getProviders` fetches (that's what the hook is
+ * for) — passing nothing degrades every Model cell to a free-text input, which is
+ * still fully usable, rather than hiding the column.
*
* `showRunFlags={false}` hides the stop-mode select and the "reviewer applies
* fixes" checkbox for surfaces that can't honor them — the `/do:next` claim
@@ -41,6 +60,8 @@ export default function ReviewerPicker({
usernames = [],
optionalReviewers = [],
reviewerMaxRounds = {},
+ reviewerModels = {},
+ modelOptions = null,
stopMode = DEFAULT_REVIEW_STOP_MODE,
reviewerApplies = false,
onChange,
@@ -68,27 +89,39 @@ export default function ReviewerPicker({
const optionalSet = new Set(optionalTokens.map(t => t.toLowerCase()));
const isOptional = (token) => optionalSet.has(token.toLowerCase());
const withoutToken = (token) => optionalTokens.filter(t => t.toLowerCase() !== token.toLowerCase());
+ // Shared shape for the two token-keyed maps below (`~max=<n>` caps and model
+ // pins). Both key on the same emitted `--review-with` token and both need the
+ // same case-insensitive read / key-preserving delete, so the lookup helpers are
+ // generated once rather than written twice.
+ const asMap = (value) => (value && typeof value === 'object' && !Array.isArray(value)) ? value : {};
+ const keyedLookup = (map) => ({
+ get: (token) => {
+ const key = Object.keys(map).find(k => k.toLowerCase() === token.toLowerCase());
+ return key === undefined ? undefined : map[key];
+ },
+ without: (token) => Object.fromEntries(
+ Object.entries(map).filter(([k]) => k.toLowerCase() !== token.toLowerCase())
+ )
+ });
// Per-reviewer `~max=<n>` round caps, keyed by the same emitted token. Absent
// key = no cap requested (slashdo's built-in default stands); `0` = loop until
// clean. The two must never collapse, so the input renders '' for absent and
// clearing it DELETES the key rather than writing 0 (server
// `normalizeReviewerMaxRounds` owns the authoritative shape).
- const maxRoundsMap = (reviewerMaxRounds && typeof reviewerMaxRounds === 'object' && !Array.isArray(reviewerMaxRounds))
- ? reviewerMaxRounds
- : {};
- const maxRoundsFor = (token) => {
- const key = Object.keys(maxRoundsMap).find(k => k.toLowerCase() === token.toLowerCase());
- return key === undefined ? undefined : maxRoundsMap[key];
- };
- const maxRoundsWithout = (token) => Object.fromEntries(
- Object.entries(maxRoundsMap).filter(([k]) => k.toLowerCase() !== token.toLowerCase())
- );
+ const maxRoundsMap = asMap(reviewerMaxRounds);
+ const maxRounds = keyedLookup(maxRoundsMap);
+ // Per-reviewer model pins, same token keying. Absent key = "let that reviewer
+ // pick its own default", which is NOT an empty string — so clearing the field
+ // DELETES the key rather than persisting `''` (a `--model ` with no id).
+ const modelsMap = asMap(reviewerModels);
+ const models = keyedLookup(modelsMap);
const emit = (next) => onChange?.({
reviewers: selected,
usernames: selectedUsernames,
optionalReviewers: optionalTokens,
reviewerMaxRounds: maxRoundsMap,
+ reviewerModels: modelsMap,
stopMode,
reviewerApplies,
...next
@@ -109,17 +142,30 @@ export default function ReviewerPicker({
// budget, never make it unlimited, and it matches the input's `max`.
const setMaxRounds = (token, raw) => {
if (raw === '') {
- emit({ reviewerMaxRounds: maxRoundsWithout(token) });
+ emit({ reviewerMaxRounds: maxRounds.without(token) });
return;
}
const parsed = Number(raw);
if (!Number.isInteger(parsed) || parsed < 0) return;
const capped = Math.min(parsed, MAX_REVIEWER_MAX_ROUNDS);
- emit({ reviewerMaxRounds: { ...maxRoundsWithout(token), [token]: capped } });
+ emit({ reviewerMaxRounds: { ...maxRounds.without(token), [token]: capped } });
};
- // The `~opt` non-blocking toggle rendered on every reviewer/username chip.
- // `subject` is the human name used in the aria-label; `title` is the (chip-
+ // Blank (or whitespace-only) clears the pin so the reviewer falls back to its
+ // own default — the DELETE, not an empty-string write, because `''` is not a
+ // model id the reviewer could run. Mirrors the server normalizer, which drops a
+ // blank value rather than persisting it.
+ const setModel = (token, raw) => {
+ const model = raw.trim();
+ if (!model) {
+ emit({ reviewerModels: models.without(token) });
+ return;
+ }
+ emit({ reviewerModels: { ...models.without(token), [token]: model } });
+ };
+
+ // The `~opt` non-blocking toggle rendered on every reviewer/username row.
+ // `subject` is the human name used in the aria-label; `title` is the (row-
// kind-specific) hover copy the caller resolves.
const renderOptToggle = (token, subject, title) => (
<button
@@ -137,37 +183,118 @@ export default function ReviewerPicker({
</button>
);
- // The `~max=<n>` round-cap input rendered on every reviewer/username chip.
+ // The `~max=<n>` round-cap input rendered on every reviewer/username row.
// Blank means "no cap" — the number input's empty string is the sentinel for an
// absent key, distinct from a typed `0` (loop until clean).
const renderMaxRounds = (token, subject) => {
- const value = maxRoundsFor(token);
+ const value = maxRounds.get(token);
const inputId = `${id}-max-${token}`;
return (
- <span className="inline-flex items-center gap-0.5">
- <label htmlFor={inputId} className="text-[10px] font-mono leading-none text-gray-600">~max</label>
+ <input
+ id={inputId}
+ type="number"
+ inputMode="numeric"
+ min={0}
+ max={MAX_REVIEWER_MAX_ROUNDS}
+ step={1}
+ disabled={disabled}
+ value={value === undefined ? '' : value}
+ placeholder="–"
+ onChange={(e) => setMaxRounds(token, e.target.value)}
+ aria-label={`Max review rounds for ${subject}`}
+ title={value === undefined
+ ? `${subject} uses slashdo's built-in round cap. Enter a number to cap its review → fix → re-review cycles (0 = loop until clean).`
+ : value === 0
+ ? `${subject} loops until clean (~max=0), bounded by slashdo's safety guardrail. Clear to restore the built-in cap.`
+ : `${subject} runs at most ${value} review round${value === 1 ? '' : 's'} (~max=${value}). Clear to restore the built-in cap.`}
+ className={`w-12 px-1 py-0.5 text-[11px] font-mono leading-none text-center rounded border bg-port-bg min-h-[28px] disabled:opacity-40 focus:outline-none focus:border-port-accent ${value === undefined
+ ? 'text-gray-500 border-port-border/60 hover:border-port-border'
+ : 'text-port-accent-2 border-port-accent-2/50'}`}
+ />
+ );
+ };
+
+ // The Model cell. Only MODEL_SELECTABLE_REVIEWERS get one — copilot has no CLI
+ // and a `@username` reviewer is a person/bot, so neither takes a model.
+ //
+ // A local backend's installed-model list is authoritative (the server probed
+ // it), so those render a closed `<select>`. A CLI reviewer renders a text input
+ // + `<datalist>` instead: its catalog is a stored snapshot, and an Ollama-backed
+ // `claude` or a Bedrock-form id can be anything the environment provides — a
+ // closed list would lock out valid ids. `loaded` gates the "nothing installed"
+ // messaging so a pre-fetch render doesn't accuse a healthy backend of being
+ // empty.
+ const renderModelCell = (token) => {
+ if (!MODEL_SELECTABLE_REVIEWERS.includes(token)) {
+ return <span className="text-[11px] text-gray-700" title={`${labelFor(token)} takes no model`}>—</span>;
+ }
+ const subject = labelFor(token);
+ const value = models.get(token) ?? '';
+ const options = modelOptions?.optionsByReviewer?.[token] || [];
+ const inputId = `${id}-model-${token}`;
+ const listId = `${id}-modellist-${token}`;
+ // No resolved options AND a closed picker would be a dead control, so fall
+ // back to free-text: better a typed id than no way to set one at all.
+ const freeText = modelOptions?.freeText?.[token] !== false || options.length === 0;
+ // Why a local backend has no options, so the empty state says the useful
+ // thing instead of a bare "default" placeholder. Only meaningful once the
+ // probe settled — before that, an empty list is "not fetched yet", not a fact.
+ const emptyHint = (options.length === 0 && modelOptions?.loaded)
+ ? (modelOptions?.unavailable?.[token]
+ ? `${subject} isn't reachable — start it from Settings → Local LLMs to list its models. You can still type an id.`
+ : `No ${subject} models listed — add one in Settings → Local LLMs, or type an id.`)
+ : null;
+
+ if (!freeText) {
+ return (
+ <select
+ id={inputId}
+ value={value}
+ disabled={disabled}
+ onChange={(e) => setModel(token, e.target.value)}
+ aria-label={`Model for ${subject}`}
+ title={value
+ ? `${subject} reviews with ${value}. Choose "default" to let it pick.`
+ : `${subject} uses the model configured for its backend. Pick one to pin it for this run.`}
+ className={`w-full min-w-0 max-w-[190px] px-1.5 py-0.5 text-[11px] font-mono rounded border bg-port-bg min-h-[28px] disabled:opacity-40 focus:outline-none focus:border-port-accent ${value
+ ? 'text-port-accent border-port-accent/50'
+ : 'text-gray-500 border-port-border/60'}`}
+ >
+ <option value="">— default —</option>
+ {/* A pin the probe no longer lists (model uninstalled, or set on
+ another machine) still needs an <option>, or the select would render
+ blank and read as "unset" while the value is in fact stored. */}
+ {value && !options.includes(value) && <option value={value}>{value} (not installed)</option>}
+ {options.map((m) => <option key={m} value={m}>{m}</option>)}
+ </select>
+ );
+ }
+
+ return (
+ <>
<input
id={inputId}
- type="number"
- inputMode="numeric"
- min={0}
- max={MAX_REVIEWER_MAX_ROUNDS}
- step={1}
+ type="text"
+ list={options.length ? listId : undefined}
+ value={value}
disabled={disabled}
- value={value === undefined ? '' : value}
- placeholder="–"
- onChange={(e) => setMaxRounds(token, e.target.value)}
- aria-label={`Max review rounds for ${subject}`}
- title={value === undefined
- ? `${subject} uses slashdo's built-in round cap. Enter a number to cap its review → fix → re-review cycles (0 = loop until clean).`
- : value === 0
- ? `${subject} loops until clean (~max=0), bounded by slashdo's safety guardrail. Clear to restore the built-in cap.`
- : `${subject} runs at most ${value} review round${value === 1 ? '' : 's'} (~max=${value}). Clear to restore the built-in cap.`}
- className={`w-8 px-0.5 py-0.5 text-[10px] font-mono leading-none text-center rounded border bg-port-bg disabled:opacity-40 focus:outline-none focus:border-port-accent ${value === undefined
- ? 'text-gray-500 border-transparent hover:border-port-border'
- : 'text-port-accent-2 border-port-accent-2/50'}`}
+ maxLength={MAX_REVIEWER_MODEL_LENGTH}
+ placeholder="default"
+ onChange={(e) => setModel(token, e.target.value)}
+ aria-label={`Model for ${subject}`}
+ title={value
+ ? `${subject} reviews with ${value}. Clear to let it use its own default.`
+ : (emptyHint || `${subject} uses its own default model. Type or pick an id to pin one.`)}
+ className={`w-full min-w-0 max-w-[190px] px-1.5 py-0.5 text-[11px] font-mono rounded border bg-port-bg min-h-[28px] disabled:opacity-40 focus:outline-none focus:border-port-accent ${value
+ ? 'text-port-accent border-port-accent/50'
+ : 'text-gray-500 border-port-border/60'}`}
/>
- </span>
+ {options.length > 0 && (
+ <datalist id={listId}>
+ {options.map((m) => <option key={m} value={m}>{m}</option>)}
+ </datalist>
+ )}
+ </>
);
};
@@ -193,14 +320,18 @@ export default function ReviewerPicker({
const removeUsername = (value) => emit({
usernames: selectedUsernames.filter(u => u !== value),
optionalReviewers: withoutToken(`@${value}`),
- reviewerMaxRounds: maxRoundsWithout(`@${value}`)
+ reviewerMaxRounds: maxRounds.without(`@${value}`),
+ // A username row has no Model cell, but prune anyway: a hand-edited settings
+ // file (or a future reviewer that gains one) must not leave an orphan pin.
+ reviewerModels: models.without(`@${value}`)
});
const add = (value) => emit({ reviewers: [...selected, value] });
const remove = (value) => emit({
reviewers: selected.filter(r => r !== value),
optionalReviewers: withoutToken(value),
- reviewerMaxRounds: maxRoundsWithout(value)
+ reviewerMaxRounds: maxRounds.without(value),
+ reviewerModels: models.without(value)
});
const move = (index, delta) => {
const target = index + delta;
@@ -210,59 +341,92 @@ export default function ReviewerPicker({
emit({ reviewers: next });
};
+ // Shared row grid. Desktop is a 5-column table (order · provider · model ·
+ // optional · max · remove); under `sm` it collapses to a stacked 2-column
+ // label/value block so a narrow screen never needs horizontal scrolling. The
+ // header row is desktop-only — on mobile each cell carries its own inline
+ // label, since a header far above a stacked row doesn't associate.
+ const ROW_CLASS = 'grid grid-cols-[auto_1fr] sm:grid-cols-[2.5rem_minmax(5rem,1fr)_minmax(0,2fr)_auto_3.25rem_auto] items-center gap-x-2 gap-y-1 px-1.5 py-1.5 rounded border border-port-border bg-port-bg sm:border-transparent sm:bg-transparent sm:py-0.5 sm:rounded-none';
+ const CELL_LABEL_CLASS = 'sm:hidden text-[10px] uppercase tracking-wide text-gray-600';
+ const HEADER_CLASS = 'hidden sm:grid sm:grid-cols-[2.5rem_minmax(5rem,1fr)_minmax(0,2fr)_auto_3.25rem_auto] items-center gap-x-2 px-1.5 text-[10px] uppercase tracking-wide text-gray-600';
+
return (
<div className="flex flex-col gap-2 w-full">
- <div className="flex flex-wrap items-center gap-1.5">
- <span className="text-xs text-gray-500 mr-1">Reviewers (in order):</span>
- {selected.map((value, index) => (
- <span
- key={value}
- className="inline-flex items-center gap-1 pl-1.5 pr-1 py-0.5 bg-port-bg border border-port-border rounded text-xs text-gray-300"
- title={REVIEWER_OPTIONS.find(o => o.value === value)?.description}
- >
- <span className="text-port-accent font-mono">{index + 1}.</span>
- {labelFor(value)}
- <button
- type="button"
- disabled={disabled || index === 0}
- onClick={() => move(index, -1)}
- className="text-gray-500 hover:text-white disabled:opacity-30 disabled:hover:text-gray-500"
- aria-label={`Move ${labelFor(value)} earlier`}
- >
- <ChevronUp size={12} />
- </button>
- <button
- type="button"
- disabled={disabled || index === selected.length - 1}
- onClick={() => move(index, 1)}
- className="text-gray-500 hover:text-white disabled:opacity-30 disabled:hover:text-gray-500"
- aria-label={`Move ${labelFor(value)} later`}
- >
- <ChevronDown size={12} />
- </button>
- {renderOptToggle(value, labelFor(value), isOptional(value)
- ? `${labelFor(value)} is non-blocking (~opt): an inconclusive verdict from it won't block the merge. Click to make it blocking.`
- : `${labelFor(value)} gates the merge. Click to make it non-blocking (~opt) — its inconclusive verdicts won't block the merge (a hard failure still does).`)}
- {renderMaxRounds(value, labelFor(value))}
- <button
- type="button"
- disabled={disabled}
- onClick={() => remove(value)}
- className="text-gray-500 hover:text-port-error"
- aria-label={`Remove ${labelFor(value)}`}
- >
- <X size={12} />
- </button>
- </span>
- ))}
+ <div className="flex flex-col gap-1">
+ <span className="text-xs text-gray-500">Reviewers (in order):</span>
+ {selected.length > 0 && (
+ <>
+ <div className={HEADER_CLASS} aria-hidden="true">
+ <span>#</span>
+ <span>Provider</span>
+ <span>Model</span>
+ <span>Optional</span>
+ <span className="text-center">Max</span>
+ <span className="sr-only">Remove</span>
+ </div>
+ <div className="flex flex-col gap-1.5 sm:gap-0.5">
+ {selected.map((value, index) => (
+ <div
+ key={value}
+ className={ROW_CLASS}
+ title={REVIEWER_OPTIONS.find(o => o.value === value)?.description}
+ >
+ <div className="flex items-center gap-0.5 col-span-2 sm:col-span-1">
+ <span className="text-port-accent font-mono text-xs">{index + 1}.</span>
+ <button
+ type="button"
+ disabled={disabled || index === 0}
+ onClick={() => move(index, -1)}
+ className="text-gray-500 hover:text-white disabled:opacity-30 disabled:hover:text-gray-500"
+ aria-label={`Move ${labelFor(value)} earlier`}
+ >
+ <ChevronUp size={12} />
+ </button>
+ <button
+ type="button"
+ disabled={disabled || index === selected.length - 1}
+ onClick={() => move(index, 1)}
+ className="text-gray-500 hover:text-white disabled:opacity-30 disabled:hover:text-gray-500"
+ aria-label={`Move ${labelFor(value)} later`}
+ >
+ <ChevronDown size={12} />
+ </button>
+ </div>
+ <span className="text-xs text-gray-300 col-span-2 sm:col-span-1 truncate">{labelFor(value)}</span>
+ <span className={CELL_LABEL_CLASS}>Model</span>
+ <div className="min-w-0">{renderModelCell(value)}</div>
+ <span className={CELL_LABEL_CLASS}>Optional</span>
+ <div>
+ {renderOptToggle(value, labelFor(value), isOptional(value)
+ ? `${labelFor(value)} is non-blocking (~opt): an inconclusive verdict from it won't block the merge. Click to make it blocking.`
+ : `${labelFor(value)} gates the merge. Click to make it non-blocking (~opt) — its inconclusive verdicts won't block the merge (a hard failure still does).`)}
+ </div>
+ <span className={CELL_LABEL_CLASS}>Max iterations</span>
+ <div>{renderMaxRounds(value, labelFor(value))}</div>
+ <div className="col-span-2 sm:col-span-1 justify-self-end">
+ <button
+ type="button"
+ disabled={disabled}
+ onClick={() => remove(value)}
+ className="text-gray-500 hover:text-port-error"
+ aria-label={`Remove ${labelFor(value)}`}
+ >
+ <X size={12} />
+ </button>
+ </div>
+ </div>
+ ))}
+ </div>
+ </>
+ )}
{selected.length === 0 && (
<span className="text-xs text-gray-600 italic">none — defaults to Copilot</span>
)}
</div>
{(selected.length > 0 || selectedUsernames.length > 0) && (
- <span className="text-[11px] text-gray-600 -mt-1">
- Tip: the <span className="font-mono text-port-warning">~opt</span> badge marks a reviewer <em>non-blocking</em> — it still runs and its findings are still fixed, but an inconclusive verdict (timeout / no result) won't block the merge. A hard failure still does. <span className="font-mono text-port-accent-2">~max</span> caps that reviewer's review → fix → re-review rounds (blank = its built-in cap, <span className="font-mono">0</span> = loop until clean) — a small cap keeps a slow local model affordable.
+ <span className="text-[11px] text-gray-600">
+ Tip: <span className="font-mono text-port-accent">Model</span> pins the model that reviewer runs (blank = its own default). The <span className="font-mono text-port-warning">~opt</span> badge marks a reviewer <em>non-blocking</em> — it still runs and its findings are still fixed, but an inconclusive verdict (timeout / no result) won't block the merge. A hard failure still does. <span className="font-mono text-port-accent-2">Max</span> caps that reviewer's review → fix → re-review rounds (blank = its built-in cap, <span className="font-mono">0</span> = loop until clean) — a small cap keeps a slow local model affordable.
</span>
)}
@@ -286,37 +450,48 @@ export default function ReviewerPicker({
)}
{/* GitHub reviewer usernames — arbitrary PR reviewers (bots/humans) that
- gate the merge. Appended to `--review-with` as `@user` tokens. */}
+ gate the merge. Appended to `--review-with` as `@user` tokens. Same row
+ grid as the keyed reviewers so the columns line up, minus reorder (their
+ order is fixed after the keyed list) and minus a Model cell. */}
<div className="flex flex-col gap-1.5 pt-1 border-t border-port-border/50">
- <div className="flex flex-wrap items-center gap-1.5">
- <span className="text-xs text-gray-500 mr-1">GitHub reviewers (gate merge):</span>
- {selectedUsernames.map((value) => (
- <span
- key={value}
- className="inline-flex items-center gap-1 pl-1.5 pr-1 py-0.5 bg-port-bg border border-port-accent/40 rounded text-xs text-gray-300"
- title="GitHub username requested as a PR reviewer to gate the merge"
- >
- <span className="text-port-accent font-mono">@</span>
- {value}
- {renderOptToggle(`@${value}`, `@${value}`, isOptional(`@${value}`)
- ? `@${value} is non-blocking (~opt): if it never submits a review, the merge isn't blocked. Click to make it blocking.`
- : `@${value} gates the merge. Click to make it non-blocking (~opt) — a missing/timed-out review from it won't block the merge.`)}
- {renderMaxRounds(`@${value}`, `@${value}`)}
- <button
- type="button"
- disabled={disabled}
- onClick={() => removeUsername(value)}
- className="text-gray-500 hover:text-port-error"
- aria-label={`Remove @${value}`}
+ <span className="text-xs text-gray-500">GitHub reviewers (gate merge):</span>
+ {selectedUsernames.length > 0 ? (
+ <div className="flex flex-col gap-1.5 sm:gap-0.5">
+ {selectedUsernames.map((value) => (
+ <div
+ key={value}
+ className={ROW_CLASS}
+ title="GitHub username requested as a PR reviewer to gate the merge"
>
- <X size={12} />
- </button>
- </span>
- ))}
- {selectedUsernames.length === 0 && (
- <span className="text-xs text-gray-600 italic">none</span>
- )}
- </div>
+ <span className="text-port-accent font-mono text-xs col-span-2 sm:col-span-1">@</span>
+ <span className="text-xs text-gray-300 col-span-2 sm:col-span-1 truncate">{value}</span>
+ <span className={CELL_LABEL_CLASS}>Model</span>
+ <div className="min-w-0">{renderModelCell(`@${value}`)}</div>
+ <span className={CELL_LABEL_CLASS}>Optional</span>
+ <div>
+ {renderOptToggle(`@${value}`, `@${value}`, isOptional(`@${value}`)
+ ? `@${value} is non-blocking (~opt): if it never submits a review, the merge isn't blocked. Click to make it blocking.`
+ : `@${value} gates the merge. Click to make it non-blocking (~opt) — a missing/timed-out review from it won't block the merge.`)}
+ </div>
+ <span className={CELL_LABEL_CLASS}>Max iterations</span>
+ <div>{renderMaxRounds(`@${value}`, `@${value}`)}</div>
+ <div className="col-span-2 sm:col-span-1 justify-self-end">
+ <button
+ type="button"
+ disabled={disabled}
+ onClick={() => removeUsername(value)}
+ className="text-gray-500 hover:text-port-error"
+ aria-label={`Remove @${value}`}
+ >
+ <X size={12} />
+ </button>
+ </div>
+ </div>
+ ))}
+ </div>
+ ) : (
+ <span className="text-xs text-gray-600 italic">none</span>
+ )}
<div className="flex items-center gap-1.5">
<span className="text-xs text-gray-600 font-mono">@</span>
<input
diff --git a/client/src/components/cos/ReviewerPicker.test.jsx b/client/src/components/cos/ReviewerPicker.test.jsx
index 0959371002..c544bdf974 100644
--- a/client/src/components/cos/ReviewerPicker.test.jsx
+++ b/client/src/components/cos/ReviewerPicker.test.jsx
@@ -234,4 +234,142 @@ describe('ReviewerPicker', () => {
}));
});
});
+
+ describe('per-reviewer Model column', () => {
+ // Shape mirrors useReviewerModelOptions()' return — the caller owns the fetch.
+ const modelOptions = {
+ optionsByReviewer: {
+ ollama: ['qwen2.5-coder:32b', 'codellama'],
+ lmstudio: ['local-model-a'],
+ codex: ['gpt-tier-a', 'gpt-tier-b'],
+ claude: ['claude-tier-a', 'qwen2.5-coder:32b'],
+ },
+ freeText: { codex: true, claude: true, lmstudio: false, ollama: false },
+ unavailable: { lmstudio: false, ollama: false },
+ loaded: true,
+ };
+
+ it('renders a Model control for each model-taking reviewer', () => {
+ render(<ReviewerPicker reviewers={['ollama', 'codex', 'copilot']} modelOptions={modelOptions} onChange={() => {}} />);
+ expect(screen.getByLabelText('Model for Ollama')).toBeInTheDocument();
+ expect(screen.getByLabelText('Model for Codex')).toBeInTheDocument();
+ // Copilot has no CLI and takes no model — no control, just the em dash.
+ expect(screen.queryByLabelText('Model for Copilot')).not.toBeInTheDocument();
+ });
+
+ it('does not render a Model control for a @username reviewer', () => {
+ render(<ReviewerPicker reviewers={['copilot']} usernames={['flaky-bot']} modelOptions={modelOptions} onChange={() => {}} />);
+ expect(screen.queryByLabelText('Model for @flaky-bot')).not.toBeInTheDocument();
+ });
+
+ it('renders a local backend as a closed select of its installed ids', () => {
+ render(<ReviewerPicker reviewers={['ollama']} modelOptions={modelOptions} onChange={() => {}} />);
+ const select = screen.getByLabelText('Model for Ollama');
+ expect(select.tagName).toBe('SELECT');
+ expect(screen.getByRole('option', { name: 'qwen2.5-coder:32b' })).toBeInTheDocument();
+ });
+
+ it('renders a CLI reviewer as a free-text input so an env-specific id can be typed', () => {
+ render(<ReviewerPicker reviewers={['claude']} modelOptions={modelOptions} onChange={() => {}} />);
+ // An Ollama-backed / Bedrock-form claude id can't be enumerated, so the
+ // control must accept a typed value rather than only a pick.
+ expect(screen.getByLabelText('Model for Claude').tagName).toBe('INPUT');
+ });
+
+ it('falls back to free-text when no options resolved (a closed empty select would be dead)', () => {
+ render(<ReviewerPicker reviewers={['ollama']} onChange={() => {}} />);
+ expect(screen.getByLabelText('Model for Ollama').tagName).toBe('INPUT');
+ });
+
+ it('shows an existing pin', () => {
+ render(<ReviewerPicker reviewers={['ollama']} reviewerModels={{ ollama: 'codellama' }} modelOptions={modelOptions} onChange={() => {}} />);
+ expect(screen.getByLabelText('Model for Ollama')).toHaveValue('codellama');
+ });
+
+ it('keeps an option for a pin the probe no longer lists', () => {
+ render(<ReviewerPicker reviewers={['ollama']} reviewerModels={{ ollama: 'uninstalled-model' }} modelOptions={modelOptions} onChange={() => {}} />);
+ // Without the synthesized option the select would render blank and read as
+ // "unset" while the value is in fact stored.
+ expect(screen.getByLabelText('Model for Ollama')).toHaveValue('uninstalled-model');
+ expect(screen.getByRole('option', { name: /uninstalled-model \(not installed\)/ })).toBeInTheDocument();
+ });
+
+ it('pins a model for a local reviewer', () => {
+ const onChange = vi.fn();
+ render(<ReviewerPicker reviewers={['ollama']} modelOptions={modelOptions} onChange={onChange} />);
+ fireEvent.change(screen.getByLabelText('Model for Ollama'), { target: { value: 'codellama' } });
+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ reviewerModels: { ollama: 'codellama' } }));
+ });
+
+ it('pins a typed model for a CLI reviewer', () => {
+ const onChange = vi.fn();
+ render(<ReviewerPicker reviewers={['codex']} modelOptions={modelOptions} onChange={onChange} />);
+ fireEvent.change(screen.getByLabelText('Model for Codex'), { target: { value: 'gpt-tier-b' } });
+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ reviewerModels: { codex: 'gpt-tier-b' } }));
+ });
+
+ it('clearing the field DELETES the pin rather than writing an empty id', () => {
+ const onChange = vi.fn();
+ render(<ReviewerPicker reviewers={['codex']} reviewerModels={{ codex: 'gpt-tier-a' }} modelOptions={modelOptions} onChange={onChange} />);
+ fireEvent.change(screen.getByLabelText('Model for Codex'), { target: { value: '' } });
+ // `''` would emit a `--model ` with no id; absent means "its own default".
+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ reviewerModels: {} }));
+ });
+
+ it('treats a whitespace-only entry as a clear, not a pin', () => {
+ const onChange = vi.fn();
+ render(<ReviewerPicker reviewers={['codex']} reviewerModels={{ codex: 'gpt-tier-a' }} modelOptions={modelOptions} onChange={onChange} />);
+ fireEvent.change(screen.getByLabelText('Model for Codex'), { target: { value: ' ' } });
+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ reviewerModels: {} }));
+ });
+
+ it('prunes the pin when its reviewer is removed', async () => {
+ const onChange = vi.fn();
+ const user = userEvent.setup();
+ render(<ReviewerPicker reviewers={['codex', 'ollama']} reviewerModels={{ ollama: 'codellama' }} modelOptions={modelOptions} onChange={onChange} />);
+ await user.click(screen.getByLabelText('Remove Ollama'));
+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ reviewers: ['codex'], reviewerModels: {} }));
+ });
+
+ it('keeps the model pin, the ~opt toggle, and the cap independent', async () => {
+ const onChange = vi.fn();
+ const user = userEvent.setup();
+ render(
+ <ReviewerPicker
+ reviewers={['ollama']}
+ reviewerModels={{ ollama: 'codellama' }}
+ reviewerMaxRounds={{ ollama: 1 }}
+ modelOptions={modelOptions}
+ onChange={onChange}
+ />
+ );
+ await user.click(screen.getByLabelText('Make Ollama non-blocking'));
+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({
+ optionalReviewers: ['ollama'],
+ reviewerMaxRounds: { ollama: 1 },
+ reviewerModels: { ollama: 'codellama' }
+ }));
+ });
+
+ it('preserves an untouched pin when another row changes', () => {
+ const onChange = vi.fn();
+ render(
+ <ReviewerPicker
+ reviewers={['codex', 'ollama']}
+ reviewerModels={{ codex: 'gpt-tier-a' }}
+ modelOptions={modelOptions}
+ onChange={onChange}
+ />
+ );
+ fireEvent.change(screen.getByLabelText('Model for Ollama'), { target: { value: 'codellama' } });
+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({
+ reviewerModels: { codex: 'gpt-tier-a', ollama: 'codellama' }
+ }));
+ });
+
+ it('reads a pin case-insensitively (legacy/hand-edited key casing)', () => {
+ render(<ReviewerPicker reviewers={['codex']} reviewerModels={{ Codex: 'gpt-tier-a' }} modelOptions={modelOptions} onChange={() => {}} />);
+ expect(screen.getByLabelText('Model for Codex')).toHaveValue('gpt-tier-a');
+ });
+ });
});
diff --git a/client/src/components/cos/TaskAddForm.jsx b/client/src/components/cos/TaskAddForm.jsx
index c34dc78414..d7374cd5fa 100644
--- a/client/src/components/cos/TaskAddForm.jsx
+++ b/client/src/components/cos/TaskAddForm.jsx
@@ -12,6 +12,8 @@ import { clickableProps } from '../../lib/a11yKeyboard';
import { slashdoLabel } from '../../lib/slashdoCatalog';
import ReviewerPicker from './ReviewerPicker';
import EffortSelect from './EffortSelect';
+import useReviewerModelOptions from '../../hooks/useReviewerModelOptions';
+import { reviewerModelsFromDefaults } from '../../lib/reviewerModels';
export default function TaskAddForm({ providers, apps, onTaskAdded, compact = false, defaultExpanded = false, defaultApp = '' }) {
const [newTask, setNewTask] = useState({ description: '', model: '', provider: '', effort: '', app: defaultApp });
@@ -26,6 +28,7 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
const [reviewUsernames, setReviewUsernames] = useState([]);
const [optionalReviewers, setOptionalReviewers] = useState([]);
const [reviewerMaxRounds, setReviewerMaxRounds] = useState({});
+ const [reviewerModels, setReviewerModels] = useState({});
const [reviewStopMode, setReviewStopMode] = useState(DEFAULT_REVIEW_STOP_MODE);
const [reviewerApplies, setReviewerApplies] = useState(false);
const [createJiraTicket, setCreateJiraTicket] = useState(false);
@@ -43,6 +46,9 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
// Bare slashdo command a quick-template pinned (`plan-task`), never a rendered
// `/do:x` string — see server/lib/slashdoInvocation.js for why.
const [slashdoCommand, setSlashdoCommand] = useState('');
+ // Resolved model lists for the reviewer table's Model column. Owned here (not by
+ // ReviewerPicker) so the picker stays fetch-free — see its `modelOptions` prop.
+ const reviewerModelOptions = useReviewerModelOptions();
const submittingRef = useRef(false);
const descriptionRef = useRef(null);
// Set by applyTemplate only when a template changes BOTH the app and the
@@ -70,6 +76,9 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
if (Array.isArray(d.usernames)) setReviewUsernames(d.usernames);
if (Array.isArray(d.optionalReviewers)) setOptionalReviewers(d.optionalReviewers);
if (d.reviewerMaxRounds && typeof d.reviewerMaxRounds === 'object' && !Array.isArray(d.reviewerMaxRounds)) setReviewerMaxRounds(d.reviewerMaxRounds);
+ // The defaults persist per-reviewer models as scalars; the picker takes the
+ // token-keyed map (see client/src/lib/reviewerModels.js).
+ setReviewerModels(reviewerModelsFromDefaults(d));
if (d.stopMode) setReviewStopMode(d.stopMode);
if (d.reviewerApplies === true) setReviewerApplies(true);
})
@@ -309,6 +318,7 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
usernames: openPR && prCompletion === 'review-then-merge' ? reviewUsernames : undefined,
optionalReviewers: openPR && prCompletion === 'review-then-merge' ? optionalReviewers : undefined,
reviewerMaxRounds: openPR && prCompletion === 'review-then-merge' ? reviewerMaxRounds : undefined,
+ reviewerModels: openPR && prCompletion === 'review-then-merge' ? reviewerModels : undefined,
reviewStopMode: openPR && prCompletion === 'review-then-merge' ? reviewStopMode : undefined,
reviewerApplies: openPR && prCompletion === 'review-then-merge' ? reviewerApplies : undefined,
screenshots: screenshots.length > 0 ? screenshots.map(s => s.path) : undefined,
@@ -562,13 +572,16 @@ export default function TaskAddForm({ providers, apps, onTaskAdded, compact = fa
usernames={reviewUsernames}
optionalReviewers={optionalReviewers}
reviewerMaxRounds={reviewerMaxRounds}
+ reviewerModels={reviewerModels}
+ modelOptions={reviewerModelOptions}
stopMode={reviewStopMode}
reviewerApplies={reviewerApplies}
- onChange={({ reviewers: r, usernames: u, optionalReviewers: o, reviewerMaxRounds: m, stopMode, reviewerApplies: ra }) => {
+ onChange={({ reviewers: r, usernames: u, optionalReviewers: o, reviewerMaxRounds: m, reviewerModels: rm, stopMode, reviewerApplies: ra }) => {
setReviewers(r);
setReviewUsernames(u);
setOptionalReviewers(o);
setReviewerMaxRounds(m);
+ setReviewerModels(rm);
setReviewStopMode(stopMode);
setReviewerApplies(ra);
}}
diff --git a/client/src/components/cos/TaskAddForm.test.jsx b/client/src/components/cos/TaskAddForm.test.jsx
index 6e65332321..184ccbdeb9 100644
--- a/client/src/components/cos/TaskAddForm.test.jsx
+++ b/client/src/components/cos/TaskAddForm.test.jsx
@@ -6,6 +6,9 @@ import TaskAddForm from './TaskAddForm';
const api = vi.hoisted(() => ({
getCosPopularTemplates: vi.fn(),
getCodeReviewDefaults: vi.fn(),
+ // Back the reviewer table's Model column (useReviewerModelOptions).
+ getLocalLlmStatus: vi.fn(),
+ getProviders: vi.fn(),
useCosTaskTemplate: vi.fn()
}));
@@ -16,6 +19,8 @@ describe('TaskAddForm responsive layout', () => {
vi.clearAllMocks();
api.getCosPopularTemplates.mockResolvedValue({ templates: [] });
api.getCodeReviewDefaults.mockResolvedValue(null);
+ api.getLocalLlmStatus.mockResolvedValue({ ollama: { models: [] }, lmstudio: { models: [] } });
+ api.getProviders.mockResolvedValue({ providers: [] });
api.useCosTaskTemplate.mockResolvedValue({ success: true });
});
@@ -65,6 +70,8 @@ describe('TaskAddForm quick templates', () => {
beforeEach(() => {
vi.clearAllMocks();
api.getCodeReviewDefaults.mockResolvedValue(null);
+ api.getLocalLlmStatus.mockResolvedValue({ ollama: { models: [] }, lmstudio: { models: [] } });
+ api.getProviders.mockResolvedValue({ providers: [] });
api.useCosTaskTemplate.mockResolvedValue({ success: true });
});
diff --git a/client/src/components/cos/constants.js b/client/src/components/cos/constants.js
index 81cbbc22b2..cc6529bfbf 100644
--- a/client/src/components/cos/constants.js
+++ b/client/src/components/cos/constants.js
@@ -191,6 +191,22 @@ export const REVIEWER_OPTIONS = [
];
export const LOCAL_LLM_REVIEWERS = ['lmstudio', 'ollama'];
+// CLI reviewers whose binary takes a `--model <id>` tier. Client mirror of
+// MODEL_CAPABLE_CLI_REVIEWERS in server/lib/cosValidation.js.
+export const MODEL_CAPABLE_CLI_REVIEWERS = ['codex', 'claude'];
+
+// Every reviewer whose model the user can pick per row in ReviewerPicker — the
+// model-capable CLIs plus the local-LLM backends. Client mirror of
+// MODEL_SELECTABLE_REVIEWERS in server/lib/cosValidation.js; keep in sync so the
+// picker only offers a Model cell where the server would keep the pin.
+// `copilot` and `@username` reviewers take no model.
+export const MODEL_SELECTABLE_REVIEWERS = [...MODEL_CAPABLE_CLI_REVIEWERS, ...LOCAL_LLM_REVIEWERS];
+
+// Upper bound on a pinned reviewer model id. Client mirror of
+// MAX_REVIEWER_MODEL_LENGTH in server/lib/cosValidation.js — a longer id is
+// dropped server-side, so the input must not accept one.
+export const MAX_REVIEWER_MODEL_LENGTH = 200;
+
// pr-watcher author gate (taskMetadata.prAuthorFilter). Mirrors
// PR_AUTHOR_FILTERS in server/lib/validation.js. 'self' = PRs opened by the
// gh-authenticated operator (or their automation); 'others' = external
diff --git a/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx b/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
index c7ccbcfe78..73b1a03714 100644
--- a/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
+++ b/client/src/components/cos/tabs/schedule/GlobalConfigControls.jsx
@@ -8,6 +8,8 @@ import InfoTooltip from '../../../ui/InfoTooltip';
import { FormField } from '../../../ui/FormField';
import { formatDateTime } from '../../../../utils/formatters';
import { useCodeReviewDefaults } from '../../../../hooks/useCodeReviewDefaults';
+import useReviewerModelOptions from '../../../../hooks/useReviewerModelOptions';
+import { reviewerModelsFromDefaults } from '../../../../lib/reviewerModels';
import ToggleSwitch from '../../../ToggleSwitch';
import { filterSelectableModels } from '../../../../utils/providers';
import EffortSelect from '../../EffortSelect';
@@ -17,6 +19,9 @@ import { INTERVAL_DESCRIPTIONS, toggleMetadataField } from './scheduleConstants'
export default function GlobalConfigControls({ taskType, config, onUpdate, onTrigger, onReset, category: _category, providers, apps, updating, setUpdating, allTaskTypes, improvementDisabled }) {
const reviewDefaults = useCodeReviewDefaults();
+ // Resolved model lists for the reviewer table's Model column (the picker itself
+ // never fetches — see its `modelOptions` prop).
+ const reviewerModelOptions = useReviewerModelOptions();
const [selectedType, setSelectedType] = useState(config.type);
const [selectedProviderId, setSelectedProviderId] = useState(config.providerId || '');
const [selectedModel, setSelectedModel] = useState(config.model || '');
@@ -435,16 +440,20 @@ export default function GlobalConfigControls({ taskType, config, onUpdate, onTri
usernames={config.taskMetadata?.usernames ?? reviewDefaults.usernames}
optionalReviewers={config.taskMetadata?.optionalReviewers ?? reviewDefaults.optionalReviewers}
reviewerMaxRounds={config.taskMetadata?.reviewerMaxRounds ?? reviewDefaults.reviewerMaxRounds}
+ // The task type's own pins when it has them, else the install's Code
+ // Review Defaults (persisted as `<reviewer>Model` scalars).
+ reviewerModels={config.taskMetadata?.reviewerModels ?? reviewerModelsFromDefaults(reviewDefaults)}
+ modelOptions={reviewerModelOptions}
stopMode={config.taskMetadata?.reviewStopMode || reviewDefaults.stopMode || DEFAULT_REVIEW_STOP_MODE}
reviewerApplies={config.taskMetadata?.reviewerApplies !== undefined
? (config.taskMetadata?.reviewerApplies === true || config.taskMetadata?.reviewerApplies === 'true')
: reviewDefaults.reviewerApplies}
disabled={updating}
- onChange={({ reviewers, usernames, optionalReviewers, reviewerMaxRounds, stopMode, reviewerApplies }) => {
+ onChange={({ reviewers, usernames, optionalReviewers, reviewerMaxRounds, reviewerModels, stopMode, reviewerApplies }) => {
// Drop the legacy single `reviewer` key so storage converges on `reviewers`.
const { reviewer: _reviewer, ...rest } = config.taskMetadata || {};
onUpdate(taskType, {
- taskMetadata: { ...rest, reviewers, usernames, optionalReviewers, reviewerMaxRounds, reviewStopMode: stopMode, reviewerApplies }
+ taskMetadata: { ...rest, reviewers, usernames, optionalReviewers, reviewerMaxRounds, reviewerModels, reviewStopMode: stopMode, reviewerApplies }
});
}}
/>
diff --git a/client/src/components/providers/CodeReviewDefaultsPanel.jsx b/client/src/components/providers/CodeReviewDefaultsPanel.jsx
index 2dcf618444..3d9052aae9 100644
--- a/client/src/components/providers/CodeReviewDefaultsPanel.jsx
+++ b/client/src/components/providers/CodeReviewDefaultsPanel.jsx
@@ -1,9 +1,10 @@
-import { useEffect, useId, useMemo, useState } from 'react';
+import { useEffect, useState } from 'react';
import { ShieldCheck } from 'lucide-react';
import toast from '../ui/Toast';
import * as api from '../../services/api';
-import { filterSelectableModels } from '../../utils/providers';
import ReviewerPicker from '../cos/ReviewerPicker';
+import useReviewerModelOptions from '../../hooks/useReviewerModelOptions';
+import { reviewerModelsFromDefaults, reviewerModelsToDefaults } from '../../lib/reviewerModels';
import {
DEFAULT_REVIEWERS,
DEFAULT_REVIEW_STOP_MODE,
@@ -12,98 +13,45 @@ import {
// Global Code Review Defaults — the chain the Review Loop uses when a task or
// task-type config didn't pin its own reviewers. Lives at the top of the AI
// Providers page so adding a new provider and pointing reviews at it stay in
-// the same flow. Per-backend model dropdowns are shown only when the
-// corresponding reviewer is in the chain: the local-LLM (LM Studio / Ollama)
-// lists come from `/api/local-llm/status` so they reflect what's actually
-// installed, while the Codex tier list comes from the provider catalog
-// (`/api/providers`) since Codex is a CLI reviewer, not a local backend.
+// the same flow. Every per-reviewer control (model, `~opt`, `~max`) now lives in
+// the shared ReviewerPicker table (#3133), so this panel owns only the fetch of
+// the model option lists (via useReviewerModelOptions) and the save.
export default function CodeReviewDefaultsPanel() {
- const lmStudioSelectId = useId();
- const ollamaSelectId = useId();
- const codexSelectId = useId();
- const claudeSelectId = useId();
- const claudeListId = useId();
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [reviewers, setReviewers] = useState(DEFAULT_REVIEWERS);
const [usernames, setUsernames] = useState([]);
const [optionalReviewers, setOptionalReviewers] = useState([]);
const [reviewerMaxRounds, setReviewerMaxRounds] = useState({});
+ const [reviewerModels, setReviewerModels] = useState({});
const [stopMode, setStopMode] = useState(DEFAULT_REVIEW_STOP_MODE);
const [reviewerApplies, setReviewerApplies] = useState(false);
- const [lmstudioModel, setLmstudioModel] = useState('');
- const [ollamaModel, setOllamaModel] = useState('');
- const [codexModel, setCodexModel] = useState('');
- const [claudeModel, setClaudeModel] = useState('');
- const [localLlmStatus, setLocalLlmStatus] = useState(null);
- const [codexProvider, setCodexProvider] = useState(null);
- const [claudeProvider, setClaudeProvider] = useState(null);
+ const modelOptions = useReviewerModelOptions();
useEffect(() => {
let cancelled = false;
- Promise.all([
- api.getCodeReviewDefaults({ silent: true }).catch(() => null),
- api.getLocalLlmStatus({ silent: true }).catch(() => null),
- api.getProviders({ silent: true }).catch(() => null),
- ]).then(([defaults, status, providers]) => {
- if (cancelled) return;
- if (defaults) {
- setReviewers(Array.isArray(defaults.reviewers) && defaults.reviewers.length ? defaults.reviewers : DEFAULT_REVIEWERS);
- setUsernames(Array.isArray(defaults.usernames) ? defaults.usernames : []);
- setOptionalReviewers(Array.isArray(defaults.optionalReviewers) ? defaults.optionalReviewers : []);
- setReviewerMaxRounds(defaults.reviewerMaxRounds && typeof defaults.reviewerMaxRounds === 'object' && !Array.isArray(defaults.reviewerMaxRounds)
- ? defaults.reviewerMaxRounds
- : {});
- setStopMode(defaults.stopMode || DEFAULT_REVIEW_STOP_MODE);
- setReviewerApplies(defaults.reviewerApplies === true);
- setLmstudioModel(defaults.lmstudioModel || '');
- setOllamaModel(defaults.ollamaModel || '');
- setCodexModel(defaults.codexModel || '');
- setClaudeModel(defaults.claudeModel || '');
- }
- setLocalLlmStatus(status || null);
- // Codex and Claude are CLI reviewers, so their selectable model tiers come
- // from the provider catalog (not the local-LLM status probe the others use).
- const providerList = providers?.providers || [];
- setCodexProvider(providerList.find((p) => p.id === 'codex') || null);
- setClaudeProvider(providerList.find((p) => p.id === 'claude-code') || null);
- setLoading(false);
- });
+ api.getCodeReviewDefaults({ silent: true })
+ .catch(() => null)
+ .then((defaults) => {
+ if (cancelled) return;
+ if (defaults) {
+ setReviewers(Array.isArray(defaults.reviewers) && defaults.reviewers.length ? defaults.reviewers : DEFAULT_REVIEWERS);
+ setUsernames(Array.isArray(defaults.usernames) ? defaults.usernames : []);
+ setOptionalReviewers(Array.isArray(defaults.optionalReviewers) ? defaults.optionalReviewers : []);
+ setReviewerMaxRounds(defaults.reviewerMaxRounds && typeof defaults.reviewerMaxRounds === 'object' && !Array.isArray(defaults.reviewerMaxRounds)
+ ? defaults.reviewerMaxRounds
+ : {});
+ setReviewerModels(reviewerModelsFromDefaults(defaults));
+ setStopMode(defaults.stopMode || DEFAULT_REVIEW_STOP_MODE);
+ setReviewerApplies(defaults.reviewerApplies === true);
+ }
+ setLoading(false);
+ });
return () => { cancelled = true; };
}, []);
- const needsLmStudio = reviewers.includes('lmstudio');
- const needsOllama = reviewers.includes('ollama');
- const needsCodex = reviewers.includes('codex');
- const needsClaude = reviewers.includes('claude');
-
- const lmStudioModels = useMemo(
- () => localLlmStatus?.lmstudio?.models?.map((m) => m.id).filter(Boolean) || [],
- [localLlmStatus]
- );
- const ollamaModels = useMemo(
- () => localLlmStatus?.ollama?.models?.map((m) => m.id).filter(Boolean) || [],
- [localLlmStatus]
- );
- const codexModels = useMemo(
- () => codexProvider ? filterSelectableModels(codexProvider.models || [codexProvider.defaultModel]) : [],
- [codexProvider]
- );
- // Claude reviewer suggestions span BOTH usage modes: the `claude-code` provider
- // tiers (normal Claude) and installed Ollama models (an Ollama-backed `claude`
- // reviewer, where `--model` selects the local model). Deduped, order-preserving.
- // A datalist (not a hard <select>) so a user whose Ollama model id isn't in the
- // probe list can still type it — ollama-backed model ids are arbitrary.
- const claudeModelSuggestions = useMemo(() => {
- const tiers = claudeProvider ? filterSelectableModels(claudeProvider.models || [claudeProvider.defaultModel]) : [];
- return Array.from(new Set([...tiers, ...ollamaModels].filter(Boolean)));
- }, [claudeProvider, ollamaModels]);
-
const handleSave = async () => {
setSaving(true);
- // Empty-string model fields round-trip via the schema's `emptyToUndefined`
- // preprocess, so an unselected dropdown clears the persisted model rather
- // than writing the literal "" the <select> renders.
const payload = {
reviewers,
usernames,
@@ -111,10 +59,7 @@ export default function CodeReviewDefaultsPanel() {
reviewerMaxRounds,
stopMode,
reviewerApplies,
- lmstudioModel: lmstudioModel || undefined,
- ollamaModel: ollamaModel || undefined,
- codexModel: codexModel || undefined,
- claudeModel: claudeModel.trim() || undefined,
+ ...reviewerModelsToDefaults(reviewerModels),
};
const ok = await api.updateSettings({ codeReview: payload }, { silent: true })
.then(() => true)
@@ -123,35 +68,6 @@ export default function CodeReviewDefaultsPanel() {
if (ok) toast.success('Code Review Defaults saved');
};
- // `emptyMessage` overrides the default local-LLM "install a model" hint so the
- // Codex picker (a CLI reviewer, not a local backend) shows relevant guidance.
- const renderModelPicker = (label, backend, value, setValue, options, selectId, emptyMessage = null) => {
- const status = localLlmStatus?.[backend];
- const unavailable = status && status.available === false;
- return (
- <div className="flex flex-col gap-1 mt-2">
- <label htmlFor={selectId} className="text-xs text-gray-500">{label} model:</label>
- {options.length > 0 ? (
- <select
- id={selectId}
- value={value}
- onChange={(e) => setValue(e.target.value)}
- className="px-2 py-1 bg-port-bg border border-port-border rounded text-xs text-gray-300 min-h-[28px] max-w-md"
- >
- <option value="">— pick a model —</option>
- {options.map((id) => <option key={id} value={id}>{id}</option>)}
- </select>
- ) : (
- <div className="text-xs text-amber-400/80">
- {emptyMessage || (unavailable
- ? `${label} backend isn't reachable — start it from Settings → Local LLMs to load models.`
- : `No ${label} models installed yet — add one in Settings → Local LLMs.`)}
- </div>
- )}
- </div>
- );
- };
-
return (
<div className="bg-port-card border border-port-border rounded-xl p-4 space-y-3">
<div className="flex items-center gap-2">
@@ -159,7 +75,7 @@ export default function CodeReviewDefaultsPanel() {
<h2 className="text-base font-semibold text-white">Code Review Defaults</h2>
</div>
<p className="text-xs text-gray-500">
- Default Review Loop reviewer chain — used by ad-hoc CoS tasks and task-type schedules that haven't pinned their own. Local-LLM reviewers route the diff through PortOS's local code-review endpoint; the Codex and Claude reviewers invoke their CLI directly. Each runs the model selected below (Claude also supports an Ollama-backed CLI for local-only setups).
+ Default Review Loop reviewer chain — used by ad-hoc CoS tasks and task-type schedules that haven't pinned their own. Local-LLM reviewers route the diff through PortOS's local code-review endpoint; the Codex and Claude reviewers invoke their CLI directly. Each runs the model pinned on its row (Claude also supports an Ollama-backed CLI for local-only setups — type one of your installed Ollama models).
</p>
{loading ? (
@@ -171,43 +87,22 @@ export default function CodeReviewDefaultsPanel() {
usernames={usernames}
optionalReviewers={optionalReviewers}
reviewerMaxRounds={reviewerMaxRounds}
+ reviewerModels={reviewerModels}
+ modelOptions={modelOptions}
stopMode={stopMode}
reviewerApplies={reviewerApplies}
disabled={saving}
- onChange={({ reviewers: r, usernames: u, optionalReviewers: o, reviewerMaxRounds: m, stopMode: s, reviewerApplies: a }) => {
+ onChange={({ reviewers: r, usernames: u, optionalReviewers: o, reviewerMaxRounds: m, reviewerModels: dm, stopMode: s, reviewerApplies: a }) => {
setReviewers(r);
setUsernames(u);
setOptionalReviewers(o);
setReviewerMaxRounds(m);
+ setReviewerModels(dm);
setStopMode(s);
setReviewerApplies(a);
}}
/>
- {needsLmStudio && renderModelPicker('LM Studio', 'lmstudio', lmstudioModel, setLmstudioModel, lmStudioModels, lmStudioSelectId)}
- {needsOllama && renderModelPicker('Ollama', 'ollama', ollamaModel, setOllamaModel, ollamaModels, ollamaSelectId)}
- {needsCodex && renderModelPicker('Codex', 'codex', codexModel, setCodexModel, codexModels, codexSelectId, 'No selectable Codex models — configure the Codex provider on the AI Providers page (or leave blank to use the Codex CLI default).')}
- {needsClaude && (
- <div className="flex flex-col gap-1 mt-2">
- <label htmlFor={claudeSelectId} className="text-xs text-gray-500">Claude model (optional):</label>
- <input
- id={claudeSelectId}
- type="text"
- list={claudeListId}
- value={claudeModel}
- onChange={(e) => setClaudeModel(e.target.value)}
- placeholder="Leave blank for the Claude CLI default"
- className="px-2 py-1 bg-port-bg border border-port-border rounded text-xs text-gray-300 min-h-[28px] max-w-md"
- />
- <datalist id={claudeListId}>
- {claudeModelSuggestions.map((id) => <option key={id} value={id}>{id}</option>)}
- </datalist>
- <p className="text-xs text-gray-500">
- Passed as <code>claude --model &lt;id&gt;</code>. Pick a Claude tier, or — if you run an Ollama-backed <code>claude</code> — type or pick one of your installed Ollama models.
- </p>
- </div>
- )}
-
<div className="flex justify-end">
<button
type="button"
@@ -223,4 +118,3 @@ export default function CodeReviewDefaultsPanel() {
</div>
);
}
-
diff --git a/client/src/hooks/README.md b/client/src/hooks/README.md
index 89a35ea3d1..7cdcadf45c 100644
--- a/client/src/hooks/README.md
+++ b/client/src/hooks/README.md
@@ -151,6 +151,7 @@ grep -i "what you want to do" client/src/hooks/README.md
| `usePostSession` | Post-render callback scheduling. | Generic post-action chaining. |
| `useRecordMerge` | Duplicate Universe/Series merge flow: open → dry-run preview → resolve field conflicts → execute, with an `onMerged` refresh callback. Drives `<MergeModal>`. | Surfacing the merge-duplicates UI anywhere (Sharing → Duplicates, Universes page). Don't re-implement the preview/execute dance. |
| `useProviderModels` | AI providers + two-step provider→model selection. | Any UI that picks a provider + model. |
+| `useReviewerModelOptions` | Selectable model ids per model-taking reviewer for `ReviewerPicker`'s Model column — local-LLM ids from `/api/local-llm/status`, codex/claude tiers from `/api/providers` (claude's list also spans installed Ollama ids for an Ollama-backed CLI). Returns `{ optionsByReviewer, freeText, unavailable, loaded }`. | Every surface that renders `ReviewerPicker` (Code Review Defaults, TaskAddForm, ScheduleTab, SlashDoRunDrawer) — the picker never fetches; pass this as its `modelOptions`. |
| `useLocalModels` | Live installed Ollama/LM Studio model ids per backend + the server's editorial recommendation. | Model pickers that must show currently-installed local models (not just a provider's stale stored `models`). Fold in via `mergeModelLists` + `localBackendForProvider`. |
| `useVisionModelIds` | `{ idsByProvider, loaded }` — vision-capable model ids the server reports (Ollama `/api/show` + LM Studio `type:'vlm'`), keyed by the provider id that serves them (`{ ollama: Set, lmstudio: Set }`), `null` until fetched; `loaded` flips once the fetch settles. Drops `backend:'cli'` rows (a blanket per-provider claim, not a per-model fact) and never vouches for a provider the server didn't enumerate. | Any VISION model picker — pass `idsByProvider` to `visionLocalModelFilter` / `assignmentModelOptions` so a new multimodal family (`gemma4`) isn't hidden by the stale client id regex, and so an installed VLM shows even when the provider's stored `models` snapshot is stale; gate any "none installed" messaging on `loaded` and on the provider being a local backend. |
| `useTheme` | Dark/light theme + paired-theme switching. | Theme picker. |
diff --git a/client/src/hooks/index.js b/client/src/hooks/index.js
index bb56ba064c..24ca22f141 100644
--- a/client/src/hooks/index.js
+++ b/client/src/hooks/index.js
@@ -45,6 +45,7 @@ export { default as useLocalModels } from './useLocalModels.js';
export { default as useVisionModelIds } from './useVisionModelIds.js';
export { default as usePreviewRoute } from './usePreviewRoute.js';
export { default as useProviderModels } from './useProviderModels.js';
+export { default as useReviewerModelOptions } from './useReviewerModelOptions.js';
export { default as useRowDraft } from './useRowDraft.js';
export { default as useTheme } from './useTheme.js';
export { default as useUniverse } from './useUniverse.js';
diff --git a/client/src/hooks/useCodeReviewDefaults.jsx b/client/src/hooks/useCodeReviewDefaults.jsx
index 21a90dab35..715d89593d 100644
--- a/client/src/hooks/useCodeReviewDefaults.jsx
+++ b/client/src/hooks/useCodeReviewDefaults.jsx
@@ -7,6 +7,10 @@ import { DEFAULT_REVIEWERS, DEFAULT_REVIEW_STOP_MODE } from '../components/cos/c
// instead of the hardcoded `['copilot']`. Returned shape mirrors the server's
// `getCodeReviewDefaults()` so a consumer can rely on the same field names
// regardless of whether it reads context or calls the API directly.
+// Mirrors the server's `pickCodeReviewDefaults` shape, including all four
+// `<reviewer>Model` scalars — the reviewer table's Model column reads them via
+// `reviewerModelsFromDefaults`, so omitting the two CLI scalars here would silently
+// blank a configured codex/claude pin on every consumer of this context.
const FALLBACK = Object.freeze({
reviewers: DEFAULT_REVIEWERS,
usernames: [],
@@ -16,6 +20,8 @@ const FALLBACK = Object.freeze({
reviewerApplies: false,
lmstudioModel: null,
ollamaModel: null,
+ codexModel: null,
+ claudeModel: null,
});
const CodeReviewDefaultsContext = createContext(FALLBACK);
@@ -43,6 +49,8 @@ export function CodeReviewDefaultsProvider({ children }) {
reviewerApplies: d.reviewerApplies === true,
lmstudioModel: d.lmstudioModel || null,
ollamaModel: d.ollamaModel || null,
+ codexModel: d.codexModel || null,
+ claudeModel: d.claudeModel || null,
});
})
.catch(() => {});
diff --git a/client/src/hooks/useReviewerModelOptions.js b/client/src/hooks/useReviewerModelOptions.js
new file mode 100644
index 0000000000..da3797779c
--- /dev/null
+++ b/client/src/hooks/useReviewerModelOptions.js
@@ -0,0 +1,94 @@
+import { useEffect, useMemo, useState } from 'react';
+import * as api from '../services/api';
+import { filterSelectableModels } from '../utils/providers';
+import { MODEL_SELECTABLE_REVIEWERS } from '../components/cos/constants';
+
+/**
+ * Selectable model ids per model-taking reviewer, for `ReviewerPicker`'s Model
+ * column. One hook so all four picker surfaces (Code Review Defaults, TaskAddForm,
+ * ScheduleTab, SlashDoRunDrawer) offer the SAME options instead of only the
+ * settings panel having them (#3133).
+ *
+ * Two sources, because the two reviewer kinds are different things:
+ * - `lmstudio` / `ollama` ids come from `/api/local-llm/status`, so they reflect
+ * what's actually installed rather than a provider's stale stored `models`.
+ * - `codex` / `claude` tiers come from the provider catalog (`/api/providers`) —
+ * these are CLI reviewers, not local backends, so there's nothing to probe.
+ *
+ * The `claude` list spans BOTH usage modes: the `claude-code` provider tiers and
+ * the installed Ollama ids (an Ollama-backed `claude` CLI, where `--model` selects
+ * the local model). Deduped, order-preserving.
+ *
+ * `freeText` marks a reviewer whose picker must accept a typed id, not just a
+ * pick: an Ollama-backed `claude` can run any locally-installed id, and a
+ * Bedrock/Vertex install needs its environment's own id form, neither of which a
+ * catalog can enumerate. Consumers render a `<datalist>` for those.
+ *
+ * `unavailable` distinguishes "backend is down" from "backend has no models" so
+ * the empty state can say the useful thing. Absent = not a local backend.
+ * `loaded` flips once both fetches settle, so a consumer can tell "no options
+ * yet" from "genuinely no options" (an empty list is a real answer, not a
+ * pre-fetch placeholder).
+ *
+ * @returns {{ optionsByReviewer: Record<string, string[]>, freeText: Record<string, boolean>, unavailable: Record<string, boolean>, loaded: boolean }}
+ */
+export default function useReviewerModelOptions() {
+ const [localStatus, setLocalStatus] = useState(null);
+ const [providers, setProviders] = useState(null);
+ const [loaded, setLoaded] = useState(false);
+
+ useEffect(() => {
+ let cancelled = false;
+ // Secondary controls — a failed fetch degrades the Model column to free-text
+ // rather than toasting over whatever page hosts the picker.
+ Promise.all([
+ api.getLocalLlmStatus({ silent: true }).catch(() => null),
+ api.getProviders({ silent: true }).catch(() => null),
+ ]).then(([status, providerData]) => {
+ if (cancelled) return;
+ setLocalStatus(status || null);
+ setProviders(providerData?.providers || []);
+ setLoaded(true);
+ });
+ return () => { cancelled = true; };
+ }, []);
+
+ return useMemo(() => {
+ const localIds = (backend) => (localStatus?.[backend]?.models || [])
+ .map((m) => m.id || m.name)
+ .filter(Boolean);
+ const providerTiers = (id) => {
+ const provider = (providers || []).find((p) => p.id === id);
+ if (!provider) return [];
+ // `models` may be empty on a CLI provider configured with only a
+ // defaultModel — `[]` is truthy, so a bare `||` wouldn't fall through.
+ return filterSelectableModels(provider.models?.length ? provider.models : [provider.defaultModel]);
+ };
+
+ const ollama = localIds('ollama');
+ const optionsByReviewer = {
+ lmstudio: localIds('lmstudio'),
+ ollama,
+ codex: providerTiers('codex'),
+ // Claude tiers first (the common case), then installed Ollama ids for an
+ // Ollama-backed `claude`. Deduped, order-preserving.
+ claude: Array.from(new Set([...providerTiers('claude-code'), ...ollama].filter(Boolean))),
+ };
+
+ return {
+ optionsByReviewer,
+ // A local backend's id list is authoritative (we probed it), so keep those
+ // pickers a closed `<select>`. The two CLI reviewers are free-text: `claude`
+ // for the Ollama-backed / Bedrock-form cases above, and `codex` because its
+ // catalog is a stored snapshot that can lag a newly-released tier.
+ freeText: { codex: true, claude: true, lmstudio: false, ollama: false },
+ unavailable: {
+ lmstudio: localStatus?.lmstudio?.available === false,
+ ollama: localStatus?.ollama?.available === false,
+ },
+ loaded,
+ // Exposed so a consumer can assert it covers every model-taking reviewer.
+ reviewers: MODEL_SELECTABLE_REVIEWERS,
+ };
+ }, [localStatus, providers, loaded]);
+}
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index c715c6bea3..cf01a3d01e 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -43,6 +43,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `editorialRoadmap.js` | `projectAnalyzedPoints` (aggregate roadmap → analyzed chart points with arc-position `frac`) + `dominant` (most-frequent string). Shared by EditorialRoadmapPanel and the Reader Map page. |
| `grokVideoClip.js` | Mirror of `server/lib/grokVideoClip.js` — `GROK_VIDEO_DURATIONS` (`[6, 10]`) + `GROK_VIDEO_DEFAULT_DURATION`, the clip lengths grok's `image_to_video` actually delivers. |
| `imageCleaners.js` | Mirror of `resolveCleanersFromConfig` from `server/lib/imageClean.js`. Reads `{cleanC2PA, denoise}` off a per-mode settings record. `cleanC2PA` defaults are mode-aware (on for `codex` + `external` — the backends that emit C2PA chunks today — off otherwise, as an allow-list rather than a deny-list); `denoise` defaults off everywhere (lossy, opt-in only). |
+| `reviewerModels.js` | `reviewerModelsFromDefaults` / `reviewerModelsToDefaults` — adapt the Code Review Defaults' per-reviewer model SCALARS (`codexModel`, `ollamaModel`, …) to and from the token-keyed map `ReviewerPicker`'s Model column takes. Mirrors `reviewerModelsFromDefaults` in `server/lib/cosValidation.js`. |
| `runnerFamilies.js` | Mirror of `server/lib/runners.js`. |
| `slashdoCatalog.js` | Mirror of `server/lib/slashdoCatalog.js` — the launchable slashdo workflows (`SLASHDO_WORKFLOWS`, `slashdoWorkflowsForApp(isSwiftApp)`, `SLASHDO_APP_TYPES`) driving the app-overview Agent Operations buttons. Adds only the per-button Tailwind classes; pinned by `server/lib/slashdoCatalog.test.js`. |
| `issueLength.js` | Mirror of `server/lib/issueLength.js`. |
diff --git a/client/src/lib/index.js b/client/src/lib/index.js
index 0933f50452..3ff7a1abe7 100644
--- a/client/src/lib/index.js
+++ b/client/src/lib/index.js
@@ -36,6 +36,7 @@ export * from './issueLength.js';
export * from './muscriptorModels.js';
export * from './pipelineImageDefaults.js';
export * from './reverseOutlineGrid.js';
+export * from './reviewerModels.js';
export * from './runnerFamilies.js';
export * from './slashdoCatalog.js';
export * from './videoGenParams.js';
diff --git a/client/src/lib/reviewerModels.js b/client/src/lib/reviewerModels.js
new file mode 100644
index 0000000000..46cadc679a
--- /dev/null
+++ b/client/src/lib/reviewerModels.js
@@ -0,0 +1,37 @@
+import { MODEL_SELECTABLE_REVIEWERS } from '../components/cos/constants';
+
+/**
+ * Adapters between the two shapes a per-reviewer model pin takes.
+ *
+ * The Code Review Defaults settings slice persists ONE SCALAR PER REVIEWER
+ * (`codexModel`, `claudeModel`, `lmstudioModel`, `ollamaModel`) and stays that way
+ * — the encoding crosses installs, so changing it would need a migration for zero
+ * gain. Everything else (the ReviewerPicker table, per-task metadata, the slashdo
+ * token builders) speaks the token-keyed MAP shape the `~opt` / `~max` controls
+ * already use, so the two need one documented conversion point rather than a
+ * hand-rolled loop in each consumer.
+ *
+ * Server mirror: `reviewerModelsFromDefaults` in `server/lib/cosValidation.js`.
+ */
+
+/** Scalars → `{ codex: 'gpt-…', ollama: 'qwen…' }`. Blank/absent scalars are omitted. */
+export function reviewerModelsFromDefaults(defaults) {
+ const out = {};
+ for (const reviewer of MODEL_SELECTABLE_REVIEWERS) {
+ const model = defaults?.[`${reviewer}Model`];
+ if (typeof model === 'string' && model.trim()) out[reviewer] = model.trim();
+ }
+ return out;
+}
+
+/**
+ * Map → scalars, for a settings PATCH. EVERY model-selectable reviewer gets a key,
+ * so an unpinned one sends `undefined` and the schema's `emptyToUndefined`
+ * preprocess CLEARS the stored scalar. Omitting absent keys instead would leave a
+ * stale model persisted after the user cleared the field.
+ */
+export function reviewerModelsToDefaults(models) {
+ return Object.fromEntries(
+ MODEL_SELECTABLE_REVIEWERS.map((reviewer) => [`${reviewer}Model`, models?.[reviewer] || undefined])
+ );
+}
diff --git a/server/lib/cosValidation.js b/server/lib/cosValidation.js
index 356f03d647..926f2f8d7b 100644
--- a/server/lib/cosValidation.js
+++ b/server/lib/cosValidation.js
@@ -43,6 +43,13 @@ export const LOCAL_LLM_REVIEWERS = ['lmstudio', 'ollama'];
// server-side by `POST /api/code-review/local`. Add a reviewer here (and a
// matching `<reviewer>Model` schema field) when its CLI gains model selection.
export const MODEL_CAPABLE_CLI_REVIEWERS = ['codex', 'claude'];
+// Every reviewer whose model the user can PICK in the UI: the model-capable CLIs
+// above (threaded into the follow-up prompt as `<reviewer> --model <id>`) plus the
+// local-LLM backends (whose id is injected server-side by
+// `POST /api/code-review/local`, or emitted as slashdo's `[<model>]` bracket for a
+// claim flow). `copilot` and `@username` reviewers are excluded — neither is a
+// model-taking backend, matching slashdo rejecting `copilot[…]`/`@login[…]`.
+export const MODEL_SELECTABLE_REVIEWERS = [...MODEL_CAPABLE_CLI_REVIEWERS, ...LOCAL_LLM_REVIEWERS];
// Stop-mode for the multi-reviewer loop (slashdo `--review-stop-on-*`).
export const REVIEW_STOP_MODES = ['all', 'on-findings', 'on-clean'];
export const DEFAULT_REVIEW_STOP_MODE = 'all';
@@ -216,6 +223,86 @@ export function resolveReviewerMaxRounds(metadataMap, defaultMap) {
: (normalizeReviewerMaxRounds(defaultMap) || {});
}
+// Upper bound on a pinned reviewer model id. Generous (Bedrock/Ollama ids get
+// long) but present so a hand-edited settings.json can't smuggle in a blob that
+// then round-trips the TASKS.md store.
+export const MAX_REVIEWER_MODEL_LENGTH = 200;
+
+// Reviewers whose slashdo `--review-with` entry accepts a `[<model>]` bracket
+// (`lib/multi-reviewer-loop.md`: codex/claude/agy/grok/ollama). PortOS's
+// `lmstudio` reviewer has NO slashdo counterpart — it's served by
+// `POST /api/code-review/local`, which takes the model in its request body — so a
+// pinned lmstudio model never becomes a bracket, and `copilot`/`@login` entries
+// reject one outright.
+export const BRACKET_MODEL_REVIEWERS = MODEL_SELECTABLE_REVIEWERS.filter(r => r !== 'lmstudio');
+
+/**
+ * Per-reviewer model pins — the model id ONE reviewer runs with, keyed by the
+ * same emitted `--review-with` token as `normalizeOptionalReviewers` /
+ * `normalizeReviewerMaxRounds` (e.g. `{ codex: 'gpt-5.6-sol', ollama: 'qwen2.5:7b' }`).
+ *
+ * The value is free-text on purpose: a reviewer CLI is spawned by the *agent*,
+ * not by PortOS's argv builder, so the id the user needs is environment-specific
+ * (a Bedrock-form Claude id on a Bedrock box, an installed Ollama model for an
+ * Ollama-backed `claude`). We validate the shape, not the catalog.
+ *
+ * Only MODEL_SELECTABLE_REVIEWERS can carry a pin — `copilot` has no CLI and a
+ * `@username` reviewer is a human/bot, mirroring slashdo rejecting `copilot[…]`
+ * and `@login[…]`. An absent key means "let that reviewer pick its own default",
+ * which is NOT the same as an empty string, so a blank/whitespace value is
+ * DROPPED rather than persisted as `''` (a `--model ` with no id would break the
+ * reviewer invocation). Non-object input → undefined, so an omitted field isn't
+ * persisted as an empty override.
+ */
+export function normalizeReviewerModels(map) {
+ if (!map || typeof map !== 'object' || Array.isArray(map)) return undefined;
+ const out = Object.create(null);
+ for (const [rawKey, rawValue] of Object.entries(map)) {
+ const token = normalizeReviewerToken(rawKey);
+ if (!token || !MODEL_SELECTABLE_REVIEWERS.includes(token)) continue;
+ if (typeof rawValue !== 'string') continue;
+ const model = rawValue.trim();
+ if (!model || model.length > MAX_REVIEWER_MODEL_LENGTH) continue;
+ // First occurrence wins for two spellings of one reviewer — mirrors the
+ // sibling normalizers' dedupe.
+ if (Object.prototype.hasOwnProperty.call(out, token)) continue;
+ out[token] = model;
+ }
+ return { ...out };
+}
+
+/**
+ * Resolve per-reviewer model pins with task-over-default precedence: a
+ * task-level map (even explicitly empty) overrides the Code Review Defaults;
+ * only fall back to the defaults when the task didn't pin its own. Mirrors
+ * `resolveReviewerMaxRounds`.
+ */
+export function resolveReviewerModels(metadataMap, defaultMap) {
+ const isMap = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
+ return isMap(metadataMap)
+ ? (normalizeReviewerModels(metadataMap) || {})
+ : (normalizeReviewerModels(defaultMap) || {});
+}
+
+/**
+ * Fold the Code Review Defaults' per-reviewer model SCALARS
+ * (`codexModel` / `claudeModel` / `lmstudioModel` / `ollamaModel`) into the
+ * token-keyed map shape the resolvers and the picker UI both speak.
+ *
+ * The scalars are the persisted settings encoding and stay that way — they cross
+ * installs, and rewriting them to a map would need a migration for zero gain.
+ * This is the one adapter between the two shapes; everything downstream works in
+ * map form.
+ */
+export function reviewerModelsFromDefaults(defaults) {
+ const out = {};
+ for (const r of MODEL_SELECTABLE_REVIEWERS) {
+ const model = defaults?.[`${r}Model`];
+ if (typeof model === 'string' && model.trim()) out[r] = model.trim();
+ }
+ return out;
+}
+
/**
* Build the set of lowercased optional-reviewer tokens for a fast membership
* test in the builders. Tolerates the raw (unnormalized) list.
@@ -236,16 +323,36 @@ function reviewerMaxRoundsLookup(reviewerMaxRounds) {
}
/**
- * Append slashdo's per-entry suffixes to `token` in slashdo's canonical storage
- * order — `~opt` first, then `~max=<n>` (the grammar accepts either order, and
- * neither is part of the reviewer's dedupe identity). A reviewer with no cap
- * emits no `~max` at all, which is what leaves slashdo's built-in default in
- * place; `~max=0` is a real, distinct value meaning "loop until clean".
+ * Build a lowercased-token → model-id lookup for the builders. Tolerates the raw
+ * (unnormalized) map. A `Map` for the same reasons as the cap lookup.
*/
-function markSuffixes(token, optSet, maxLookup) {
+function reviewerModelLookup(reviewerModels) {
+ const normalized = normalizeReviewerModels(reviewerModels) || {};
+ return new Map(Object.entries(normalized).map(([token, model]) => [token.toLowerCase(), model]));
+}
+
+/**
+ * Render one emitted `--review-with` entry: the reviewer token, its optional
+ * `[<model>]` selector, then slashdo's per-entry suffixes in canonical storage
+ * order — `~opt`, then `~max=<n>`.
+ *
+ * Order matters. slashdo's grammar is
+ * `entry := ( <agent> [ "[" <model> "]" ] | "@" <login> ) ( "~opt" | "~max=" <n> )*`
+ * and its parser strips the `~` suffixes from the RIGHT before reading the
+ * bracket — so the bracket has to sit between the slug and the suffixes.
+ *
+ * A reviewer with no pinned model emits no bracket, which is what leaves that
+ * reviewer's own default in place; likewise a reviewer with no cap emits no
+ * `~max` at all (`~max=0` is a real, distinct value meaning "loop until clean").
+ * Only BRACKET_MODEL_REVIEWERS get a bracket — `copilot`/`@login` reject one, and
+ * PortOS's `lmstudio` reviewer has no slashdo slug at all (its model rides in the
+ * `POST /api/code-review/local` body instead).
+ */
+function markSuffixes(token, optSet, maxLookup, modelLookup) {
const key = token.toLowerCase();
const max = maxLookup?.get(key);
- return `${token}${optSet.has(key) ? '~opt' : ''}${max === undefined ? '' : `~max=${max}`}`;
+ const model = BRACKET_MODEL_REVIEWERS.includes(key) ? modelLookup?.get(key) : undefined;
+ return `${token}${model ? `[${model}]` : ''}${optSet.has(key) ? '~opt' : ''}${max === undefined ? '' : `~max=${max}`}`;
}
/**
@@ -299,16 +406,19 @@ export function resolveKeyedReviewers(reviewers, hasUsernames) {
* placeholder in claim/plan prompts: keyed reviewers (falling back to the
* default when empty) followed by `@user` tokens for the reviewer usernames.
* Reviewers in `optionalReviewers` get slashdo's `~opt` non-blocking suffix, and
- * reviewers carrying a `reviewerMaxRounds` cap get `~max=<n>` after it.
+ * reviewers carrying a `reviewerMaxRounds` cap get `~max=<n>` after it. A
+ * reviewer with a `reviewerModels` pin gets slashdo's `[<model>]` selector
+ * between the slug and those suffixes.
* The flag-string variant is `buildReviewWithArgs`.
*/
-export function buildReviewersCsv(reviewers, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}) {
+export function buildReviewersCsv(reviewers, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}, reviewerModels = {}) {
const keyed = Array.isArray(reviewers) && reviewers.length ? reviewers : [...DEFAULT_REVIEWERS];
const users = normalizeReviewUsernames(usernames);
const optSet = optionalReviewerSet(optionalReviewers);
const maxLookup = reviewerMaxRoundsLookup(reviewerMaxRounds);
+ const modelLookup = reviewerModelLookup(reviewerModels);
const combined = [...keyed, ...users.map(u => `@${u}`)];
- return combined.map(t => markSuffixes(t, optSet, maxLookup)).join(',');
+ return combined.map(t => markSuffixes(t, optSet, maxLookup, modelLookup)).join(',');
}
/**
@@ -323,17 +433,21 @@ export function buildReviewersCsv(reviewers, usernames = [], optionalReviewers =
* username reviewer is an external PR reviewer, not a CLI that applies fixes).
* - Reviewers in `optionalReviewers` get slashdo's `~opt` non-blocking suffix on
* their emitted token, so an inconclusive verdict from them doesn't gate the
- * merge. Reviewers with a `reviewerMaxRounds` cap get `~max=<n>` after it.
+ * merge. Reviewers with a `reviewerMaxRounds` cap get `~max=<n>` after it, and
+ * a reviewer with a `reviewerModels` pin gets a `[<model>]` selector before both.
* A lone default `copilot` that is marked optional OR carries a cap DOES force
* the flag on (otherwise the suffix — the whole point — would be dropped with
- * the flag).
+ * the flag). A model pin can't trigger that exemption because `copilot[…]` isn't
+ * a legal slashdo entry (see BRACKET_MODEL_REVIEWERS) — so a lone copilot with a
+ * stray pin emits nothing extra, exactly as before.
*/
-export function buildReviewWithArgs(reviewers, stopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}) {
+export function buildReviewWithArgs(reviewers, stopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}, reviewerModels = {}) {
const users = normalizeReviewUsernames(usernames);
const keyed = resolveKeyedReviewers(reviewers, users.length > 0);
const combined = [...keyed, ...users.map(u => `@${u}`)];
const optSet = optionalReviewerSet(optionalReviewers);
const maxLookup = reviewerMaxRoundsLookup(reviewerMaxRounds);
+ const modelLookup = reviewerModelLookup(reviewerModels);
// The lone-default-copilot suppression only applies when copilot carries NO
// per-entry suffix — a `copilot~opt` / `copilot~max=2`-only list must still
// emit the flag to carry that suffix.
@@ -341,7 +455,7 @@ export function buildReviewWithArgs(reviewers, stopMode = DEFAULT_REVIEW_STOP_MO
&& !optSet.has(DEFAULT_REVIEWER) && maxLookup.get(DEFAULT_REVIEWER) === undefined;
const hasNonCopilot = keyed.some(r => r !== DEFAULT_REVIEWER);
const parts = [];
- if (!isDefaultOnly) parts.push(`--review-with ${combined.map(t => markSuffixes(t, optSet, maxLookup)).join(',')}`);
+ if (!isDefaultOnly) parts.push(`--review-with ${combined.map(t => markSuffixes(t, optSet, maxLookup, modelLookup)).join(',')}`);
if (combined.length >= 2) {
if (stopMode === 'on-findings') parts.push('--review-stop-on-findings');
else if (stopMode === 'on-clean') parts.push('--review-stop-on-clean');
@@ -466,6 +580,15 @@ export const createCosTaskSchema = z.object({
v => normalizeReviewerMaxRounds(v),
z.record(z.number().int().min(0).max(MAX_REVIEWER_MAX_ROUNDS)).optional()
),
+ // Per-reviewer model pins, keyed by the emitted `--review-with` token — the
+ // model id ONE reviewer runs with (emitted as slashdo's `[<model>]`, or threaded
+ // into the follow-up prompt as `<reviewer> --model <id>`). Normalized so a
+ // hand-crafted request can't pin a model on a reviewer that takes none, or
+ // persist a blank id. Absent → undefined (not `{}`).
+ reviewerModels: z.preprocess(
+ v => normalizeReviewerModels(v),
+ z.record(z.string().min(1).max(MAX_REVIEWER_MODEL_LENGTH)).optional()
+ ),
// Bundled slashdo workflow this task runs (#3089) — the BARE command name,
// never a rendered `/do:x` string (see slashdoInvocation.js).
slashdoCommand: z.preprocess(emptyToUndefined, slashdoCommandSchema.optional()),
@@ -809,7 +932,8 @@ function sanitizeQuotaBurnFamilies(raw) {
export const slashdoTaskSchema = createCosTaskSchema
.pick({
model: true, provider: true, effort: true, simplify: true,
- reviewers: true, usernames: true, optionalReviewers: true, reviewerMaxRounds: true
+ reviewers: true, usernames: true, optionalReviewers: true, reviewerMaxRounds: true,
+ reviewerModels: true
})
.extend({
command: z.string().min(1),
@@ -888,6 +1012,15 @@ export function sanitizeTaskMetadata(raw) {
clean.reviewerMaxRounds = normalizeReviewerMaxRounds(raw.reviewerMaxRounds) || {};
hasKeys = true;
}
+ // `reviewerModels` pins the model each reviewer runs with (slashdo's
+ // `[<model>]` / the follow-up prompt's `--model <id>`). Like `reviewerMaxRounds`,
+ // an explicitly empty MAP is KEPT so a task/type can override the Code Review
+ // Defaults' pins back to "each reviewer's own default"; an entry naming a
+ // reviewer that takes no model, or a blank id, is dropped by the normalizer.
+ if (raw.reviewerModels && typeof raw.reviewerModels === 'object' && !Array.isArray(raw.reviewerModels)) {
+ clean.reviewerModels = normalizeReviewerModels(raw.reviewerModels) || {};
+ hasKeys = true;
+ }
if (Object.prototype.hasOwnProperty.call(raw, 'reviewStopMode') && REVIEW_STOP_MODES.includes(raw.reviewStopMode)) {
clean.reviewStopMode = raw.reviewStopMode;
hasKeys = true;
diff --git a/server/lib/validation.test.js b/server/lib/validation.test.js
index 82f1bddc4b..59b4026333 100644
--- a/server/lib/validation.test.js
+++ b/server/lib/validation.test.js
@@ -18,6 +18,10 @@ import {
normalizeReviewerMaxRounds,
resolveReviewerMaxRounds,
MAX_REVIEWER_MAX_ROUNDS,
+ normalizeReviewerModels,
+ resolveReviewerModels,
+ reviewerModelsFromDefaults,
+ MAX_REVIEWER_MODEL_LENGTH,
resolveKeyedReviewers,
buildReviewersCsv,
buildReviewWithArgs,
@@ -198,6 +202,21 @@ describe('validation.js', () => {
expect(r.success).toBe(true)
expect(r.data.reviewerMaxRounds).toBeUndefined()
})
+
+ it('keeps the per-reviewer model SCALARS as the persisted encoding (#3133)', () => {
+ // The picker speaks a token-keyed map, but settings.codeReview stays on the
+ // `<reviewer>Model` scalars — the encoding crosses installs, and the client
+ // adapts via reviewerModelsFromDefaults/ToDefaults. An empty string clears.
+ const r = codeReviewSettingsSchema.safeParse({
+ codexModel: 'gpt-tier-a', claudeModel: 'qwen2.5:7b', ollamaModel: '',
+ })
+ expect(r.success).toBe(true)
+ expect(r.data.codexModel).toBe('gpt-tier-a')
+ expect(r.data.claudeModel).toBe('qwen2.5:7b')
+ expect(r.data.ollamaModel).toBeUndefined()
+ // A token-keyed map is NOT part of this slice — the scalars are.
+ expect(codeReviewSettingsSchema.safeParse({ reviewerModels: { codex: 'a' } }).success).toBe(false)
+ })
})
describe('processSchema', () => {
@@ -793,6 +812,20 @@ describe('validation.js', () => {
expect(sanitizeTaskMetadata({ reviewerMaxRounds: 'ollama=1' })).toBeNull();
});
+ it('should keep a reviewerModels map (including an explicitly empty one) and drop bad entries', () => {
+ expect(sanitizeTaskMetadata({ reviewerModels: { codex: 'gpt-tier-a' } }))
+ .toEqual({ reviewerModels: { codex: 'gpt-tier-a' } });
+ // An explicit `{}` is a real "use each reviewer's own default" override of
+ // the Code Review Defaults' pins, not an absent field.
+ expect(sanitizeTaskMetadata({ reviewerModels: {} }))
+ .toEqual({ reviewerModels: {} });
+ // copilot takes no model; a blank id would emit `--model ` with no id.
+ expect(sanitizeTaskMetadata({ reviewerModels: { copilot: 'x', ollama: ' ', codex: 'ok' } }))
+ .toEqual({ reviewerModels: { codex: 'ok' } });
+ expect(sanitizeTaskMetadata({ reviewerModels: ['codex'] })).toBeNull();
+ expect(sanitizeTaskMetadata({ reviewerModels: 'codex=a' })).toBeNull();
+ });
+
it('should keep an optionalReviewers list (including an explicitly empty one)', () => {
expect(sanitizeTaskMetadata({ optionalReviewers: ['ollama', 'nope'] }))
.toEqual({ optionalReviewers: ['ollama'] });
@@ -1170,6 +1203,124 @@ describe('validation.js', () => {
});
});
+ describe('normalizeReviewerModels', () => {
+ it('keeps a trimmed model id for each model-taking reviewer', () => {
+ expect(normalizeReviewerModels({ codex: 'gpt-tier-a', ollama: ' qwen2.5:7b ' }))
+ .toEqual({ codex: 'gpt-tier-a', ollama: 'qwen2.5:7b' });
+ });
+
+ it('drops a pin on a reviewer that takes no model', () => {
+ // copilot has no CLI; a @login reviewer is a human/bot. slashdo rejects
+ // `copilot[…]` / `@login[…]` for the same reason.
+ expect(normalizeReviewerModels({ copilot: 'x', '@bot': 'y', codex: 'ok' }))
+ .toEqual({ codex: 'ok' });
+ });
+
+ it('drops a blank id rather than persisting it (absent ≠ empty string)', () => {
+ // `''` would emit a `--model ` with no id, breaking the invocation.
+ expect(normalizeReviewerModels({ codex: '', claude: ' ', ollama: 'ok' }))
+ .toEqual({ ollama: 'ok' });
+ });
+
+ it('drops non-strings, unknown tokens, and an over-long id', () => {
+ expect(normalizeReviewerModels({
+ codex: 'ok',
+ claude: 42,
+ ollama: null,
+ nope: 'x',
+ lmstudio: 'm'.repeat(MAX_REVIEWER_MODEL_LENGTH + 1),
+ })).toEqual({ codex: 'ok' });
+ });
+
+ it('accepts an id exactly at the length ceiling', () => {
+ const id = 'm'.repeat(MAX_REVIEWER_MODEL_LENGTH);
+ expect(normalizeReviewerModels({ codex: id })).toEqual({ codex: id });
+ });
+
+ it('returns undefined for non-object input (an omitted field is not an empty override)', () => {
+ expect(normalizeReviewerModels(undefined)).toBeUndefined();
+ expect(normalizeReviewerModels(null)).toBeUndefined();
+ expect(normalizeReviewerModels([['codex', 'a']])).toBeUndefined();
+ expect(normalizeReviewerModels('codex=a')).toBeUndefined();
+ });
+
+ it('returns a prototype-free plain object (no prototype pollution via a __proto__ key)', () => {
+ const out = normalizeReviewerModels({ __proto__: { polluted: true }, codex: 'ok' });
+ expect(out).toEqual({ codex: 'ok' });
+ expect({}.polluted).toBeUndefined();
+ });
+ });
+
+ describe('resolveReviewerModels', () => {
+ it('lets a task-level map (even empty) override the defaults', () => {
+ expect(resolveReviewerModels({ codex: 'a' }, { codex: 'b' })).toEqual({ codex: 'a' });
+ expect(resolveReviewerModels({}, { codex: 'b' })).toEqual({});
+ });
+
+ it('falls back to the defaults when the task did not pin its own', () => {
+ expect(resolveReviewerModels(undefined, { codex: 'b', nope: 'x' })).toEqual({ codex: 'b' });
+ expect(resolveReviewerModels(undefined, undefined)).toEqual({});
+ });
+ });
+
+ describe('reviewerModelsFromDefaults', () => {
+ it('folds the per-reviewer settings scalars into the token-keyed map', () => {
+ expect(reviewerModelsFromDefaults({
+ codexModel: 'gpt-tier-a',
+ claudeModel: ' qwen2.5:7b ',
+ ollamaModel: null,
+ lmstudioModel: '',
+ stopMode: 'all',
+ })).toEqual({ codex: 'gpt-tier-a', claude: 'qwen2.5:7b' });
+ });
+
+ it('tolerates absent defaults', () => {
+ expect(reviewerModelsFromDefaults(null)).toEqual({});
+ });
+ });
+
+ describe('buildReviewWithArgs — per-reviewer [model] selector', () => {
+ it('emits <token>[<model>] for exactly the tokens carrying a pin', () => {
+ expect(buildReviewWithArgs(['claude', 'ollama', 'codex'], 'all', false, [], [], {}, { ollama: 'qwen2.5:7b' }))
+ .toBe('--review-with claude,ollama[qwen2.5:7b],codex');
+ });
+
+ it('places the bracket between the slug and the ~ suffixes (slashdo strips suffixes first)', () => {
+ expect(buildReviewWithArgs(['ollama'], 'all', false, [], ['ollama'], { ollama: 1 }, { ollama: 'qwen2.5:7b' }))
+ .toBe('--review-with ollama[qwen2.5:7b]~opt~max=1');
+ });
+
+ it('never brackets copilot, a @username, or lmstudio (no slashdo slug takes one)', () => {
+ // lmstudio's model rides in the /api/code-review/local request body instead.
+ expect(buildReviewWithArgs(['copilot', 'lmstudio'], 'all', false, ['Bot'], [], {}, {
+ copilot: 'x', lmstudio: 'local-a', '@Bot': 'y',
+ })).toBe('--review-with copilot,lmstudio,@Bot');
+ });
+
+ it('does not let a stray copilot pin force the suppressed lone-default flag on', () => {
+ // Unlike ~opt / ~max, a model pin is not an explicit naming of copilot —
+ // `copilot[…]` isn't even legal slashdo, so nothing would be emitted.
+ expect(buildReviewWithArgs(['copilot'], 'all', false, [], [], {}, { copilot: 'x' })).toBe('');
+ });
+
+ it('ignores pins for tokens not in the emitted list, and invalid entries', () => {
+ expect(buildReviewWithArgs(['codex'], 'all', false, [], [], {}, { ollama: 'a', nope: 'b', codex: ' ' }))
+ .toBe('--review-with codex');
+ });
+ });
+
+ describe('buildReviewersCsv — per-reviewer [model] selector', () => {
+ it('carries the bracket into the claim prompts\' {reviewers} token', () => {
+ expect(buildReviewersCsv(['codex', 'claude'], [], [], {}, { claude: 'qwen2.5:7b' }))
+ .toBe('codex,claude[qwen2.5:7b]');
+ });
+
+ it('combines the bracket with both ~ suffixes in slashdo\'s canonical order', () => {
+ expect(buildReviewersCsv(['ollama'], [], ['ollama'], { ollama: 0 }, { ollama: 'codellama' }))
+ .toBe('ollama[codellama]~opt~max=0');
+ });
+ });
+
describe('createCosTaskSchema reviewers fields', () => {
it('accepts an explicit PR completion policy and rejects unknown values', () => {
expect(createCosTaskSchema.safeParse({ description: 'inspect', prCompletion: 'leave-open' }).success).toBe(true);
@@ -1225,6 +1376,24 @@ describe('validation.js', () => {
expect(cleared.data.reviewerMaxRounds).toEqual({});
});
+ it('normalizes reviewerModels and leaves the field undefined when absent', () => {
+ const withModels = createCosTaskSchema.safeParse({
+ description: 'x',
+ reviewerModels: { codex: 'gpt-tier-a', copilot: 'x', ollama: ' ' },
+ });
+ expect(withModels.success).toBe(true);
+ // copilot takes no model; a blank id is dropped, not persisted as ''.
+ expect(withModels.data.reviewerModels).toEqual({ codex: 'gpt-tier-a' });
+ // Absent → undefined (not coerced to {}), so it isn't persisted as an override.
+ const withoutModels = createCosTaskSchema.safeParse({ description: 'x' });
+ expect(withoutModels.success).toBe(true);
+ expect(withoutModels.data.reviewerModels).toBeUndefined();
+ // An explicitly empty map IS kept — a real "each reviewer's own default" override.
+ const cleared = createCosTaskSchema.safeParse({ description: 'x', reviewerModels: {} });
+ expect(cleared.success).toBe(true);
+ expect(cleared.data.reviewerModels).toEqual({});
+ });
+
it('accepts multiple image screenshots and attachment objects', () => {
const parsed = createCosTaskSchema.safeParse({
description: 'do a thing',
diff --git a/server/routes/cosTaskRoutes.js b/server/routes/cosTaskRoutes.js
index c4a04edef7..6deb751c76 100644
--- a/server/routes/cosTaskRoutes.js
+++ b/server/routes/cosTaskRoutes.js
@@ -122,7 +122,7 @@ router.post('/tasks/enhance', asyncHandler(async (req, res) => {
router.post('/tasks/slashdo', asyncHandler(async (req, res) => {
const {
command, app, provider, model, effort, simplify,
- target, issueAuthorFilter, reviewers, usernames, optionalReviewers, reviewerMaxRounds
+ target, issueAuthorFilter, reviewers, usernames, optionalReviewers, reviewerMaxRounds, reviewerModels
} = validateRequest(slashdoTaskSchema, req.body);
const workflow = getSlashdoWorkflow(command);
@@ -172,7 +172,7 @@ router.post('/tasks/slashdo', asyncHandler(async (req, res) => {
const { useWorktree, openPR } = workflow.settings;
let shape;
if (command === 'next') {
- const claim = await buildClaimWorkTask(appObj, { target, issueAuthorFilter, reviewers, usernames, optionalReviewers, reviewerMaxRounds });
+ const claim = await buildClaimWorkTask(appObj, { target, issueAuthorFilter, reviewers, usernames, optionalReviewers, reviewerMaxRounds, reviewerModels });
const scope = claim.target
? `claim ${workTrackerLabel(claim.tracker)} item ${claim.target}`
: `claim next ${workTrackerLabel(claim.tracker)} item`;
diff --git a/server/services/agentPromptBuilder.js b/server/services/agentPromptBuilder.js
index a801f6db9d..b5f4a35b3f 100644
--- a/server/services/agentPromptBuilder.js
+++ b/server/services/agentPromptBuilder.js
@@ -16,7 +16,7 @@ import { getToolsSummaryForPrompt } from './tools.js';
import { getActiveProvider } from './providers.js';
import { runPromptThroughProvider } from '../lib/promptRunner.js';
import { readJSONFile, loadSlashdoFile, loadSlashdoLib, writeResolvedSlashdoBody, PATHS, tryReadFile } from '../lib/fileUtils.js';
-import { DEFAULT_REVIEWER, DEFAULT_REVIEWERS, DEFAULT_REVIEW_STOP_MODE, LOCAL_LLM_REVIEWERS, MODEL_CAPABLE_CLI_REVIEWERS, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers, normalizeReviewerMaxRounds, resolveReviewUsernames, resolveOptionalReviewers, resolveReviewerMaxRounds, resolveKeyedReviewers, buildReviewWithArgs, buildReviewersCsv } from '../lib/validation.js';
+import { DEFAULT_REVIEWER, DEFAULT_REVIEWERS, DEFAULT_REVIEW_STOP_MODE, LOCAL_LLM_REVIEWERS, MODEL_CAPABLE_CLI_REVIEWERS, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers, normalizeReviewerMaxRounds, resolveReviewUsernames, resolveOptionalReviewers, resolveReviewerMaxRounds, resolveReviewerModels, reviewerModelsFromDefaults, resolveKeyedReviewers, buildReviewWithArgs, buildReviewersCsv } from '../lib/validation.js';
import { PROVIDER_TYPES } from '../lib/aiToolkit/constants.js';
import { canTypeSlashCommands, resolveSlashdoInvocation, buildSlashdoSection, unreachableReviewerIncludes, SLASHDO_INLINE_BUDGET_CHARS } from '../lib/slashdoInvocation.js';
import { shellQuote } from '../lib/shellQuote.js';
@@ -374,6 +374,7 @@ async function applySlashdoInvocation(task, {
const resolvedUsernames = resolveReviewUsernames(task.metadata?.usernames, codeReviewDefaults?.usernames);
const resolvedOptional = resolveOptionalReviewers(task.metadata?.optionalReviewers, codeReviewDefaults?.optionalReviewers);
const resolvedMaxRounds = resolveReviewerMaxRounds(task.metadata?.reviewerMaxRounds, codeReviewDefaults?.reviewerMaxRounds);
+ const resolvedModels = resolveReviewerModels(task.metadata?.reviewerModels, reviewerModelsFromDefaults(codeReviewDefaults));
// A resolved lone `copilot` with no usernames is ambiguous: it's what an
// unconfigured install produces (`pickCodeReviewDefaults` and
@@ -419,7 +420,7 @@ async function applySlashdoInvocation(task, {
: null;
const reviewWith = skipIncludes.length
- ? buildReviewersCsv(resolvedReviewers, resolvedUsernames, resolvedOptional, resolvedMaxRounds)
+ ? buildReviewersCsv(resolvedReviewers, resolvedUsernames, resolvedOptional, resolvedMaxRounds, resolvedModels)
: '';
const section = buildSlashdoSection(resolved, body, { bodyPath, reviewWith });
return { ...task, description: `${task.description}\n\n${section}` };
@@ -500,12 +501,14 @@ export function buildReviewLoopFollowUpSection(metadata = {}, { verbose = false,
const hasLocalLlm = reviewers.some(r => LOCAL_LLM_REVIEWERS.includes(r));
const hasCli = reviewers.some(r => r !== DEFAULT_REVIEWER && !LOCAL_LLM_REVIEWERS.includes(r));
const hasGithubUser = usernames.length > 0;
- // Optional per-CLI-reviewer model tiers chosen on the Code Review Defaults panel,
- // threaded as a reviewer-keyed map. Each configured, model-capable reviewer that
- // is actually in this loop's list gets a `<reviewer> --model <id>` note (empty =
- // let that CLI use its own default). For an Ollama-backed `claude` reviewer the id
- // is the local Ollama model. Falls back to the legacy codex-scalar metadata key so
- // a follow-up task persisted by an older install still threads its codex model.
+ // Optional per-reviewer model pins (Code Review Defaults panel, or the task's own
+ // ReviewerPicker row), threaded as a reviewer-keyed map. A model-capable CLI
+ // reviewer in this loop's list gets a `<reviewer> --model <id>` note; a local-LLM
+ // reviewer's pin goes into its `/api/code-review/local` request body instead
+ // (below). Absent = let that reviewer use its own default. For an Ollama-backed
+ // `claude` reviewer the id is the local Ollama model. Falls back to the legacy
+ // codex-scalar metadata key so a follow-up task persisted by an older install
+ // still threads its codex model.
const reviewerModelMap = (metadata.reviewLoopReviewerModels && typeof metadata.reviewLoopReviewerModels === 'object')
? metadata.reviewLoopReviewerModels
: (typeof metadata.reviewLoopCodexModel === 'string' && metadata.reviewLoopCodexModel
@@ -546,7 +549,7 @@ export function buildReviewLoopFollowUpSection(metadata = {}, { verbose = false,
...reviewers.map(r => `\`${r}\``),
...usernames.map(u => `\`@${u}\``),
].join(' → ');
- const equivArgs = buildReviewWithArgs(reviewers, stopMode, reviewerApplies, usernames, optionalReviewers, reviewerMaxRounds);
+ const equivArgs = buildReviewWithArgs(reviewers, stopMode, reviewerApplies, usernames, optionalReviewers, reviewerMaxRounds, reviewerModelMap);
const equiv = equivArgs ? ` (equivalent to \`/do:pr ${equivArgs}\`)` : '';
// First step: how to obtain a review. For a single copilot/CLI reviewer keep the
@@ -556,6 +559,15 @@ export function buildReviewLoopFollowUpSection(metadata = {}, { verbose = false,
// `POST /api/code-review/local` which runs the configured local model against
// the diff and returns findings text. The agent always reaches it via
// `http://localhost:5555` (the canonical loopback API port).
+ // A pinned local-LLM model can't ride the endpoint's server-side default: that
+ // reads the GLOBAL settings scalar and has never seen this task. So when the
+ // user pinned one on the reviewer's row, name it in the request body — `model`
+ // in the POST body overrides the configured default (see routes/codeReview.js).
+ // Absent pin ⇒ omit the key entirely rather than sending `""`, which would be a
+ // model id the backend can't resolve.
+ const localLlmModelNote = LOCAL_LLM_REVIEWERS
+ .filter(r => reviewers.includes(r) && typeof reviewerModelMap[r] === 'string' && reviewerModelMap[r])
+ .map(r => `\`${r}\` → \`"model": "${reviewerModelMap[r]}"\``);
const localLlmInvocation = `POST the diff to PortOS's local reviewer endpoint and extract its review text before evaluating it. Substitute the active reviewer name for \`<lmstudio|ollama>\`:
\`\`\`bash
REVIEW_RESPONSE=$(mktemp)
@@ -568,7 +580,9 @@ else
cat "\${REVIEW_RESPONSE}.findings"
fi
\`\`\`
-Only a successfully extracted \`.findings\` value is the review text; treat it like any other reviewer's findings.`;
+Only a successfully extracted \`.findings\` value is the review text; treat it like any other reviewer's findings.${localLlmModelNote.length
+ ? ` This run pins a model for ${localLlmModelNote.join(', ')} — add that key to the JSON body (\`jq -Rs '{ backend: "…", model: "…", diff: . }'\`) so the review runs on the pinned model instead of the install default.`
+ : ''}`;
// Instruct the agent to request each username reviewer as a PR reviewer and
// gate the merge on their approval. `gh pr edit --add-reviewer` takes the bare
// login, so strip the `@`.
@@ -1182,6 +1196,7 @@ After completing your work and before committing, ${simplifyInstruction}. Fix an
const taskReviewerUsernames = resolveReviewUsernames(task.metadata?.usernames, codeReviewDefaults?.usernames);
const taskOptionalReviewers = resolveOptionalReviewers(task.metadata?.optionalReviewers, codeReviewDefaults?.optionalReviewers);
const taskReviewerMaxRounds = resolveReviewerMaxRounds(task.metadata?.reviewerMaxRounds, codeReviewDefaults?.reviewerMaxRounds);
+ const taskReviewerModels = resolveReviewerModels(task.metadata?.reviewerModels, reviewerModelsFromDefaults(codeReviewDefaults));
const taskReviewStopMode = task.metadata?.reviewStopMode || codeReviewDefaults?.stopMode || DEFAULT_REVIEW_STOP_MODE;
const taskReviewerApplies = task.metadata?.reviewerApplies !== undefined
? isTruthyMetaFn(task.metadata?.reviewerApplies)
@@ -1222,6 +1237,7 @@ After completing your work and before committing, ${simplifyInstruction}. Fix an
usernames: taskReviewerUsernames,
optionalReviewers: taskOptionalReviewers,
reviewerMaxRounds: taskReviewerMaxRounds,
+ reviewerModels: taskReviewerModels,
reviewStopMode: taskReviewStopMode,
reviewerApplies: taskReviewerApplies
})
@@ -1493,6 +1509,7 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet
const lightReviewerUsernames = resolveReviewUsernames(task.metadata?.usernames, codeReviewDefaults?.usernames);
const lightOptionalReviewers = resolveOptionalReviewers(task.metadata?.optionalReviewers, codeReviewDefaults?.optionalReviewers);
const lightReviewerMaxRounds = resolveReviewerMaxRounds(task.metadata?.reviewerMaxRounds, codeReviewDefaults?.reviewerMaxRounds);
+ const lightReviewerModels = resolveReviewerModels(task.metadata?.reviewerModels, reviewerModelsFromDefaults(codeReviewDefaults));
const lightReviewStopMode = task.metadata?.reviewStopMode || codeReviewDefaults?.stopMode || DEFAULT_REVIEW_STOP_MODE;
const lightReviewerApplies = task.metadata?.reviewerApplies !== undefined
? isTruthyMetaFn(task.metadata?.reviewerApplies)
@@ -1611,10 +1628,10 @@ function buildLightContextSections(task, workspaceDir, worktreeInfo, isTruthyMet
branchName: worktreeInfo?.branchName || null,
baseBranch: worktreeInfo?.baseBranch || null,
leavePrOpen: leavesPrForHuman(task),
- reviewers: lightReviewers, usernames: lightReviewerUsernames, optionalReviewers: lightOptionalReviewers, reviewerMaxRounds: lightReviewerMaxRounds, reviewStopMode: lightReviewStopMode, reviewerApplies: lightReviewerApplies
+ reviewers: lightReviewers, usernames: lightReviewerUsernames, optionalReviewers: lightOptionalReviewers, reviewerMaxRounds: lightReviewerMaxRounds, reviewerModels: lightReviewerModels, reviewStopMode: lightReviewStopMode, reviewerApplies: lightReviewerApplies
}));
} else {
- sections.push(buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompletion, hasSlashdo, simplifyEnabled, leavePrOpen: leavesPrForHuman(task), reviewers: lightReviewers, usernames: lightReviewerUsernames, optionalReviewers: lightOptionalReviewers, reviewerMaxRounds: lightReviewerMaxRounds, reviewStopMode: lightReviewStopMode, reviewerApplies: lightReviewerApplies }));
+ sections.push(buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompletion, hasSlashdo, simplifyEnabled, leavePrOpen: leavesPrForHuman(task), reviewers: lightReviewers, usernames: lightReviewerUsernames, optionalReviewers: lightOptionalReviewers, reviewerMaxRounds: lightReviewerMaxRounds, reviewerModels: lightReviewerModels, reviewStopMode: lightReviewStopMode, reviewerApplies: lightReviewerApplies }));
}
return { taskSections, contractSections };
@@ -1708,7 +1725,7 @@ function buildPostPRMergeSteps(startStep, { prCompletion = PR_COMPLETIONS.REVIEW
* return this IS a Claude session, so `/simplify` and `/do:pr` are both safe to
* emit without a second provider check.
*/
-function buildTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, simplifyEnabled, sentinelPath, slashdoFree = false, branchName = null, baseBranch = null, leavePrOpen = false, reviewers = DEFAULT_REVIEWERS, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}, reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false }) {
+function buildTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, simplifyEnabled, sentinelPath, slashdoFree = false, branchName = null, baseBranch = null, leavePrOpen = false, reviewers = DEFAULT_REVIEWERS, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}, reviewerModels = {}, reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false }) {
const policyLeavesOpen = prCompletion === PR_COMPLETIONS.LEAVE_OPEN;
const runsReviewLoop = prCompletion === PR_COMPLETIONS.REVIEW_THEN_MERGE;
if (slashdoFree) {
@@ -1723,7 +1740,7 @@ function buildTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLETIONS.M
// when the task's Review Loop control is off so that default cannot start a
// Copilot (or other external) review unexpectedly.
const reviewArgs = willOpenPR
- ? (runsReviewLoop ? buildReviewWithArgs(reviewers, reviewStopMode, reviewerApplies, reviewUsernames, optionalReviewers, reviewerMaxRounds) : '--review-with none')
+ ? (runsReviewLoop ? buildReviewWithArgs(reviewers, reviewStopMode, reviewerApplies, reviewUsernames, optionalReviewers, reviewerMaxRounds, reviewerModels) : '--review-with none')
: '';
// A saved slashdo `merge: true` default would otherwise merge a PR that must
// stay open — dropping our own merge steps isn't enough, `/do:pr` has to be
@@ -1878,7 +1895,7 @@ function buildManualTuiCompletionSection({ willOpenPR, prCompletion = PR_COMPLET
* CLI providers fall through to the legacy commit-only block where PortOS
* handles push+PR on exit.
*/
-function buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, hasSlashdo = false, simplifyEnabled = false, leavePrOpen = false, reviewers = DEFAULT_REVIEWERS, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}, reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false }) {
+function buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompletion = PR_COMPLETIONS.MERGE_ON_GREEN, hasSlashdo = false, simplifyEnabled = false, leavePrOpen = false, reviewers = DEFAULT_REVIEWERS, usernames = [], optionalReviewers = [], reviewerMaxRounds = {}, reviewerModels = {}, reviewStopMode = DEFAULT_REVIEW_STOP_MODE, reviewerApplies = false }) {
const policyLeavesOpen = prCompletion === PR_COMPLETIONS.LEAVE_OPEN;
const runsReviewLoop = prCompletion === PR_COMPLETIONS.REVIEW_THEN_MERGE;
const reviewUsernames = normalizeReviewUsernames(usernames);
@@ -1889,7 +1906,7 @@ function buildCliCompletionSection({ worktreeInfo, willOpenPR, prCompletion = PR
lines.push(`${step++}. \`/simplify\` — review the changed code for reuse, quality, and efficiency, and fix any findings.`);
}
const reviewArgs = runsReviewLoop
- ? buildReviewWithArgs(reviewers, reviewStopMode, reviewerApplies, reviewUsernames, optionalReviewers, reviewerMaxRounds)
+ ? buildReviewWithArgs(reviewers, reviewStopMode, reviewerApplies, reviewUsernames, optionalReviewers, reviewerMaxRounds, reviewerModels)
: '--review-with none';
// `--no-merge` overrides a saved slashdo `merge: true` default, which would
// otherwise merge a PR this task must leave open (see lib/prDisposition.js).
diff --git a/server/services/agentWorktreeCleanup.js b/server/services/agentWorktreeCleanup.js
index 7a9d20a864..8e3f44708a 100644
--- a/server/services/agentWorktreeCleanup.js
+++ b/server/services/agentWorktreeCleanup.js
@@ -24,7 +24,7 @@ import { PATHS } from '../lib/fileUtils.js';
import { RECOVERY_TASK_PREFIX } from './recoveryTasks.js';
import { detectForgeCli } from '../lib/gitForge.js';
import { PR_COMPLETIONS, PR_COMPLETION_VALUES, leavesPrForHuman } from '../lib/prDisposition.js';
-import { DEFAULT_REVIEWER, DEFAULT_REVIEWERS, DEFAULT_REVIEW_STOP_MODE, MODEL_CAPABLE_CLI_REVIEWERS, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers, normalizeReviewerMaxRounds } from '../lib/validation.js';
+import { DEFAULT_REVIEWER, DEFAULT_REVIEWERS, DEFAULT_REVIEW_STOP_MODE, MODEL_SELECTABLE_REVIEWERS, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers, normalizeReviewerMaxRounds } from '../lib/validation.js';
/**
* Clean up a worktree for a completed agent.
@@ -335,13 +335,15 @@ export async function spawnReviewLoopFollowUp({ originalAgentId, originalTask, p
// normally catches this; the guard keeps the invariant local to this function.
if (mergeOnly && leaveOpen) return null;
- // Reviewer-keyed CLI model map, narrowed to the model-capable reviewers actually
- // in this loop's list (e.g. `{ codex: 'gpt-5.6-sol', claude: 'qwen2.5:7b' }`); the
- // prompt threads each as `<reviewer> --model <id>`. `reviewerModels` is already
- // coerced to string values upstream (resolveReviewLoopOptions).
+ // Reviewer-keyed model map, narrowed to the model-selectable reviewers actually
+ // in this loop's list (e.g. `{ codex: 'gpt-5.6-sol', ollama: 'qwen2.5:7b' }`).
+ // The prompt threads a CLI reviewer's model as `<reviewer> --model <id>` and a
+ // local-LLM reviewer's as the `model` field of its `/api/code-review/local` body.
+ // `reviewerModels` is already coerced to string values upstream
+ // (resolveReviewLoopOptions).
const narrowedReviewerModels = {};
for (const r of effectiveReviewers) {
- if (MODEL_CAPABLE_CLI_REVIEWERS.includes(r) && reviewerModels?.[r]) narrowedReviewerModels[r] = reviewerModels[r];
+ if (MODEL_SELECTABLE_REVIEWERS.includes(r) && reviewerModels?.[r]) narrowedReviewerModels[r] = reviewerModels[r];
}
// One place that names the mode, so the title, the log line, and the warning
diff --git a/server/services/codeReview.js b/server/services/codeReview.js
index 1b2bbb43a0..25e3bc4bda 100644
--- a/server/services/codeReview.js
+++ b/server/services/codeReview.js
@@ -16,7 +16,6 @@ import { fetchWithTimeout } from '../lib/fetchWithTimeout.js'
import { readResponseJson } from '../lib/readResponseJson.js'
import {
LOCAL_LLM_REVIEWERS,
- MODEL_CAPABLE_CLI_REVIEWERS,
DEFAULT_REVIEWERS,
DEFAULT_REVIEW_STOP_MODE,
REVIEWER_ALIASES,
@@ -28,6 +27,8 @@ import {
resolveOptionalReviewers,
normalizeReviewerMaxRounds,
resolveReviewerMaxRounds,
+ resolveReviewerModels,
+ reviewerModelsFromDefaults,
} from '../lib/validation.js'
import { getSettings, settingsEvents } from './settings.js'
import { getBaseUrl as getLmStudioBaseUrl } from './lmStudioManager.js'
@@ -117,13 +118,17 @@ export async function getCodeReviewDefaults() {
* single source of truth for the reviewer enum & fallback rules.
*
* `reviewerModels` is a reviewer-keyed model map (e.g. `{ codex: 'gpt-5.6-sol',
- * claude: 'qwen2.5:7b' }`) built from the per-CLI-reviewer model scalars on the
- * Code Review Defaults panel (see MODEL_CAPABLE_CLI_REVIEWERS). Unlike the
- * local-LLM models — which the `/api/code-review/local` endpoint injects
- * server-side — these CLIs are invoked directly by the follow-up agent, so each
- * configured model has to ride along into the follow-up's prompt as
- * `<reviewer> --model <id>`. Only reviewers with a non-empty configured model
- * appear in the map (absent = let that CLI pick its own default).
+ * ollama: 'qwen2.5:7b' }`) resolved with task-over-default precedence: the task's
+ * own `reviewerModels` map when it pinned one, else the `<reviewer>Model` scalars
+ * from the Code Review Defaults panel (MODEL_SELECTABLE_REVIEWERS). Only reviewers
+ * with a non-empty model appear (absent = let that reviewer pick its own default).
+ *
+ * Both reviewer kinds ride in the one map because both need it downstream: a CLI
+ * reviewer is invoked directly by the follow-up agent, so its model rides into the
+ * prompt as `<reviewer> --model <id>`; a local-LLM reviewer's model normally comes
+ * from the global settings scalar that `/api/code-review/local` reads, which can't
+ * see a per-task pin — so that pin has to travel here and land in the prompt's
+ * request body instead.
*
* Errors in settings I/O fall back to the hardcoded defaults — settings read
* failures shouldn't block agent completion.
@@ -143,14 +148,18 @@ export async function resolveReviewLoopOptions(metadata, { normalize, isTruthyMe
const reviewerApplies = metadata?.reviewerApplies !== undefined
? isTruthyMeta(metadata?.reviewerApplies)
: (defaults?.reviewerApplies === true)
- // Reviewer-keyed model map from the `<reviewer>Model` scalars. spawnReviewLoopFollowUp
- // further narrows it to the reviewers actually in the list; here we surface every
- // configured one so the caller doesn't need to know the list yet.
- const reviewerModels = {}
- for (const r of MODEL_CAPABLE_CLI_REVIEWERS) {
- const model = defaults?.[`${r}Model`]
- if (model) reviewerModels[r] = model
- }
+ // Reviewer-keyed model map: a task-level `reviewerModels` map (even explicitly
+ // empty) wins, else the `<reviewer>Model` scalars from the Code Review Defaults
+ // — the same task-over-default precedence as the caps above, now that the shared
+ // ReviewerPicker can pin a model per task (#3133).
+ //
+ // Every model-selectable reviewer rides along, CLI *and* local-LLM: a task-level
+ // local pin can't be dropped here, because the endpoint that would otherwise
+ // inject it (`POST /api/code-review/local`) reads the global settings scalar and
+ // has never seen the task. The prompt builder routes each kind to its own
+ // mechanism (`--model <id>` for a CLI, the request body's `model` for a local
+ // backend); spawnReviewLoopFollowUp narrows to the reviewers actually in the list.
+ const reviewerModels = resolveReviewerModels(metadata?.reviewerModels, reviewerModelsFromDefaults(defaults))
return { reviewers, usernames, optionalReviewers, reviewerMaxRounds, reviewStopMode, reviewerApplies, reviewerModels }
}
diff --git a/server/services/codeReview.test.js b/server/services/codeReview.test.js
index 12c8724182..30f35e5161 100644
--- a/server/services/codeReview.test.js
+++ b/server/services/codeReview.test.js
@@ -192,10 +192,34 @@ describe('codeReview helpers', () => {
expect(out.reviewerModels).toEqual({ codex: 'gpt-5.6-sol' })
})
- it('returns an empty map when no CLI-reviewer model is configured', async () => {
+ it('returns an empty map when no reviewer has a configured model', async () => {
+ mockedSettings.current = { codeReview: { reviewers: ['copilot', 'codex'] } }
+ const out = await resolveReviewLoopOptions({}, testDeps)
+ expect(out.reviewerModels).toEqual({})
+ })
+
+ it('carries a local-LLM model pin too, so a per-task one can reach the endpoint (#3133)', async () => {
mockedSettings.current = { codeReview: { reviewers: ['copilot', 'ollama'], ollamaModel: 'codellama' } }
const out = await resolveReviewLoopOptions({}, testDeps)
- // ollama's model is injected server-side by /api/code-review/local, never threaded here.
+ // /api/code-review/local's own default reads the GLOBAL settings scalar and
+ // can't see a task-level pin, so the pin has to travel in this map instead
+ // of being dropped as a CLI-only concern.
+ expect(out.reviewerModels).toEqual({ ollama: 'codellama' })
+ })
+
+ it('lets a task-level model map (including an explicitly empty one) override the defaults', async () => {
+ mockedSettings.current = { codeReview: { reviewers: ['codex'], codexModel: 'gpt-5.6-sol' } }
+ const pinned = await resolveReviewLoopOptions({ reviewerModels: { codex: 'gpt-tier-b' } }, testDeps)
+ expect(pinned.reviewerModels).toEqual({ codex: 'gpt-tier-b' })
+ // An explicit `{}` is a real "use each reviewer's own default for this task"
+ // choice, not an absent field — it must not fall back to the scalars.
+ const cleared = await resolveReviewLoopOptions({ reviewerModels: {} }, testDeps)
+ expect(cleared.reviewerModels).toEqual({})
+ })
+
+ it('drops a pin on a reviewer that takes no model', async () => {
+ mockedSettings.current = { codeReview: { reviewers: ['copilot'] } }
+ const out = await resolveReviewLoopOptions({ reviewerModels: { copilot: 'nope', '@bot': 'nope' } }, testDeps)
expect(out.reviewerModels).toEqual({})
})
diff --git a/server/services/cosTaskGenerator.js b/server/services/cosTaskGenerator.js
index 29bf8638dd..726e30057e 100644
--- a/server/services/cosTaskGenerator.js
+++ b/server/services/cosTaskGenerator.js
@@ -22,7 +22,7 @@
import { readFile } from 'fs/promises';
import { existsSync } from 'fs';
import { join } from 'path';
-import { sanitizeTaskMetadata, PIPELINE_BEHAVIOR_FLAGS, MAX_TOTAL_SPAWNS, normalizeReviewers, resolveReviewUsernames, resolveOptionalReviewers, resolveReviewerMaxRounds, buildReviewersCsv, LOCAL_LLM_REVIEWERS, SWARM_COUNT_MIN } from '../lib/validation.js';
+import { sanitizeTaskMetadata, PIPELINE_BEHAVIOR_FLAGS, MAX_TOTAL_SPAWNS, normalizeReviewers, resolveReviewUsernames, resolveOptionalReviewers, resolveReviewerMaxRounds, resolveReviewerModels, reviewerModelsFromDefaults, buildReviewersCsv, LOCAL_LLM_REVIEWERS, SWARM_COUNT_MIN } from '../lib/validation.js';
import { parsePlanItems, extractAllIds, findInProgressIds, pickFirstAvailable, diagnoseUnpickablePlan } from '../lib/planIds.js';
import { loadState, saveState, withStateLock, isImprovementEnabled, isDaemonRunning } from './cosState.js';
import { getDomainMode } from '../lib/domainAutonomy.js';
@@ -329,7 +329,7 @@ export function resolveClaimAuthorFilter(explicit, metadata) {
*
* @returns {Promise<{ tracker, source, promptTaskType, prompt, taskMetadata, target }>}
*/
-export async function buildClaimWorkTask(app, { issueAuthorFilter, reviewers, usernames, optionalReviewers, reviewerMaxRounds, target } = {}) {
+export async function buildClaimWorkTask(app, { issueAuthorFilter, reviewers, usernames, optionalReviewers, reviewerMaxRounds, reviewerModels, target } = {}) {
const { resolveAppWorkTracker, trackerToClaimTaskType } = await import('../lib/workTracker.js');
const { getTaskPrompt } = await import('./taskPromptService.js');
const taskSchedule = await import('./taskSchedule.js');
@@ -370,7 +370,10 @@ export async function buildClaimWorkTask(app, { issueAuthorFilter, reviewers, us
// Per-reviewer `~max=<n>` round caps ride the same explicit-option → task
// metadata → Code Review Defaults precedence.
const promptReviewerMaxRounds = resolveReviewerMaxRounds(reviewerMaxRounds ?? metadata.reviewerMaxRounds, codeReviewDefaults?.reviewerMaxRounds);
- const reviewersCsv = buildReviewersCsv(reviewersList, promptUsernames, promptOptionalReviewers, promptReviewerMaxRounds);
+ // Per-reviewer model pins (slashdo's `[<model>]` bracket) ride the same
+ // explicit-option → task metadata → Code Review Defaults precedence.
+ const promptReviewerModels = resolveReviewerModels(reviewerModels ?? metadata.reviewerModels, reviewerModelsFromDefaults(codeReviewDefaults));
+ const reviewersCsv = buildReviewersCsv(reviewersList, promptUsernames, promptOptionalReviewers, promptReviewerMaxRounds, promptReviewerModels);
const issueAuthorFilterBlock = resolveIssueAuthorFilterBlock(promptTaskType, resolvedAuthorFilter);
// Swarm mode (`/do:next --swarm`) is prepended (not an in-template
// placeholder) so it stays an opt-in orchestration wrapper that needs no
@@ -415,7 +418,7 @@ async function resolveClaimReviewersCsv() {
// as `@user` tokens so the play button's claim gates the merge on them too.
// Optional-reviewer set rides along so a `~opt` reviewer stays non-blocking,
// as do the per-reviewer `~max=<n>` round caps.
- return buildReviewersCsv(list, codeReviewDefaults?.usernames, codeReviewDefaults?.optionalReviewers, codeReviewDefaults?.reviewerMaxRounds);
+ return buildReviewersCsv(list, codeReviewDefaults?.usernames, codeReviewDefaults?.optionalReviewers, codeReviewDefaults?.reviewerMaxRounds, reviewerModelsFromDefaults(codeReviewDefaults));
}
/**
@@ -2227,7 +2230,11 @@ async function buildImprovementTaskDescription({ promptTemplate, app, promptTask
const promptUsernames = resolveReviewUsernames(metadata.usernames, codeReviewDefaults?.usernames);
const promptOptionalReviewers = resolveOptionalReviewers(metadata.optionalReviewers, codeReviewDefaults?.optionalReviewers);
const promptReviewerMaxRounds = resolveReviewerMaxRounds(metadata.reviewerMaxRounds, codeReviewDefaults?.reviewerMaxRounds);
- const reviewersCsv = buildReviewersCsv(promptReviewers, promptUsernames, promptOptionalReviewers, promptReviewerMaxRounds);
+ // Per-reviewer model pins ride the same precedence, emitted as slashdo's
+ // `[<model>]` bracket. Entries for the local-LLM reviewers filtered out above
+ // are inert — the emitter only brackets tokens it actually emits.
+ const promptReviewerModels = resolveReviewerModels(metadata.reviewerModels, reviewerModelsFromDefaults(codeReviewDefaults));
+ const reviewersCsv = buildReviewersCsv(promptReviewers, promptUsernames, promptOptionalReviewers, promptReviewerMaxRounds, promptReviewerModels);
// {issueAuthorFilter} directive — the filter was already merged (global →
// per-app override) and value-constrained by sanitizeTaskMetadata, so read it
// from `metadata` (default 'self', the slashdo `/do:next --self` security
diff --git a/server/services/cosTaskGenerator.test.js b/server/services/cosTaskGenerator.test.js
index 8d5a2a7934..b1dddc18e0 100644
--- a/server/services/cosTaskGenerator.test.js
+++ b/server/services/cosTaskGenerator.test.js
@@ -166,7 +166,7 @@ describe('{reviewers} interpolation honors Code Review Defaults', () => {
// into buildReviewersCsv, which owns the fallback to the hardcoded copilot
// default when the filter empties the list (unit-tested in validation.test.js).
expect(GEN_SRC).toContain('.filter((r) => !LOCAL_LLM_REVIEWERS.includes(r))');
- expect(GEN_SRC).toContain('buildReviewersCsv(promptReviewers, promptUsernames, promptOptionalReviewers, promptReviewerMaxRounds)');
+ expect(GEN_SRC).toContain('buildReviewersCsv(promptReviewers, promptUsernames, promptOptionalReviewers, promptReviewerMaxRounds, promptReviewerModels)');
});
it('threads per-reviewer ~max round caps into the prompt CSV on both claim paths', () => {
@@ -176,7 +176,18 @@ describe('{reviewers} interpolation honors Code Review Defaults', () => {
// precedence (unit-tested in validation.test.js).
expect(GEN_SRC).toContain('resolveReviewerMaxRounds(metadata.reviewerMaxRounds, codeReviewDefaults?.reviewerMaxRounds)');
expect(GEN_SRC).toContain('resolveReviewerMaxRounds(reviewerMaxRounds ?? metadata.reviewerMaxRounds, codeReviewDefaults?.reviewerMaxRounds)');
- expect(GEN_SRC).toContain('buildReviewersCsv(reviewersList, promptUsernames, promptOptionalReviewers, promptReviewerMaxRounds)');
+ expect(GEN_SRC).toContain('buildReviewersCsv(reviewersList, promptUsernames, promptOptionalReviewers, promptReviewerMaxRounds, promptReviewerModels)');
+ });
+
+ it('threads per-reviewer model pins into the prompt CSV on both claim paths (#3133)', () => {
+ // Same argument as the caps above: `{reviewers}` IS the flag string for the
+ // claim flows, so a pinned model only reaches slashdo (as its `[<model>]`
+ // bracket) if the CSV carries it. Both paths resolve with task-over-default
+ // precedence off the Code Review Defaults' `<reviewer>Model` scalars.
+ expect(GEN_SRC).toContain('resolveReviewerModels(metadata.reviewerModels, reviewerModelsFromDefaults(codeReviewDefaults))');
+ expect(GEN_SRC).toContain('resolveReviewerModels(reviewerModels ?? metadata.reviewerModels, reviewerModelsFromDefaults(codeReviewDefaults))');
+ // The play-button path reads the defaults directly (no task metadata to layer).
+ expect(GEN_SRC).toContain('codeReviewDefaults?.reviewerMaxRounds, reviewerModelsFromDefaults(codeReviewDefaults)');
});
});
diff --git a/server/services/cosTaskStore.js b/server/services/cosTaskStore.js
index 1434c5c55f..cbaad9717f 100644
--- a/server/services/cosTaskStore.js
+++ b/server/services/cosTaskStore.js
@@ -16,7 +16,7 @@ import { readFile, writeFile } from 'fs/promises';
import { existsSync } from 'fs';
import { join } from 'path';
import { parseTasksMarkdown, groupTasksByStatus, getAutoApprovedTasks, getAwaitingApprovalTasks, generateTasksMarkdown, hasKnownPrefix } from '../lib/taskParser.js';
-import { REVIEW_STOP_MODES, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers, normalizeReviewerMaxRounds } from '../lib/validation.js';
+import { REVIEW_STOP_MODES, normalizeReviewers, normalizeReviewUsernames, normalizeOptionalReviewers, normalizeReviewerMaxRounds, normalizeReviewerModels } from '../lib/validation.js';
import { PR_COMPLETIONS, PR_COMPLETION_VALUES } from '../lib/prDisposition.js';
import { loadState, withStateLock, ROOT_DIR } from './cosState.js';
import { cosEvents } from './cosEvents.js';
@@ -316,6 +316,14 @@ export async function addTask(taskData, taskType = 'user', { raw = false, ignore
if (taskData.reviewerMaxRounds && typeof taskData.reviewerMaxRounds === 'object' && !Array.isArray(taskData.reviewerMaxRounds)) {
metadata.reviewerMaxRounds = normalizeReviewerMaxRounds(taskData.reviewerMaxRounds) || {};
}
+ // Per-reviewer model pins, keyed by the same emitted token. Same
+ // explicit-empty semantics as the caps above: an empty MAP is a real "use each
+ // reviewer's own default for this task" choice that overrides the Code Review
+ // Defaults' pins. An entry naming a reviewer that takes no model, or a blank
+ // id, is dropped by the normalizer.
+ if (taskData.reviewerModels && typeof taskData.reviewerModels === 'object' && !Array.isArray(taskData.reviewerModels)) {
+ metadata.reviewerModels = normalizeReviewerModels(taskData.reviewerModels) || {};
+ }
if (REVIEW_STOP_MODES.includes(taskData.reviewStopMode)) metadata.reviewStopMode = taskData.reviewStopMode;
if (taskData.reviewerApplies === true) metadata.reviewerApplies = true;
else if (taskData.reviewerApplies === false) metadata.reviewerApplies = false;