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 (copilot): tighten isHfRepoId for Windows paths + 3 doc fixes
[._.]/ Adam Eivyc8a1c9787ebc
diff --git a/client/src/components/media/ModelDownloadBadge.jsx b/client/src/components/media/ModelDownloadBadge.jsxindex c3e49d3aa9..3898c598ef 100644--- a/client/src/components/media/ModelDownloadBadge.jsx+++ b/client/src/components/media/ModelDownloadBadge.jsx@@ -1,7 +1,7 @@// Inline "Available · 7.8 GB" / "Download (~8 GB)" badge for the image and// video gen model pickers. Drops below the model <select> so the user can// see — before hitting Render — whether their pick still needs a multi-GB-// HF pull. Rendering Render is NOT blocked: lazy download remains the+// HF pull. Hitting Render is NOT blocked: lazy download remains the// fallback, so a user who just wants to fire and wait can keep doing that.//// Three render states:diff --git a/scripts/hf_download_repo.py b/scripts/hf_download_repo.pyindex 4ce63ced98..7ecf7922ce 100755--- a/scripts/hf_download_repo.py+++ b/scripts/hf_download_repo.py@@ -5,8 +5,10 @@ PortOS HuggingFace snapshot pre-fetch.Downloads a full HF repo into the standard `~/.cache/huggingface/hub/` cacheso the image / video gen forms can show a model as "Available" instead offorcing the user to discover a multi-GB pull mid-render. Spawned over SSE-from `server/routes/imageGen.js#/models/:repoId/download` and the matching-video route.+from `GET /api/image-gen/models/:id/download` and the matching+`GET /api/video-gen/models/:id/download` (model-id-keyed; the route maps+the id to an HF repo before invoking this helper), plus+`GET /api/video-gen/text-encoder/download` for the Gemma encoder.Wire protocol (matches the STAGE:/DOWNLOAD: convention the rest of theimage-gen runners use, so the existing SSE bridge picks it up unchanged):diff --git a/server/lib/hfDownload.js b/server/lib/hfDownload.jsindex 86bd786425..5359033a32 100644--- a/server/lib/hfDownload.js+++ b/server/lib/hfDownload.js@@ -11,7 +11,10 @@// STAGE:list -> { type: 'stage', stage: 'list' }// STAGE:download:<n>/<total>:<file> -> stage + progress n/total// STAGE:complete:<bytes> -> { type: 'complete', sizeBytes }-// USER_ERROR:<kind>:<repo> -> typed-error capture+// USER_ERROR:<kind>:<detail> -> typed-error capture; <detail>+// is the repo id for list/auth+// failures and the filename+// for per-file download errors// ❌ <prose> -> errorMessage// Unknown lines fall through as raw `{ type: 'log', message }`.diff --git a/server/lib/mediaModels.js b/server/lib/mediaModels.jsindex 717cd28ebf..905ad70f5f 100644--- a/server/lib/mediaModels.js+++ b/server/lib/mediaModels.js@@ -573,15 +573,26 @@ export const repoForModel = (model) => {// `getTextEncoderRepo()` can return either an HF repo id (`org/name`) or a// resolved local filesystem path when the registry entry has a `localPath`-// override. Anything that starts with `/` or `~` is a local path; only-// `org/name` is a valid input to HF-cache inspection / download endpoints.-export const isHfRepoId = (value) => (- typeof value === 'string'- && value.length > 0- && !value.startsWith('/')- && !value.startsWith('~')- && value.includes('/')-);+// override. Only `org/name` is a valid input to HF-cache inspection /+// download endpoints.+//+// Reject local-path shapes across platforms:+// - POSIX absolute / home-relative: `/foo/bar`, `~/foo`+// - Windows drive paths (both backslash and forward-slash style): `C:\…`,+// `C:/Users/…` — without this check, a Windows install with a+// forward-slash-style localPath text encoder would be misclassified as+// an HF repo, triggering bogus cache inspection / download requests.+// - Windows UNC paths: `\\server\share\…`+// - Any path containing a backslash (Windows separator)+// Then require exactly one `/` separator — standard HF repo ids are the+// `org/name` shape; zero (`legacy-bare-name`) and multiple (a path) are not.+export const isHfRepoId = (value) => {+ if (typeof value !== 'string' || value.length === 0) return false;+ if (value.startsWith('/') || value.startsWith('~')) return false;+ if (value.includes('\\')) return false;+ if (/^[A-Za-z]:/.test(value)) return false;+ return (value.match(/\//g) || []).length === 1;+};// Resolve the active text encoder to a path mlx_video can pass via// --text-encoder-repo. Prefers `localPath` (e.g. an existing LM Studiodiff --git a/server/lib/mediaModels.test.js b/server/lib/mediaModels.test.jsindex 4af8a0bc57..48d6c152f8 100644--- a/server/lib/mediaModels.test.js+++ b/server/lib/mediaModels.test.js@@ -605,6 +605,29 @@ describe('mediaModels registry', () => {logSpy.mockRestore();});+ it('isHfRepoId accepts canonical org/name shape and rejects local paths cross-platform', async () => {+ const { isHfRepoId } = await import('./mediaModels.js');+ expect(isHfRepoId('black-forest-labs/FLUX.1-dev')).toBe(true);+ expect(isHfRepoId('mlx-community/gemma-3-12b-it-4bit')).toBe(true);+ // POSIX / home-relative+ expect(isHfRepoId('/usr/local/share/model')).toBe(false);+ expect(isHfRepoId('~/.cache/huggingface/hub')).toBe(false);+ // Windows drive paths — both backslash and forward-slash style.+ // These would silently pass the old `includes('/')` check and trip the+ // download endpoints into treating an LM Studio path as a Hub repo.+ expect(isHfRepoId('C:/Users/foo/model')).toBe(false);+ expect(isHfRepoId('C:\\Users\\foo\\model')).toBe(false);+ expect(isHfRepoId('D:/lmstudio/models')).toBe(false);+ // UNC and other backslash-bearing paths+ expect(isHfRepoId('\\\\server\\share\\model')).toBe(false);+ // Multi-slash shapes are paths, not repo ids+ expect(isHfRepoId('org/name/subdir')).toBe(false);+ // Empty / non-string / non-namespaced legacy bare names+ expect(isHfRepoId('')).toBe(false);+ expect(isHfRepoId(null)).toBe(false);+ expect(isHfRepoId('bare-name')).toBe(false);+ });+it('does NOT auto-recover the drifted entry (warn loud, but trust the registry on disk)', async () => {// Same setup as the first drift test — confirm that the warning does// NOT cause normalizeRegistry to silently re-add the missing built-in.