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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): scope the reviewer picker to /do:next, and drop a model id that would corrupt the emitted token
[._.]/ Adam Eivy9b042bff8b94
diff --git a/client/src/components/apps/SlashDoRunDrawer.jsx b/client/src/components/apps/SlashDoRunDrawer.jsxindex 7f524fc69d..bcea997698 100644--- a/client/src/components/apps/SlashDoRunDrawer.jsx+++ b/client/src/components/apps/SlashDoRunDrawer.jsx@@ -78,7 +78,10 @@ function SlashDoRunDrawerBody({ open, command, label, appId, appName, onClose, omodel: selectedModel || undefined,effort: effort || undefined,simplify,- ...(review ? {+ // `isNext &&` states the route's contract rather than leaning on the picker+ // being unrendered: only the `next` branch of POST /tasks/slashdo reads these,+ // so sending them for another command would be a silent no-op.+ ...(isNext && review ? {reviewers: review.reviewers,usernames: review.usernames,optionalReviewers: review.optionalReviewers,@@ -142,23 +145,33 @@ function SlashDoRunDrawerBody({ open, command, label, appId, appName, onClose, oSimplify before committing</span></label>- <ReviewerPicker- reviewers={reviewValue.reviewers}- 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, 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>).- {!review && ' Leave them untouched to use this app’s configured reviewers.'}- </p>+ {/* Reviewer choices are `/do:next`-only: they're substituted into the+ claim prompt's reviewer CSV, and `POST /tasks/slashdo` reads them only+ on that branch. Every other `/do:*` body owns its own review/PR+ sequence, so rendering the picker there would be four knobs wired to+ nothing — the user would pick a reviewer and a model and the run would+ silently discard both. */}+ {isNext && (+ <>+ <ReviewerPicker+ reviewers={reviewValue.reviewers}+ 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, 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>).+ {!review && ' Leave them untouched to use this app’s configured reviewers.'}+ </p>+ </>+ )}</section>{submitError && <p className="text-xs text-port-error">{submitError}</p>}diff --git a/client/src/components/apps/SlashDoRunDrawer.test.jsx b/client/src/components/apps/SlashDoRunDrawer.test.jsxindex 9115a85607..c157d3ecb1 100644--- a/client/src/components/apps/SlashDoRunDrawer.test.jsx+++ b/client/src/components/apps/SlashDoRunDrawer.test.jsx@@ -86,6 +86,31 @@ describe('SlashDoRunDrawer', () => {expect(screen.queryByText(/Reviewer applies fixes/)).not.toBeInTheDocument();});+ it('hides the reviewer picker entirely for a command that cannot honor it', async () => {+ // Only the `next` branch of POST /tasks/slashdo reads the reviewer fields —+ // every other `/do:*` body owns its own review/PR sequence. Rendering the+ // picker there would let the user pick a reviewer and a model and have the run+ // silently discard both.+ renderDrawer({ command: 'better', label: '/do:better' });++ await waitFor(() => expect(screen.getByText('Task settings')).toBeInTheDocument());+ expect(screen.queryByText('Reviewers (in order):')).not.toBeInTheDocument();+ expect(screen.queryByText('GitHub reviewers (gate merge):')).not.toBeInTheDocument();+ });++ it('never sends reviewer fields for a non-next command', async () => {+ renderDrawer({ command: 'better', label: '/do:better' });++ await waitFor(() => expect(screen.getByText('Task settings')).toBeInTheDocument());+ await userEvent.click(screen.getByRole('button', { name: /Queue/ }));++ await waitFor(() => expect(api.createSlashdoTask).toHaveBeenCalled());+ const [, , body] = api.createSlashdoTask.mock.calls[0];+ expect(body.reviewers).toBeUndefined();+ expect(body.reviewerModels).toBeUndefined();+ expect(body.reviewerMaxRounds).toBeUndefined();+ });+it('lists the tracker items once "pick a specific" is chosen and sends the pinned ref', async () => {const onQueued = vi.fn();renderDrawer({ onQueued });diff --git a/client/src/components/cos/ReviewerPicker.jsx b/client/src/components/cos/ReviewerPicker.jsxindex 70792d14cd..3de5d7062b 100644--- a/client/src/components/cos/ReviewerPicker.jsx+++ b/client/src/components/cos/ReviewerPicker.jsx@@ -9,7 +9,8 @@ import {MAX_REVIEWER_MODEL_LENGTH,MODEL_SELECTABLE_REVIEWERS,cleanReviewUsername,- normalizeReviewUsernames+ normalizeReviewUsernames,+ sanitizeReviewerModelInput} from './constants';const labelFor = (value) => REVIEWER_OPTIONS.find(o => o.value === value)?.label || value;@@ -155,8 +156,12 @@ export default function ReviewerPicker({// 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.+ //+ // Structural characters (`[`, `]`, `,`, line breaks) are stripped first: they'd+ // corrupt the emitted `[<model>]` selector and the server drops any id carrying+ // one, so accepting them here would show the user a pin that never persists.const setModel = (token, raw) => {- const model = raw.trim();+ const model = sanitizeReviewerModelInput(raw).trim();if (!model) {emit({ reviewerModels: models.without(token) });return;diff --git a/client/src/components/cos/ReviewerPicker.test.jsx b/client/src/components/cos/ReviewerPicker.test.jsxindex c544bdf974..cf7a46b335 100644--- a/client/src/components/cos/ReviewerPicker.test.jsx+++ b/client/src/components/cos/ReviewerPicker.test.jsx@@ -371,5 +371,22 @@ describe('ReviewerPicker', () => {render(<ReviewerPicker reviewers={['codex']} reviewerModels={{ Codex: 'gpt-tier-a' }} modelOptions={modelOptions} onChange={() => {}} />);expect(screen.getByLabelText('Model for Codex')).toHaveValue('gpt-tier-a');});++ it('strips characters that would corrupt the emitted [model] selector', () => {+ const onChange = vi.fn();+ render(<ReviewerPicker reviewers={['codex']} modelOptions={modelOptions} onChange={onChange} />);+ // `foo]~opt` would close the selector early and leave slashdo reading the+ // rest as a suffix; the server drops such an id, so accepting it here would+ // show a pin that never persists.+ fireEvent.change(screen.getByLabelText('Model for Codex'), { target: { value: 'foo]~opt' } });+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ reviewerModels: { codex: 'foo~opt' } }));+ });++ it('keeps a space in a typed id (slashdo selectors are free-form)', () => {+ const onChange = vi.fn();+ render(<ReviewerPicker reviewers={['claude']} modelOptions={modelOptions} onChange={onChange} />);+ fireEvent.change(screen.getByLabelText('Model for Claude'), { target: { value: 'Some Model (High)' } });+ expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ reviewerModels: { claude: 'Some Model (High)' } }));+ });});});diff --git a/client/src/components/cos/constants.js b/client/src/components/cos/constants.jsindex cc6529bfbf..232740c55c 100644--- a/client/src/components/cos/constants.js+++ b/client/src/components/cos/constants.js@@ -207,6 +207,19 @@ export const MODEL_SELECTABLE_REVIEWERS = [...MODEL_CAPABLE_CLI_REVIEWERS, ...LO// dropped server-side, so the input must not accept one.export const MAX_REVIEWER_MODEL_LENGTH = 200;+// Characters that are STRUCTURAL in slashdo's emitted `--review-with` token and+// have no escape inside the `[<model>]` selector, so the server drops an id+// containing one (mirror of REVIEWER_MODEL_FORBIDDEN_RE in+// server/lib/cosValidation.js). Stripped as the user types rather than silently+// accepted, so the field can't display a pin the server would refuse to store.+// A space is deliberately legal — `agy[Gemini 3.5 Flash (High)]` is a valid entry.+const REVIEWER_MODEL_FORBIDDEN_RE = /[[\],\r\n\t]/g;++// Strip the structural characters from a typed model id. Trimming is left to the+// 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, '') : '';+// 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' = externaldiff --git a/server/lib/cosValidation.js b/server/lib/cosValidation.jsindex 926f2f8d7b..e168f89256 100644--- a/server/lib/cosValidation.js+++ b/server/lib/cosValidation.js@@ -228,6 +228,19 @@ export function resolveReviewerMaxRounds(metadataMap, defaultMap) {// then round-trips the TASKS.md store.export const MAX_REVIEWER_MODEL_LENGTH = 200;+// Characters a model id may not contain, because they are STRUCTURAL in the+// emitted `--review-with` token and there is no escape for them:+// - `]` would close the `[<model>]` selector early (`foo]~opt` → a corrupt entry+// whose remainder slashdo then parses as suffixes),+// - `[` would open a nested one,+// - `,` would split the entry list, turning one reviewer into two bogus ones,+// - whitespace that breaks lines would split the single-line flag string.+// Everything else stays legal on purpose: the value is free-form in slashdo's+// grammar (`agy[Gemini 3.5 Flash (High)]` is valid), and the field has to accept+// whatever id the user's environment actually needs. A space is fine; a newline is+// not.+const REVIEWER_MODEL_FORBIDDEN_RE = /[[\],\r\n\t]/;+// 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@@ -253,6 +266,13 @@ export const BRACKET_MODEL_REVIEWERS = MODEL_SELECTABLE_REVIEWERS.filter(r => r* 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.+ *+ * An id carrying a character that is structural in the emitted token+ * (REVIEWER_MODEL_FORBIDDEN_RE — `[`, `]`, `,`, line breaks) is dropped rather+ * than emitted: there's no escape for them inside `[<model>]`, so `foo]~opt` would+ * close the selector early and leave slashdo parsing the remainder as a suffix.+ * Dropping is the safe failure — the reviewer falls back to its own default model+ * instead of running against a corrupt reviewer list.*/export function normalizeReviewerModels(map) {if (!map || typeof map !== 'object' || Array.isArray(map)) return undefined;@@ -263,6 +283,7 @@ export function normalizeReviewerModels(map) {if (typeof rawValue !== 'string') continue;const model = rawValue.trim();if (!model || model.length > MAX_REVIEWER_MODEL_LENGTH) continue;+ if (REVIEWER_MODEL_FORBIDDEN_RE.test(model)) continue;// First occurrence wins for two spellings of one reviewer — mirrors the// sibling normalizers' dedupe.if (Object.prototype.hasOwnProperty.call(out, token)) continue;diff --git a/server/lib/validation.test.js b/server/lib/validation.test.jsindex 59b4026333..dc837cc292 100644--- a/server/lib/validation.test.js+++ b/server/lib/validation.test.js@@ -1237,6 +1237,23 @@ describe('validation.js', () => {expect(normalizeReviewerModels({ codex: id })).toEqual({ codex: id });});+ it('drops an id carrying a character that is structural in the emitted token', () => {+ // `]` would close the `[<model>]` selector early and leave slashdo parsing+ // the remainder as a suffix; `,` would split one entry into two. There is no+ // escape for either inside the selector, so the pin is dropped (the reviewer+ // falls back to its own default) rather than emitted corrupt.+ expect(normalizeReviewerModels({ codex: 'foo]~opt' })).toEqual({});+ expect(normalizeReviewerModels({ codex: 'a[b' })).toEqual({});+ expect(normalizeReviewerModels({ codex: 'a,b' })).toEqual({});+ expect(normalizeReviewerModels({ codex: 'a\nb' })).toEqual({});+ });++ it('still accepts a space — slashdo model selectors are free-form', () => {+ // e.g. `agy[Gemini 3.5 Flash (High)]` is a valid slashdo entry.+ expect(normalizeReviewerModels({ claude: 'Some Model (High)' }))+ .toEqual({ claude: 'Some Model (High)' });+ });+it('returns undefined for non-object input (an omitted field is not an empty override)', () => {expect(normalizeReviewerModels(undefined)).toBeUndefined();expect(normalizeReviewerModels(null)).toBeUndefined();