fix(with-watch): use metadata snapshots for ls#373
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11b4ddf07c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| push_inferred_path_with_mode( | ||
| &mut inputs, | ||
| token, | ||
| cwd, | ||
| ls_like_snapshot_mode(token, cwd, recursive, directory_mode), |
There was a problem hiding this comment.
Parse ls flags before mapping operand snapshot modes
analyze_ls_like assigns each operand’s PathSnapshotMode immediately using the current recursive/directory_mode booleans, so options that appear later never update earlier operands. This under-watches valid invocations like ls subdir -R (GNU ls treats it as recursive): subdir is recorded as MetadataChildren, and deep descendant updates will not trigger reruns even though delegated command output changes. Parse all effective flags first (or retroactively update collected operands) before choosing snapshot modes.
Useful? React with 👍 / 👎.
| match fs::metadata(path) { | ||
| Ok(metadata) if metadata.is_dir() => PathSnapshotMode::ContentTree, | ||
| Ok(_) | Err(_) => PathSnapshotMode::ContentPath, |
There was a problem hiding this comment.
Avoid freezing missing path inputs to non-recursive mode
default_path_snapshot_mode maps metadata lookup failures to ContentPath, and that snapshot mode is fixed when WatchInput::path is created. If a watched path is missing at startup and later becomes a directory (for example with-watch find src before src/ exists), future snapshots keep treating it as a single path entry, so changes under src/** are missed after the first creation rerun. This regresses prior behavior where directory recursion was determined from the current filesystem state at snapshot time.
Useful? React with 👍 / 👎.
Summary
ls/dir/vdirto metadata-based listing snapshots so the first run does not recurse through large trees before spawningls -Rrecursive, keepls -dscoped to the named path, and add snapshot timing/mode debug logsTesting
/Users/kdy1/projects/cloud:with-watch lsnow prints immediately withsnapshot_modes="metadata-children"