Rework remote task synchronization (#18746)

Reworks the way tasks are stored, accessed and synchronized in the
`project`.
Now both collab and ssh remote projects use the same TaskStorage kind to
get the task context from the remote host, and worktree task templates
are synchronized along with other worktree settings.

Release Notes:

- Adds ssh support to tasks, improves collab-remote projects' tasks sync
This commit is contained in:
Kirill Bulatov authored and GitHub committed 2024-10-09 22:28:42 +03:00
1 parent 9a636daf4d
commit e8f67192da
18 files changed
+1262 -1366

No files matched your search

+2 -2
View File
@@ -14,8 +14,8 @@ pub use json_schema::*;
pub use keymap_file::KeymapFile;
pub use settings_file::*;
pub use settings_store::{
InvalidSettingsError, LocalSettingsKind, Settings, SettingsLocation, SettingsSources,
SettingsStore,
parse_json_with_comments, InvalidSettingsError, LocalSettingsKind, Settings, SettingsLocation,
SettingsSources, SettingsStore,
};
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)]
+22 -11
View File
@@ -515,13 +515,11 @@ impl SettingsStore {
} else {
parse_json_with_comments(user_settings_content)?
};
if settings.is_object() {
self.raw_user_settings = settings;
self.recompute_values(None, cx)?;
Ok(())
} else {
Err(anyhow!("settings must be an object"))
}
anyhow::ensure!(settings.is_object(), "settings must be an object");
self.raw_user_settings = settings;
self.recompute_values(None, cx)?;
Ok(())
}
/// Add or remove a set of local settings via a JSON string.
@@ -533,16 +531,29 @@ impl SettingsStore {
settings_content: Option<&str>,
cx: &mut AppContext,
) -> Result<()> {
anyhow::ensure!(
kind != LocalSettingsKind::Tasks,
"Attempted to submit tasks into the settings store"
);
let raw_local_settings = self
.raw_local_settings
.entry((root_id, directory_path.clone()))
.or_default();
if settings_content.is_some_and(|content| !content.is_empty()) {
raw_local_settings.insert(kind, parse_json_with_comments(settings_content.unwrap())?);
let changed = if settings_content.is_some_and(|content| !content.is_empty()) {
let new_contents = parse_json_with_comments(settings_content.unwrap())?;
if Some(&new_contents) == raw_local_settings.get(&kind) {
false
} else {
raw_local_settings.insert(kind, new_contents);
true
}
} else {
raw_local_settings.remove(&kind);
raw_local_settings.remove(&kind).is_some()
};
if changed {
self.recompute_values(Some((root_id, &directory_path)), cx)?;
}
self.recompute_values(Some((root_id, &directory_path)), cx)?;
Ok(())
}