Session settings panel module: switch session restore and window placement on or off
CI / test (push) Failing after 16s
CI / test (push) Failing after 16s
- New 'session-settings' capability (wit/capabilities.wit: settings, is-on, set-setting) and 'session-settings' panel module: a "Session" button whose popup lists the session settings, each with an on/off switch. Clicking a row flips it at once (the list stays open); Up/Down move the highlight, Enter or Space flips it, Escape or a click elsewhere closes. In the default panel, between Wallpaper and Log out. - Two settings to start with, kept in state.edn and written only when off (absent means on): "Reopen windows at login" (:restore-session, the key session restore already read) and "Remember window positions" (:remember-windows; when off, floating windows aren't placed where their app was left and new places aren't recorded, but the saved ones are kept). - Served by both hosts: wasmer stub (native; settings table 6, bit mask in host int 3, requests 10/11) and host-wasm (publish-session-settings, set-session-setting request). - Tests: native end-to-end (open, click both rows, keyboard, Escape), a state.edn round trip that checks both settings take effect, and a host-wasm module test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hgxf6exeYrDGcy4WW3
This commit is contained in:
32 files changed
+1192
-44
No files matched your search
@@ -1253,3 +1253,75 @@ test "the open windows are saved as the session and a restored app's window gets
|
||||
assert_eq(b.shell.load_session().length(), 0)
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
test "the session settings module flips the session settings from its popup" {
|
||||
let comp = new_comp("sessset")
|
||||
let slot = comp.shell.slot_of("session-settings")
|
||||
assert_true(comp.shell.slot_rect(slot).w > 0) // it is in the default panel
|
||||
assert_true(comp.shell.restore_session)
|
||||
assert_true(comp.shell.remember_windows)
|
||||
// A click opens the list of switches; nothing changes yet.
|
||||
click_module(comp, "session-settings", 1U)
|
||||
let pr = comp.shell.slot_popup_rect(slot)
|
||||
assert_true(pr.h >= 6 * 2 + 2 * 32) // one row per setting
|
||||
assert_true(comp.shell.restore_session)
|
||||
// First row: "Reopen windows at login" goes off, and on again with a second click.
|
||||
click_at(comp, pr.x + 40, pr.y + 6 + 5, 5U)
|
||||
assert_false(comp.shell.restore_session)
|
||||
assert_true(comp.shell.remember_windows)
|
||||
assert_true(comp.shell.slot_popup_rect(slot).w > 0) // the list stays open
|
||||
click_at(comp, pr.x + 40, pr.y + 6 + 5, 10U)
|
||||
assert_true(comp.shell.restore_session)
|
||||
// Second row: "Remember window positions"; then Down and Enter flip it back from the keyboard.
|
||||
click_at(comp, pr.x + 40, pr.y + 6 + 32 + 5, 15U)
|
||||
assert_false(comp.shell.remember_windows)
|
||||
comp.shell.key_down("Enter")
|
||||
ignore(comp.compose_frame())
|
||||
assert_true(comp.shell.remember_windows)
|
||||
assert_true(comp.shell.restore_session)
|
||||
comp.shell.key_down("Escape")
|
||||
ignore(comp.compose_frame())
|
||||
assert_eq(comp.shell.slot_popup_rect(slot).w, 0)
|
||||
// Out-of-range settings are ignored.
|
||||
comp.shell.set_session_setting(7, false)
|
||||
assert_true(comp.shell.restore_session && comp.shell.remember_windows)
|
||||
}
|
||||
|
||||
///|
|
||||
test "session settings are saved to state.edn and restored, and take effect" {
|
||||
if @sys.getenv("CHANDRA_TEST_CONFIG") == "1" {
|
||||
write_state_edn("{:note \"keep\" :session [{:app \"foot\"}]}\n")
|
||||
let a = new_comp("sess-a")
|
||||
a.shell.persist = true
|
||||
a.restore_state()
|
||||
assert_true(a.shell.restore_session) // absent: on
|
||||
assert_eq(a.shell.load_session().length(), 1)
|
||||
a.shell.remember_window("foot", 10, 20, 300, 200)
|
||||
assert_eq(a.shell.saved_window("foot"), Some((10, 20, 300, 200)))
|
||||
// Turning them off writes them, keeps the other keys, and stops reopening and placing.
|
||||
a.shell.set_session_setting(0, false)
|
||||
a.shell.set_session_setting(1, false)
|
||||
let text = read_state_edn()
|
||||
assert_true(text.contains(":restore-session false"))
|
||||
assert_true(text.contains(":remember-windows false"))
|
||||
assert_true(text.contains(":note \"keep\""))
|
||||
assert_true(text.contains(":session"))
|
||||
assert_eq(a.shell.load_session().length(), 0)
|
||||
assert_eq(a.shell.saved_window("foot"), None)
|
||||
a.shell.remember_window("foot", 50, 60, 300, 200) // not recorded while off
|
||||
let b = new_comp("sess-b")
|
||||
b.shell.persist = true
|
||||
b.restore_state()
|
||||
assert_false(b.shell.restore_session)
|
||||
assert_false(b.shell.remember_windows)
|
||||
// On again: the keys go away (absent means on), and the old place is still known.
|
||||
b.shell.set_session_setting(0, true)
|
||||
b.shell.set_session_setting(1, true)
|
||||
let text2 = read_state_edn()
|
||||
assert_false(text2.contains(":restore-session"))
|
||||
assert_false(text2.contains(":remember-windows"))
|
||||
assert_eq(b.shell.load_session().length(), 1)
|
||||
assert_eq(b.shell.saved_window("foot"), Some((10, 20, 300, 200)))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user