feat(fs-watcher): add inotify watch limit sensing with toast warning

This commit is contained in:
Hibryda 2026-03-11 01:07:46 +01:00
parent d1ce031624
commit b19aa632c8
4 changed files with 168 additions and 7 deletions

View file

@ -26,3 +26,16 @@ export function onFsWriteDetected(
): Promise<UnlistenFn> {
return listen<FsWriteEvent>('fs-write-detected', (e) => callback(e.payload));
}
export interface FsWatcherStatus {
max_watches: number;
estimated_watches: number;
usage_ratio: number;
active_projects: number;
warning: string | null;
}
/** Get inotify watcher status including kernel limit check */
export function fsWatcherStatus(): Promise<FsWatcherStatus> {
return invoke('fs_watcher_status');
}

View file

@ -13,7 +13,7 @@
import MemoriesTab from './MemoriesTab.svelte';
import { getTerminalTabs } from '../../stores/workspace.svelte';
import { getProjectHealth } from '../../stores/health.svelte';
import { fsWatchProject, fsUnwatchProject, onFsWriteDetected } from '../../adapters/fs-watcher-bridge';
import { fsWatchProject, fsUnwatchProject, onFsWriteDetected, fsWatcherStatus } from '../../adapters/fs-watcher-bridge';
import { recordExternalWrite } from '../../stores/conflicts.svelte';
import { notify } from '../../stores/notifications.svelte';
@ -58,10 +58,17 @@
const projectId = project.id;
if (!cwd) return;
// Start watching
fsWatchProject(projectId, cwd).catch(e =>
console.warn(`Failed to start fs watcher for ${projectId}:`, e)
);
// Start watching, then check inotify capacity
fsWatchProject(projectId, cwd)
.then(() => fsWatcherStatus())
.then((status) => {
if (status.warning) {
notify('warning', status.warning);
}
})
.catch(e =>
console.warn(`Failed to start fs watcher for ${projectId}:`, e)
);
// Listen for fs write events (filter to this project)
let unlisten: (() => void) | null = null;