Skip to content

[BUG] File Watcher Fails to Re-index Modified Files in Local Mode #197

@Crimsonyx412

Description

@Crimsonyx412

Project

vgrep

Description

When running in local mode (--local), the file watcher detects file modifications and deletes the old file entry from the database, but then only prints "(pending)" and never actually re-indexes the updated file. This causes modified files to disappear from search results permanently.

Error Message

N/A - No error is raised. The console shows:
  [~] modified filename.rs (pending)
But no indexing occurs.

Debug Logs

$ RUST_LOG=debug vgrep --local watch
# Modify a file
  [~] modified test.rs (pending)
# File is never re-indexed - no further output

System Information

vgrep version: 0.1.0
Mode: local (--local flag)

Screenshots

No response

Steps to Reproduce

  1. Run vgrep --local watch in a project directory
  2. Wait for initial indexing to complete
  3. Modify an indexed source file (e.g., add a comment)
  4. Observe console shows [~] modified filename.rs (pending)
  5. Run vgrep "content from that file" in another terminal
  6. Observe the modified file no longer appears in search results

Expected Behavior

Modified files should be re-indexed immediately in local mode, just as they are in server mode. The file should remain searchable after modification.

Actual Behavior

The file is removed from the index (line 326-328 deletes the entry) but in local mode, the code only prints a message and returns without calling any indexing function. The file is permanently lost from the index until a full re-index is performed.

Additional Context

File: src/watcher.rs
Function: process_files() (lines 330-351)
Problematic code:

Mode::Local => {
    println!(
        "  {} {} {} {}",
        style("[~]").yellow(),
        style("modified").yellow(),
        style(filename).cyan(),
        style("(pending)").dim()   // <-- Never actually processed!
    );
}

Fix direction: Add local indexing logic similar to index_file_server() for the Mode::Local branch:

Mode::Local => {
    let engine = crate::core::EmbeddingEngine::new(&self.config)?;
    self.index_file_local(&db, &engine, path, &content)?;
    println!("  {} {} {}", style("[+]").green(), style("indexed").green(), style(filename).cyan());
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginvalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions