* fix(server): watch extra_models_dir's nested folders on Linux and macOS
The Linux and macOS DirectoryWatchers watched extra_models_dir itself, which
reports changes to that directory's own entries only. A GGUF added to an
existing model folder, or a cache repo's refs/main moving to a new revision,
left the model list stale until something else invalidated it.
On Linux every folder below the root now gets an inotify watch, including
folders created after the watcher starts. Nested watches leave out IN_MODIFY
so a file being downloaded fires once when it is closed rather than on every
write.
On macOS the kqueue watcher is replaced with FSEvents, which reports changes
anywhere below the watched path. Recursive kqueue would need a descriptor per
folder, and a large model tree would exceed the default open-file limit.
Windows already polls the whole tree.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
* fix(server): fire macOS DirectoryWatcher once per download
FSEvents keeps reporting a file while it is written, so a download in
extra_models_dir fired the callback every latency window and pushed a
models-changed notification to every client each time. Wait for 200 ms
of quiet before calling back, matching Linux's IN_CLOSE_WRITE behavior.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VYbd5msDN6hLgsh4Rv5wAB
* test(routing): wait for the updated policy after a watcher reload
The watcher test accepted any engine swap, but a watcher event left over
from the first write can reload the unchanged file. With the macOS quiet
period that stale reload lands just before the edit, so the poll caught
the old policy and failed. Poll until the updated policy is loaded, and
drop the delete-then-write step that kqueue needed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VYbd5msDN6hLgsh4Rv5wAB
* fix(server): announce a new file on Linux only once it is closed
A regular file's IN_CREATE fired the callback while the file could still
be open, so a download that outlived the 100 ms debounce was listed
incomplete and then again on IN_CLOSE_WRITE. Skip IN_CREATE for a new
regular file, which always reports IN_CLOSE_WRITE; symlinks and hard
links never close, so they still count. Drop IN_MODIFY from the root
watch too, so a download straight into extra_models_dir also fires once.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VYbd5msDN6hLgsh4Rv5wAB
---------
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
* Monitor extra models directory for changes
* fix macOS watcher: skip callback on kevent timeout
kevent() returns 0 on timeout with no events, but the code fell
through and invoked the callback anyway. This caused the model cache
to be invalidated every 200ms even when the directory did not change.
Add 'if (n == 0) continue;' after the kevent() call to skip the
callback when no events were received.