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

refactor: put every client reviewer-vocabulary constant behind the server drift test (#5704)

Adam Eivy271f9d1ce682
diff --git a/client/src/components/cos/constants.js b/client/src/components/cos/constants.js
index 7a0aeddf1c..b2ee6a756d 100644
--- a/client/src/components/cos/constants.js
+++ b/client/src/components/cos/constants.js
@@ -16,7 +16,7 @@ import {
ScrollText,
MessageCircle
} from 'lucide-react';
-import { normalizeReviewerSlug } from '../../lib/reviewerPins';
+import { normalizeReviewerSlug, REVIEWER_VALUES } from '../../lib/reviewerPins';
import { inPlaceClipName } from '../../utils/animationClips';
export const TABS = [
@@ -276,26 +276,40 @@ export function pinnedPrCompletion(metadata) {
return metadata?.reviewLoop === true || metadata?.reviewLoop === 'true' ? 'review-then-merge' : '';
}
-// Reviewer choices for the Review Loop. `copilot` requests a GitHub Copilot
-// review via the native reviewer API; CLI reviewers (claude/antigravity/codex/grok/cursor)
-// instruct the follow-up agent to invoke the named CLI; local-LLM reviewers
-// (lmstudio/ollama) route the diff through PortOS's `POST /api/code-review/local`
-// endpoint, which runs the model configured on the Models → Code Reviewers
-// page. Keep in sync with the `REVIEWER_VALUES` enum in
-// `server/lib/validation.js`.
-export const REVIEWER_OPTIONS = [
- { value: 'copilot', label: 'Copilot', description: 'GitHub Copilot (GitHub-only)' },
- { value: 'claude', label: 'Claude', description: 'Claude CLI reviews the PR diff (optional model on Models → Code Reviewers; supports an Ollama-backed Claude for local-only setups)' },
- { value: 'antigravity', label: 'Antigravity', description: 'Antigravity CLI (agy) reviews the PR diff' },
- { value: 'codex', label: 'Codex', description: 'Codex CLI reviews the PR diff (optional model tier on Models → Code Reviewers)' },
- { value: 'grok', label: 'Grok', description: 'Grok Build CLI (grok) reviews the PR diff' },
- { value: 'cursor', label: 'Cursor Agent', description: 'Cursor Agent CLI (cursor-agent) reviews the PR diff' },
- { value: 'opencode', label: 'OpenCode', description: 'OpenCode CLI reviews the PR diff (optional provider/model on Models → Code Reviewers)' },
- { value: 'kimi', label: 'Kimi', description: 'Kimi CLI reviews the PR diff (optional model on Models → Code Reviewers)' },
- { value: 'lmstudio', label: 'LM Studio', description: 'Local LM Studio model reviews the diff (set model on AI Providers)' },
- { value: 'ollama', label: 'Ollama', description: 'Local Ollama model reviews the diff (set model on AI Providers)' },
- { value: 'mtplx', label: 'MTPLX', description: 'Local MTPLX model reviews the diff (set model on AI Providers)' }
-];
+// UI copy for each reviewer in the Review Loop picker. `copilot` requests a
+// GitHub Copilot review via the native reviewer API; CLI reviewers
+// (claude/antigravity/codex/grok/cursor/opencode/kimi) instruct the follow-up agent
+// to invoke the named CLI; local-LLM reviewers (lmstudio/ollama/mtplx) route the
+// diff through
+// PortOS's `POST /api/code-review/local` endpoint, which runs the model
+// configured on the Models → Code Reviewers page.
+//
+// Copy only — the ROSTER is `REVIEWER_VALUES` in `client/src/lib/reviewerPins.js`,
+// which the server suite pins against the server's own enum.
+const REVIEWER_COPY = {
+ copilot: { label: 'Copilot', description: 'GitHub Copilot (GitHub-only)' },
+ claude: { label: 'Claude', description: 'Claude CLI reviews the PR diff (optional model on Models → Code Reviewers; supports an Ollama-backed Claude for local-only setups)' },
+ antigravity: { label: 'Antigravity', description: 'Antigravity CLI (agy) reviews the PR diff' },
+ codex: { label: 'Codex', description: 'Codex CLI reviews the PR diff (optional model tier on Models → Code Reviewers)' },
+ grok: { label: 'Grok', description: 'Grok Build CLI (grok) reviews the PR diff' },
+ cursor: { label: 'Cursor Agent', description: 'Cursor Agent CLI (cursor-agent) reviews the PR diff' },
+ opencode: { label: 'OpenCode', description: 'OpenCode CLI reviews the PR diff (optional provider/model on Models → Code Reviewers)' },
+ kimi: { label: 'Kimi', description: 'Kimi CLI reviews the PR diff (optional model on Models → Code Reviewers)' },
+ lmstudio: { label: 'LM Studio', description: 'Local LM Studio model reviews the diff (set model on AI Providers)' },
+ ollama: { label: 'Ollama', description: 'Local Ollama model reviews the diff (set model on AI Providers)' },
+ mtplx: { label: 'MTPLX', description: 'Local MTPLX model reviews the diff (set model on AI Providers)' }
+};
+
+// Derived from the roster rather than mirroring it, so a reviewer added
+// server-side surfaces as a loud module-load failure here instead of a silently
+// missing dropdown row — and so the picker can never offer a slug the server's
+// enum rejects.
+export const REVIEWER_OPTIONS = REVIEWER_VALUES.map((value) => {
+ const copy = REVIEWER_COPY[value];
+ if (!copy) throw new Error(`❌ REVIEWER_COPY is missing UI copy for reviewer '${value}'`);
+ return { value, ...copy };
+});
+
// The display label for a reviewer token — the one place UI copy turns a
// reviewer slug into prose, so a roster addition renders everywhere without a
// literal edit. Resolves the `gemini` alias; an `@username` (or any token with no
@@ -303,13 +317,25 @@ export const REVIEWER_OPTIONS = [
export const reviewerLabel = (value) =>
REVIEWER_OPTIONS.find(o => o.value === normalizeReviewerSlug(value))?.label || value;
-// The per-reviewer PIN vocabularies (which reviewers take a model or an effort,
-// and the values each accepts) live in `client/src/lib/reviewerPins.js` and are
-// re-exported here so existing imports keep working. They are NOT defined in this
-// file because the server suite pins them against the server's own ladders, and
-// this module's `lucide-react` icon import isn't installed in that workspace —
-// see the leaf module's header for the full rationale.
+// The whole reviewer vocabulary — the roster, its aliases and defaults, the
+// review-username pattern and cap, the max-rounds ceiling, the stop-mode list,
+// and the per-reviewer pin vocabularies — lives in `client/src/lib/reviewerPins.js`
+// and is re-exported here so existing imports keep working. It is NOT defined in
+// this file because the server suite pins the mirror against the server's own
+// constants, and this module's `lucide-react` icon import isn't installed in that
+// workspace — see the leaf module's header for the full rationale.
export {
+ REVIEWER_VALUES,
+ REVIEWER_ALIASES,
+ DEFAULT_REVIEWER,
+ DEFAULT_REVIEWERS,
+ MAX_REVIEW_USERNAMES,
+ cleanReviewUsername,
+ normalizeReviewUsernames,
+ MAX_REVIEWER_MAX_ROUNDS,
+ REVIEW_STOP_MODES,
+ DEFAULT_REVIEW_STOP_MODE,
+ normalizeReviewers,
MODEL_CAPABLE_CLI_REVIEWERS,
LOCAL_LLM_REVIEWERS,
MODEL_SELECTABLE_REVIEWERS,
@@ -376,79 +402,6 @@ export const BRANCHES_PER_AGENT_OPTIONS = [1, 2, 3, 4, 5, 6].map((value) => ({
description: `Give each branch-reconcile coordinator up to ${value} prioritized branch${value === 1 ? '' : 'es'} per run`
}));
-export const DEFAULT_REVIEWER = 'copilot';
-export const DEFAULT_REVIEWERS = ['copilot'];
-
-// Arbitrary GitHub reviewer usernames (e.g. `@CodeReviewbot`) requested as PR
-// reviewers to gate merging, appended to slashdo's `--review-with` after the
-// keyed reviewers. Client mirror of server/lib/reviewerConfig.js
-// `normalizeReviewUsernames` + MAX_REVIEW_USERNAMES — keep the pattern/cap in
-// sync so the picker rejects the same tokens the server would drop. Stored
-// WITHOUT the leading `@` (added back only for display / the flag string).
-export const MAX_REVIEW_USERNAMES = 20;
-const REVIEW_USERNAME_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})(?:\/[A-Za-z0-9._-]{1,100})?$/;
-
-// Validate a single raw username entry (strip `@`, trim). Returns the clean
-// token or null if it isn't a shell-safe GitHub username/team slug.
-export function cleanReviewUsername(raw) {
- if (typeof raw !== 'string') return null;
- const trimmed = raw.trim().replace(/^@+/, '');
- return trimmed && REVIEW_USERNAME_RE.test(trimmed) ? trimmed : null;
-}
-
-// Normalize a raw list: drop invalid tokens, case-insensitively dedupe while
-// preserving order, cap at MAX_REVIEW_USERNAMES. Returns clean usernames sans `@`.
-export function normalizeReviewUsernames(list) {
- if (!Array.isArray(list)) return [];
- const seen = new Set();
- const out = [];
- for (const raw of list) {
- const clean = cleanReviewUsername(raw);
- if (!clean) continue;
- const key = clean.toLowerCase();
- if (seen.has(key)) continue;
- seen.add(key);
- out.push(clean);
- if (out.length >= MAX_REVIEW_USERNAMES) break;
- }
- return out;
-}
-
-// Upper bound on a per-reviewer `~max=<n>` round cap. Client mirror of
-// MAX_REVIEWER_MAX_ROUNDS in `server/lib/reviewerConfig.js` — a value above it is
-// dropped server-side, so the input must not offer one. `0` is valid and means
-// "loop until clean" (slashdo's unlimited mode, bounded by its own guardrail);
-// blank/absent means "no cap requested" and keeps slashdo's built-in default.
-export const MAX_REVIEWER_MAX_ROUNDS = 10;
-
-// Stop-mode for the multi-reviewer loop (slashdo `--review-stop-on-*`).
-// Keep in sync with REVIEW_STOP_MODES in `server/lib/validation.js`.
-export const REVIEW_STOP_MODES = [
- { value: 'all', label: 'Run all', description: 'Run every reviewer in order before merging (default)' },
- { value: 'on-findings', label: 'Stop on first fix', description: 'Stop after the first reviewer that landed a fix' },
- { value: 'on-clean', label: 'Stop on first clean', description: 'Stop after the first reviewer that reports zero findings' }
-];
-export const DEFAULT_REVIEW_STOP_MODE = 'all';
-
-// Resolve metadata to an ordered, deduped reviewer list (client mirror of the
-// server's normalizeReviewers): prefers `reviewers`, falls back to legacy
-// single `reviewer`, defaults to `['copilot']`.
-const REVIEWER_VALUES = REVIEWER_OPTIONS.map(o => o.value);
-const REVIEWER_ALIASES = { gemini: 'antigravity', 'cursor-agent': 'cursor' };
-export function normalizeReviewers(meta) {
- const raw = meta && typeof meta === 'object' && !Array.isArray(meta) ? meta : {};
- const source = Array.isArray(raw.reviewers)
- ? raw.reviewers
- : (typeof raw.reviewer === 'string' && raw.reviewer ? [raw.reviewer] : []);
- const seen = new Set();
- const out = [];
- for (const r of source) {
- const normalized = REVIEWER_ALIASES[r] || r;
- if (REVIEWER_VALUES.includes(normalized) && !seen.has(normalized)) { seen.add(normalized); out.push(normalized); }
- }
- return out.length ? out : [...DEFAULT_REVIEWERS];
-}
-
// Returns the Tailwind className string for an agent option toggle button.
// effective: whether the option is on (global + override resolved)
// hasOverride: whether there's an explicit per-app override set
diff --git a/client/src/components/cos/constants.test.js b/client/src/components/cos/constants.test.js
index 8174e34f18..06ea91588a 100644
--- a/client/src/components/cos/constants.test.js
+++ b/client/src/components/cos/constants.test.js
@@ -13,6 +13,8 @@ import {
MUSE_ROOT_MOTION_CLIPS,
resolveMuseMotion,
MODEL_CAPABLE_CLI_REVIEWERS,
+ REVIEWER_OPTIONS,
+ REVIEWER_VALUES,
reviewerLabel,
summarizeHealthIssues,
healthIssueTone,
@@ -332,3 +334,21 @@ describe('hasProviderPin', () => {
});
// @vitest-environment node
+
+// REVIEWER_OPTIONS is UI copy DERIVED from the roster in `lib/reviewerPins.js`,
+// which the server suite pins against the server's own enum. Re-listing the slugs
+// here would put the picker back outside that gate, so the derivation is the
+// thing under test: same slugs, same order, and a loud module-load throw (rather
+// than a missing dropdown row) if a roster addition arrives without copy.
+describe('REVIEWER_OPTIONS derivation', () => {
+ it('offers exactly the roster the server validates against, in order', () => {
+ expect(REVIEWER_OPTIONS.map(o => o.value)).toEqual(REVIEWER_VALUES);
+ });
+
+ it('gives every reviewer a label and a description', () => {
+ for (const option of REVIEWER_OPTIONS) {
+ expect(option.label, option.value).toBeTruthy();
+ expect(option.description, option.value).toBeTruthy();
+ }
+ });
+});
diff --git a/client/src/lib/README.md b/client/src/lib/README.md
index b0213b7ef9..4489445902 100644
--- a/client/src/lib/README.md
+++ b/client/src/lib/README.md
@@ -53,7 +53,7 @@ grep -i "what you want to do" client/src/lib/README.md
| `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` / `reviewerEffortsFromDefaults` / `reviewerEffortsToDefaults` — adapt the Code Review Defaults' per-reviewer SCALARS (`codexModel`, `ollamaModel`, `claudeEffort`, …) to and from the token-keyed maps `ReviewerPicker`'s Model and Effort columns take. Mirrors `reviewerModelsFromDefaults` / `reviewerEffortsFromDefaults` in `server/lib/reviewerConfig.js`. |
-| `reviewerPins.js` | Client mirrors of the per-reviewer pin vocabularies — `MODEL_SELECTABLE_REVIEWERS` / `EFFORT_SELECTABLE_REVIEWERS` / `REVIEWER_EFFORT_LEVELS` / `reviewerEffortLevels` / `normalizeReviewerSlug` / `sanitizeReviewerModelInput` and their bounds. Dependency-free on purpose: the server suite imports it to pin the mirror against the server's own ladders, so it must not reach for a client-only package. Re-exported by `components/cos/constants.js`. |
+| `reviewerPins.js` | Client mirror of the whole reviewer vocabulary — the roster (`REVIEWER_VALUES`), `REVIEWER_ALIASES`, `DEFAULT_REVIEWER(S)`, `normalizeReviewers`, the review-username pattern/cap (`MAX_REVIEW_USERNAMES` / `cleanReviewUsername` / `normalizeReviewUsernames`), `MAX_REVIEWER_MAX_ROUNDS`, `REVIEW_STOP_MODES` / `DEFAULT_REVIEW_STOP_MODE`, plus the per-reviewer pin vocabularies (`MODEL_SELECTABLE_REVIEWERS` / `EFFORT_SELECTABLE_REVIEWERS` / `REVIEWER_EFFORT_LEVELS` / `reviewerEffortLevels` / `normalizeReviewerSlug` / `sanitizeReviewerModelInput`) and their bounds. Dependency-free on purpose: the server suite imports it to pin the mirror against `server/lib/reviewerConfig.js`, so it must not reach for a client-only package. Re-exported by `components/cos/constants.js`. |
| `loraEffect.js` | Mirror of the LoRA adapter-effect report vocabulary in `server/lib/loraEffect.js` (#4872): `LORA_EFFECT_STATUSES` (`ok`/`zero`/`nonfinite`/`unreadable`/`unmeasurable`), `LORA_EFFECT_BADGES` + `loraEffectBadge(status)` (badge label and Tailwind tone — only `zero` is styled as an error, because only `zero` refuses a render server-side), and `formatLoraEffect(report)`, the same one-line summary the server logs, returning `null` when the badge already says everything. Pinned by `loraEffect.parity.test.js`. |
| `loraTriggers.js` | Mirror of the trigger-word predicates in `server/lib/loraTriggers.js` (#4665): `firstTriggerWord` (the canonical activation token of a Civitai `trainedWords` list) and `promptHasTriggerWord` (whole-token, case-insensitive presence — `aria_tok` does not match inside `aria_token`). Plus `appendTriggerWords(prompt, words, effectivePrompt?)` — the "+ trigger" button's append, which adds ALL of a LoRA's words (the server only ever weaves the first) and judges presence against the composed prompt the page will actually submit. Lets the LoRA picker warn that the server is about to append a token, with the button and the hint sharing one presence rule. |
| `runnerFamilies.js` | Mirror of `server/lib/runners.js`, including the shared LTX + MiniMax H3 Ref2VA audio-to-video runtime predicate. |
diff --git a/client/src/lib/reviewerPins.js b/client/src/lib/reviewerPins.js
index cbe825833f..751c91b456 100644
--- a/client/src/lib/reviewerPins.js
+++ b/client/src/lib/reviewerPins.js
@@ -7,9 +7,11 @@ import {
} from '../utils/providers';
/**
- * Client mirrors of the per-reviewer PIN vocabularies in
- * `server/lib/reviewerConfig.js` — which reviewers can carry a model or an effort
- * pin, and which values each one accepts.
+ * Client mirrors of the reviewer vocabulary in `server/lib/reviewerConfig.js` —
+ * the roster itself, its aliases and defaults, the review-username pattern and
+ * cap, the max-rounds ceiling, the stop-mode list, and the per-reviewer PIN
+ * vocabularies (which reviewers can carry a model or an effort pin, and which
+ * values each one accepts).
*
* **Why these live in a leaf module rather than in `components/cos/constants.js`.**
* The server suite pins this mirror against the server's own derived ladders (see
@@ -79,8 +81,11 @@ export const REVIEWER_EFFORT_LEVELS = Object.freeze({
// Mirror of EFFORT_SELECTABLE_REVIEWERS.
export const EFFORT_SELECTABLE_REVIEWERS = Object.freeze(Object.keys(REVIEWER_EFFORT_LEVELS));
-// Reviewer slug aliases. `gemini` is the historical name for the Antigravity CLI.
-const REVIEWER_ALIASES = { gemini: 'antigravity', 'cursor-agent': 'cursor' };
+// Reviewer slug aliases. `gemini` is the historical name for the Antigravity CLI,
+// `cursor-agent` the binary name for `cursor`. Mirror of REVIEWER_ALIASES in
+// `server/lib/reviewerConfig.js` — a legacy slug the client stops resolving turns
+// a stored reviewer into a row the picker can no longer show.
+export const REVIEWER_ALIASES = { gemini: 'antigravity', 'cursor-agent': 'cursor' };
// The canonical slug for a reviewer token: lower-cased, trimmed, aliases resolved.
// `''` for a non-string. `@username` tokens ride through as-is (they're no
@@ -110,3 +115,95 @@ const REVIEWER_MODEL_FORBIDDEN_RE = /[[\],\r\n\t]/g;
// caller: an id being typed may legitimately have a trailing space mid-entry.
export const sanitizeReviewerModelInput = (raw) =>
typeof raw === 'string' ? raw.replace(REVIEWER_MODEL_FORBIDDEN_RE, '') : '';
+
+// =============================================================================
+// REVIEWER ROSTER, DEFAULTS, AND CAPS
+//
+// Every constant below mirrors `server/lib/reviewerConfig.js` and is pinned by
+// the `client mirror of the reviewer vocabulary` drift test in
+// `server/lib/reviewerConfig.test.js`. They live in this leaf rather than in
+// `components/cos/constants.js` for the same reason as the pin vocabularies
+// above: that module imports `lucide-react`, so the server suite cannot import
+// it, and anything left there is guarded by a comment instead of a test.
+// =============================================================================
+
+// The reviewer roster, and the client's SOURCE OF TRUTH for it: `REVIEWER_OPTIONS`
+// in `components/cos/constants.js` is derived from this list, so the picker can
+// never offer a slug the server's enum would reject. Mirror of REVIEWER_VALUES —
+// a reviewer listed here but unknown to the server leaves the user configuring a
+// review-loop reviewer that never runs; the reverse hides one their install has.
+export const REVIEWER_VALUES = ['copilot', 'claude', 'antigravity', 'codex', 'grok', 'cursor', 'opencode', 'kimi', 'lmstudio', 'ollama', 'mtplx'];
+
+// The reviewer a task falls back to when none is configured. Mirror of
+// DEFAULT_REVIEWER / DEFAULT_REVIEWERS.
+export const DEFAULT_REVIEWER = 'copilot';
+export const DEFAULT_REVIEWERS = [DEFAULT_REVIEWER];
+
+// Arbitrary GitHub reviewer usernames (e.g. `@CodeReviewbot`) requested as PR
+// reviewers to gate merging, appended to slashdo's `--review-with` after the
+// keyed reviewers. Mirror of `normalizeReviewUsernames` + MAX_REVIEW_USERNAMES —
+// the picker has to reject exactly the tokens the server drops, or the user sees
+// a saved reviewer that never persisted. Stored WITHOUT the leading `@` (added
+// back only for display / the flag string).
+export const MAX_REVIEW_USERNAMES = 20;
+const REVIEW_USERNAME_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})(?:\/[A-Za-z0-9._-]{1,100})?$/;
+
+// Validate a single raw username entry (strip `@`, trim). Returns the clean
+// token or null if it isn't a shell-safe GitHub username/team slug.
+export function cleanReviewUsername(raw) {
+ if (typeof raw !== 'string') return null;
+ const trimmed = raw.trim().replace(/^@+/, '');
+ return trimmed && REVIEW_USERNAME_RE.test(trimmed) ? trimmed : null;
+}
+
+// Normalize a raw list: drop invalid tokens, case-insensitively dedupe while
+// preserving order, cap at MAX_REVIEW_USERNAMES. Returns clean usernames sans `@`.
+export function normalizeReviewUsernames(list) {
+ if (!Array.isArray(list)) return [];
+ const seen = new Set();
+ const out = [];
+ for (const raw of list) {
+ const clean = cleanReviewUsername(raw);
+ if (!clean) continue;
+ const key = clean.toLowerCase();
+ if (seen.has(key)) continue;
+ seen.add(key);
+ out.push(clean);
+ if (out.length >= MAX_REVIEW_USERNAMES) break;
+ }
+ return out;
+}
+
+// Upper bound on a per-reviewer `~max=<n>` round cap. Mirror of
+// MAX_REVIEWER_MAX_ROUNDS — a value above it is dropped server-side, so the input
+// must not offer one. `0` is valid and means "loop until clean" (slashdo's
+// unlimited mode, bounded by its own guardrail); blank/absent means "no cap
+// requested" and keeps slashdo's built-in default.
+export const MAX_REVIEWER_MAX_ROUNDS = 10;
+
+// Stop-mode for the multi-reviewer loop (slashdo `--review-stop-on-*`). The
+// `value`s mirror REVIEW_STOP_MODES; the labels/descriptions are UI copy. A mode
+// the UI offers but the server's enum rejects 400s on save.
+export const REVIEW_STOP_MODES = [
+ { value: 'all', label: 'Run all', description: 'Run every reviewer in order before merging (default)' },
+ { value: 'on-findings', label: 'Stop on first fix', description: 'Stop after the first reviewer that landed a fix' },
+ { value: 'on-clean', label: 'Stop on first clean', description: 'Stop after the first reviewer that reports zero findings' }
+];
+export const DEFAULT_REVIEW_STOP_MODE = 'all';
+
+// Resolve task metadata to an ordered, deduped reviewer list (mirror of the
+// server's normalizeReviewers): prefers `reviewers`, falls back to the legacy
+// single `reviewer`, defaults to DEFAULT_REVIEWERS.
+export function normalizeReviewers(meta) {
+ const raw = meta && typeof meta === 'object' && !Array.isArray(meta) ? meta : {};
+ const source = Array.isArray(raw.reviewers)
+ ? raw.reviewers
+ : (typeof raw.reviewer === 'string' && raw.reviewer ? [raw.reviewer] : []);
+ const seen = new Set();
+ const out = [];
+ for (const r of source) {
+ const normalized = REVIEWER_ALIASES[r] || r;
+ if (REVIEWER_VALUES.includes(normalized) && !seen.has(normalized)) { seen.add(normalized); out.push(normalized); }
+ }
+ return out.length ? out : [...DEFAULT_REVIEWERS];
+}
diff --git a/server/lib/reviewerConfig.test.js b/server/lib/reviewerConfig.test.js
index 9d5aea74f8..2a2066bf4b 100644
--- a/server/lib/reviewerConfig.test.js
+++ b/server/lib/reviewerConfig.test.js
@@ -32,6 +32,12 @@ import {
reviewerModelFlag,
splitSlashdoReviewerTokens,
PORTOS_ONLY_REVIEWERS,
+ DEFAULT_REVIEWERS,
+ REVIEW_STOP_MODES,
+ DEFAULT_REVIEW_STOP_MODE,
+ MAX_REVIEW_USERNAMES,
+ MAX_REVIEWER_MAX_ROUNDS,
+ normalizeReviewUsernames,
} from './reviewerConfig.js';
// The Zod half of the old cosValidation.js — these cases assert that a reviewer
// pin survives the schema that persists it, so they need both modules.
@@ -380,7 +386,7 @@ describe('per-reviewer reasoning effort (reviewerEfforts)', () => {
// offered there but rejected here would show the user a pin that silently never
// persists (and the reverse would hide a tier their CLI accepts), so the mirror is
// pinned rather than trusted to a "keep in sync" comment.
-describe('client mirror of the reviewer effort ladders', () => {
+describe('client mirror of the reviewer vocabulary', () => {
it('matches server reviewerEffortLevels for every reviewer', async () => {
// The dependency-free leaf, NOT `components/cos/constants.js` (which re-exports
// these but also imports `lucide-react` — absent from the server workspace, so
@@ -403,6 +409,60 @@ describe('client mirror of the reviewer effort ladders', () => {
expect([...client.MODEL_CAPABLE_CLI_REVIEWERS].sort()).toEqual([...MODEL_CAPABLE_CLI_REVIEWERS].sort());
expect([...client.MODEL_SELECTABLE_REVIEWERS].sort()).toEqual([...MODEL_SELECTABLE_REVIEWERS].sort());
});
+
+ // The roster itself. A reviewer added on one side only is the `antigravity`
+ // drift of #3728: the picker offers a reviewer the server's enum rejects (the
+ // save 400s), or the server gains one the user can never select.
+ it('matches the server reviewer roster', async () => {
+ const client = await import('../../client/src/lib/reviewerPins.js');
+ expect([...client.REVIEWER_VALUES].sort()).toEqual([...REVIEWER_VALUES].sort());
+ });
+
+ // Aliases resolve slugs already stored on tasks (`gemini`, `cursor-agent`). One
+ // dropped client-side turns a saved reviewer into a row the picker can't render.
+ it('matches the server reviewer aliases', async () => {
+ const client = await import('../../client/src/lib/reviewerPins.js');
+ expect(client.REVIEWER_ALIASES).toEqual(REVIEWER_ALIASES);
+ });
+
+ // Defaults and caps. A cap the input offers above the server's ceiling is
+ // silently dropped on save, which reads to the user as the field not working.
+ it('matches the server defaults and caps', async () => {
+ const client = await import('../../client/src/lib/reviewerPins.js');
+ expect(client.DEFAULT_REVIEWER).toBe(DEFAULT_REVIEWER);
+ expect(client.DEFAULT_REVIEWERS).toEqual(DEFAULT_REVIEWERS);
+ expect(client.MAX_REVIEWER_MAX_ROUNDS).toBe(MAX_REVIEWER_MAX_ROUNDS);
+ expect(client.MAX_REVIEW_USERNAMES).toBe(MAX_REVIEW_USERNAMES);
+ });
+
+ // Stop modes: the client rows carry UI copy, but their `value`s are the enum
+ // the save is validated against. An extra row 400s the whole task update.
+ it('matches the server review stop modes', async () => {
+ const client = await import('../../client/src/lib/reviewerPins.js');
+ expect(client.REVIEW_STOP_MODES.map(m => m.value)).toEqual([...REVIEW_STOP_MODES]);
+ expect(client.DEFAULT_REVIEW_STOP_MODE).toBe(DEFAULT_REVIEW_STOP_MODE);
+ });
+
+ // The username pattern and cap are two independent facts, and neither side's
+ // own tests can see a divergence — only running the same inputs through both
+ // normalizers can. The 25 valid entries exercise the cap, the rest the pattern.
+ it('normalizes review usernames identically to the server', async () => {
+ const client = await import('../../client/src/lib/reviewerPins.js');
+ const cases = [
+ ['@octocat'],
+ ['org/team'],
+ ['bad name'],
+ ['-lead'],
+ ['octocat', 'OCTOCAT', '@octocat'],
+ ['a'.repeat(40)],
+ ['', ' ', null, 42, undefined],
+ Array.from({ length: 25 }, (_, i) => `reviewer-${i}`),
+ ];
+ for (const input of cases) {
+ expect(client.normalizeReviewUsernames(input)).toEqual(normalizeReviewUsernames(input));
+ }
+ expect(client.normalizeReviewUsernames('not-an-array')).toEqual(normalizeReviewUsernames('not-an-array'));
+ });
});
describe('per-reviewer model pins', () => {