@@ -8800,15 +8800,15 @@ fn activate_virtual_projection_mount(
88008800 {
88018801 wait_for_virtual_projection_mount_point_children(state_root, mount)?;
88028802 }
8803- register_virtual_projection(state_root, mount)?;
8803+ let macos_domain_registration = register_virtual_projection(state_root, mount)?;
88048804 prefetch_virtual_projection_root(state_root, mount)?;
88058805 if wait_for_entities
88068806 && !virtual_projection_waits_for_mount_point_children_before_registration(&mount.projection)
88078807 {
88088808 wait_for_mount_entities(state_root, &mount.mount_id)?;
88098809 }
88108810 ensure_virtual_projection_runtime(state_root, mount)?;
8811- refresh_virtual_projection_mount_activation(mount);
8811+ refresh_virtual_projection_mount_activation(mount, macos_domain_registration );
88128812 recover_virtual_projection_mount_root_if_needed(state_root, mount)?;
88138813 desktop_log(
88148814 "info",
@@ -8885,7 +8885,7 @@ fn recover_macos_file_provider_mount_root_if_needed(
88858885 );
88868886 prefetch_virtual_projection_root(state_root, mount)?;
88878887 ensure_virtual_projection_runtime(state_root, mount)?;
8888- refresh_virtual_projection_mount_activation(mount);
8888+ refresh_virtual_projection_mount_activation(mount, MacosFileProviderDomainRegistration::Reused );
88898889
88908890 wait_for_macos_file_provider_mount_root_recovery(
88918891 &root,
@@ -9786,6 +9786,12 @@ enum VirtualProjectionRefreshAction {
97869786 ReimportThenSignal(String),
97879787}
97889788
9789+ #[derive(Clone, Copy, Debug, PartialEq, Eq)]
9790+ enum MacosFileProviderDomainRegistration {
9791+ Created,
9792+ Reused,
9793+ }
9794+
97899795impl VirtualProjectionRefreshAction {
97909796 fn identifier(&self) -> &str {
97919797 match self {
@@ -9800,8 +9806,11 @@ fn signal_virtual_projection_refresh(mount: &MountConfig) {
98009806 }
98019807}
98029808
9803- fn refresh_virtual_projection_mount_activation(mount: &MountConfig) {
9804- for action in virtual_projection_mount_activation_refresh_actions(mount) {
9809+ fn refresh_virtual_projection_mount_activation(
9810+ mount: &MountConfig,
9811+ domain_registration: MacosFileProviderDomainRegistration,
9812+ ) {
9813+ for action in virtual_projection_mount_activation_refresh_actions(mount, domain_registration) {
98059814 run_virtual_projection_refresh_action(mount, &action);
98069815 }
98079816}
@@ -9839,12 +9848,19 @@ fn virtual_projection_refresh_actions(mount: &MountConfig) -> Vec<VirtualProject
98399848
98409849fn virtual_projection_mount_activation_refresh_actions(
98419850 mount: &MountConfig,
9851+ domain_registration: MacosFileProviderDomainRegistration,
98429852) -> Vec<VirtualProjectionRefreshAction> {
98439853 if mount.projection == ProjectionMode::MacosFileProvider {
9844- return vec![
9854+ let mut actions = vec![
98459855 VirtualProjectionRefreshAction::Signal(ROOT_CONTAINER_IDENTIFIER.to_string()),
98469856 VirtualProjectionRefreshAction::ReimportThenSignal(mount_point_identifier(mount)),
98479857 ];
9858+ if domain_registration == MacosFileProviderDomainRegistration::Created {
9859+ actions.push(VirtualProjectionRefreshAction::Signal(
9860+ "working-set".to_string(),
9861+ ));
9862+ }
9863+ return actions;
98489864 }
98499865 virtual_projection_refresh_actions(mount)
98509866}
@@ -9934,35 +9950,62 @@ fn refresh_macos_virtual_projection(
99349950 Ok(())
99359951}
99369952
9937- fn register_virtual_projection(state_root: &Path, mount: &MountConfig) -> Result<(), String> {
9953+ fn register_virtual_projection(
9954+ state_root: &Path,
9955+ mount: &MountConfig,
9956+ ) -> Result<MacosFileProviderDomainRegistration, String> {
99389957 match mount.projection {
99399958 ProjectionMode::MacosFileProvider => {
99409959 register_macos_virtual_projection(&mount.mount_id.0, &mount.root.display().to_string())
99419960 }
9942- ProjectionMode::LinuxFuse => register_linux_virtual_projection(state_root, mount),
9943- ProjectionMode::PlainFiles => Ok(()),
9944- ProjectionMode::WindowsCloudFiles => register_windows_virtual_projection(state_root, mount),
9961+ ProjectionMode::LinuxFuse => register_linux_virtual_projection(state_root, mount)
9962+ .map(|_| MacosFileProviderDomainRegistration::Reused),
9963+ ProjectionMode::PlainFiles => Ok(MacosFileProviderDomainRegistration::Reused),
9964+ ProjectionMode::WindowsCloudFiles => register_windows_virtual_projection(state_root, mount)
9965+ .map(|_| MacosFileProviderDomainRegistration::Reused),
99459966 }
99469967}
99479968
99489969#[cfg(target_os = "macos")]
9949- fn register_macos_virtual_projection(_mount_id: &str, _root: &str) -> Result<(), String> {
9950- register_macos_file_provider_domain(
9970+ fn register_macos_virtual_projection(
9971+ _mount_id: &str,
9972+ _root: &str,
9973+ ) -> Result<MacosFileProviderDomainRegistration, String> {
9974+ let report = register_macos_file_provider_domain(
99519975 localityd::file_provider::MACOS_FILE_PROVIDER_DOMAIN_ID,
99529976 localityd::file_provider::MACOS_FILE_PROVIDER_DISPLAY_NAME,
99539977 )
9954- .map(|_| ())
99559978 .map_err(|error| {
99569979 format!(
99579980 "Could not register macOS File Provider: {}",
99589981 error.message()
99599982 )
9960- })
9983+ })?;
9984+ Ok(macos_file_provider_domain_registration(
9985+ &report.helper_report,
9986+ ))
99619987}
99629988
99639989#[cfg(not(target_os = "macos"))]
9964- fn register_macos_virtual_projection(_mount_id: &str, _root: &str) -> Result<(), String> {
9965- Ok(())
9990+ fn register_macos_virtual_projection(
9991+ _mount_id: &str,
9992+ _root: &str,
9993+ ) -> Result<MacosFileProviderDomainRegistration, String> {
9994+ Ok(MacosFileProviderDomainRegistration::Reused)
9995+ }
9996+
9997+ fn macos_file_provider_domain_registration(
9998+ helper_report: &serde_json::Value,
9999+ ) -> MacosFileProviderDomainRegistration {
10000+ if helper_report
10001+ .get("registrationCreated")
10002+ .and_then(serde_json::Value::as_bool)
10003+ == Some(true)
10004+ {
10005+ MacosFileProviderDomainRegistration::Created
10006+ } else {
10007+ MacosFileProviderDomainRegistration::Reused
10008+ }
996610009}
996710010
996810011#[cfg(target_os = "linux")]
@@ -12027,14 +12070,14 @@ mod tests {
1202712070 use super::{
1202812071 ActionReport, DESKTOP_ACTIVITY_LIMIT, DESKTOP_INSTALL_MARKER_VERSION,
1202912072 LIVE_MODE_REMOTE_FAST_FORWARD_LEASE, LIVE_MODE_RUNNER_ACTIVE_INTERVAL,
12030- LIVE_MODE_RUNNER_PERIODIC_RECHECK, MonitorScreenBounds, PendingChange, ScreenBounds ,
12031- TerminalCliLinkState, TrayVisualState, VirtualProjectionRefreshAction ,
12032- acknowledge_install_state_at, activity_timestamp, clear_mount_cached_projection ,
12033- clear_state_root_contents, clear_visible_projection_paths, conflict_preview ,
12034- connection_metadata_changed, current_daemon_build_id, current_desktop_build_id ,
12035- diff_report_message, exact_located_entity_record, exact_notion_entry_matches ,
12036- failed_push_summary, has_unresolved_conflict_markers, hydration_after_editor_write ,
12037- inspect_install_state, install_terminal_cli_link_at,
12073+ LIVE_MODE_RUNNER_PERIODIC_RECHECK, MacosFileProviderDomainRegistration ,
12074+ MonitorScreenBounds, PendingChange, ScreenBounds, TerminalCliLinkState, TrayVisualState ,
12075+ VirtualProjectionRefreshAction, acknowledge_install_state_at, activity_timestamp ,
12076+ clear_mount_cached_projection, clear_state_root_contents, clear_visible_projection_paths ,
12077+ conflict_preview, connection_metadata_changed, current_daemon_build_id ,
12078+ current_desktop_build_id, diff_report_message, exact_located_entity_record ,
12079+ exact_notion_entry_matches, failed_push_summary, has_unresolved_conflict_markers ,
12080+ hydration_after_editor_write, inspect_install_state, install_terminal_cli_link_at,
1203812081 install_terminal_cli_link_in_path_dirs, is_notion_access_lost_message,
1203912082 is_unsupported_schema_version_message, live_mode_claim_remote_fast_forward_key,
1204012083 live_mode_enabled_mount, live_mode_local_reconcile_targets_for_mount_at,
@@ -12044,7 +12087,7 @@ mod tests {
1204412087 live_mode_should_reconcile_local_target_for_key, live_mode_target,
1204512088 live_mode_tick_from_snapshot, live_mode_wake_generation, load_desktop_activity,
1204612089 macos_app_bundle_for_exe, macos_file_provider_child_item_count,
12047- macos_file_provider_mount_root_health_error,
12090+ macos_file_provider_domain_registration, macos_file_provider_mount_root_health_error,
1204812091 macos_file_provider_mount_root_inspection_recovery_reason,
1204912092 macos_file_provider_mount_root_is_missing, macos_file_provider_mount_root_recovery_reason,
1205012093 mark_mount_live_mode_syncing, mount_has_pending_local_changes,
@@ -14998,7 +15041,7 @@ mod tests {
1499815041 }
1499915042
1500015043 #[test]
15001- fn macos_file_provider_refresh_is_scoped_to_the_new_mount () {
15044+ fn macos_file_provider_reused_domain_refresh_is_scoped_to_the_new_mount () {
1500215045 let mount = MountConfig::new(
1500315046 MountId::new("google-calendar-main"),
1500415047 "google-calendar",
@@ -15007,7 +15050,10 @@ mod tests {
1500715050 .projection(ProjectionMode::MacosFileProvider);
1500815051
1500915052 assert_eq!(
15010- virtual_projection_mount_activation_refresh_actions(&mount),
15053+ virtual_projection_mount_activation_refresh_actions(
15054+ &mount,
15055+ MacosFileProviderDomainRegistration::Reused,
15056+ ),
1501115057 vec![
1501215058 VirtualProjectionRefreshAction::Signal("root".to_string()),
1501315059 VirtualProjectionRefreshAction::ReimportThenSignal(
@@ -15017,6 +15063,44 @@ mod tests {
1501715063 );
1501815064 }
1501915065
15066+ #[test]
15067+ fn macos_file_provider_new_domain_seeds_the_working_set_once() {
15068+ let mount = MountConfig::new(
15069+ MountId::new("notion-main"),
15070+ "notion",
15071+ "/tmp/Locality/notion",
15072+ )
15073+ .projection(ProjectionMode::MacosFileProvider);
15074+
15075+ assert_eq!(
15076+ virtual_projection_mount_activation_refresh_actions(
15077+ &mount,
15078+ MacosFileProviderDomainRegistration::Created,
15079+ ),
15080+ vec![
15081+ VirtualProjectionRefreshAction::Signal("root".to_string()),
15082+ VirtualProjectionRefreshAction::ReimportThenSignal("mount:notion-main".to_string(),),
15083+ VirtualProjectionRefreshAction::Signal("working-set".to_string()),
15084+ ]
15085+ );
15086+ }
15087+
15088+ #[test]
15089+ fn macos_file_provider_registration_report_defaults_to_reused() {
15090+ assert_eq!(
15091+ macos_file_provider_domain_registration(&serde_json::json!({
15092+ "registrationCreated": true,
15093+ })),
15094+ MacosFileProviderDomainRegistration::Created
15095+ );
15096+ assert_eq!(
15097+ macos_file_provider_domain_registration(&serde_json::json!({
15098+ "message": "already registered loc",
15099+ })),
15100+ MacosFileProviderDomainRegistration::Reused
15101+ );
15102+ }
15103+
1502015104 #[test]
1502115105 fn macos_file_provider_visible_refresh_never_reimports_the_shared_root() {
1502215106 let mount = MountConfig::new(
0 commit comments