Add private window entry point

This commit is contained in:
2026-05-09 00:31:40 -04:00
parent 97a06d7b52
commit 7797203bbf
6 changed files with 139 additions and 29 deletions
+21 -2
View File
@@ -43,7 +43,10 @@ pub use spaces::TrashedSpace;
pub struct InitialBrowserConfig {
pub space_name: String,
pub space_icon: String,
pub space_color_hex: u32,
pub profile_name: String,
pub profile_color_hex: u32,
pub profile_kind: ProfileKind,
pub new_tab_destination: NewTabDestination,
}
@@ -52,7 +55,22 @@ impl InitialBrowserConfig {
Ok(Self {
space_name: "Work".to_string(),
space_icon: "W".to_string(),
space_color_hex: 0xf54e00,
profile_name: "Default".to_string(),
profile_color_hex: 0x26251e,
profile_kind: ProfileKind::Standard,
new_tab_destination: NewTabDestination::default(),
})
}
pub fn private_window() -> Result<Self, DomainError> {
Ok(Self {
space_name: "Private".to_string(),
space_icon: "P".to_string(),
space_color_hex: 0x807d72,
profile_name: "Private".to_string(),
profile_color_hex: 0x807d72,
profile_kind: ProfileKind::Private,
new_tab_destination: NewTabDestination::default(),
})
}
@@ -127,12 +145,13 @@ pub struct BrowserCore {
impl BrowserCore {
pub fn new(config: InitialBrowserConfig) -> Result<Self, CoreError> {
let profile = Profile::new(config.profile_name, 0x26251e, ProfileKind::Standard);
let profile =
Profile::new(config.profile_name, config.profile_color_hex, config.profile_kind);
let active_profile_id = profile.id().clone();
let space = Space::new(
config.space_name,
config.space_icon,
0xf54e00,
config.space_color_hex,
active_profile_id.clone(),
0,
);
+20
View File
@@ -24,6 +24,26 @@ fn new_private_profile_command_creates_private_profile() -> Result<(), Box<dyn E
Ok(())
}
#[test]
fn private_window_config_starts_with_private_profile() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::private_window()?)?;
let snapshot = core.snapshot()?;
let Some(private_profile) =
snapshot.profiles.iter().find(|profile| profile.id() == &snapshot.active_profile_id)
else {
return Err("missing active private profile".into());
};
assert_eq!(snapshot.active_space_name, "Private");
assert_eq!(snapshot.active_profile_name, "Private");
assert_eq!(private_profile.kind(), &ProfileKind::Private);
assert_eq!(private_profile.sync_policy(), ProfileSyncPolicy::Paused);
core.open_tab(UrlText::parse("https://example.com/private-window")?);
assert!(core.snapshot()?.history_entries.is_empty());
Ok(())
}
#[test]
fn private_profiles_do_not_record_history() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;