Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ semver = "1.0.28"
schemars = "1.2.2"
serde = { version = "1.0.229", features = ["derive"] }
serde_json = "1.0.151"
jsonc-parser = { version = "0.32.1", default-features = false, features = ["serde"] }
signal-hook = "0.4.4"
smallvec = "1.15.2"
smol = "2.0.2"
Expand Down
1 change: 1 addition & 0 deletions crates/gitcomet-state/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ notify = { workspace = true }
smol = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
jsonc-parser = { workspace = true }
rustc-hash = { workspace = true }
smallvec = { workspace = true }
tempfile = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion crates/gitcomet-state/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub use effect::Effect;
pub use message::{
CommitSelectMode, ConflictAutosolveMode, ConflictAutosolveStats, ConflictBulkChoice,
ConflictBulkScope, ConflictRegionChoice, ConflictRegionResolutionUpdate, InternalMsg, Msg,
RepoActionKind, RepoWatchDegradedReason,
RepoActionKind, RepoWatchDegradedReason, WatcherExcludeLoadStatus,
};
pub use repo_command_kind::RepoCommandKind;
pub use repo_external_change::RepoExternalChange;
Expand Down
24 changes: 22 additions & 2 deletions crates/gitcomet-state/src/msg/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,32 @@ impl ConflictAutosolveStats {
}
}

/// How `<workdir>/.vscode/settings.json` `files.watcherExclude` loaded for the
/// active monitor. `Copy` so it can ride on [`RepoWatchDegradedReason`].
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum WatcherExcludeLoadStatus {
/// The Respect-IDE-excludes setting is off; the file was not read.
#[default]
Disabled,
/// The settings file is absent.
Missing,
/// The file existed but could not be read or parsed as JSONC.
Unreadable,
/// The file parsed. True-entry count lives on the rule set, not here.
Parsed,
}

/// Why the file-system watcher is in a degraded state (carried by [`Msg::RepoWatchDegraded`]).
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum RepoWatchDegradedReason {
/// The worktree has more non-ignored folders than the watch budget, so its source folders are
/// not watched live at all. Carries the folder count.
TooManyFolders { dir_count: usize },
/// not watched live at all. `dir_count` is the probe length; `capped` means the walk stopped
/// early so the count is not an exact census.
TooManyFolders {
dir_count: usize,
capped: bool,
load_status: WatcherExcludeLoadStatus,
},
/// Some per-directory watches could not be added (the kernel inotify limit was reached), so part
/// of the worktree is not watched live. Carries the number of folders left unwatched.
WatchLimitReached { unwatched_dirs: usize },
Expand Down
70 changes: 60 additions & 10 deletions crates/gitcomet-state/src/store/reducer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,12 +900,31 @@ fn reduce_inner(
}
Msg::RepoWatchDegraded { repo_id: _, reason } => {
let message = match reason {
crate::msg::RepoWatchDegradedReason::TooManyFolders { dir_count } => format!(
"This repository has {dir_count} folders — live file watching is disabled to \
stay within system limits. Changes refresh when the window regains focus. Add \
build/output dirs to .gitignore or raise fs.inotify.max_user_watches to \
re-enable."
),
crate::msg::RepoWatchDegradedReason::TooManyFolders {
dir_count,
capped,
load_status,
} => {
let count = if capped {
format!("more than {}", dir_count.saturating_sub(1))
} else {
dir_count.to_string()
};
let parse_note = match load_status {
crate::msg::WatcherExcludeLoadStatus::Unreadable => {
" .vscode/settings.json could not be parsed, so files.watcherExclude was not applied."
}
crate::msg::WatcherExcludeLoadStatus::Disabled
| crate::msg::WatcherExcludeLoadStatus::Missing
| crate::msg::WatcherExcludeLoadStatus::Parsed => "",
};
format!(
"This repository has {count} folders — live file watching is disabled to \
stay within system limits. Changes refresh when the window regains focus.{parse_note} \
Add build/output dirs to .gitignore or to .vscode/settings.json files.watcherExclude, \
or raise fs.inotify.max_user_watches to re-enable."
)
}
crate::msg::RepoWatchDegradedReason::WatchLimitReached { unwatched_dirs } => {
format!(
"Live file watching is partial: {unwatched_dirs} folders could not be watched \
Expand Down Expand Up @@ -2398,7 +2417,11 @@ mod nav_history_tests {
&mut state,
Msg::RepoWatchDegraded {
repo_id: RepoId(1),
reason: crate::msg::RepoWatchDegradedReason::TooManyFolders { dir_count: 9000 },
reason: crate::msg::RepoWatchDegradedReason::TooManyFolders {
dir_count: 9000,
capped: false,
load_status: crate::msg::WatcherExcludeLoadStatus::Parsed,
},
},
);
assert_eq!(state.notifications.len(), 1);
Expand All @@ -2409,8 +2432,35 @@ mod nav_history_tests {
"warning should mention the folder count: {}",
note.message
);
assert!(
note.message.contains("files.watcherExclude"),
"warning should name the IDE exclude remedy: {}",
note.message
);

dispatch(
&mut state,
Msg::RepoWatchDegraded {
repo_id: RepoId(1),
reason: crate::msg::RepoWatchDegradedReason::TooManyFolders {
dir_count: 4097,
capped: true,
load_status: crate::msg::WatcherExcludeLoadStatus::Unreadable,
},
},
);
let note = &state.notifications[1];
assert!(
note.message.contains("more than 4096"),
"capped warning must not treat the probe as an exact census: {}",
note.message
);
assert!(
note.message.contains("could not be parsed"),
"unreadable settings must be named: {}",
note.message
);

// A partial watch failure surfaces a (distinct) warning too — not just the stderr log.
dispatch(
&mut state,
Msg::RepoWatchDegraded {
Expand All @@ -2420,8 +2470,8 @@ mod nav_history_tests {
},
},
);
assert_eq!(state.notifications.len(), 2);
let note = &state.notifications[1];
assert_eq!(state.notifications.len(), 3);
let note = &state.notifications[2];
assert_eq!(note.kind, crate::model::AppNotificationKind::Warning);
assert!(
note.message.contains("42"),
Expand Down
Loading