Skip to content

Feature request: File watching for local mode (detect external changes) #54

@itsbluetic

Description

@itsbluetic

Problem

When using Stik in local mode (custom notes directory), external file modifications are not detected by the app. If another program (e.g., a CLI tool, another editor, or a script) modifies a .md file in the Stik directory, the changes are not reflected in the Stik UI until the app is restarted.

Root Cause (from code analysis)

  • iCloud mode: File watching is fully implemented via NSFileCoordinatornotify_external_change() → frontend event. Works great.
  • Local mode: No file system watcher exists. Notes are read once via std::fs::read_to_string() and cached in AppState::viewing_notes. The cache is never invalidated on external file changes.

Key locations:

  • src-tauri/src/commands/storage.rs — no local file watching (line 313-325)
  • src-tauri/src/commands/index.rsnotify_external_change() exists but is never called for local files
  • src-tauri/src/windows.rsget_viewing_note_content() returns cached content without checking disk (line 488-502)

Proposed Solution

Add a file system watcher for local mode using notify-rs crate:

  1. Watch the Stik root directory recursively for .md file changes
  2. On change, call the existing index.notify_external_change() method
  3. Emit a frontend event (similar to icloud-files-changed) to trigger UI refresh
  4. In get_viewing_note_content(), check file modification timestamp vs cache timestamp

The architecture already supports this — notify_external_change() and the frontend event system are in place. Only the local file watcher trigger is missing.

Use Case

I use Stik alongside Obsidian and CLI tools (Claude Code). My workflow:

  • Stik notes directory points to an Obsidian vault folder
  • CLI tools update note contents programmatically
  • I expect Stik to reflect those changes in real-time

Love the app — this would make it perfect for developer workflows!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions