multi_workspace_tests.rs

  1use std::path::PathBuf;
  2
  3use super::*;
  4use client::proto;
  5use fs::{FakeFs, Fs};
  6use gpui::TestAppContext;
  7use project::DisableAiSettings;
  8use serde_json::json;
  9use settings::SettingsStore;
 10use util::path;
 11
 12fn init_test(cx: &mut TestAppContext) {
 13    cx.update(|cx| {
 14        let settings_store = SettingsStore::test(cx);
 15        cx.set_global(settings_store);
 16        theme_settings::init(theme::LoadThemes::JustBase, cx);
 17        DisableAiSettings::register(cx);
 18    });
 19}
 20
 21#[gpui::test]
 22async fn test_sidebar_disabled_when_disable_ai_is_enabled(cx: &mut TestAppContext) {
 23    init_test(cx);
 24    let fs = FakeFs::new(cx.executor());
 25    let project = Project::test(fs, [], cx).await;
 26
 27    let (multi_workspace, cx) =
 28        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project, window, cx));
 29
 30    multi_workspace.read_with(cx, |mw, cx| {
 31        assert!(mw.multi_workspace_enabled(cx));
 32    });
 33
 34    multi_workspace.update_in(cx, |mw, _window, cx| {
 35        mw.open_sidebar(cx);
 36        assert!(mw.sidebar_open());
 37    });
 38
 39    cx.update(|_window, cx| {
 40        DisableAiSettings::override_global(DisableAiSettings { disable_ai: true }, cx);
 41    });
 42    cx.run_until_parked();
 43
 44    multi_workspace.read_with(cx, |mw, cx| {
 45        assert!(
 46            !mw.sidebar_open(),
 47            "Sidebar should be closed when disable_ai is true"
 48        );
 49        assert!(
 50            !mw.multi_workspace_enabled(cx),
 51            "Multi-workspace should be disabled when disable_ai is true"
 52        );
 53    });
 54
 55    multi_workspace.update_in(cx, |mw, window, cx| {
 56        mw.toggle_sidebar(window, cx);
 57    });
 58    multi_workspace.read_with(cx, |mw, _cx| {
 59        assert!(
 60            !mw.sidebar_open(),
 61            "Sidebar should remain closed when toggled with disable_ai true"
 62        );
 63    });
 64
 65    cx.update(|_window, cx| {
 66        DisableAiSettings::override_global(DisableAiSettings { disable_ai: false }, cx);
 67    });
 68    cx.run_until_parked();
 69
 70    multi_workspace.read_with(cx, |mw, cx| {
 71        assert!(
 72            mw.multi_workspace_enabled(cx),
 73            "Multi-workspace should be enabled after re-enabling AI"
 74        );
 75        assert!(
 76            !mw.sidebar_open(),
 77            "Sidebar should still be closed after re-enabling AI (not auto-opened)"
 78        );
 79    });
 80
 81    multi_workspace.update_in(cx, |mw, window, cx| {
 82        mw.toggle_sidebar(window, cx);
 83    });
 84    multi_workspace.read_with(cx, |mw, _cx| {
 85        assert!(
 86            mw.sidebar_open(),
 87            "Sidebar should open when toggled after re-enabling AI"
 88        );
 89    });
 90}
 91
 92#[gpui::test]
 93async fn test_project_group_keys_initial(cx: &mut TestAppContext) {
 94    init_test(cx);
 95    let fs = FakeFs::new(cx.executor());
 96    fs.insert_tree("/root_a", json!({ "file.txt": "" })).await;
 97    let project = Project::test(fs, ["/root_a".as_ref()], cx).await;
 98
 99    let expected_key = project.read_with(cx, |project, cx| project.project_group_key(cx));
100
101    let (multi_workspace, cx) =
102        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project, window, cx));
103
104    multi_workspace.update(cx, |mw, cx| {
105        mw.open_sidebar(cx);
106    });
107
108    multi_workspace.read_with(cx, |mw, _cx| {
109        let keys: Vec<ProjectGroupKey> = mw.project_group_keys();
110        assert_eq!(keys.len(), 1, "should have exactly one key on creation");
111        assert_eq!(keys[0], expected_key);
112    });
113}
114
115#[gpui::test]
116async fn test_project_group_keys_add_workspace(cx: &mut TestAppContext) {
117    init_test(cx);
118    let fs = FakeFs::new(cx.executor());
119    fs.insert_tree("/root_a", json!({ "file.txt": "" })).await;
120    fs.insert_tree("/root_b", json!({ "file.txt": "" })).await;
121    let project_a = Project::test(fs.clone(), ["/root_a".as_ref()], cx).await;
122    let project_b = Project::test(fs.clone(), ["/root_b".as_ref()], cx).await;
123
124    let key_a = project_a.read_with(cx, |p, cx| p.project_group_key(cx));
125    let key_b = project_b.read_with(cx, |p, cx| p.project_group_key(cx));
126    assert_ne!(
127        key_a, key_b,
128        "different roots should produce different keys"
129    );
130
131    let (multi_workspace, cx) =
132        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project_a, window, cx));
133
134    multi_workspace.update(cx, |mw, cx| {
135        mw.open_sidebar(cx);
136    });
137
138    multi_workspace.read_with(cx, |mw, _cx| {
139        assert_eq!(mw.project_group_keys().len(), 1);
140    });
141
142    // Adding a workspace with a different project root adds a new key.
143    multi_workspace.update_in(cx, |mw, window, cx| {
144        mw.test_add_workspace(project_b, window, cx);
145    });
146
147    multi_workspace.read_with(cx, |mw, _cx| {
148        let keys: Vec<ProjectGroupKey> = mw.project_group_keys();
149        assert_eq!(
150            keys.len(),
151            2,
152            "should have two keys after adding a second workspace"
153        );
154        assert_eq!(keys[0], key_b);
155        assert_eq!(keys[1], key_a);
156    });
157}
158
159#[gpui::test]
160async fn test_open_new_window_does_not_open_sidebar_on_existing_window(cx: &mut TestAppContext) {
161    init_test(cx);
162
163    let app_state = cx.update(AppState::test);
164    let fs = app_state.fs.as_fake();
165    fs.insert_tree(path!("/project_a"), json!({ "file.txt": "" }))
166        .await;
167    fs.insert_tree(path!("/project_b"), json!({ "file.txt": "" }))
168        .await;
169
170    let project = Project::test(app_state.fs.clone(), [path!("/project_a").as_ref()], cx).await;
171
172    let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project, window, cx));
173
174    window
175        .read_with(cx, |mw, _cx| {
176            assert!(!mw.sidebar_open(), "sidebar should start closed",);
177        })
178        .unwrap();
179
180    cx.update(|cx| {
181        open_paths(
182            &[PathBuf::from(path!("/project_b"))],
183            app_state,
184            OpenOptions {
185                open_mode: OpenMode::NewWindow,
186                ..OpenOptions::default()
187            },
188            cx,
189        )
190    })
191    .await
192    .unwrap();
193
194    window
195        .read_with(cx, |mw, _cx| {
196            assert!(
197                !mw.sidebar_open(),
198                "opening a project in a new window must not open the sidebar on the original window",
199            );
200        })
201        .unwrap();
202}
203
204#[gpui::test]
205async fn test_open_directory_in_empty_workspace_does_not_open_sidebar(cx: &mut TestAppContext) {
206    init_test(cx);
207
208    let app_state = cx.update(AppState::test);
209    let fs = app_state.fs.as_fake();
210    fs.insert_tree(path!("/project"), json!({ "file.txt": "" }))
211        .await;
212
213    let project = Project::test(app_state.fs.clone(), [], cx).await;
214    let window = cx.add_window(|window, cx| {
215        let mw = MultiWorkspace::test_new(project, window, cx);
216        // Simulate a blank project that has an untitled editor tab,
217        // so that workspace_windows_for_location finds this window.
218        mw.workspace().update(cx, |workspace, cx| {
219            workspace.active_pane().update(cx, |pane, cx| {
220                let item = cx.new(|cx| item::test::TestItem::new(cx));
221                pane.add_item(Box::new(item), false, false, None, window, cx);
222            });
223        });
224        mw
225    });
226
227    window
228        .read_with(cx, |mw, _cx| {
229            assert!(!mw.sidebar_open(), "sidebar should start closed");
230        })
231        .unwrap();
232
233    // Simulate what open_workspace_for_paths does for an empty workspace:
234    // it downgrades OpenMode::NewWindow to Activate and sets requesting_window.
235    cx.update(|cx| {
236        open_paths(
237            &[PathBuf::from(path!("/project"))],
238            app_state,
239            OpenOptions {
240                requesting_window: Some(window),
241                open_mode: OpenMode::Activate,
242                ..OpenOptions::default()
243            },
244            cx,
245        )
246    })
247    .await
248    .unwrap();
249
250    window
251        .read_with(cx, |mw, _cx| {
252            assert!(
253                !mw.sidebar_open(),
254                "opening a directory in a blank project via the file picker must not open the sidebar",
255            );
256        })
257        .unwrap();
258}
259
260#[gpui::test]
261async fn test_project_group_keys_duplicate_not_added(cx: &mut TestAppContext) {
262    init_test(cx);
263    let fs = FakeFs::new(cx.executor());
264    fs.insert_tree("/root_a", json!({ "file.txt": "" })).await;
265    let project_a = Project::test(fs.clone(), ["/root_a".as_ref()], cx).await;
266    // A second project entity pointing at the same path produces the same key.
267    let project_a2 = Project::test(fs.clone(), ["/root_a".as_ref()], cx).await;
268
269    let key_a = project_a.read_with(cx, |p, cx| p.project_group_key(cx));
270    let key_a2 = project_a2.read_with(cx, |p, cx| p.project_group_key(cx));
271    assert_eq!(key_a, key_a2, "same root path should produce the same key");
272
273    let (multi_workspace, cx) =
274        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project_a, window, cx));
275
276    multi_workspace.update(cx, |mw, cx| {
277        mw.open_sidebar(cx);
278    });
279
280    multi_workspace.update_in(cx, |mw, window, cx| {
281        mw.test_add_workspace(project_a2, window, cx);
282    });
283
284    multi_workspace.read_with(cx, |mw, _cx| {
285        let keys: Vec<ProjectGroupKey> = mw.project_group_keys();
286        assert_eq!(
287            keys.len(),
288            1,
289            "duplicate key should not be added when a workspace with the same root is inserted"
290        );
291    });
292}
293
294#[gpui::test]
295async fn test_groups_with_same_paths_merge(cx: &mut TestAppContext) {
296    init_test(cx);
297    let fs = FakeFs::new(cx.executor());
298    fs.insert_tree("/a", json!({ "file.txt": "" })).await;
299    fs.insert_tree("/b", json!({ "file.txt": "" })).await;
300    let project_a = Project::test(fs.clone(), ["/a".as_ref()], cx).await;
301    let project_b = Project::test(fs.clone(), ["/b".as_ref()], cx).await;
302
303    let (multi_workspace, cx) =
304        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project_a, window, cx));
305
306    // Open the sidebar so workspaces get grouped.
307    multi_workspace.update(cx, |mw, cx| {
308        mw.open_sidebar(cx);
309    });
310    cx.run_until_parked();
311
312    // Add a second workspace, creating group_b with path [/b].
313    let group_a_key = multi_workspace.update_in(cx, |mw, window, cx| {
314        let group_a_key = mw.project_groups(cx)[0].key.clone();
315        mw.test_add_workspace(project_b, window, cx);
316        group_a_key
317    });
318    cx.run_until_parked();
319
320    // Now add /b to group_a so it has [/a, /b].
321    multi_workspace.update(cx, |mw, cx| {
322        mw.add_folders_to_project_group(&group_a_key, vec!["/b".into()], cx);
323    });
324    cx.run_until_parked();
325
326    // Verify we have two groups.
327    multi_workspace.read_with(cx, |mw, cx| {
328        assert_eq!(
329            mw.project_groups(cx).len(),
330            2,
331            "should have two groups before the merge"
332        );
333    });
334
335    // After adding /b, group_a's key changed. Get the updated key.
336    let group_a_key_updated = multi_workspace.read_with(cx, |mw, cx| {
337        mw.project_groups(cx)
338            .iter()
339            .find(|g| g.key.path_list().paths().contains(&PathBuf::from("/a")))
340            .unwrap()
341            .key
342            .clone()
343    });
344
345    // Remove /a from group_a, making its key [/b] — same as group_b.
346    multi_workspace.update(cx, |mw, cx| {
347        mw.remove_folder_from_project_group(&group_a_key_updated, Path::new("/a"), cx);
348    });
349    cx.run_until_parked();
350
351    // The two groups now have identical keys [/b] and should have been merged.
352    multi_workspace.read_with(cx, |mw, cx| {
353        assert_eq!(
354            mw.project_groups(cx).len(),
355            1,
356            "groups with identical paths should be merged into one"
357        );
358    });
359}
360
361#[gpui::test]
362async fn test_adding_worktree_updates_project_group_key(cx: &mut TestAppContext) {
363    init_test(cx);
364    let fs = FakeFs::new(cx.executor());
365    fs.insert_tree("/root_a", json!({ "file.txt": "" })).await;
366    fs.insert_tree("/root_b", json!({ "other.txt": "" })).await;
367    let project = Project::test(fs.clone(), ["/root_a".as_ref()], cx).await;
368
369    let initial_key = project.read_with(cx, |p, cx| p.project_group_key(cx));
370
371    let (multi_workspace, cx) =
372        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
373
374    // Open sidebar to retain the workspace and create the initial group.
375    multi_workspace.update(cx, |mw, cx| {
376        mw.open_sidebar(cx);
377    });
378    cx.run_until_parked();
379
380    multi_workspace.read_with(cx, |mw, _cx| {
381        let keys = mw.project_group_keys();
382        assert_eq!(keys.len(), 1);
383        assert_eq!(keys[0], initial_key);
384    });
385
386    // Add a second worktree to the project. This triggers WorktreeAdded →
387    // handle_workspace_key_change, which should update the group key.
388    project
389        .update(cx, |project, cx| {
390            project.find_or_create_worktree("/root_b", true, cx)
391        })
392        .await
393        .expect("adding worktree should succeed");
394    cx.run_until_parked();
395
396    let updated_key = project.read_with(cx, |p, cx| p.project_group_key(cx));
397    assert_ne!(
398        initial_key, updated_key,
399        "adding a worktree should change the project group key"
400    );
401
402    multi_workspace.read_with(cx, |mw, _cx| {
403        let keys = mw.project_group_keys();
404        assert!(
405            keys.contains(&updated_key),
406            "should contain the updated key; got {keys:?}"
407        );
408    });
409}
410
411#[gpui::test]
412async fn test_find_or_create_local_workspace_reuses_active_workspace_when_sidebar_closed(
413    cx: &mut TestAppContext,
414) {
415    init_test(cx);
416    let fs = FakeFs::new(cx.executor());
417    fs.insert_tree("/root_a", json!({ "file.txt": "" })).await;
418    let project = Project::test(fs, ["/root_a".as_ref()], cx).await;
419
420    let (multi_workspace, cx) =
421        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project, window, cx));
422
423    let active_workspace = multi_workspace.read_with(cx, |mw, cx| {
424        assert!(
425            mw.project_groups(cx).is_empty(),
426            "sidebar-closed setup should start with no retained project groups"
427        );
428        mw.workspace().clone()
429    });
430    let active_workspace_id = active_workspace.entity_id();
431
432    let workspace = multi_workspace
433        .update_in(cx, |mw, window, cx| {
434            mw.find_or_create_local_workspace(
435                PathList::new(&[PathBuf::from("/root_a")]),
436                None,
437                &[],
438                window,
439                cx,
440            )
441        })
442        .await
443        .expect("reopening the same local workspace should succeed");
444
445    assert_eq!(
446        workspace.entity_id(),
447        active_workspace_id,
448        "should reuse the current active workspace when the sidebar is closed"
449    );
450
451    multi_workspace.read_with(cx, |mw, _cx| {
452        assert_eq!(
453            mw.workspace().entity_id(),
454            active_workspace_id,
455            "active workspace should remain unchanged after reopening the same path"
456        );
457        assert_eq!(
458            mw.workspaces().count(),
459            1,
460            "reusing the active workspace should not create a second open workspace"
461        );
462    });
463}
464
465#[gpui::test]
466async fn test_find_or_create_workspace_uses_project_group_key_when_paths_are_missing(
467    cx: &mut TestAppContext,
468) {
469    init_test(cx);
470    let fs = FakeFs::new(cx.executor());
471    fs.insert_tree(
472        "/project",
473        json!({
474            ".git": {},
475            "src": {},
476        }),
477    )
478    .await;
479    cx.update(|cx| <dyn Fs>::set_global(fs.clone(), cx));
480    let project = Project::test(fs.clone(), ["/project".as_ref()], cx).await;
481    project
482        .update(cx, |project, cx| project.git_scans_complete(cx))
483        .await;
484
485    let project_group_key = project.read_with(cx, |project, cx| project.project_group_key(cx));
486
487    let (multi_workspace, cx) =
488        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project, window, cx));
489
490    let main_workspace = multi_workspace.read_with(cx, |mw, _cx| mw.workspace().clone());
491    let main_workspace_id = main_workspace.entity_id();
492
493    let workspace = multi_workspace
494        .update_in(cx, |mw, window, cx| {
495            mw.find_or_create_workspace(
496                PathList::new(&[PathBuf::from("/wt-feature-a")]),
497                None,
498                Some(project_group_key.clone()),
499                |_options, _window, _cx| Task::ready(Ok(None)),
500                &[],
501                window,
502                cx,
503            )
504        })
505        .await
506        .expect("opening a missing linked-worktree path should fall back to the project group key workspace");
507
508    assert_eq!(
509        workspace.entity_id(),
510        main_workspace_id,
511        "missing linked-worktree paths should reuse the main worktree workspace from the project group key"
512    );
513
514    multi_workspace.read_with(cx, |mw, cx| {
515        assert_eq!(
516            mw.workspace().entity_id(),
517            main_workspace_id,
518            "the active workspace should remain the main worktree workspace"
519        );
520        assert_eq!(
521            PathList::new(&mw.workspace().read(cx).root_paths(cx)),
522            project_group_key.path_list().clone(),
523            "the activated workspace should use the project group key path list rather than the missing linked-worktree path"
524        );
525        assert_eq!(
526            mw.workspaces().count(),
527            1,
528            "falling back to the project group key should not create a second workspace"
529        );
530    });
531}
532
533#[gpui::test]
534async fn test_find_or_create_local_workspace_reuses_active_workspace_after_sidebar_open(
535    cx: &mut TestAppContext,
536) {
537    init_test(cx);
538    let fs = FakeFs::new(cx.executor());
539    fs.insert_tree("/root_a", json!({ "file.txt": "" })).await;
540    let project = Project::test(fs, ["/root_a".as_ref()], cx).await;
541
542    let (multi_workspace, cx) =
543        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project, window, cx));
544
545    multi_workspace.update(cx, |mw, cx| {
546        mw.open_sidebar(cx);
547    });
548    cx.run_until_parked();
549
550    let active_workspace = multi_workspace.read_with(cx, |mw, cx| {
551        assert_eq!(
552            mw.project_groups(cx).len(),
553            1,
554            "opening the sidebar should retain the active workspace in a project group"
555        );
556        mw.workspace().clone()
557    });
558    let active_workspace_id = active_workspace.entity_id();
559
560    let workspace = multi_workspace
561        .update_in(cx, |mw, window, cx| {
562            mw.find_or_create_local_workspace(
563                PathList::new(&[PathBuf::from("/root_a")]),
564                None,
565                &[],
566                window,
567                cx,
568            )
569        })
570        .await
571        .expect("reopening the same retained local workspace should succeed");
572
573    assert_eq!(
574        workspace.entity_id(),
575        active_workspace_id,
576        "should reuse the retained active workspace after the sidebar is opened"
577    );
578
579    multi_workspace.read_with(cx, |mw, _cx| {
580        assert_eq!(
581            mw.workspaces().count(),
582            1,
583            "reopening the same retained workspace should not create another workspace"
584        );
585    });
586}
587
588#[gpui::test]
589async fn test_switching_projects_with_sidebar_closed_detaches_old_active_workspace(
590    cx: &mut TestAppContext,
591) {
592    init_test(cx);
593    let fs = FakeFs::new(cx.executor());
594    fs.insert_tree("/root_a", json!({ "file_a.txt": "" })).await;
595    fs.insert_tree("/root_b", json!({ "file_b.txt": "" })).await;
596    let project_a = Project::test(fs.clone(), ["/root_a".as_ref()], cx).await;
597    let project_b = Project::test(fs, ["/root_b".as_ref()], cx).await;
598
599    let (multi_workspace, cx) =
600        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project_a, window, cx));
601
602    let workspace_a = multi_workspace.read_with(cx, |mw, cx| {
603        assert!(
604            mw.project_groups(cx).is_empty(),
605            "sidebar-closed setup should start with no retained project groups"
606        );
607        mw.workspace().clone()
608    });
609    assert!(
610        workspace_a.read_with(cx, |workspace, _cx| workspace.session_id().is_some()),
611        "initial active workspace should start attached to the session"
612    );
613
614    let workspace_b = multi_workspace.update_in(cx, |mw, window, cx| {
615        mw.test_add_workspace(project_b, window, cx)
616    });
617    cx.run_until_parked();
618
619    multi_workspace.read_with(cx, |mw, _cx| {
620        assert_eq!(
621            mw.workspace().entity_id(),
622            workspace_b.entity_id(),
623            "the new workspace should become active"
624        );
625        assert_eq!(
626            mw.workspaces().count(),
627                        1,
628                        "only the new active workspace should remain open after switching with the sidebar closed"
629        );
630    });
631
632    assert!(
633        workspace_a.read_with(cx, |workspace, _cx| workspace.session_id().is_none()),
634        "the previous active workspace should be detached when switching away with the sidebar closed"
635    );
636}
637
638#[gpui::test]
639async fn test_remote_worktree_without_git_updates_project_group(cx: &mut TestAppContext) {
640    init_test(cx);
641    let fs = FakeFs::new(cx.executor());
642    fs.insert_tree("/local", json!({ "file.txt": "" })).await;
643    let project = Project::test(fs.clone(), ["/local".as_ref()], cx).await;
644
645    let (multi_workspace, cx) =
646        cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
647
648    multi_workspace.update(cx, |mw, cx| {
649        mw.open_sidebar(cx);
650    });
651    cx.run_until_parked();
652
653    let initial_key = project.read_with(cx, |p, cx| p.project_group_key(cx));
654    multi_workspace.read_with(cx, |mw, _cx| {
655        let keys = mw.project_group_keys();
656        assert_eq!(keys.len(), 1);
657        assert_eq!(keys[0], initial_key);
658    });
659
660    // Add a remote worktree without git repo info.
661    let remote_worktree = project.update(cx, |project, cx| {
662        project.add_test_remote_worktree("/remote/project", cx)
663    });
664    cx.run_until_parked();
665
666    // The remote worktree has no entries yet, so project_group_key should
667    // still exclude it.
668    let key_after_add = project.read_with(cx, |p, cx| p.project_group_key(cx));
669    assert_eq!(
670        key_after_add, initial_key,
671        "remote worktree without entries should not affect the group key"
672    );
673
674    // Send an UpdateWorktree to the remote worktree with entries but no repo.
675    // This triggers UpdatedRootRepoCommonDir on the first update (the fix),
676    // which propagates through WorktreeStore → Project → MultiWorkspace.
677    let worktree_id = remote_worktree.read_with(cx, |wt, _| wt.id().to_proto());
678    remote_worktree.update(cx, |worktree, _cx| {
679        worktree
680            .as_remote()
681            .unwrap()
682            .update_from_remote(proto::UpdateWorktree {
683                project_id: 0,
684                worktree_id,
685                abs_path: "/remote/project".to_string(),
686                root_name: "project".to_string(),
687                updated_entries: vec![proto::Entry {
688                    id: 1,
689                    is_dir: true,
690                    path: "".to_string(),
691                    inode: 1,
692                    mtime: Some(proto::Timestamp {
693                        seconds: 0,
694                        nanos: 0,
695                    }),
696                    is_ignored: false,
697                    is_hidden: false,
698                    is_external: false,
699                    is_fifo: false,
700                    size: None,
701                    canonical_path: None,
702                }],
703                removed_entries: vec![],
704                scan_id: 1,
705                is_last_update: true,
706                updated_repositories: vec![],
707                removed_repositories: vec![],
708                root_repo_common_dir: None,
709            });
710    });
711    cx.run_until_parked();
712
713    let updated_key = project.read_with(cx, |p, cx| p.project_group_key(cx));
714    assert_ne!(
715        initial_key, updated_key,
716        "adding a remote worktree should change the project group key"
717    );
718
719    multi_workspace.read_with(cx, |mw, _cx| {
720        let keys = mw.project_group_keys();
721        assert!(
722            keys.contains(&updated_key),
723            "should contain the updated key; got {keys:?}"
724        );
725    });
726}