Logout button for the session, and a dev install that symlinks into the checkout
CI / test (push) Failing after 28s
CI / test (push) Failing after 28s
- New 'session' capability (wit/capabilities.wit) and 'logout' panel module: a button whose popup asks 'Log out | Cancel' (Enter confirms, Escape cancels). Confirming makes the compositor exit, which ends the login session; works in the wasm host and the native build. In the default panel. - session/install.py --link (just install-session-dev): symlink the host, component, modules, fonts and config into this checkout, so after one root install a rebuild is just 'just compositor-wasm host-wasm modules' for the next login. Plain installs still copy. - Tests: host runtime test for the module, native end-to-end test (click, cancel, confirm). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c03d4c6c17
commit
0ba975da67
42 files changed
+1033
-152
No files matched your search
@@ -33,6 +33,7 @@ pub enum Req {
|
||||
LoadModule(String),
|
||||
UnloadInstance(String),
|
||||
Browse,
|
||||
Logout,
|
||||
}
|
||||
|
||||
pub const T_APPS: usize = 0;
|
||||
@@ -265,6 +266,12 @@ impl d::modules::Host for PState {
|
||||
}
|
||||
}
|
||||
|
||||
impl d::session::Host for PState {
|
||||
fn logout(&mut self) {
|
||||
self.shared.borrow_mut().requests.push_back(Req::Logout);
|
||||
}
|
||||
}
|
||||
|
||||
impl d::system::Host for PState {
|
||||
fn read(&mut self) -> d::system::Snapshot {
|
||||
self.shared.borrow().system.clone().unwrap_or(d::system::Snapshot {
|
||||
@@ -521,4 +528,37 @@ mod tests {
|
||||
assert!(!texts(&ops).is_empty());
|
||||
rt.unload(l.handle);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn logout_asks_for_confirmation_then_requests_it() {
|
||||
let mut rt = runtime();
|
||||
let l = rt.load(&module("logout")).expect("logout loads");
|
||||
assert!(l.imports.contains(&"session".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());
|
||||
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()));
|
||||
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 })));
|
||||
assert!(matches!(rt.shared.borrow_mut().requests.pop_front(), Some(Req::Logout)));
|
||||
assert!(rt.popup(h).is_none());
|
||||
// Enter confirms too.
|
||||
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)));
|
||||
rt.unload(h);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user