fix: check model file existence against disk, not the scan cache#28
Open
Buckeyes1995 wants to merge 1 commit into
Open
fix: check model file existence against disk, not the scan cache#28Buckeyes1995 wants to merge 1 commit into
Buckeyes1995 wants to merge 1 commit into
Conversation
ModelCard's "Missing File" indicator and the start-button disable used `models.some(m => m.path === card.template.modelPath)` to decide whether the model exists. That cache only contains files under MODELS_DIR and the registered externalModelFolders. Templates whose modelPath was set via the Browse picker to an arbitrary path (sibling directory, outside any registered folder) were always flagged as missing — even when the file was present on disk and llama-server would have started fine. Replace the cache lookup with an explicit fs.existsSync via a new `file-exists` IPC. Keep the cache hit as a fast optimistic path so most cards skip the IPC round-trip entirely; only modelPaths not in the cache trigger the disk check. - src/main/ipc.ts: new `file-exists` handler returning a plain boolean. - src/preload/index.ts + env.d.ts: surface `window.api.fileExists`. - src/renderer/src/components/ModelCard.tsx: useEffect-driven disk check with optimistic in-cache fast path. Returns to `null` (treated as exists) while the IPC is in flight so the card doesn't flicker. Reported by an issue against the existing logic at ModelCard.tsx:14.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15.
Summary
ModelCardwas using the cachedlist-modelsscan to decide whether a template'smodelPathexists. The cache only coversMODELS_DIRand registeredexternalModelFolders, so files picked via the Browse button from any other directory were always flagged "Missing File" — even when on disk and runnable.Switches the existence check to an explicit
fs.existsSyncvia a newfile-existsIPC. Keeps the cache lookup as a fast optimistic path, so the IPC round-trip only fires for paths the scan didn't see.Reproduction (before this PR)
.ggufoutsidemodels/and outside any registered external folderAfter
The file is correctly reported as present. The Start button enables.
ModelCard.tsx:14no longer over-rejects.Implementation
src/main/ipc.tsfile-existshandler returning a plain boolean fromexistsSync(path).src/preload/index.ts+src/renderer/src/env.d.tswindow.api.fileExists.src/renderer/src/components/ModelCard.tsxnullwhile in-flight is treated as "exists" so cards don't flicker into the missing state between renders.Test plan
npm run buildpasses; zero new tsc errors vsdevelopbaseline.MODELS_DIR→ not missing (uses cache fast path).