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([unify-videogen-resolutions-with-shared-image-gen]): share resolveResolutionLabel helper between image + video dropdowns

[._.]/ Adam Eivyd444d426390d
diff --git a/DONE.md b/DONE.md
index 03abe0fc21..d1223224b1 100644
--- a/DONE.md
+++ b/DONE.md
@@ -10,7 +10,7 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./
### 2026-05-19
-- **[unify-videogen-resolutions-with-shared-image-gen] Unify VideoGen `RESOLUTIONS` with shared image-gen list.** New `client/src/lib/videoGenResolutions.js` holding `VIDEO_RESOLUTIONS` as the companion to `imageGenResolutions.js`, registered in the lib barrel + README so future image+video work finds it via the catalog. `client/src/pages/VideoGen.jsx` now imports from there instead of defining its own local `RESOLUTIONS` const. Picked a distinct constant name (`VIDEO_RESOLUTIONS` vs the image side's `RESOLUTIONS`) to avoid a flat-barrel name collision; the image-side const stays unchanged since no caller imports it directly. All 154 client tests pass (barrel-shape test confirms the new module is wired correctly into both `index.js` and `README.md`).
+- **[unify-videogen-resolutions-with-shared-image-gen] Unify VideoGen `RESOLUTIONS` with shared image-gen list.** New `client/src/lib/videoGenResolutions.js` holding `VIDEO_RESOLUTIONS` as the companion to `imageGenResolutions.js`, registered in the lib barrel + README so future image+video work finds it via the catalog. New `resolveResolutionLabel(list, w, h) → { matched, label }` helper in `imageGenResolutions.js` collapses the duplicate "find matching preset OR fall back to `${w}×${h}` for the custom-fallback dropdown option" pattern that lived inline in both `client/src/pages/VideoGen.jsx` and `client/src/components/imageGen/ImageGenControls.jsx`. Both consumers now import the helper; image side's prior `(width && height ? ... : '')` empty-string-when-unset guard is preserved in the helper (returns `label: ''` when either dimension is falsy). Picked a distinct constant name (`VIDEO_RESOLUTIONS` vs the image side's `RESOLUTIONS`) to avoid a flat-barrel name collision in the lib `index.js` `export *` chain. All 154 client tests pass (barrel-shape test confirms the new module is wired correctly into both `index.js` and `README.md`).
- **[med-sharing-server-services-sharing] [med-sharing-server-services-mediaannotations-js-38] [low-sharing-server-services-mediaannotations-js] [low-sharing-server-services-mediaannotations-js-2] [low-sharing-server-services-sharing] Sharing/annotation-merge hardening bundle.** Five v2.1.0 pre-release residue items shipped together because they all touch the same annotation-sync + LWW-merge surface. (1) `annotationsSync.flushAll` no longer resolves one `sourceName` for all buckets — `exportAnnotationsToBucket` now resolves its own per-bucket name, so per-bucket `displayNameOverride` is honored in outgoing annotation manifest envelopes the same way it already was for series/universe/media manifests. The bucket-effective resolver lives in `sharing/annotationIdentity.js` as a new `resolveBucketSourceName(bucket)` export consumed by both the exporter and the annotation flush (the exporter's local copy in `sharing/exporter.js` was deleted in favor of the shared helper). (2) `mediaAnnotations.mergePeerAnnotations` now pre-rejects peer payloads with missing/invalid `updatedAt` before they reach `sanitizeAuthorEntry`'s `now`-fallback — previously a malformed peer record would always win LWW. The pre-check disambiguates "empty tombstone" (still applies as a delete) from "malformed payload" (now ignored entirely, instead of silently deleting the prior peer entry through the tombstone branch). (3) `sanitizeAuthorEntry` gained an opt-in `clampUpdatedAtTo` option used by the merge path so a peer whose clock is years ahead can't ratchet every subsequent LWW round on the same key — its `updatedAt` is clamped to local-now on import without disturbing reasonable timestamps. (4) `mergePeerAnnotations` rejects `peerInstanceId === 'unknown'` (and empty/non-string) on import — the outgoing path already guarded but a hand-crafted manifest or inconsistent peer could otherwise alias every record into the same "unknown" bucket and clobber each other on every merge. (5) `exportAnnotationsToBucket` now has a cheap early-out before `listBucketAssetKeys`: if local has zero annotations AND no prior record exists on disk for this `(bucket, instance)`, skip the manifest+asset-dir scan entirely (the common fresh-install fan-out case). A late-stage skip (both filtered AND prior empty) still covers the case where the bucket has assets but none overlap local. Coverage: 11 new vitest cases across `mediaAnnotations.test.js` (refuses `'unknown'` / empty peer id, drops missing+invalid updatedAt without nuking prior, clamps future-skewed peer ts) and new sibling `sharing/annotationsSync.test.js` (per-bucket displayNameOverride honored in record, cheap early-out skips `listManifestFilenames`, late skip when no local matches + no prior, asset-less bucket short-circuit, inbox-mode short-circuit, tombstone synthesis preserved for prior keys still in bucket). `/simplify` follow-up deferred to `[promote-unknown-instance-id-constant]` — promote the existing `UNKNOWN_INSTANCE_ID` constant from `importer.js` to a shared module + replace the bare `'unknown'` literal at the four remaining sites. All 5775 server tests pass.
- **[voice-picker-on-character-cards-voiceid-binding] Voice picker on character cards + per-line override.** New reusable `client/src/components/voice/VoicePicker.jsx` — engine-grouped dropdown over the merged `/api/pipeline/tts/voices` flat namespaced list (Kokoro + Piper today; future engines slot in upstream) with an audition button that POSTs to `/api/pipeline/tts/preview` and pipes the resulting WAV through `voiceClient.playWav` so it composes with voice-mode echo gating. Module-local cache shared between mounts so the universe character editor opening N picker instances fires exactly one `listPipelineTtsVoices` request. Wired into two consumers: (1) `CharacterDetailEditor`'s Identity section binds `entry.voiceId` (canon-level default for every line spoken by that character — server-side `resolveVoiceForLine` already preferred `character.voiceId` after a per-line override); (2) `AudioStage`'s per-line row gets a `compact + hideWhenEmpty` picker driving `voiceIdOverride` through the existing per-line PATCH path (`saveLineText` generalized to `saveLinePatch` so both text edits and voice-override changes share the in-flight-promise gate that `handleRender` already awaits — preventing a synth fired before the override PATCH settles from rendering against the prior voice). New client API helpers `listPipelineTtsVoices` + `previewPipelineTtsVoice` in `apiPipeline.js` (preview uses raw fetch since the shared `request()` helper auto-parses JSON). Unavailable saved voiceIds (engine uninstalled, voice renamed) are preserved as an `(unavailable)` option so the user sees what was bound instead of silently dropping to the placeholder. Empty voices catalog hides the AudioStage row picker (`hideWhenEmpty`) so a broken TTS install doesn't print an empty picker on every line. Coverage: 9 new vitest cases in `VoicePicker.test.jsx` cover catalog fetch + engine-group rendering, namespaced onChange + null-on-clear, unavailable-voice retention, audition→preview→playWav pipe, audition disabled with no selection, load-error inline display, hideWhenEmpty no-op, and the module-cache single-fetch invariant across mounts. Server-side voiceId + voiceIdOverride support was already complete (storyBible.js sanitizer, audio.js#resolveVoiceForLine, lineEditSchema in routes/pipeline.js, audio.test.js for both resolution priorities). All 5755 server tests + 130 client tests pass.
- **[high-tests-create-test-files-for-server-services] Create test files for `server/services/clinvar.js` and `server/services/telegramBridge.js`.** Both services had no sibling test file — clinvar covers the genome-scan path PortOS uses to flag actionable variants from a 23andMe upload, and telegramBridge is the outbound HTTP bridge that mirrors notifications to a Telegram chat. New `clinvar.test.js` (12 cases) pins `getClinvarStatus`, `scanClinvar` (severity sort + star tiebreak + corrupt-JSON + unknown-severity fallback), `invalidateClinvarCache`, and `deleteClinvar` (success + ENOENT-swallowed). New `telegramBridge.test.js` (14 cases) pins `init` (4 branches: no token, no allowFrom, getMe rejection, happy path + multi-line .env), `sendMessage` (pre-init, success body shape, ok:false surfaced, rate-limit drain at 30), `reload` (no-op when inactive, chat-id swap when active), `cleanup` (state reset + listener unsubscribe), and notification forwarding through the real `notificationEvents` EventEmitter (HTML-escape + emoji formatting + cachedForwardTypes whitelist filter). Module-level token-bucket reset between tests uses `vi.useFakeTimers({ toFake: ['Date'] })` + `setSystemTime` advancing 5 minutes per test so `refillTokens()` fires on the next consumeToken call. All 5781 server tests pass.
diff --git a/client/src/components/imageGen/ImageGenControls.jsx b/client/src/components/imageGen/ImageGenControls.jsx
index 7fba115520..01c09a7c74 100644
--- a/client/src/components/imageGen/ImageGenControls.jsx
+++ b/client/src/components/imageGen/ImageGenControls.jsx
@@ -9,7 +9,7 @@
// resolution; external swaps guidance for cfgScale; local shows guidance + quantize.
import { Dice5 } from 'lucide-react';
-import { filterResolutions } from '../../lib/imageGenResolutions';
+import { filterResolutions, resolveResolutionLabel } from '../../lib/imageGenResolutions';
import { randomSeed } from '../../lib/genUtils';
import { RUNNER_FAMILIES } from '../../lib/runnerFamilies';
@@ -49,8 +49,7 @@ export default function ImageGenControls({
// falls through to the (custom) <option> below so the value stays visible
// until the user picks a supported one.
const availableResolutions = filterResolutions(mode, currentModel?.runner);
- const matched = availableResolutions.find((r) => r.w === width && r.h === height);
- const resolutionLabel = matched?.label || (width && height ? `${width}×${height}` : '');
+ const { matched, label: resolutionLabel } = resolveResolutionLabel(availableResolutions, width, height);
const handleResolution = (e) => {
const r = availableResolutions.find((opt) => opt.label === e.target.value);
if (r) onResolutionChange?.(r.w, r.h);
diff --git a/client/src/lib/imageGenResolutions.js b/client/src/lib/imageGenResolutions.js
index 6d0d289015..33c6aa3c7c 100644
--- a/client/src/lib/imageGenResolutions.js
+++ b/client/src/lib/imageGenResolutions.js
@@ -58,3 +58,15 @@ export const filterResolutions = (mode, runner) => {
const key = compatibilityKey(mode, runner);
return RESOLUTIONS.filter((r) => !r.compatible || r.compatible.includes(key));
};
+
+// Shared dropdown resolver — find the matching preset for an arbitrary w/h
+// pair (returning its preset label) or fall back to a `${w}×${h}` custom
+// label so the dropdown can render an "(custom)" option for unmatched
+// dimensions. Works on any list shaped like RESOLUTIONS / VIDEO_RESOLUTIONS,
+// so both Image Gen and Video Gen consume the same helper.
+export const resolveResolutionLabel = (list, w, h) => {
+ const matched = list.find((r) => r.w === w && r.h === h);
+ if (matched) return { matched, label: matched.label };
+ if (!w || !h) return { matched: null, label: '' };
+ return { matched: null, label: `${w}×${h}` };
+};
diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsx
index 419fd9e3d4..6dafaa728a 100644
--- a/client/src/pages/VideoGen.jsx
+++ b/client/src/pages/VideoGen.jsx
@@ -54,6 +54,7 @@ import {
} from '../services/api';
import { randomSeed, safeParseJSON } from '../lib/genUtils';
import { VIDEO_RESOLUTIONS } from '../lib/videoGenResolutions';
+import { resolveResolutionLabel } from '../lib/imageGenResolutions';
// Values follow LTX-2's 8k+1 latent boundary so the model doesn't silently
// snap. 241 = 10s @ 24fps is the comfortable single-pass ceiling on 48 GB
@@ -315,8 +316,7 @@ export default function VideoGen() {
}, [refreshStatus]);
const currentModel = models.find((m) => m.id === modelId);
- const matchedResolution = VIDEO_RESOLUTIONS.find((r) => r.w === width && r.h === height);
- const resolutionLabel = matchedResolution?.label || `${width}×${height}`;
+ const { matched: matchedResolution, label: resolutionLabel } = resolveResolutionLabel(VIDEO_RESOLUTIONS, width, height);
const progressPct = progress?.progress != null ? Math.round(progress.progress * 100) : null;
const handleResolutionChange = (e) => {