Settings > Panel: a cleaner module selector with reordering
CI / test (push) Failing after 17s

The Panel tab was one flat list: every panel module with an "x" that removed
it on any click, then every module on disk again with cryptic "x1" counts and
a Browse row that looked selected.

- "In the panel, left to right": the modules in panel order, each with
  move up / move down / remove buttons. Clicking the row itself does nothing,
  so a stray click no longer removes a module. Backspace/Delete removes the
  highlighted one, PageUp/PageDown move it.
- "Add to the panel": grouped (Apps and windows, System, Clocks, Other),
  each with a one-line description and an Add button. A module already in the
  panel is left out, except clocks, which offer "Add another". With nothing
  left: "Everything is in the panel".
- "Browse for a module file..." is a secondary outlined button.
- Section headings are larger and full contrast; the popup is 320 wide and
  now fits a 720-high screen with the default panel.

Reordering goes through a new modules.move-instance(slot, delta) capability
call, plumbed through both hosts: wasmer stub request 17, host-wasm, the
plasmoids host WIT (move-instance(instance-move)) and wasmhost. The shell's
move_slot clamps to the ends and saves panel.edn, so the saved format is
unchanged. DesktopShell::slot_popup_texts lets tests find popup rows by text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hhRDWZf5WcmrNwnFe3
This commit is contained in:
Claude committed 2026-11-25 20:35:54 +00:00
1 parent c1936299cb
commit 8ecdef17d4
16 files changed
+514 -98

No files matched your search

+15 -12
View File
@@ -12,20 +12,25 @@ fn wasmImportLoadModule(p0 : Int, p1 : Int) = "chandra:desktop/modules@0.1.0" "
///|
fn wasmImportUnloadInstance(p0 : Int, p1 : Int) = "chandra:desktop/modules@0.1.0" "unload-instance"
///|
fn wasmImportMoveInstance(p0 : Int, p1 : Int, p2 : Int) = "chandra:desktop/modules@0.1.0" "move-instance"
///|
fn wasmImportBrowse() = "chandra:desktop/modules@0.1.0" "browse"
///|
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
#|(func (param i32) (result i32) (local i32)
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
#| local.tee 1 i32.const 0 call $moonbit.init_array8
#| local.get 1)
extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) local.get 0 call $moonbit.decref)
///|
extern "wasm" fn mbt_ffi_load32(offset : Int) -> Int =
#|(func (param i32) (result i32) local.get 0 i32.load)
///|
#owned(str)
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
#|(func (param i32) (result i32) local.get 0)
///|
extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
#|(func (param i32) (param i32) (result i32)
@@ -34,11 +39,9 @@ extern "wasm" fn mbt_ffi_ptr2str(ptr : Int, len : Int) -> String =
#| local.get 0)
///|
extern "wasm" fn mbt_ffi_free(position : Int) =
#|(func (param i32) local.get 0 call $moonbit.decref)
///|
#owned(str)
extern "wasm" fn mbt_ffi_str2ptr(str : String) -> Int =
#|(func (param i32) (result i32) local.get 0)
extern "wasm" fn mbt_ffi_malloc(size : Int) -> Int =
#|(func (param i32) (result i32) (local i32)
#| local.get 0 i32.const 4 i32.add call $moonbit.gc.malloc
#| local.tee 1 i32.const 0 call $moonbit.init_array8
#| local.get 1)
@@ -74,6 +74,15 @@ pub fn unload_instance(slot : String) -> Unit {
wasmImportUnloadInstance(ptr, slot.length());
mbt_ffi_free(ptr)
}
///|
/// Move one loaded instance `delta` places along the panel (negative: towards the start).
pub fn move_instance(slot : String, delta : Int) -> Unit {
let ptr = mbt_ffi_str2ptr(slot)
wasmImportMoveInstance(ptr, slot.length(), delta);
mbt_ffi_free(ptr)
}
///|
/// Ask the host to show its native file chooser for a .wasm elsewhere on disk.
@@ -61,6 +61,11 @@ pub(all) struct ConfigItem {
value : String
}
pub(all) struct InstanceMove {
slot : String
delta : Int32
}
pub(all) struct Loaded {
handle : UInt32
id : String
@@ -104,6 +109,7 @@ pub(all) enum Request {
SetSuspendAfter(Int32)
PowerAction(Int32)
Network(NetworkRequest)
MoveInstance(InstanceMove)
}
pub(all) struct SettingChange {
+14 -2
View File
@@ -30,6 +30,11 @@ pub(all) struct NetworkRequest {
action : Int; ssid : String; password : String
}
///|
/// A module moving a panel instance `delta` places (negative: towards the start).
pub(all) struct InstanceMove {
slot : String; delta : Int
}
///|
/// A module turning a session setting on or off.
pub(all) struct SettingChange {
index : Int; on : Bool
@@ -52,6 +57,7 @@ pub(all) enum Request {
SetSuspendAfter(Int)
PowerAction(Int)
Network(NetworkRequest)
MoveInstance(InstanceMove)
}
///|
/// A native file-chooser dialog (zenity on the host session) for "Add widget".
@@ -477,7 +483,7 @@ pub fn next_request() -> Request? {
let return_area = mbt_ffi_malloc(28)
wasmImportNextRequest(return_area);
let lifted4 : Request? = match mbt_ffi_load8_u((return_area) + 0) {
let lifted5 : Request? = match mbt_ffi_load8_u((return_area) + 0) {
0 => Option::None
1 => {
@@ -552,6 +558,12 @@ pub fn next_request() -> Request? {
Request::Network(NetworkRequest::{action : mbt_ffi_load32((return_area) + 8), ssid : result2, password : result3})
}
15 => {
let result4 = mbt_ffi_ptr2str(mbt_ffi_load32((return_area) + 8), mbt_ffi_load32((return_area) + 12))
Request::MoveInstance(InstanceMove::{slot : result4, delta : mbt_ffi_load32((return_area) + 16)})
}
_ => panic()
}
@@ -559,7 +571,7 @@ pub fn next_request() -> Request? {
}
_ => panic()
}
let ret = lifted4
let ret = lifted5
mbt_ffi_free(return_area)
return ret