Launcher: Reload session, and Log out moves in from its own module
CI / test (push) Failing after 17s
CI / test (push) Failing after 17s
The Application Launcher's menu now ends in a session row: Reload, Log out, Suspend, Restart,
Power off. Log out, Restart and Power off take a second click on the same button (a status line
says "Click Log out again to confirm"); Reload and Suspend act at once.
- Reload calls the new session.reload, which reaches the shell as the ReloadSession request
(native stub: request 8 with n 1; host plasmoids.wit: reload-session; host-wasm: Req::ReloadSession)
and runs DesktopShell::reload_modules(""): every panel module again from disk, in place, with
its settings. Windows and apps keep running. The compositor redraws the whole frame after it.
- Suspend / Restart / Power off use the power capability, the same calls as Settings > Power.
- The standalone logout module is gone (component, world, components.txt). Saved panels drop
"logout", or get the launcher in its place when they had none; panel.edn is rewritten without
it. A stale logout.wasm is hidden from Settings > Panel (retired_modules).
- Tests: lib/launcher session row, shell migrate_panel, host input tests for Log out and Reload,
host-wasm launcher session row; control_test uses inspector.wasm instead of logout.wasm.
- README and docs/reloading.md describe the session row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hjKUnSS3D92ThigvJf
This commit is contained in:
37 files changed
+420
-827
No files matched your search
@@ -264,6 +264,7 @@ impl chandra::host::plasmoids::Host for State {
|
||||
}
|
||||
Req::Browse => R::Browse,
|
||||
Req::Logout => R::Logout,
|
||||
Req::ReloadSession => R::ReloadSession,
|
||||
Req::SetWallpaper(n) => R::SetWallpaper(n),
|
||||
Req::SetSessionSetting(index, on) => {
|
||||
R::SetSessionSetting(chandra::host::plasmoids::SettingChange { index, on })
|
||||
|
||||
+33
-21
@@ -46,6 +46,8 @@ pub enum Req {
|
||||
MoveInstance(String, i32),
|
||||
Browse,
|
||||
Logout,
|
||||
/// `session.reload`: reload every loaded panel module from disk.
|
||||
ReloadSession,
|
||||
SetWallpaper(i32),
|
||||
SetSessionSetting(i32, bool),
|
||||
/// The screenshot capability: 0-3 take, 10-12 record, 20 stop, 30/31 pointer off/on.
|
||||
@@ -318,6 +320,9 @@ impl d::session::Host for PState {
|
||||
fn logout(&mut self) {
|
||||
self.shared.borrow_mut().requests.push_back(Req::Logout);
|
||||
}
|
||||
fn reload(&mut self) {
|
||||
self.shared.borrow_mut().requests.push_back(Req::ReloadSession);
|
||||
}
|
||||
}
|
||||
|
||||
impl d::wallpaper::Host for PState {
|
||||
@@ -746,7 +751,7 @@ mod tests {
|
||||
// Its capability grant is what the binary imports (the MoonBit side drops the base `theme`).
|
||||
let mut imports = l.imports.clone();
|
||||
imports.sort();
|
||||
assert_eq!(imports, ["app-catalog", "app-launch", "theme"]);
|
||||
assert_eq!(imports, ["app-catalog", "app-launch", "power", "session", "theme"]);
|
||||
let h = l.handle;
|
||||
// It draws its button.
|
||||
assert!(!rt.render(h, Size { w: 190, h: 36 }).is_empty());
|
||||
@@ -814,35 +819,42 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn logout_asks_for_confirmation_then_requests_it() {
|
||||
fn launcher_session_row_reloads_and_logs_out_after_confirming() {
|
||||
let mut rt = runtime();
|
||||
let l = rt.load(&module("logout")).expect("logout loads");
|
||||
let l = rt.load(&module("launcher")).expect("launcher loads");
|
||||
assert!(l.imports.contains(&"session".to_string()));
|
||||
assert!(l.imports.contains(&"power".to_string()));
|
||||
let h = l.handle;
|
||||
assert!(!rt.render(h, Size { w: 84, h: 34 }).is_empty());
|
||||
// Closed: no popup. A click opens it; nothing is requested yet.
|
||||
assert!(rt.popup(h).is_none());
|
||||
// Open the menu; its last row is the session row.
|
||||
assert!(rt.on_event(h, false, InputEvent::PointerDown(Point { x: 5, y: 5 })));
|
||||
let p = rt.popup(h).expect("popup open");
|
||||
assert!(texts(&p.ops).contains(&"Log out".to_string()) && texts(&p.ops).contains(&"Cancel".to_string()));
|
||||
let t = texts(&p.ops);
|
||||
for b in ["Reload", "Log out", "Suspend", "Restart", "Power off"] {
|
||||
assert!(t.contains(&b.to_string()), "{b} missing from {t:?}");
|
||||
}
|
||||
// Button i's centre: 5 buttons across 340 px with 8 px margins and 4 px gaps, in a
|
||||
// 44 px row at the bottom (lib/launcher).
|
||||
let button = |i: i32, ph: i32| Point { x: 8 + i * 65 + 30, y: ph - 44 + 6 + 15 };
|
||||
let ph = p.size.h as i32;
|
||||
// Log out: the first click only arms it, the second requests it.
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(button(1, ph))));
|
||||
assert!(rt.shared.borrow().requests.is_empty());
|
||||
// Cancel row (second): closes without logging out.
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(Point { x: 20, y: 6 + 30 + 5 })));
|
||||
assert!(rt.popup(h).is_none());
|
||||
assert!(rt.shared.borrow().requests.is_empty());
|
||||
// Escape also cancels.
|
||||
rt.on_event(h, false, InputEvent::PointerDown(Point { x: 5, y: 5 }));
|
||||
assert!(rt.on_event(h, true, InputEvent::KeyDown("Escape".to_string())));
|
||||
assert!(rt.shared.borrow().requests.is_empty());
|
||||
// Open again and click the first row: that is the logout request.
|
||||
rt.on_event(h, false, InputEvent::PointerDown(Point { x: 5, y: 5 }));
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(Point { x: 20, y: 6 + 5 })));
|
||||
let p = rt.popup(h).expect("still open");
|
||||
assert!(texts(&p.ops).contains(&"Click Log out again to confirm".to_string()));
|
||||
let ph = p.size.h as i32;
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(button(1, ph))));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::Logout)));
|
||||
assert!(rt.popup(h).is_none());
|
||||
// Enter confirms too.
|
||||
// Reload acts at once.
|
||||
rt.on_event(h, false, InputEvent::PointerDown(Point { x: 5, y: 5 }));
|
||||
rt.on_event(h, true, InputEvent::KeyDown("Enter".to_string()));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::Logout)));
|
||||
let ph = rt.popup(h).expect("open").size.h as i32;
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(button(0, ph))));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::ReloadSession)));
|
||||
// Suspend acts at once too, through the power capability.
|
||||
rt.on_event(h, false, InputEvent::PointerDown(Point { x: 5, y: 5 }));
|
||||
let ph = rt.popup(h).expect("open").size.h as i32;
|
||||
assert!(rt.on_event(h, true, InputEvent::PointerDown(button(2, ph))));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::PowerAction(0))));
|
||||
rt.unload(h);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user