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

address review (codex): pin the remaining clear/type-then-submit sites in DuplicatesTab and ReviewerPicker

[._.]/ Adam Eivy74754db94a6e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 1d4311ce57..0c81ba860a 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -156,4 +156,4 @@
- **[issue-3313] The URL search-param patch helper is now one hook instead of three copies.** `updateParams(patch, { replace })` — merge a patch into the query string, dropping keys set to empty so a cleared filter leaves the URL clean — had been re-typed into Catalog, Media Collections, and (in a narrower single-key form) the 3D page. It now lives in `useUrlParams`, which reads the live params off a ref because react-router's functional updater hands the callback the params captured at the render that memoized it — a debounced `?q=` write armed before a sort change would otherwise navigate with the pre-change snapshot and silently drop the sort the user just picked. The hook is also referentially stable, so the debounce effects on those pages stop re-arming every time an unrelated param changes.
- **[issue-3335] Deleting a prompt stage now checks the source, not a hand-written list of ten.** `DELETE /api/prompts/:stage` force-guarded exactly the ten curated CoS/Brain/Memory stages, so removing `pipeline-series-concept-judge` (or roughly a hundred others PortOS resolves by literal key) succeeded with no warning and left the feature naming it throwing `Stage <key> not found` on its next run. Adding them all to the curated table was the wrong fix — the same table drives the Prompt Manager's `SYSTEM` badge and its "System only" filter, and badging ~100 of 127 rows makes both meaningless. Deletion protection is now a second, generated set: a checked-in manifest indexes every stage key a `server/` source names, including the ones reached only through an interpolated prefix like `pipeline-panel-${personaId}`, and a drift test fails until a new call site is regenerated into it. The badge and the filter still show the same ten stages; the delete dialog now names the files that reference the one you're about to remove.
- **[issue-3288] Video render submission is no longer a 717-line route handler — and a failed lookup mid-request stops orphaning your upload.** `POST /api/video-gen` did request validation, backend-pin resolution, model checks, durable staging for four upload kinds with rollback bookkeeping, IC-LoRA/keyframe/a2v validation, render-history lookups, LoRA normalization and chunk resolution inline, with twenty-plus throw sites sharing mutable cleanup state — so every new video-gen parameter meant editing the monolith and risking an unrelated validation branch. That whole region now lives in `services/videoGen/prepareParams.js`, mirroring what `imageGen` already did, and the route is a thin parse → prepare → enqueue → respond shell. Validation order and the exact cleanup-on-throw unwind are preserved verbatim, pinned by the existing route suite plus a new service suite. The extraction also closed a real leak (#3326): every *explicit* throw released the staged uploads, but a plain rejected `await` — a music-video project or track lookup, a render-history read, or the enqueue itself — bubbled straight past them, orphaning up to 100MB per request under `data/uploads` with no job to ever clean it up. One rollback guard now covers every rejection point at once and stays correct as new awaits are added, rethrowing the original error untouched.
-- **[issue-3353] Client tests that type into a field and then submit no longer race the keystrokes.** A Stacker News save test failed on CI for a pull request whose entire diff was a dependency config file, and passed on the rerun. The cause is a shape that suite had in six places: `user.type` enters `20` as two separate events, and nothing between the last keystroke and the Save click asserted that the controlled input had actually reached `20` — so under load the click could send a payload built from the intermediate `2`, or from the post-clear empty string that `Number('')` turns into `0`. Waiting on the assertion cannot recover from that, because the call has already happened with the wrong argument and re-waiting never produces a second one. A shared `src/test/settledInput.js` helper now pins the settled input value between the keystrokes and whatever depends on them, and all six instances in the Stacker News suite plus five more with the identical shape — in the CoS agent card and reviewer picker, the sprite reference workflow, and the media jobs queue — now use it. The failure mode it replaces is an honest one — an input that never settles now fails saying so, rather than silently asserting against a half-typed value.
+- **[issue-3353] Client tests that type into a field and then submit no longer race the keystrokes.** A Stacker News save test failed on CI for a pull request whose entire diff was a dependency config file, and passed on the rerun. The cause is a shape that suite had in six places: `user.type` enters `20` as two separate events, and nothing between the last keystroke and the Save click asserted that the controlled input had actually reached `20` — so under load the click could send a payload built from the intermediate `2`, or from the post-clear empty string that `Number('')` turns into `0`. Waiting on the assertion cannot recover from that, because the call has already happened with the wrong argument and re-waiting never produces a second one. A shared `src/test/settledInput.js` helper now pins the settled input value between the keystrokes and whatever depends on them, and all six instances in the Stacker News suite plus nine more with the identical shape — in the CoS agent card and reviewer picker, the sprite reference workflow, the media jobs queue, and the duplicate-universe merge tab — now use it. Two of those submitted with Enter typed as part of the same keystroke run, where a partially-typed `bad token!` would have been a *valid* username and quietly emitted; the Enter is now a separate press after the draft is pinned. The failure mode it replaces is an honest one — an input that never settles now fails saying so, rather than silently asserting against a half-typed value.
diff --git a/client/src/components/cos/ReviewerPicker.test.jsx b/client/src/components/cos/ReviewerPicker.test.jsx
index 7548acb424..4c9c21e570 100644
--- a/client/src/components/cos/ReviewerPicker.test.jsx
+++ b/client/src/components/cos/ReviewerPicker.test.jsx
@@ -91,7 +91,10 @@ describe('ReviewerPicker', () => {
const onChange = vi.fn();
const user = userEvent.setup();
render(<ReviewerPicker reviewers={['copilot']} onChange={onChange} />);
- await user.type(screen.getByLabelText('Add a GitHub reviewer username'), 'reviewer-bot{Enter}');
+ // Enter is pressed separately so the draft can be pinned first: the keydown
+ // handler adds whatever `usernameInput` state holds at that moment.
+ await typeSettled(user, screen.getByLabelText('Add a GitHub reviewer username'), 'reviewer-bot');
+ await user.keyboard('{Enter}');
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ usernames: ['reviewer-bot'] }));
});
@@ -99,7 +102,10 @@ describe('ReviewerPicker', () => {
const onChange = vi.fn();
const user = userEvent.setup();
render(<ReviewerPicker reviewers={['copilot']} onChange={onChange} />);
- await user.type(screen.getByLabelText('Add a GitHub reviewer username'), 'bad token!{Enter}');
+ // Same pin: a partially-typed `bad` is a *valid* username, so an Enter that
+ // beat the last keystrokes would emit and make this assertion lie.
+ await typeSettled(user, screen.getByLabelText('Add a GitHub reviewer username'), 'bad token!');
+ await user.keyboard('{Enter}');
expect(onChange).not.toHaveBeenCalled();
expect(screen.getByText(/valid GitHub username/)).toBeInTheDocument();
});
diff --git a/client/src/components/sharing/DuplicatesTab.test.jsx b/client/src/components/sharing/DuplicatesTab.test.jsx
index a291543cc0..9862052d24 100644
--- a/client/src/components/sharing/DuplicatesTab.test.jsx
+++ b/client/src/components/sharing/DuplicatesTab.test.jsx
@@ -1,6 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
+import { retypeSettled } from '../../test/settledInput';
vi.mock('../../services/api', () => ({
listUniverseDuplicates: vi.fn(),
@@ -94,8 +95,7 @@ describe('DuplicatesTab', () => {
// automatically switches to the "AI merged" choice.
const ta = await screen.findByLabelText('AI-merged starterPrompt');
expect(ta.value).toBe('Unified A+B');
- await user.clear(ta);
- await user.type(ta, 'Hand-tweaked unified');
+ await retypeSettled(user, ta, 'Hand-tweaked unified');
// Execute — survivor/loser choice is dropped (server's enum doesn't accept 'ai'),
// override is sent as fieldOverrides.
@@ -115,8 +115,7 @@ describe('DuplicatesTab', () => {
const renameButtons = screen.getAllByTitle('Rename');
await user.click(renameButtons[0]);
const input = screen.getByDisplayValue('Clandestiny');
- await user.clear(input);
- await user.type(input, 'Clandestiny (v2)');
+ await retypeSettled(user, input, 'Clandestiny (v2)');
await user.keyboard('{Enter}');
await waitFor(() => expect(api.updateUniverse).toHaveBeenCalledWith('u-new', { name: 'Clandestiny (v2)' }, expect.anything()));
});