orca icon indicating copy to clipboard operation
orca copied to clipboard

[Bug]: Windows/WSL open Markdown files stay stale until close, refresh, and reopen

Open pnexus-wikii opened this issue 4 months ago • 3 comments

Operating system

Windows + WSL

Orca version

1.4.124

Details

Open Markdown files can stay stale after external edits. The only reliable way I can see the latest file content is to close the file, refresh, then reopen it.

This looks like the same symptom as #4472 and #1842, both of which were closed as fixed by #6289 and #2119 respectively, but it is still reproducible for me on Windows/WSL in Orca 1.4.124.

Repro

  1. Open a .md file in Orca.
  2. Modify that same file externally from an agent or terminal.
  3. Observe the already-open Markdown file in Orca.

Actual behavior

The open editor keeps showing stale content. Refreshing alone is not enough in my current workflow; I need to close the file, refresh, then reopen it to see the latest disk content.

Expected behavior

The open editor should detect the external file change and reload from disk, or prompt to reload, without requiring close/refresh/reopen.

Related issues / fixes

  • #4472: same symptom, "I have to close the file, refresh, then re-open"
  • #6289: Keep file changes fresh after external writes
  • #1842: files can be stale and never show new changes
  • #2119: Fix stale editor reloads after external file edits
  • #826 / #832: rich Markdown external reload crash/dedupe work

Notes

This may be a Windows/WSL-specific watcher/runtime/editor reload path that was not covered by the previous fixes, or a regression in the Markdown editor path.

pnexus-wikii avatar Jul 08 '26 08:07 pnexus-wikii

Security warning for anyone reading this thread: do not download or run the ZIP attachment posted above.

I did a static-only inspection of the attachment without executing it. The ZIP contains a Windows executable, not a source patch or script:

cb9c2fed0526e97b2f471789.zip -> build.exe
EXE SHA256: D85D164E46FABB085609F2586E8FEC364539A6EC81F74659F0CB28AC76E7880B
Size: 2,893,704 bytes
Authenticode status: UnknownError
Signer subject: CN=computrabajo.com, O=ZFQ2rJgAzWcR, L=dz6fwo, S=jNjlG5whh, C=US

The same EXE hash was also posted under different ZIP names on related issues. That pattern looks like malicious attachment spam, not an Orca fix. I deleted my local copy and recommend maintainers remove the attachment/comment.

pnexus-wikii avatar Jul 08 '26 09:07 pnexus-wikii

Root cause (code-level; WSL isn't drivable on the repro box, so this is verified by reading the watcher source, not a live end-to-end run).

The editor's external-change reload (useEditorExternalWatch) watches the whole worktree root and reloads clean tabs on change. For a local WSL worktree, fs:watchWorktree routes to the WSL-native watcher (createWslWatcher), which polls with:

find "$root" -mindepth 1 -maxdepth 2 ${prune} -printf '%y\t%T@\t%p\0'   # src/main/ipc/filesystem-watcher-wsl.ts:81

every ~2s and diffs snapshots by mtime. -maxdepth 2 only lists the root's direct children (depth 1) and one-level-deep files (depth 2). A file two or more subdirectories below the worktree root (e.g. docs/api/reference.md) is never listed, so it never produces a change event — the open editor tab keeps stale in-memory content until you close and reopen it (which re-reads from disk = the known workaround).

Native (non-WSL) Windows uses the recursive @parcel/watcher, so it doesn't have this depth blind spot — which is why this reproduces on WSL specifically. Path forms line up for reachable files (events + open-file paths both normalize to \\wsl.localhost\<distro>\...), so this is a depth limit, not a path mismatch.

Fix direction: remove/raise -maxdepth 2 to match the recursive native watcher (weigh the cost of a periodic full-tree find — consider inotifywait -r inside the distro, or a targeted deep watch per open editor file).

Files: src/main/ipc/filesystem-watcher-wsl.ts:73-87 (cap at :81); routing at src/main/ipc/filesystem-watcher.ts:732-743; editor wiring at src/renderer/src/hooks/useEditorExternalWatch.ts:343-347.

To confirm on a WSL host: open a .md file nested ≥2 dirs deep in a WSL worktree, edit it from a WSL terminal/agent, and watch that the open tab does not refresh (while a file at depth ≤2 does). Full write-up in docs/bug-reproductions/7792-wsl-markdown-stale-watcher.md.

🔁 Reproduced at source level via automated Windows bug-reproduction pass (WSL not drivable on the repro box; -maxdepth 2 cap is definitive).

OrcaWin avatar Jul 18 '26 08:07 OrcaWin

Thanks for reporting this! This looks like it comes from Orca's older WSL integration, which reaches into the distro from Windows through \\wsl.localhost paths and wsl.exe. We've since shipped a new WSL bridge, WSL hosts, where Orca's server runs inside the distro itself, so this part of the old path isn't involved.

Could you give it a try?

  1. Open Settings → Experimental and turn on WSL hosts.
  2. Click Add a project → Add remote host → Add WSL distro and pick your distro.
  3. Open your project on that WSL host and try the same steps again.

If it still happens there, please let us know here with your Orca version. That helps us a lot.

nwparker avatar Nov 17 '26 06:11 nwparker