R7.2: the settings window draws no app menus or update banner

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-16 11:43:20 -04:00
1 parent b12858c7f0
commit 03e8e9bcb3
9 files changed
+88 -6

No files matched your search

+41
View File
@@ -53,3 +53,44 @@ fn each_app_shows_its_own_sections(cx: &mut TestAppContext) {
assert_eq!(shown, keys, "{app:?}");
}
}
/// A main window's frame.
struct Main(gpui::FocusHandle);
impl gpui::Render for Main {
fn render(&mut self, _: &mut gpui::Window, _: &mut gpui::Context<Self>) -> impl gpui::IntoElement {
crate::shell::Shell::new("main", &self.0)
}
}
/// How far below the title bar the content starts.
fn below_title(cx: &mut TestAppContext, window: gpui::AnyWindowHandle) -> gpui::Pixels {
let mut shown = gpui::VisualTestContext::from_window(window, cx);
for _ in 0..3 {
shown.update(|window, _| window.refresh());
shown.run_until_parked();
}
let title = shown.debug_bounds("shell-title").expect("a title bar");
shown.debug_bounds("shell-body").expect("a body").origin.y - title.bottom()
}
#[gpui::test]
fn only_the_main_window_carries_menus_and_updates(cx: &mut TestAppContext) {
installed(cx);
cx.update(|cx| {
let menus = crate::commands::menus(AppId::Mark, &crate::commands::OPENING, false, Vec::new(), cx);
cx.set_menus(menus);
});
let main = cx.add_window(|_, cx| Main(cx.focus_handle()));
let menus = below_title(cx, main.into());
// macOS keeps menus in the system bar.
match cfg!(target_os = "macos") {
true => assert_eq!(menus, gpui::px(0.0), "no menu row on macOS"),
false => assert!(menus > gpui::px(0.0), "the main window shows the menus"),
}
cx.update(crate::updates::offer_for_tests);
let main = cx.add_window(|_, cx| Main(cx.focus_handle()));
assert!(below_title(cx, main.into()) > menus, "the main window shows the update");
let settings = cx.add_window(|window, cx| SettingsView::new(AppId::Mark, window, cx));
assert_eq!(below_title(cx, settings.into()), gpui::px(0.0), "settings repeats neither");
}
+1
View File
@@ -353,6 +353,7 @@ impl Render for SettingsView {
})
.collect();
Shell::new(text(cx, "settings.title", &[]), &self.focus)
.secondary()
.child(div().size_full().p_6().flex().flex_col().gap_4().children(unreadable).children(app_error).children(unsaved).child(layout))
.children(dialog)
}
+18 -5
View File
@@ -10,8 +10,8 @@ use ely_gpui_component::{
theme::{ActiveTheme, TextSize},
};
use gpui::{
AnyElement, AnyView, App, ElementId, FocusHandle, IntoElement, ParentElement, RenderOnce,
SharedString, Styled, Window, div,
AnyElement, AnyView, App, ElementId, FocusHandle, InteractiveElement, IntoElement,
ParentElement, RenderOnce, SharedString, Styled, Window, div,
};
mod page;
@@ -32,6 +32,7 @@ pub struct Shell {
right: Option<AnyView>,
status: Option<StatusBar>,
page: Option<ElementId>,
main: bool,
body: Vec<AnyElement>,
}
@@ -45,10 +46,17 @@ impl Shell {
right: None,
status: None,
page: None,
main: true,
body: Vec::new(),
}
}
/// Beside the main window: no menus, no update banner.
pub fn secondary(mut self) -> Self {
self.main = false;
self
}
pub fn tabs(mut self, tabs: EditorTabs) -> Self {
self.tabs = Some(tabs);
self
@@ -98,6 +106,7 @@ impl RenderOnce for Shell {
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement {
let length = motion::duration(motion::BASE, cx);
let content = div()
.debug_selector(|| "shell-body".into())
.flex_1()
.min_w_0()
.h_full()
@@ -123,9 +132,13 @@ impl RenderOnce for Shell {
let header = div()
.flex()
.flex_col()
.child(TitleBar::new("titlebar").title(self.title))
.children(crate::updates::updater(cx))
.children(menu_bar(cx))
.child(
div()
.debug_selector(|| "shell-title".into())
.child(TitleBar::new("titlebar").title(self.title)),
)
.children(self.main.then(|| crate::updates::updater(cx)).flatten())
.children(self.main.then(|| menu_bar(cx)).flatten())
.children(self.tabs);
// Panels give way so the content keeps its room.
let (left, right) = (panel::fitted(Side::Left, window, cx), panel::fitted(Side::Right, window, cx));
+19
View File
@@ -359,6 +359,25 @@ impl Render for Updates {
}
}
/// An offered release, for window tests.
#[cfg(test)]
pub(crate) fn offer_for_tests(cx: &mut App) {
let release = Release {
version: semver::Version::new(9, 0, 0),
url: "https://example.test/9.dmg".into(),
sha256: String::new(),
};
let updates = cx.new(|_| Updates {
app: AppId::Mark,
bundle: PathBuf::new(),
offer: Some((release, Phase::Offered)),
dismissed: false,
pending: None,
note: None,
});
cx.set_global(Updater(updates));
}
#[cfg(test)]
mod tests {
use super::*;