Settings > Apps: choose the default browser, email, files, terminal, editor, viewers and players
CI / test (push) Failing after 45s

- A sixth Settings tab, Apps (key 6, SettingsTab::Apps; the popup is 390 px wide for it): Web
  browser, Email, File manager, Terminal, Text editor, Image viewer, Video player, Music player,
  PDF and documents, Archive manager. Each row shows the current default with its real icon (the
  icon-theme lookup the task manager uses; a letter tile when there is none). Click a row to list
  the installed apps that can take it, click one to make it the default. A chosen app that has
  been uninstalled since is named in red under its row ("gthumb is not installed any more").
- Installed apps come from the .desktop files in the XDG data dirs (and flatpak's exports), with
  MimeType= and Categories= (desktop_entry_keys, now shared with the launcher's parse_desktop).
  A kind lists the shown apps that handle one of its MIME types; the terminal lists
  TerminalEmulator apps; browsers are only offered as browsers.
- Reading follows the mimeapps.list spec: $XDG_CONFIG_HOME/[chandra-]mimeapps.list, then
  $XDG_CONFIG_DIRS (/etc/xdg), then $XDG_DATA_HOME and $XDG_DATA_DIRS applications/; the first
  installed [Default Applications] entry wins, else [Added Associations], else mimeinfo.cache
  (minus [Removed Associations]), else the first installed app that handles the type. A hidden
  (NoDisplay) default still counts and its name is shown.
- Setting writes [Default Applications] in ~/.config/mimeapps.list for each of the kind's MIME
  types the app handles (always the main one: http/https/text/html for browsers, mailto,
  inode/directory, text/plain, image/png..., video/mp4..., audio/mpeg..., application/pdf...,
  application/zip...), as xdg-mime default / xdg-settings do, without running them. Every other
  section, entry, comment and blank line is kept; the app leaves those types' [Removed
  Associations]; a chandra-mimeapps.list that already names one of those types is updated too.
- The terminal has no MIME type: state.edn :terminal "kitty" (desktop id), also written first in
  ~/.config/xdg-terminals.list (xdg-terminal-exec). Terminal=true apps from the launcher (and
  session restore) now start in it (foot -e, kgx/gnome-terminal/ptyxis --, kitty <cmd>, wezterm
  start --) instead of always foot; with no choice: xdg-terminals.list, then foot, then any
  installed terminal. Terminal apps are listed when any terminal emulator is installed, not only
  foot.
- New `default-apps` capability (categories, apps, set-default, refresh): host tables 11 (sss:
  name current missing) and 12 (issii: category id name icon current), request 19 (category *
  1000 + app, -1 rescans) in the wasmer/wasmtime stub, host-wasm and the MoonBit wasmhost
  (chandra:host/plasmoids default-app(s32)). Nothing is scanned until the tab opens (refresh).
- Tests with a temporary XDG tree: categories and current defaults (user file, system file,
  Added Associations, mimeinfo.cache, missing apps, hidden defaults), writing that keeps other
  entries, desktop-specific files, the terminal list and commands, the Apps tab end to end, and
  the :terminal round trip through state.edn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hgywj7RPmFdFhpzGZj
This commit is contained in:
Claude committed 2026-11-25 21:27:30 +00:00
1 parent 442f9477b4
commit bb7c9b947f
26 files changed
+1605 -73

No files matched your search

+10
View File
@@ -305,6 +305,10 @@ pub(all) enum HostTable {
NetNetworks
/// Keyboard shortcuts (ssssi: name binding default-binding conflict capturing).
Shortcuts
/// Default-app categories (sss: name current missing).
AppCategories
/// Default-app choices (issii: category id name icon current).
AppChoices
}
///|
@@ -330,6 +334,8 @@ pub fn publish(which : HostTable, t : Table) -> Unit {
NetStatus => 8U
NetNetworks => 9U
Shortcuts => 10U
AppCategories => 11U
AppChoices => 12U
}
// Most tables are republished every frame unchanged: skip the copy into the host then.
let slot = id.reinterpret_as_int()
@@ -405,6 +411,9 @@ pub(all) enum HostRequest {
/// The shortcuts capability: action * 1000 + index (0 capture, 1 reset, 2 reset all, 3 cancel
/// the capture).
Shortcut(Int)
/// The default-apps capability: category * 1000 + app sets that category's default, -1 scans
/// the apps and defaults again.
DefaultApp(Int)
/// The session capability's `reload`: reload every loaded panel module from disk.
ReloadSession
} derive(Eq, Debug)
@@ -430,6 +439,7 @@ pub fn next_request() -> HostRequest? {
Some(PowerAction(a)) => Some(PowerAction(a))
Some(Network(r)) => Some(Network(r.action, r.ssid, r.password))
Some(Shortcut(code)) => Some(Shortcut(code))
Some(DefaultApp(code)) => Some(DefaultApp(code))
Some(ReloadSession) => Some(ReloadSession)
}
}
+10
View File
@@ -697,6 +697,10 @@ pub(all) enum HostTable {
NetNetworks
/// Keyboard shortcuts (ssssi: name binding default-binding conflict capturing).
Shortcuts
/// Default-app categories (sss: name current missing).
AppCategories
/// Default-app choices (issii: category id name icon current).
AppChoices
}
///| Publish `t` as the data behind `which` for every module's next call.
@@ -713,6 +717,8 @@ pub fn publish(which : HostTable, t : Table) -> Unit {
NetStatus => 8
NetNetworks => 9
Shortcuts => 10
AppCategories => 11
AppChoices => 12
}
let out : Array[Byte] = []
for k = 0; k < 4; k = k + 1 {
@@ -787,6 +793,9 @@ pub(all) enum HostRequest {
/// The shortcuts capability: action * 1000 + index (0 capture, 1 reset, 2 reset all, 3 cancel
/// the capture).
Shortcut(Int)
/// The default-apps capability: category * 1000 + app sets that category's default, -1 scans
/// the apps and defaults again.
DefaultApp(Int)
/// The session capability's `reload`: reload every loaded panel module from disk.
ReloadSession
} derive(Eq, Debug)
@@ -829,6 +838,7 @@ pub fn next_request() -> HostRequest? {
}
}
18 => Some(Shortcut(c_host_req_int()))
19 => Some(DefaultApp(c_host_req_int()))
_ => None
}
}
+13 -2
View File
@@ -60,14 +60,15 @@ enum {
K_BAT_READ,
K_NET_STATUS, K_NET_LIST, K_NET_SCAN, K_NET_CONNECT, K_NET_DISCONNECT, K_NET_FORGET, K_NET_SET_WIFI,
K_NET_SET_AIRPLANE,
K_SC_LIST, K_SC_CAPTURE, K_SC_CANCEL, K_SC_RESET, K_SC_RESET_ALL
K_SC_LIST, K_SC_CAPTURE, K_SC_CANCEL, K_SC_RESET, K_SC_RESET_ALL,
K_DA_CATS, K_DA_APPS, K_DA_SET, K_DA_REFRESH
};
typedef struct Env { Inst *inst; int kind; } Env;
/* ---- host data the shell publishes before calling a guest ----
* A table is [u32 rows] then rows of fields, each field a LE i32 ('i') or a u32 byte length + UTF-8 ('s'). */
enum { T_APPS, T_WINDOWS, T_LAYOUTS, T_MODULES, T_INSTANCES, T_WALLPAPERS, T_SESSION_SETTINGS, T_ICONS,
T_NET_STATUS, T_NET_NETWORKS, T_SHORTCUTS, T_N };
T_NET_STATUS, T_NET_NETWORKS, T_SHORTCUTS, T_APP_CATS, T_APP_CHOICES, T_N };
typedef struct { uint8_t *data; size_t len; } Blob;
static Blob tables[T_N];
static int32_t host_ints[12] = {[7] = -1}; /* 0 layout mode, 1 inspector on, 2 current wallpaper, 3 session settings on (bit i: row i),
@@ -402,6 +403,12 @@ static wasm_trap_t *host_import(void *env, const wasm_val_vec_t *args, wasm_val_
case K_SC_RESET: if (a0 >= 0 && a0 < 1000) push_req(18, 1000 + a0, NULL); break;
case K_SC_RESET_ALL: push_req(18, 2000, NULL); break;
case K_SC_CANCEL: push_req(18, 3000, NULL); break;
/* Default apps: categories from table 11 (name current missing), choices from table 12 (category id name
* icon current); request 19 is category * 1000 + app, or -1 to scan again. */
case K_DA_CATS: build_list(in, T_APP_CATS, "sss", a0); break;
case K_DA_APPS: build_list(in, T_APP_CHOICES, "issib", a0); break;
case K_DA_SET: if (a0 >= 0 && a0 < 1000 && a1 >= 0 && a1 < 1000) push_req(19, a0 * 1000 + a1, NULL); break;
case K_DA_REFRESH: push_req(19, -1, NULL); break;
case K_NET_SCAN: push_req(16, 0, NULL); break;
case K_NET_DISCONNECT: push_req(16, 1, NULL); break;
case K_NET_SET_WIFI: push_req(16, a0 ? 3 : 2, NULL); break;
@@ -603,6 +610,10 @@ static int classify_import(const wasm_name_t *m, const wasm_name_t *f) {
if (!strcmp(iface, "shortcuts") && !strcmp(fn, "cancel-capture")) return K_SC_CANCEL;
if (!strcmp(iface, "shortcuts") && !strcmp(fn, "reset")) return K_SC_RESET;
if (!strcmp(iface, "shortcuts") && !strcmp(fn, "reset-all")) return K_SC_RESET_ALL;
if (!strcmp(iface, "default-apps") && !strcmp(fn, "categories")) return K_DA_CATS;
if (!strcmp(iface, "default-apps") && !strcmp(fn, "apps")) return K_DA_APPS;
if (!strcmp(iface, "default-apps") && !strcmp(fn, "set-default")) return K_DA_SET;
if (!strcmp(iface, "default-apps") && !strcmp(fn, "refresh")) return K_DA_REFRESH;
if (!strcmp(iface, "network") && !strcmp(fn, "status")) return K_NET_STATUS;
if (!strcmp(iface, "network") && !strcmp(fn, "wifi-networks")) return K_NET_LIST;
if (!strcmp(iface, "network") && !strcmp(fn, "scan")) return K_NET_SCAN;