From 03c211ab6b991cc26db695d7bf99ff02eab7a48f Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 22 Nov 2026 07:02:29 -0500 Subject: [PATCH] Start screen: pinned folders above recent files; a Clear button on the Recent heading --- crates/ui-shell/src/shell/start.rs | 12 +++++++++--- crates/ui-shell/src/shell/words.rs | 2 ++ crates/ui-shell/tests/it/shell/start.rs | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/crates/ui-shell/src/shell/start.rs b/crates/ui-shell/src/shell/start.rs index ebccef798..46d2bba63 100644 --- a/crates/ui-shell/src/shell/start.rs +++ b/crates/ui-shell/src/shell/start.rs @@ -528,6 +528,10 @@ impl StartScreen<'_> { let _ = Row::new().gap(Gap::Tight).show(ui, |ui, _| new_and_open(&page, ui)); } host_sections(ui, StartPlace::BeforeRecent); + // The pinned folders stand above the recent files, as production's Folders section does. + if let Some(pinned) = pinned { + pinned_section(&page, ui, pinned); + } if max_recent > 0 { let current_view = view.borrow_mut().reborrow().read(cx).and_then(|held| held.same().copied()).unwrap_or_default(); let current_sort = sort.borrow_mut().reborrow().read(cx).and_then(|held| held.same().copied()).unwrap_or_default(); @@ -535,9 +539,6 @@ impl StartScreen<'_> { sort_recent(&mut files, current_sort, &collator); recent_section(&page, ui, &view, &sort, current_view, &files); } - if let Some(pinned) = pinned { - pinned_section(&page, ui, pinned); - } if !templates.is_empty() { templates_section(&page, ui, templates); } @@ -635,6 +636,11 @@ fn recent_section( .controls(|ui, _| { let _ = Segmented::new(words.view.clone(), view.borrow_mut().reborrowed(), &modes).show(ui); let _ = Select::new(words.sort.clone(), sort.borrow_mut().reborrowed(), &orders).show(ui); + // Clear empties the list, as the menu's Clear Recent Files does; with no files there is nothing to clear. + let clear = Button::new(words.clear_recent.clone()).icon(IconId::new("trash")).enabled(!files.is_empty()).id_salt("clear").show(ui); + if clicked(&clear) { + page.push(StartAction::ClearRecent); + } }) .show(ui, |ui, cx| { let mut lead = cx.keep::().recent.clone().filter(|path| files.iter().any(|file| &file.path == path)); diff --git a/crates/ui-shell/src/shell/words.rs b/crates/ui-shell/src/shell/words.rs index ace7d4afb..6ab876545 100644 --- a/crates/ui-shell/src/shell/words.rs +++ b/crates/ui-shell/src/shell/words.rs @@ -20,6 +20,8 @@ craft_ui::words! { grid_view: "startScreen.gridView" = "Grid"; list_view: "startScreen.listView" = "List"; sort: "startScreen.sort" = "Sort"; + /// The button at the Recent heading's end that empties the list. + clear_recent: "startScreen.clearRecent" = "Clear"; sort_opened: "startScreen.sortOpened" = "Last Opened"; sort_name: "startScreen.sortName" = "Name"; sort_created: "startScreen.sortCreated" = "Created"; diff --git a/crates/ui-shell/tests/it/shell/start.rs b/crates/ui-shell/tests/it/shell/start.rs index 3748540a3..f95834a35 100644 --- a/crates/ui-shell/tests/it/shell/start.rs +++ b/crates/ui-shell/tests/it/shell/start.rs @@ -388,3 +388,26 @@ fn a_listed_pinned_folder_folds_shows_more_and_opens_its_files() { fixture.key(Key::ArrowLeft, Modifiers::NONE).idle(2); assert_eq!(*log.borrow(), vec![StartAction::FoldPinned(PathBuf::from("/tmp/Empty"))], "an empty folder's disclosure folds it"); } + +/// The pinned folders stand above the recent files, as production's Folders section does, and the Recent heading carries +/// a Clear button that asks the app to clear the list. +#[trial] +fn folders_come_before_recent_and_recent_has_a_clear_button() { + let log: Log = Rc::default(); + let seen = log.clone(); + let files = vec![RecentFile::new("/tmp/work/Poster.psd", "Poster.psd")]; + let folders = vec![PinnedFolder::new("/tmp/Work", "Work")]; + let mut fixture = Fixture::new(move |ui| { + let (mut view, mut sort) = (RecentView::List, RecentSort::Opened); + let out = StartScreen::new(Bind::bound(&mut view), Bind::bound(&mut sort), &files).pinned(&folders).show(ui); + seen.borrow_mut().extend(out.actions); + }); + fixture.room(egui::Vec2::new(1100.0, 700.0)).settle(); + let top = |fixture: &Fixture, text: &str| fixture.texts().iter().find(|run| run.text == text).map(|run| run.rect.min.y); + let pinned = top(&fixture, "Pinned Folders").expect("the pinned folders heading"); + let recent = top(&fixture, "Recent").expect("the recent heading"); + assert!(pinned < recent, "the folders ({pinned}) come before the recent files ({recent})"); + let clear = fixture.by_label("Clear").expect("the Recent heading's Clear button"); + fixture.click(&clear).idle(2); + assert!(log.borrow().iter().any(|action| matches!(action, StartAction::ClearRecent)), "Clear asks the app to clear the list"); +}