feat: enhance watcher control modal to fetch indexed projects and set default path

This commit is contained in:
catlog22
2026-01-04 11:20:49 +08:00
parent f28b6c6197
commit df4d6fdc45
2 changed files with 46 additions and 6 deletions

View File

@@ -1357,6 +1357,29 @@ export async function handleCodexLensRoutes(ctx: RouteContext): Promise<boolean>
return { success: false, error: 'CodexLens not installed', status: 400 };
}
// Verify directory is indexed before starting watcher
try {
const statusResult = await executeCodexLens(['projects', 'list', '--json']);
if (statusResult.success && statusResult.stdout) {
const parsed = extractJSON(statusResult.stdout);
const projects = parsed.result || parsed || [];
const normalizedTarget = targetPath.toLowerCase().replace(/\\/g, '/');
const isIndexed = Array.isArray(projects) && projects.some((p: { source_root: string }) =>
p.source_root && p.source_root.toLowerCase().replace(/\\/g, '/') === normalizedTarget
);
if (!isIndexed) {
return {
success: false,
error: `Directory is not indexed: ${targetPath}. Run 'codexlens init' first.`,
status: 400
};
}
}
} catch (err) {
console.warn('[CodexLens] Could not verify index status:', err);
// Continue anyway - watcher will fail with proper error if not indexed
}
// Spawn watch process using Python (no shell: true for security)
// CodexLens is a Python package, must run via python -m codexlens
const pythonPath = getVenvPythonPath();