feat(reload): reload the active tab with Cmd/Ctrl+R

This commit is contained in:
2026-07-10 16:55:25 -04:00
parent a12b8c8bd8
commit c5890058db
16 changed files with 147 additions and 5 deletions
@@ -50,6 +50,14 @@ impl BrowserCore {
self.mark_tab_ready(tab_id)
}
/// Reload the active tab in place: recover a crashed or sleeping tab to
/// the ready state and stamp fresh activity. The shell pairs this with a
/// Servo reload so the page is actually refetched.
pub fn reload_active_tab(&mut self) -> Result<TabId, CoreError> {
let tab_id = self.active_tab_id.clone();
self.refresh_tab(&tab_id)
}
pub fn archive_idle_tabs(&mut self, now: SystemTime) -> Result<usize, CoreError> {
let ArchivePolicy::IdleDays(idle_days) = self.active_space()?.archive_policy() else {
return Ok(0);
@@ -53,6 +53,21 @@ fn recover_crashed_tab_marks_tab_ready() -> Result<(), Box<dyn Error>> {
Ok(())
}
#[test]
fn reload_active_tab_recovers_a_crashed_tab() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
let tab_id = core.open_tab(UrlText::parse("https://example.com/reload")?);
core.crash_active_tab()?;
assert_eq!(core.active_tab()?.state(), &TabState::Crashed);
let reloaded = core.reload_active_tab()?;
assert_eq!(reloaded, tab_id);
assert_eq!(core.active_tab()?.state(), &TabState::Ready);
assert_eq!(core.active_tab()?.url().as_str(), "https://example.com/reload");
Ok(())
}
#[test]
fn crash_tab_command_marks_active_tab_crashed() -> Result<(), Box<dyn Error>> {
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;