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
feat([issue-1376]): repair UI for a corrupt video text-encoder
[._.]/ Adam Eivyc884f53b53a3
diff --git a/client/src/hooks/useModelDownloadStatus.js b/client/src/hooks/useModelDownloadStatus.jsindex cb512c8bc5..7b2f63be62 100644--- a/client/src/hooks/useModelDownloadStatus.js+++ b/client/src/hooks/useModelDownloadStatus.js@@ -4,6 +4,7 @@ import toast from '../components/ui/Toast';import {getImageModelStatuses, getVideoModelStatuses,verifyImageModels, verifyVideoModels, repairImageModel, repairVideoModel,+ repairTextEncoder,} from '../services/apiImageVideo.js';// Sentinel `modelId` used to drive a text-encoder download instead of a model@@ -104,8 +105,14 @@ export function useModelDownloadStatus({ kind = 'image' } = {}) {const repair = useCallback(async (modelId, { deep = false } = {}) => {if (!modelId) return;setRepairing(true);- const fn = kind === 'video' ? repairVideoModel : repairImageModel;- const result = await fn(modelId, { deep }).catch((err) => {+ // The shared text encoder isn't a model id, so its repair hits the scalar+ // /text-encoder/repair endpoint; the sentinel `start()` below already maps+ // to the dedicated /text-encoder/download SSE for the clean re-fetch.+ const isTextEncoder = kind === 'video' && modelId === TEXT_ENCODER_DOWNLOAD_ID;+ const run = isTextEncoder+ ? () => repairTextEncoder({ deep })+ : () => (kind === 'video' ? repairVideoModel : repairImageModel)(modelId, { deep });+ const result = await run().catch((err) => {toast.error(err?.message || 'Repair failed');return null;});diff --git a/client/src/pages/VideoGen.jsx b/client/src/pages/VideoGen.jsxindex 3c7d1c3fd3..e81d5af522 100644--- a/client/src/pages/VideoGen.jsx+++ b/client/src/pages/VideoGen.jsx@@ -885,6 +885,17 @@ export default function VideoGen() {const [dismissedIntegrityKey, setDismissedIntegrityKey] = useState(null);const showIntegrityBanner = integrityBad && dismissedIntegrityKey !== integrityKey && !modelDownload.downloading;+ // Text-encoder integrity. The shared Gemma encoder is a separate HF repo, so a+ // corrupt encoder needs its own Repair banner — the model-keyed repair above+ // can't reach it (it isn't a listVideoModels() entry). Local-path encoders+ // report `integrity: null`, so this only fires for a damaged HF-cached encoder.+ const encoderIntegrity = textEncoderStatus && !textEncoderStatus.downloading ? textEncoderStatus.integrity : null;+ const encoderIntegrityBad = encoderIntegrity?.status === 'bad';+ const encoderIntegrityBadCount = encoderIntegrityBad ? (encoderIntegrity.badFiles || []).length : 0;+ const encoderIntegrityKey = encoderIntegrityBad ? `text-encoder:${(encoderIntegrity.badFiles || []).map((f) => f.name).join(',')}` : null;+ const [dismissedEncoderIntegrityKey, setDismissedEncoderIntegrityKey] = useState(null);+ const showEncoderIntegrityBanner = encoderIntegrityBad && dismissedEncoderIntegrityKey !== encoderIntegrityKey && !modelDownload.downloading;+const { matched: matchedResolution, label: resolutionLabel } = resolveResolutionLabel(VIDEO_RESOLUTIONS, width, height);const progressPct = progress?.progress != null ? Math.round(progress.progress * 100) : null;@@ -1478,6 +1489,35 @@ export default function VideoGen() {</div></div>)}+ {showEncoderIntegrityBanner && (+ <div className="rounded-lg border border-port-error/40 bg-port-error/10 px-3 py-3 text-xs text-port-error flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2">+ <div className="flex items-start gap-2">+ <AlertTriangle className="w-4 h-4 shrink-0 mt-0.5" />+ <div>+ The shared <strong className="font-semibold">text encoder</strong> ({textEncoderStatus?.repo}) has {encoderIntegrityBadCount || 'corrupt'} damaged weight file{encoderIntegrityBadCount === 1 ? '' : 's'} — renders may come out garbled.+ Repair deletes the bad file{encoderIntegrityBadCount === 1 ? '' : 's'} and re-downloads clean copies.+ </div>+ </div>+ <div className="flex items-center gap-2 self-start sm:self-auto">+ <button+ type="button"+ onClick={() => { setDismissedEncoderIntegrityKey(encoderIntegrityKey); modelDownload.repair(TEXT_ENCODER_DOWNLOAD_ID); }}+ disabled={modelDownload.repairing || modelDownload.downloading}+ className="whitespace-nowrap inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-port-error text-white text-xs font-medium hover:bg-port-error/80 disabled:opacity-50"+ >+ <RefreshCw className={`w-3.5 h-3.5 ${modelDownload.repairing ? 'animate-spin' : ''}`} />+ Repair encoder+ </button>+ <button+ type="button"+ onClick={() => setDismissedEncoderIntegrityKey(encoderIntegrityKey)}+ className="text-gray-400 hover:text-gray-200 text-xs"+ >+ Dismiss+ </button>+ </div>+ </div>+ )}<StylePresetPickervalue={stylePreset?.id || ''}onChange={setStylePreset}diff --git a/client/src/services/apiImageVideo.js b/client/src/services/apiImageVideo.jsindex ee37ee7ac4..fbe613d3aa 100644--- a/client/src/services/apiImageVideo.js+++ b/client/src/services/apiImageVideo.js@@ -103,6 +103,14 @@ export const repairVideoModel = (modelId, { deep = false } = {}) => request(`/vibody: JSON.stringify({ deep }),silent: true,});+// Repair the shared text encoder — delete its corrupt files so the existing+// /text-encoder/download SSE re-fetches clean copies. The encoder isn't a model+// id, so it needs this scalar endpoint rather than repairVideoModel.+export const repairTextEncoder = ({ deep = false } = {}) => request('/video-gen/text-encoder/repair', {+ method: 'POST',+ body: JSON.stringify({ deep }),+ silent: true,+});export const cancelVideoGen = () => request('/video-gen/cancel', { method: 'POST' });// Currently-running (or next-queued) video job — used on VideoGen mount to// resume progress display after a page reload. Silent so a 5xx during statusdiff --git a/server/routes/videoGen.integrity.test.js b/server/routes/videoGen.integrity.test.jsindex 1bf17b70e6..f7d405c1f7 100644--- a/server/routes/videoGen.integrity.test.js+++ b/server/routes/videoGen.integrity.test.js@@ -77,6 +77,7 @@ vi.mock('fs/promises', () => ({ unlink: vi.fn(async () => {}), copyFile: vi.fn(aimport videoGenRoutes from './videoGen.js';import { verifyModelCache, repairModelCache } from '../lib/hfCache.js';+import { isHfRepoId } from '../lib/mediaModels.js';describe('Video Gen integrity routes', () => {let app;@@ -114,4 +115,26 @@ describe('Video Gen integrity routes', () => {const res = await request(app).post('/api/video-gen/models/nope/repair').send({});expect(res.status).toBe(404);});++ it('POST /text-encoder/repair deletes the encoder repo flagged files', async () => {+ const res = await request(app).post('/api/video-gen/text-encoder/repair').send({});+ expect(res.status).toBe(200);+ expect(res.body.repos).toEqual(['org/text-encoder']);+ expect(res.body.deleted).toEqual([{ repo: 'org/text-encoder', name: 'model.safetensors' }]);+ expect(repairModelCache).toHaveBeenCalledWith('org/text-encoder', { deep: false });+ });++ it('POST /text-encoder/repair passes deep through', async () => {+ const res = await request(app).post('/api/video-gen/text-encoder/repair').send({ deep: true });+ expect(res.status).toBe(200);+ expect(res.body.deep).toBe(true);+ expect(repairModelCache).toHaveBeenCalledWith('org/text-encoder', { deep: true });+ });++ it('POST /text-encoder/repair 400s for a local-path (non-HF) encoder', async () => {+ isHfRepoId.mockReturnValueOnce(false);+ const res = await request(app).post('/api/video-gen/text-encoder/repair').send({});+ expect(res.status).toBe(400);+ expect(res.body.code).toBe('NOT_DOWNLOADABLE');+ });});diff --git a/server/routes/videoGen.js b/server/routes/videoGen.jsindex 67fc1a4128..03b816290e 100644--- a/server/routes/videoGen.js+++ b/server/routes/videoGen.js@@ -478,6 +478,25 @@ router.get('/models/:modelId/download', asyncHandler(async (req, res) => {await startHfDownloadStream({ req, res, repo });}));+// POST /text-encoder/repair — delete the flagged (corrupt/truncated) weight+// files for the active text encoder repo so the existing /text-encoder/download+// SSE re-fetches clean copies. The encoder is shared across all video renders+// and is NOT a listVideoModels() entry, so the model-id-keyed+// /models/:modelId/repair can't cover it — this scalar route does. A local-path+// encoder (e.g. an LM Studio install) isn't an HF repo and has nothing to+// repair through the cache.+router.post('/text-encoder/repair', asyncHandler(async (req, res) => {+ const repo = getTextEncoderRepo();+ if (!isHfRepoId(repo)) {+ throw new ServerError('Active text encoder is a local-path entry, not an HF repo.', { status: 400, code: 'NOT_DOWNLOADABLE' });+ }+ const parsed = z.object({ deep: z.boolean().optional() }).safeParse(req.body || {});+ if (!parsed.success) failValidation(parsed);+ const deep = parsed.data.deep || false;+ const result = await repairModelCache(repo, { deep });+ res.json({ deep, deleted: result.deleted.map((name) => ({ repo: result.repoId, name })), repos: [repo] });+}));+// Text encoder pre-fetch. The Gemma encoder is a separate ~7-25 GB pull from// the video model itself, so it gets its own button on the video form.router.get('/text-encoder/download', asyncHandler(async (req, res) => {