From df3a158f8c9a7aee3eadec88d056ea5de9b9fc52 Mon Sep 17 00:00:00 2001 From: steigr Date: Thu, 19 Nov 2026 23:29:39 +0100 Subject: [PATCH 1/3] iris-gui: list every machine's own drives in the summary and preflight The stopped-machine summary now lists the NVMe card and Fibre Channel disks, names SCSI targets on a second bus as controller:id, leaves out the IP35 bricks' unused [scsi] map and shows an unplugged or stream Ethernet. The missing-disk prompt names targets the same way. Both are worked out in the new summary module from the config alone. The rest of issue 304 was already fixed upstream: the O2's own o2.prom, o2.disks and similar keys are folded into the shared keys on load, so the summary and the disk check read the O2's settings, and the Advanced tab edits [o2]. Tests cover a config in that old spelling. Refs techomancer/iris#304 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 + clanker/INDEX.md | 1 + ...y-and-disk-preflight-live-in-summary-rs.md | 26 ++ iris-gui-README.md | 9 +- iris-gui/locales/en/main.ftl | 7 +- iris-gui/src/main.rs | 103 ++----- iris-gui/src/summary.rs | 268 ++++++++++++++++++ 7 files changed, 343 insertions(+), 75 deletions(-) create mode 100644 clanker/gui/summary-and-disk-preflight-live-in-summary-rs.md create mode 100644 iris-gui/src/summary.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b2c1060f..4a0d4365f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -595,6 +595,10 @@ image) where the guest test suites showed they differed: earlier keeps its `threads = 1` until **Automatic** is ticked. - The CI tab's **Ping** and the CI self-test reach the configured CI socket. - The **Use built-in PROM** button no longer leaves a `prom` iris refuses. +- The stopped-machine summary lists NVMe and Fibre Channel disks, names SCSI + targets on a second bus as `controller:id` (also in the missing-disk prompt), + leaves out the Origin 3200's unused SCSI map and shows an unplugged or + stream Ethernet. ## October 2026 diff --git a/clanker/INDEX.md b/clanker/INDEX.md index cb6e76d06..834fce587 100644 --- a/clanker/INDEX.md +++ b/clanker/INDEX.md @@ -370,6 +370,7 @@ Host GL pass-through for guest GL programs (`iris-hostgl`). | [cdrom-hot-insert-remount.md](gui/cdrom-hot-insert-remount.md) | rule | GUI CD-ROM insert must hot-load + remount /CDROM | | [cmd-q-bypasses-close-intercept-fold-on-poweroff.md](gui/cmd-q-bypasses-close-intercept-fold-on-poweroff.md) | rule | macOS Cmd+Q bypasses the close-intercept — fold CHD overlays on power-off, not just quit | | [cycles-ptr-must-be-cleared-before-dropping-the-machine.md](gui/cycles-ptr-must-be-cleared-before-dropping-the-machine.md) | rule | iris-gui: clear the cached `CyclesPtr` before dropping the Machine | +| [summary-and-disk-preflight-live-in-summary-rs.md](gui/summary-and-disk-preflight-live-in-summary-rs.md) | rule | iris-gui summary and missing-disk preflight are per-profile, in `summary.rs` | | [removed-config-keys-must-be-folded-not-deleted.md](gui/removed-config-keys-must-be-folded-not-deleted.md) | rule | Retired MachineConfig keys: keep + fold in `fold_deprecated`, or old gui.json locks the GUI | | [egui-default-font-glyph-coverage-avoid-tofu.md](gui/egui-default-font-glyph-coverage-avoid-tofu.md) | rule | egui default fonts: which glyphs render, which are tofu | | [gfxdisplay-is-generic-new-boards-need-no-gui-wiring.md](gui/gfxdisplay-is-generic-new-boards-need-no-gui-wiring.md) | design | A new graphics board needs no `iris-gui` capture wiring | diff --git a/clanker/gui/summary-and-disk-preflight-live-in-summary-rs.md b/clanker/gui/summary-and-disk-preflight-live-in-summary-rs.md new file mode 100644 index 000000000..895eb0d69 --- /dev/null +++ b/clanker/gui/summary-and-disk-preflight-live-in-summary-rs.md @@ -0,0 +1,26 @@ +# The stopped-machine summary and the missing-disk preflight live in `summary.rs` + +Status: rule, 2026-11. + +**Symptom (issue 304).** On an O2 the summary and the Start preflight looked +Indy-only: the summary listed `[scsi]` and nothing else, the missing-disk +modal named an O2 external-bus target by its raw `[scsi.KEY]` key, which reads like an internal-bus target or a +number the Disks tab never shows, and an +Origin 3200 listed the `[scsi]` map it never uses. The original report (an +O2 summary showing the Indy's PROM, memory and disks, and Start stopping at +"missing disk" until a `[scsi.N]` existed) dates from when the O2 kept its +own `o2.prom`/`o2.disks`/... keys. Those are now deprecated and folded into +the shared keys by `MachineConfig::fold_deprecated`, so reading the shared +keys is right for every profile, as long as the file goes through +`from_toml_str` (`gui-reads-configs-through-core-parse.md`). + +**Rule.** +- Work out what the summary lists and what the preflight checks in + `iris-gui/src/summary.rs` (`drives`, `network`, `missing_disks`, + `expansion_paths`), from the config alone, so tests need no window. +- Name SCSI targets with `extra_ui::scsi_name` (controller:id), never the + `[scsi.KEY]` key; keep the key only for detaching. +- A new place disks can live (another expansion card, another machine's own + map) goes into `drives` and, if a missing image would make `Machine::new` + exit, into `missing_disks` or `expansion_paths`. +- The IP35 bricks take no `[scsi]` disks; both functions skip that map there. diff --git a/iris-gui-README.md b/iris-gui-README.md index e009d8ff9..e3648ca06 100644 --- a/iris-gui-README.md +++ b/iris-gui-README.md @@ -137,7 +137,12 @@ work. The window is split into a **control column** on the left and the **emulator screen** on the right. The screen shows the live framebuffer once a machine is -running (with an overlay while it is powered off). The **VM screen** scale in +running (with an overlay while it is powered off); while the machine is +stopped it shows a summary of the selected machine: platform, processor, PROM, +NVRAM, memory, drives and network. The drives are the ones that machine starts +with: SCSI targets by controller and ID (`1:3` is ID 3 on the second bus, such +as the O2's external connector), the NVMe card and Fibre Channel disks. The +Origin 3200 and Onyx 3000 show no SCSI targets, as they take none. The **VM screen** scale in the View menu is the maximum draw scale: a larger window (fullscreen, maximised, resized) centres the picture at that scale, and only a smaller window shrinks it to fit. @@ -409,7 +414,7 @@ guards every reachable exit: | Exit site | When | iris-gui guard | | --- | --- | --- | -| SCSI attach failure in `Machine::new` | configured image file missing | **Pre-flight**: `App::missing_disks()` runs before sending `Cmd::Start`. If any image is missing, a modal lists them with **Cancel / Edit Disks tab / Detach missing & start**. | +| SCSI attach failure in `Machine::new` | configured image file missing | **Pre-flight**: `summary::missing_disks()` runs before sending `Cmd::Start`, on the selected machine's SCSI targets (none on the IP35 bricks). If any image is missing, a modal lists them by controller and ID with **Cancel / Edit Disks tab / Detach missing & start**. An unreadable NVMe or Fibre Channel image stops the start with a message instead. | | PowerOff handler (`machine.rs`) | IRIX `halt` finishes | iris-gui sets **`IRIS_NO_EXIT_ON_POWEROFF=1`** in `main()`. iris skips the `exit(0)`; the machine is still stopped cleanly. | | CI socket `quit` (`ci.rs`) | CI tab enabled | Same env-var guard. | | Anywhere a `Machine` method panics | such as a bad image or a parse failure | **Worker thread `catch_unwind`** in `handle.rs` around `Machine::new`/`start`/`stop`. The worker stays alive and emits `Evt::Error` instead. | diff --git a/iris-gui/locales/en/main.ftl b/iris-gui/locales/en/main.ftl index 2ca7c7cd7..260b26a07 100644 --- a/iris-gui/locales/en/main.ftl +++ b/iris-gui/locales/en/main.ftl @@ -423,15 +423,20 @@ welcome-nvram = NVRAM welcome-memory = Memory welcome-memory-running = Memory (running) welcome-drives = Drives -# $id is the SCSI ID. +# $id is the SCSI target: its ID, or controller:ID on a second bus. welcome-drive-daynaport = SCSI { $id }: DaynaPort Ethernet adapter welcome-drive-cdrom = SCSI { $id }: CD-ROM, { $path } welcome-drive-disk = SCSI { $id }: disk, { $path } +welcome-drive-nvme = NVMe: disk, { $path } +# $id is the disk's loop ID. +welcome-drive-fc = Fibre Channel { $id }: disk, { $path } welcome-drives-subtitle = welcome-network = Network welcome-network-bridged = Bridged to { $iface } welcome-network-nat = NAT on { $subnet } welcome-network-nat-default = NAT on 192.168.0.0/24 (default) +welcome-network-off = Off (no Ethernet) +welcome-network-stream = Stream segment to { $peer } welcome-start = ▶ Start ## Status footer: machine diff --git a/iris-gui/src/main.rs b/iris-gui/src/main.rs index 6567beb38..0c6fedb68 100644 --- a/iris-gui/src/main.rs +++ b/iris-gui/src/main.rs @@ -22,6 +22,7 @@ mod scsi_menu; mod serial_console; mod settings; mod single_instance; +mod summary; use config_ui::{show_tab, ConfigAction, MemoryUiContext, Tab}; use dialogs::create_disk::CreateDiskDialog; @@ -413,13 +414,6 @@ struct NetSanityModal { revert_to: Option, } -/// One SCSI device that is missing its backing file at Start time. -struct MissingDisk { - id: u8, - path: String, - cdrom: bool, -} - /// True if `path` can actually be *read*. The Start preflight uses this instead /// of `Path::exists()` because under the macOS App Sandbox a user-selected file /// we hold no current grant for (e.g. a disk image picked in a previous session, @@ -481,7 +475,7 @@ fn folder_accessible(path: &str) -> bool { /// `Machine::new` would otherwise call `std::process::exit(1)` and take /// the whole GUI down with it. struct MissingDiskModal { - missing: Vec, + missing: Vec, } /// One attached CHD whose containing folder the app can't write to, so its @@ -792,13 +786,11 @@ impl App { // Preflight: Machine::new will call std::process::exit(1) on the // first SCSI device whose backing file is missing — we'd lose the // GUI process. Catch that case here and prompt the user instead. - let expansion_paths = self.cfg.fibre_channel.iter().flat_map(|fc| fc.disks.values().map(|d| d.path.as_str())) - .chain((!self.cfg.nvme.path.is_empty()).then_some(self.cfg.nvme.path.as_str())); - if let Some(path) = expansion_paths.into_iter().find(|p| !disk_readable(p)) { + if let Some(path) = summary::expansion_paths(&self.cfg).into_iter().find(|p| !disk_readable(p)) { self.toast(t!("extra-unreadable-disk", path = path)); return; } - let missing = self.missing_disks(); + let missing = summary::missing_disks(&self.cfg, disk_readable); if !missing.is_empty() { self.missing_modal = Some(MissingDiskModal { missing }); return; @@ -913,33 +905,6 @@ impl App { } - /// Walk the configured SCSI devices and report any whose image file - /// is missing. Scratch volumes are skipped (iris auto-creates those). - /// For CD-ROMs the device is "present" if either the primary path or - /// any disc in the changer list exists. - fn missing_disks(&self) -> Vec { - let mut out = Vec::new(); - if self.cfg.machine.profile.is_ip35_bricks() { return out; } - for (&id, dev) in &self.cfg.scsi { - if dev.scratch { continue; } - // A DaynaPort is a network adapter — no image to be missing. - if dev.is_daynaport() { continue; } - // Empty CD-ROM (no path, no changer entries) means "drive present, - // tray empty" — a valid configured state, not missing. - if dev.is_cdrom() && dev.path.is_empty() && dev.discs.is_empty() { - continue; - } - let primary_ok = disk_readable(&dev.path); - let any_disc_ok = dev.discs.iter().any(|d| disk_readable(d)); - let present = primary_ok || (dev.is_cdrom() && any_disc_ok); - if !present { - out.push(MissingDisk { id, path: dev.path.clone(), cdrom: dev.is_cdrom() }); - } - } - out.sort_by_key(|m| m.id); - out - } - /// Detach the given SCSI IDs from the live config and (optionally) try Start again. fn detach_and_start(&mut self, ids: &[u8]) { for id in ids { self.cfg.scsi.remove(id); } @@ -3139,23 +3104,18 @@ impl App { } ui.label(t!("welcome-drives")); ui.vertical(|ui| { - let mut ids: Vec = self.cfg.scsi.keys().copied().collect(); - ids.sort(); - if ids.is_empty() { + let drives = summary::drives(&self.cfg); + if drives.is_empty() { ui.label(RichText::new(t!("common-none")).weak()); } - for key in ids { - let d = &self.cfg.scsi[&key]; - let id = crate::extra_ui::scsi_name(&self.cfg, key); - if d.is_daynaport() { - ui.label(t!("welcome-drive-daynaport", id = &id)); - continue; - } - let path = abs_path(&d.path); - ui.label(if d.is_cdrom() { - t!("welcome-drive-cdrom", id = &id, path = &path) - } else { - t!("welcome-drive-disk", id = &id, path = &path) + for drive in drives { + use summary::Drive; + ui.label(match drive { + Drive::Daynaport { id } => t!("welcome-drive-daynaport", id = &id), + Drive::Cdrom { id, path } => { let path = abs_path(&path); t!("welcome-drive-cdrom", id = &id, path = &path) } + Drive::Disk { id, path } => { let path = abs_path(&path); t!("welcome-drive-disk", id = &id, path = &path) } + Drive::Nvme { path } => { let path = abs_path(&path); t!("welcome-drive-nvme", path = &path) } + Drive::FibreChannel { id, path } => { let path = abs_path(&path); t!("welcome-drive-fc", id = id, path = &path) } }); } subtitle(ui, t!("welcome-drives-subtitle")); @@ -3164,21 +3124,20 @@ impl App { ui.label(t!("welcome-network")); // On a build without PCAP support, the runtime always uses NAT // regardless of any imported `mode = "pcap"`, and the UI must never - // surface PCAP — so report NAT unconditionally there. - let effective_pcap = iris::build_features::PCAP - && self.cfg.network.mode == iris::config::NetMode::Pcap; - if effective_pcap { - let iface = match self.cfg.network.pcap_interface.as_deref() { - Some(s) if !s.is_empty() => s.to_string(), - _ => t!("common-auto"), - }; - ui.label(t!("welcome-network-bridged", iface = &iface)); - } else { - ui.label(match self.cfg.nat_subnet.as_deref() { - Some(subnet) => t!("welcome-network-nat", subnet = subnet), - None => t!("welcome-network-nat-default"), - }); - } + // surface PCAP (`summary::network` reports NAT there). + ui.label(match summary::network(&self.cfg, iris::build_features::PCAP) { + summary::Network::Bridged(iface) => { + let iface = iface.unwrap_or_else(|| t!("common-auto")); + t!("welcome-network-bridged", iface = &iface) + } + summary::Network::Nat(Some(subnet)) => t!("welcome-network-nat", subnet = &subnet), + summary::Network::Nat(None) => t!("welcome-network-nat-default"), + summary::Network::Off => t!("welcome-network-off"), + summary::Network::Stream(peer) => { + let peer = peer.unwrap_or_else(|| t!("common-none")); + t!("welcome-network-stream", peer = &peer) + } + }); ui.end_row(); }); @@ -3618,9 +3577,9 @@ impl eframe::App for App { ui.label(RichText::new(t!("modal-missing-body")).strong()); for m in &modal.missing { ui.label(if m.cdrom { - t!("modal-missing-cdrom", id = m.id, path = &m.path) + t!("modal-missing-cdrom", id = &m.name, path = &m.path) } else { - t!("modal-missing-disk", id = m.id, path = &m.path) + t!("modal-missing-disk", id = &m.name, path = &m.path) }); } ui.add_space(8.0); @@ -3657,7 +3616,7 @@ impl eframe::App for App { } MissingChoice::Detach => { let ids: Vec = self.missing_modal.as_ref() - .map(|m| m.missing.iter().map(|d| d.id).collect()) + .map(|m| m.missing.iter().map(|d| d.key).collect()) .unwrap_or_default(); self.missing_modal = None; self.detach_and_start(&ids); diff --git a/iris-gui/src/summary.rs b/iris-gui/src/summary.rs new file mode 100644 index 000000000..0a5667d5e --- /dev/null +++ b/iris-gui/src/summary.rs @@ -0,0 +1,268 @@ +//! What the welcome summary lists and what the Start preflight checks, worked +//! out from the config alone so every machine profile gets the same answer +//! and the tests need no window. +//! +//! Disks sit in different places per machine: `[scsi.N]` on every machine but +//! the IP35 bricks (where that map is unused), `[nvme]` on the O2 and in an +//! Octane option board, `[fibre_channel]` on the machines with a PCI slot for +//! it. The SCSI targets are named by their (controller, id) placement, so the +//! O2's external bus reads `1:3`, not the `[scsi.19]` key. + +use iris::config::{MachineConfig, NetMode}; + +/// One line of the summary's Drives row. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Drive { + Daynaport { id: String }, + Cdrom { id: String, path: String }, + Disk { id: String, path: String }, + Nvme { path: String }, + FibreChannel { id: u8, path: String }, +} + +/// Every drive the machine will be started with, SCSI targets in (controller, +/// id) order, then the NVMe card, then the Fibre Channel loop. +pub fn drives(cfg: &MachineConfig) -> Vec { + let mut out = Vec::new(); + if !cfg.machine.profile.is_ip35_bricks() { + let mut keys: Vec = cfg.scsi.keys().copied().collect(); + keys.sort_by_key(|k| cfg.scsi[k].placement(*k)); + for key in keys { + let d = &cfg.scsi[&key]; + let id = crate::extra_ui::scsi_name(cfg, key); + out.push(if d.is_daynaport() { + Drive::Daynaport { id } + } else if d.is_cdrom() { + Drive::Cdrom { id, path: d.path.clone() } + } else { + Drive::Disk { id, path: d.path.clone() } + }); + } + } + if !cfg.nvme.path.is_empty() { + out.push(Drive::Nvme { path: cfg.nvme.path.clone() }); + } + if let Some(fc) = &cfg.fibre_channel { + for (&id, d) in &fc.disks { + out.push(Drive::FibreChannel { id, path: d.path.clone() }); + } + } + out +} + +/// The summary's Network row. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Network { + /// Bridged to a host interface; `None` picks one automatically. + Bridged(Option), + /// Built-in NAT; `None` is the default subnet. + Nat(Option), + /// No Ethernet (every machine but the Indy and Indigo2). + Off, + /// A QEMU-style stream segment to this peer. + Stream(Option), +} + +/// What the machine's Ethernet is attached to. A build without PCAP runs +/// NAT whatever the file says, so `pcap_built` false never reports a bridge. +pub fn network(cfg: &MachineConfig, pcap_built: bool) -> Network { + match cfg.network.mode { + NetMode::Pcap if pcap_built => Network::Bridged( + cfg.network.pcap_interface.clone().filter(|s| !s.is_empty())), + NetMode::Off => Network::Off, + NetMode::Stream => Network::Stream(cfg.network.stream.clone()), + NetMode::Nat | NetMode::Pcap => Network::Nat(cfg.nat_subnet.clone()), + } +} + +/// One SCSI target that is missing its backing file at Start time. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct MissingDisk { + /// The `[scsi.KEY]` key, for detaching it. + pub key: u8, + /// The (controller, id) name the Disks tab shows. + pub name: String, + pub path: String, + pub cdrom: bool, +} + +/// The SCSI targets whose image `readable` refuses. Scratch volumes (iris +/// creates them), DaynaPorts (no image) and empty CD-ROM drives (tray empty) +/// are never missing, and a CD-ROM is present if any disc in its changer +/// list is. The IP35 bricks take no `[scsi]` disks, so nothing there is +/// missing. NVMe and Fibre Channel images are checked separately +/// ([`expansion_paths`]): they cannot be detached from this list. +pub fn missing_disks(cfg: &MachineConfig, readable: impl Fn(&str) -> bool) -> Vec { + let mut out = Vec::new(); + if cfg.machine.profile.is_ip35_bricks() { + return out; + } + let mut keys: Vec = cfg.scsi.keys().copied().collect(); + keys.sort_by_key(|k| cfg.scsi[k].placement(*k)); + for key in keys { + let dev = &cfg.scsi[&key]; + if dev.scratch || dev.is_daynaport() { + continue; + } + if dev.is_cdrom() && dev.path.is_empty() && dev.discs.is_empty() { + continue; + } + let present = readable(&dev.path) + || (dev.is_cdrom() && dev.discs.iter().any(|d| readable(d))); + if !present { + out.push(MissingDisk { + key, + name: crate::extra_ui::scsi_name(cfg, key), + path: dev.path.clone(), + cdrom: dev.is_cdrom(), + }); + } + } + out +} + +/// The NVMe and Fibre Channel images the machine will open. +pub fn expansion_paths(cfg: &MachineConfig) -> Vec<&str> { + cfg.fibre_channel.iter() + .flat_map(|fc| fc.disks.values().map(|d| d.path.as_str())) + .chain((!cfg.nvme.path.is_empty()).then_some(cfg.nvme.path.as_str())) + .collect() +} + +#[cfg(test)] +mod tests { + use super::*; + use iris::config::MachineProfile; + + fn parse(text: &str) -> MachineConfig { + MachineConfig::from_toml_str(text).expect("config parses") + } + + fn none_readable(_: &str) -> bool { false } + + #[test] + fn o2_summary_lists_its_own_buses_by_placement() { + let cfg = parse(r#" + [machine] + profile = "o2_ip32" + [scsi.1] + path = "irix.img" + [scsi.19] + path = "cd.iso" + cdrom = true + [nvme] + path = "nvme.img" + "#); + assert_eq!(cfg.machine.profile, MachineProfile::O2Ip32); + assert_eq!(drives(&cfg), vec![ + Drive::Disk { id: "1".into(), path: "irix.img".into() }, + Drive::Cdrom { id: "1:3".into(), path: "cd.iso".into() }, + Drive::Nvme { path: "nvme.img".into() }, + ]); + } + + #[test] + fn deprecated_o2_disks_reach_the_summary_and_the_disk_check() { + // The spelling issue #304 was filed against: disks in `[o2]`, not in + // `[scsi.N]`. The core folds them into `[scsi.N]` on load. + let cfg = parse(r#" + [machine] + profile = "o2_ip32" + [o2] + disks = [ { id = 2, path = "o2-root.img" }, + { id = 4, bus = 1, path = "o2-cd.iso", cdrom = true } ] + "#); + assert_eq!(drives(&cfg), vec![ + Drive::Disk { id: "2".into(), path: "o2-root.img".into() }, + Drive::Cdrom { id: "1:4".into(), path: "o2-cd.iso".into() }, + ]); + let missing = missing_disks(&cfg, none_readable); + assert_eq!(missing.iter().map(|m| (m.name.as_str(), m.path.as_str(), m.cdrom)).collect::>(), + vec![("2", "o2-root.img", false), ("1:4", "o2-cd.iso", true)]); + // Every name maps back to a key that detaching removes. + for m in &missing { + assert!(cfg.scsi.contains_key(&m.key)); + } + } + + #[test] + fn o2_with_readable_disks_starts_without_an_indy_disk() { + let cfg = parse(r#" + [machine] + profile = "o2_ip32" + [scsi.1] + path = "o2.img" + "#); + assert!(missing_disks(&cfg, |p| p == "o2.img").is_empty()); + assert_eq!(missing_disks(&cfg, none_readable).len(), 1); + } + + #[test] + fn empty_disk_path_is_missing_but_empty_cdrom_and_scratch_are_not() { + let cfg = parse(r#" + [machine] + profile = "o2_ip32" + [scsi.1] + path = "" + [scsi.2] + path = "" + cdrom = true + [scsi.3] + path = "scratch.img" + scratch = true + [scsi.4] + path = "gone.iso" + cdrom = true + discs = ["there.iso"] + "#); + let missing = missing_disks(&cfg, |p| p == "there.iso"); + assert_eq!(missing.iter().map(|m| m.name.as_str()).collect::>(), vec!["1"]); + } + + #[test] + fn ip35_bricks_ignore_the_scsi_map() { + let cfg = parse(r#" + [machine] + profile = "origin3200_ip35" + [scsi.1] + path = "unused.img" + [fibre_channel.disk.0] + path = "fc0.img" + "#); + assert!(missing_disks(&cfg, none_readable).is_empty()); + assert_eq!(drives(&cfg), vec![Drive::FibreChannel { id: 0, path: "fc0.img".into() }]); + assert_eq!(expansion_paths(&cfg), vec!["fc0.img"]); + } + + #[test] + fn indy_summary_is_unchanged() { + let cfg = parse(r#" + [scsi.1] + path = "indy.img" + [scsi.4] + path = "cd.iso" + cdrom = true + "#); + assert_eq!(cfg.machine.profile, MachineProfile::IndyIp24); + assert_eq!(drives(&cfg), vec![ + Drive::Disk { id: "1".into(), path: "indy.img".into() }, + Drive::Cdrom { id: "4".into(), path: "cd.iso".into() }, + ]); + assert!(expansion_paths(&cfg).is_empty()); + } + + #[test] + fn network_row_follows_the_mode() { + let mut cfg = parse("[machine]\nprofile = \"o2_ip32\"\n"); + assert_eq!(network(&cfg, true), Network::Nat(None)); + cfg.network.mode = NetMode::Off; + assert_eq!(network(&cfg, true), Network::Off); + cfg.network.mode = NetMode::Stream; + cfg.network.stream = Some("tcp:127.0.0.1:5555".into()); + assert_eq!(network(&cfg, true), Network::Stream(Some("tcp:127.0.0.1:5555".into()))); + cfg.network.mode = NetMode::Pcap; + cfg.network.pcap_interface = Some(String::new()); + assert_eq!(network(&cfg, true), Network::Bridged(None)); + assert_eq!(network(&cfg, false), Network::Nat(None)); + } +} From c8a799720654d9f1817d5d7a00e2d7d83567ee05 Mon Sep 17 00:00:00 2001 From: steigr Date: Fri, 20 Nov 2026 08:49:48 +0100 Subject: [PATCH 2/3] iris-gui: name new machines after their model and ask for an EEPROM only on the Indigo2 A drive with no image reads "no image chosen" (a CD-ROM "tray empty") in the summary instead of ending in a comma. The New machine dialog names the machine after the chosen model until a name is typed, and it and the settings editor offer the motherboard EEPROM file only on the Indigo2: the Indy keeps its PROM environment in the NVRAM. Refs techomancer/iris#304 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 3 ++ iris-gui-README.md | 3 +- iris-gui/locales/en/main.ftl | 2 ++ iris-gui/src/config_ui.rs | 6 ++-- iris-gui/src/dialogs/new_machine.rs | 47 +++++++++++++++++++++++++---- iris-gui/src/extra_ui.rs | 6 ++++ iris-gui/src/main.rs | 2 ++ 7 files changed, 59 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a0d4365f..e04723947 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -599,6 +599,9 @@ image) where the guest test suites showed they differed: targets on a second bus as `controller:id` (also in the missing-disk prompt), leaves out the Origin 3200's unused SCSI map and shows an unplugged or stream Ethernet. +- The New machine dialog names the machine after the chosen model (`o2`, + `octane`) until a name is typed, and asks for a motherboard EEPROM only on + the Indigo2, as the settings editor now does. ## October 2026 diff --git a/iris-gui-README.md b/iris-gui-README.md index e3648ca06..3d6ff263e 100644 --- a/iris-gui-README.md +++ b/iris-gui-README.md @@ -97,7 +97,8 @@ cargo tree -p iris | grep -E 'egui|eframe|rfd' # should print nothing When no machine TOML files exist, the **New machine** dialog opens automatically. You'll be asked for: -- **Name** — names the machine folder and its TOML file. Conflicts get a +- **Name** — names the machine folder and its TOML file. Until you type + one it follows the model (`indy`, `o2`, `octane`, …). Conflicts get a numeric suffix (`indy`, `indy-2`, …). Names cannot contain path separators or reserved filename characters. - **Machine model** — any of the twelve profiles listed below. **Processor** diff --git a/iris-gui/locales/en/main.ftl b/iris-gui/locales/en/main.ftl index 260b26a07..1006e9f4b 100644 --- a/iris-gui/locales/en/main.ftl +++ b/iris-gui/locales/en/main.ftl @@ -427,6 +427,8 @@ welcome-drives = Drives welcome-drive-daynaport = SCSI { $id }: DaynaPort Ethernet adapter welcome-drive-cdrom = SCSI { $id }: CD-ROM, { $path } welcome-drive-disk = SCSI { $id }: disk, { $path } +welcome-drive-cdrom-empty = SCSI { $id }: CD-ROM, tray empty +welcome-drive-disk-no-image = SCSI { $id }: disk, no image chosen welcome-drive-nvme = NVMe: disk, { $path } # $id is the disk's loop ID. welcome-drive-fc = Fibre Channel { $id }: disk, { $path } diff --git a/iris-gui/src/config_ui.rs b/iris-gui/src/config_ui.rs index 5e26346fd..b5b89c523 100644 --- a/iris-gui/src/config_ui.rs +++ b/iris-gui/src/config_ui.rs @@ -383,9 +383,9 @@ fn show_general(ui: &mut Ui, cfg: &mut MachineConfig, mem_ctx: MemoryUiContext) path_row(ui, "octane_flash", &mut flash, Pick::SaveFile, &nvram_filters()); cfg.octane.flash = if flash.is_empty() { None } else { Some(flash) }; ui.end_row(); - } else if crate::extra_ui::mc_machine(cfg.machine.profile) { - // The O2's NVRAM is its own PROM flash, already covered by `nvram` - // above; it has no separate motherboard EEPROM. + } else if crate::extra_ui::has_nveeprom(cfg.machine.profile) { + // Only the Indigo2 has a motherboard EEPROM: the Indy's PROM + // environment is in the NVRAM, the O2's in its flash (`nvram`). ui.label(t!("config-nveeprom")) .tip(t!("config-nveeprom-tip")); path_row(ui, "nveeprom", &mut cfg.nveeprom, Pick::SaveFile, &nvram_filters()); diff --git a/iris-gui/src/dialogs/new_machine.rs b/iris-gui/src/dialogs/new_machine.rs index bcf318a74..904b4bd68 100644 --- a/iris-gui/src/dialogs/new_machine.rs +++ b/iris-gui/src/dialogs/new_machine.rs @@ -41,7 +41,7 @@ impl Default for NewMachineDialog { fn default() -> Self { Self { open: false, - name: "indy".into(), + name: default_name(MachineProfile::default()).into(), profile: MachineProfile::default(), cpu: &parts::R4400_150, graphics: iris::config::GraphicsBoard::Newport, @@ -62,6 +62,13 @@ impl Default for NewMachineDialog { } } +/// The name a new machine of `profile` gets until the user types one: +/// the profile's name up to its board number (`o2`, `octane`, `indigo2`). +pub fn default_name(profile: MachineProfile) -> &'static str { + let name = profile.name(); + name.split_once('_').map_or(name, |(model, _)| model) +} + /// Fill the profile's banks largest first, without gaps. pub fn distribute_ram(total: u32, profile: MachineProfile) -> [u32; iris::config::MAX_BANKS] { let mut remaining = total; @@ -118,6 +125,11 @@ impl NewMachineDialog { } }); if self.profile != profile_before { + // A name the user has not changed follows the model. + let name = self.name.trim(); + if name.is_empty() || name == default_name(profile_before) { + self.name = default_name(self.profile).into(); + } self.cpu = self.profile.cpus()[0]; self.graphics = if self.profile.ip28() { iris::config::GraphicsBoard::SolidImpact } else { iris::config::GraphicsBoard::default_for(self.profile) }; self.use_embedded_prom = true; @@ -204,9 +216,9 @@ impl NewMachineDialog { }); ui.end_row(); - // The O2's NVRAM is its own PROM flash, already asked for - // above; it has no separate motherboard EEPROM. - if crate::extra_ui::mc_machine(self.profile) { + // Only the Indigo2 has a motherboard EEPROM; the Indy keeps + // its PROM environment in the NVRAM, the O2 in its flash. + if crate::extra_ui::has_nveeprom(self.profile) { ui.label(t!("dialog-new-machine-eeprom")) .tip(t!("dialog-new-machine-eeprom-tip")); ui.horizontal(|ui| { @@ -338,7 +350,7 @@ impl NewMachineDialog { ui.add_space(6.0); ui.horizontal(|ui| { if ui.button(t!("common-cancel")).clicked() { close = true; } - let name = if self.name.trim().is_empty() { "indy" } else { self.name.trim() }; + let name = if self.name.trim().is_empty() { default_name(self.profile) } else { self.name.trim() }; let valid = crate::machines::validate_name(name); if let Err(e) = &valid { ui.colored_label(Color32::from_rgb(230, 140, 70), e); } if ui.add_enabled(valid.is_ok(), egui::Button::new(RichText::new(t!("dialog-new-machine-create")).strong()) @@ -385,7 +397,7 @@ impl NewMachineDialog { ..Default::default() }); } - let name = if self.name.trim().is_empty() { "indy".to_string() } else { self.name.trim().to_string() }; + let name = if self.name.trim().is_empty() { default_name(self.profile) } else { self.name.trim() }.to_string(); self.result = Some(NewMachineResult { name, cfg }); close = true; } @@ -395,6 +407,29 @@ impl NewMachineDialog { } } +#[cfg(test)] +mod name_tests { + use super::{default_name, MachineProfile}; + use crate::extra_ui::has_nveeprom; + + #[test] + fn default_names_follow_the_model() { + assert_eq!(default_name(MachineProfile::IndyIp24), "indy"); + assert_eq!(default_name(MachineProfile::O2Ip32), "o2"); + assert_eq!(default_name(MachineProfile::OctaneIp30), "octane"); + assert_eq!(default_name(MachineProfile::Indigo2Ip28), "indigo2"); + for p in MachineProfile::ALL { + assert!(crate::machines::validate_name(default_name(p)).is_ok(), "{p:?}"); + } + } + + #[test] + fn only_the_indigo2_has_a_motherboard_eeprom() { + let with: Vec<_> = MachineProfile::ALL.into_iter().filter(|&p| has_nveeprom(p)).collect(); + assert_eq!(with, vec![MachineProfile::Indigo2Ip22, MachineProfile::Indigo2Ip28]); + } +} + #[cfg(test)] mod ram_tests { use super::{distribute_ram, MachineProfile}; diff --git a/iris-gui/src/extra_ui.rs b/iris-gui/src/extra_ui.rs index aaeaf5a05..32fc0ba5b 100644 --- a/iris-gui/src/extra_ui.rs +++ b/iris-gui/src/extra_ui.rs @@ -9,6 +9,12 @@ pub fn mc_machine(profile: MachineProfile) -> bool { matches!(profile, MachineProfile::IndyIp24 | MachineProfile::Indigo2Ip22 | MachineProfile::Indigo2Ip28) } +/// Whether `profile` has the Indigo2's motherboard EEPROM (`nveeprom`). The +/// Indy keeps its PROM environment in the NVRAM, the O2 in its flash. +pub fn has_nveeprom(profile: MachineProfile) -> bool { + matches!(profile, MachineProfile::Indigo2Ip22 | MachineProfile::Indigo2Ip28) +} + /// Whether `cfg.prom` runs the PROM built into iris: `(embedded)`, an empty /// value the GUI writes as `(embedded)` before a start, or the default name /// with neither it nor the machine's release file name in the machine diff --git a/iris-gui/src/main.rs b/iris-gui/src/main.rs index 0c6fedb68..44f3c6f5c 100644 --- a/iris-gui/src/main.rs +++ b/iris-gui/src/main.rs @@ -3112,7 +3112,9 @@ impl App { use summary::Drive; ui.label(match drive { Drive::Daynaport { id } => t!("welcome-drive-daynaport", id = &id), + Drive::Cdrom { id, path } if path.is_empty() => t!("welcome-drive-cdrom-empty", id = &id), Drive::Cdrom { id, path } => { let path = abs_path(&path); t!("welcome-drive-cdrom", id = &id, path = &path) } + Drive::Disk { id, path } if path.is_empty() => t!("welcome-drive-disk-no-image", id = &id), Drive::Disk { id, path } => { let path = abs_path(&path); t!("welcome-drive-disk", id = &id, path = &path) } Drive::Nvme { path } => { let path = abs_path(&path); t!("welcome-drive-nvme", path = &path) } Drive::FibreChannel { id, path } => { let path = abs_path(&path); t!("welcome-drive-fc", id = id, path = &path) } From 7554c16a82cc62b0588b093ba2c71d43f5985edc Mon Sep 17 00:00:00 2001 From: steigr Date: Fri, 20 Nov 2026 08:57:12 +0100 Subject: [PATCH 3/3] iris-gui: readable summary paths, button text and network status The summary shows the machine folder and gives paths inside it relative to it, cut to the panel's width with the full path in the tooltip; long absolute paths ran off the window. Coloured buttons get white text, which the light theme's dark grey made hard to read on green, red and blue. The status footer shows "No network" with no light on a machine with networking off and names a running stream network; a build without PCAP no longer records off or stream as NAT. Refs techomancer/iris#304 Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 4 ++ iris-gui-README.md | 9 ++- iris-gui/locales/en/main.ftl | 6 ++ iris-gui/src/dialogs/create_disk.rs | 3 +- iris-gui/src/dialogs/new_machine.rs | 3 +- iris-gui/src/extra_ui.rs | 7 ++ iris-gui/src/main.rs | 103 ++++++++++++++++------------ iris-gui/src/summary.rs | 22 ++++++ 8 files changed, 108 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e04723947..da744ec60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -602,6 +602,10 @@ image) where the guest test suites showed they differed: - The New machine dialog names the machine after the chosen model (`o2`, `octane`) until a name is typed, and asks for a motherboard EEPROM only on the Indigo2, as the settings editor now does. +- The summary shows the machine folder and paths relative to it, cut to the + panel's width; coloured buttons (Start, Stop, Create, …) have white text; + the status footer says "No network" instead of a network light on a machine + with networking off, and names a stream network. ## October 2026 diff --git a/iris-gui-README.md b/iris-gui-README.md index 3d6ff263e..d6ecb2efb 100644 --- a/iris-gui-README.md +++ b/iris-gui-README.md @@ -139,8 +139,10 @@ work. The window is split into a **control column** on the left and the **emulator screen** on the right. The screen shows the live framebuffer once a machine is running (with an overlay while it is powered off); while the machine is -stopped it shows a summary of the selected machine: platform, processor, PROM, -NVRAM, memory, drives and network. The drives are the ones that machine starts +stopped it shows a summary of the selected machine: its folder, platform, +processor, PROM, NVRAM, memory, drives and network. Paths in the machine +folder are shown relative to it; a path too long for the panel is cut short, +and its tooltip shows it whole. The drives are the ones that machine starts with: SCSI targets by controller and ID (`1:3` is ID 3 on the second bus, such as the O2's external connector), the NVMe card and Fibre Channel disks. The Origin 3200 and Onyx 3000 show no SCSI targets, as they take none. The **VM screen** scale in @@ -151,7 +153,8 @@ to fit. The control column holds, top to bottom: the drop-down menus, the capture button and hint, the configuration editor, and a status footer (run state, machine name, MIPS, kernel tick **Hz**, graphics FIFO depth, and the **NET** -light for the internal network). +light for the internal network, or "No network" on a machine with +`[network] mode = "off"`). ### Menus diff --git a/iris-gui/locales/en/main.ftl b/iris-gui/locales/en/main.ftl index 1006e9f4b..d5abbd819 100644 --- a/iris-gui/locales/en/main.ftl +++ b/iris-gui/locales/en/main.ftl @@ -220,6 +220,11 @@ status-net-nat-active-tip = NAT networking. The guest is sending traffic. status-net-nat-idle-tip = NAT networking. No traffic from the guest yet. It may have no IP address, or one outside the NAT subnet. status-net-nat-off-tip = NAT networking. The machine isn't running. status-net-off-tip = The machine isn't running. +status-net-stream = Stream +status-net-stream-active-tip = Stream networking. The guest is sending traffic. +status-net-stream-idle-tip = Stream networking. No traffic from the guest yet. +status-net-unplugged = No network +status-net-unplugged-tip = This machine has no Ethernet connection ([network] mode = "off"). status-net-check = Check status-net-check-tip = Diagnose guest networking. # $scale is a number such as 1 or 1.25. @@ -413,6 +418,7 @@ welcome-unsaved = Unsaved welcome-machine = Machine: { $name } ({ $profile }) welcome-autosave-pending-subtitle = welcome-summary = Summary +welcome-folder = Folder welcome-platform = Platform welcome-processor = Processor welcome-processor-running = Processor (running) diff --git a/iris-gui/src/dialogs/create_disk.rs b/iris-gui/src/dialogs/create_disk.rs index e6e2511fb..54b8ac88f 100644 --- a/iris-gui/src/dialogs/create_disk.rs +++ b/iris-gui/src/dialogs/create_disk.rs @@ -86,8 +86,7 @@ impl CreateDiskDialog { ui.add_space(6.0); ui.horizontal(|ui| { if ui.button(t!("common-cancel")).clicked() { close = true; } - if ui.add_enabled(!exists || self.overwrite, egui::Button::new(t!("dialog-create-disk-create")) - .fill(Color32::from_rgb(60, 110, 60))).clicked() + if ui.add_enabled(!exists || self.overwrite, crate::extra_ui::filled_button(t!("dialog-create-disk-create"), Color32::from_rgb(60, 110, 60))).clicked() { // Create file on disk now (making the parent dir first, // e.g. the managed /disks on first use). diff --git a/iris-gui/src/dialogs/new_machine.rs b/iris-gui/src/dialogs/new_machine.rs index 904b4bd68..bb31faaab 100644 --- a/iris-gui/src/dialogs/new_machine.rs +++ b/iris-gui/src/dialogs/new_machine.rs @@ -353,8 +353,7 @@ impl NewMachineDialog { let name = if self.name.trim().is_empty() { default_name(self.profile) } else { self.name.trim() }; let valid = crate::machines::validate_name(name); if let Err(e) = &valid { ui.colored_label(Color32::from_rgb(230, 140, 70), e); } - if ui.add_enabled(valid.is_ok(), egui::Button::new(RichText::new(t!("dialog-new-machine-create")).strong()) - .fill(Color32::from_rgb(60, 110, 60))).clicked() + if ui.add_enabled(valid.is_ok(), crate::extra_ui::filled_button(RichText::new(t!("dialog-new-machine-create")).strong(), Color32::from_rgb(60, 110, 60))).clicked() { let mut cfg = MachineConfig::default(); cfg.machine.profile = self.profile; diff --git a/iris-gui/src/extra_ui.rs b/iris-gui/src/extra_ui.rs index 32fc0ba5b..35f693bbb 100644 --- a/iris-gui/src/extra_ui.rs +++ b/iris-gui/src/extra_ui.rs @@ -9,6 +9,13 @@ pub fn mc_machine(profile: MachineProfile) -> bool { matches!(profile, MachineProfile::IndyIp24 | MachineProfile::Indigo2Ip22 | MachineProfile::Indigo2Ip28) } +/// A button filled with `fill` (the green Start, the red Stop, the blue +/// confirm buttons). Its text is white: the theme's text colour is dark grey +/// in light mode, which can hardly be read on these fills. +pub fn filled_button<'a>(text: impl Into, fill: egui::Color32) -> egui::Button<'a> { + egui::Button::new(text.into().color(egui::Color32::WHITE)).fill(fill) +} + /// Whether `profile` has the Indigo2's motherboard EEPROM (`nveeprom`). The /// Indy keeps its PROM environment in the NVRAM, the O2 in its flash. pub fn has_nveeprom(profile: MachineProfile) -> bool { diff --git a/iris-gui/src/main.rs b/iris-gui/src/main.rs index 44f3c6f5c..e20860f00 100644 --- a/iris-gui/src/main.rs +++ b/iris-gui/src/main.rs @@ -827,11 +827,11 @@ impl App { // running status footer can report PCAP vs NAT (and which interface) // independent of any later edits to the config editor. On a build without // PCAP support the runtime forces NAT (even for an imported `mode = - // "pcap"`), so reflect that here and never surface PCAP. - self.launched_net = Some(if iris::build_features::PCAP { - (self.cfg.network.mode, self.cfg.network.pcap_interface.clone()) - } else { - (iris::config::NetMode::Nat, None) + // "pcap"`), so reflect that here and never surface PCAP. Off and + // stream stay what they are. + self.launched_net = Some(match self.cfg.network.mode { + iris::config::NetMode::Pcap if !iris::build_features::PCAP => (iris::config::NetMode::Nat, None), + mode => (mode, self.cfg.network.pcap_interface.clone()), }); self.started_banks = Some(self.cfg.banks); self.started_cpu = Some(self.cfg.cpu()); @@ -1642,13 +1642,11 @@ impl App { let running = self.emu.is_running(); let full = egui::vec2(ui.available_width(), 0.0); if !running { - if ui.add_sized(full, egui::Button::new(RichText::new(t!("main-start")).size(16.0)) - .fill(Color32::from_rgb(40, 110, 40))).clicked() + if ui.add_sized(full, crate::extra_ui::filled_button(RichText::new(t!("main-start")).size(16.0), Color32::from_rgb(40, 110, 40))).clicked() { self.start_emulator(); } - } else if ui.add_sized(full, egui::Button::new(RichText::new(t!("main-stop")).size(16.0)) - .fill(Color32::from_rgb(160, 60, 60))).clicked() + } else if ui.add_sized(full, crate::extra_ui::filled_button(RichText::new(t!("main-stop")).size(16.0), Color32::from_rgb(160, 60, 60))).clicked() { self.request_stop(); } @@ -1894,8 +1892,18 @@ impl App { }; (t!("status-net-nat"), tip) } + (true, Some((NetMode::Stream, _))) => { + let tip = match state { + NetState::Active => t!("status-net-stream-active-tip"), + _ => t!("status-net-stream-idle-tip"), + }; + (t!("status-net-stream"), tip) + } _ => (t!("status-net"), t!("status-net-off-tip")), }; + // A machine with no Ethernet has no light: nothing can carry traffic. + let net_mode = if running { backend.as_ref().map(|(m, _)| *m) } else { Some(self.cfg.network.mode) }; + let unplugged = net_mode == Some(NetMode::Off); // "check" diagnoses the guest IP against the NAT subnet — only meaningful // in NAT mode, so it's hidden in PCAP. let nat_running = running && matches!(backend.as_ref(), Some((NetMode::Nat, _))); @@ -1903,6 +1911,11 @@ impl App { ui.horizontal(|ui| { // U+2022 (bullet) as a status light. NOT U+25CF (●), which renders as // tofu in egui's font chain. See clanker/gui/egui-…-tofu.md. + if unplugged { + ui.label(RichText::new(t!("status-net-unplugged")).weak()) + .tip(t!("status-net-unplugged-tip")); + return; + } ui.label(RichText::new("\u{2022}").size(18.0).color(net_color)).tip(net_tip.clone()); ui.label(net_label).tip(net_tip); if nat_running && ui.small_button(t!("status-net-check")).tip(t!("status-net-check-tip")).clicked() { @@ -3029,8 +3042,7 @@ impl App { if ui.button(t!("common-cancel")).clicked() { decision = Some(false); } - if ui.add(egui::Button::new(RichText::new(t!("modal-discard-confirm")).color(Color32::WHITE)) - .fill(Color32::from_rgb(140, 40, 40))).clicked() + if ui.add(crate::extra_ui::filled_button(RichText::new(t!("modal-discard-confirm")).color(Color32::WHITE), Color32::from_rgb(140, 40, 40))).clicked() { decision = Some(true); } @@ -3061,8 +3073,21 @@ impl App { ui.add_space(8.0); let ram_line = ram_summary(&self.cfg.banks); + // Paths are shown relative to the machine folder (the working + // directory) and cut to the panel's width; the tooltip has them whole. + let machine_dir = std::env::current_dir().ok(); + let path_label = |ui: &mut egui::Ui, text: String, path: &str| { + ui.add(egui::Label::new(text).truncate()).on_hover_text(abs_path(path)); + }; + let shown = |path: &str| summary::shown_path(path, machine_dir.as_deref()); ui.label(RichText::new(t!("welcome-summary")).strong()); egui::Grid::new("summary_grid").num_columns(2).striped(true).show(ui, |ui| { + ui.label(t!("welcome-folder")); + if let Some(dir) = &machine_dir { + let dir = dir.to_string_lossy().into_owned(); + path_label(ui, dir.clone(), &dir); + } + ui.end_row(); ui.label(t!("welcome-platform")); ui.label(self.cfg.machine.profile.label()); ui.end_row(); @@ -3079,18 +3104,18 @@ impl App { } } ui.label(t!("welcome-prom")); - ui.label(if crate::extra_ui::builtin_prom(&self.cfg) { + let prom = if crate::extra_ui::builtin_prom(&self.cfg) || self.cfg.prom.is_empty() { t!("welcome-prom-builtin") } else if std::path::Path::new(&self.cfg.prom).exists() { - abs_path(&self.cfg.prom) - } else if self.cfg.prom.is_empty() { - t!("welcome-prom-builtin") + shown(&self.cfg.prom) } else { - t!("welcome-prom-missing", path = &self.cfg.prom) - }); + let s = shown(&self.cfg.prom); + t!("welcome-prom-missing", path = &s) + }; + path_label(ui, prom, &self.cfg.prom); ui.end_row(); ui.label(t!("welcome-nvram")); - ui.label(abs_path(&self.cfg.nvram)); + path_label(ui, shown(&self.cfg.nvram), &self.cfg.nvram); ui.end_row(); ui.label(t!("welcome-memory")); ui.label(ram_line); @@ -3110,15 +3135,16 @@ impl App { } for drive in drives { use summary::Drive; - ui.label(match drive { - Drive::Daynaport { id } => t!("welcome-drive-daynaport", id = &id), - Drive::Cdrom { id, path } if path.is_empty() => t!("welcome-drive-cdrom-empty", id = &id), - Drive::Cdrom { id, path } => { let path = abs_path(&path); t!("welcome-drive-cdrom", id = &id, path = &path) } - Drive::Disk { id, path } if path.is_empty() => t!("welcome-drive-disk-no-image", id = &id), - Drive::Disk { id, path } => { let path = abs_path(&path); t!("welcome-drive-disk", id = &id, path = &path) } - Drive::Nvme { path } => { let path = abs_path(&path); t!("welcome-drive-nvme", path = &path) } - Drive::FibreChannel { id, path } => { let path = abs_path(&path); t!("welcome-drive-fc", id = id, path = &path) } - }); + let (text, path) = match drive { + Drive::Daynaport { id } => (t!("welcome-drive-daynaport", id = &id), String::new()), + Drive::Cdrom { id, path } if path.is_empty() => (t!("welcome-drive-cdrom-empty", id = &id), path), + Drive::Cdrom { id, path } => { let s = shown(&path); (t!("welcome-drive-cdrom", id = &id, path = &s), path) } + Drive::Disk { id, path } if path.is_empty() => (t!("welcome-drive-disk-no-image", id = &id), path), + Drive::Disk { id, path } => { let s = shown(&path); (t!("welcome-drive-disk", id = &id, path = &s), path) } + Drive::Nvme { path } => { let s = shown(&path); (t!("welcome-drive-nvme", path = &s), path) } + Drive::FibreChannel { id, path } => { let s = shown(&path); (t!("welcome-drive-fc", id = id, path = &s), path) } + }; + path_label(ui, text, &path); } subtitle(ui, t!("welcome-drives-subtitle")); }); @@ -3147,8 +3173,7 @@ impl App { // Welcome panel is only rendered when the emulator is stopped // (the central panel switches to the framebuffer when running), // so a single Start button is sufficient here. - if ui.add(egui::Button::new(RichText::new(t!("welcome-start")).size(20.0)) - .fill(Color32::from_rgb(40, 120, 40)) + if ui.add(crate::extra_ui::filled_button(RichText::new(t!("welcome-start")).size(20.0), Color32::from_rgb(40, 120, 40)) .min_size(egui::vec2(220.0, 44.0))).clicked() { self.start_emulator(); @@ -3368,7 +3393,7 @@ impl eframe::App for App { let entered = resp.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)); ui.add_space(6.0); ui.horizontal(|ui| { - let ok = ui.add(egui::Button::new(t!("modal-rename-confirm")).fill(Color32::from_rgb(60, 90, 140))).clicked(); + let ok = ui.add(crate::extra_ui::filled_button(t!("modal-rename-confirm"), Color32::from_rgb(60, 90, 140))).clicked(); if (ok || entered) && !buf.trim().is_empty() { rename_result = Some(Some(buf.clone())); } @@ -3451,8 +3476,7 @@ impl eframe::App for App { ui.horizontal(|ui| { if ui.button(t!("common-cancel")).clicked() { close_modal = true; } if ui.button(t!("modal-stop-halt")).clicked() { do_halt = true; close_modal = true; } - if ui.add(egui::Button::new(RichText::new(t!("modal-stop-force")).color(Color32::WHITE)) - .fill(Color32::from_rgb(140, 40, 40))).clicked() + if ui.add(crate::extra_ui::filled_button(RichText::new(t!("modal-stop-force")).color(Color32::WHITE), Color32::from_rgb(140, 40, 40))).clicked() { do_force = true; close_modal = true; } @@ -3520,13 +3544,11 @@ impl eframe::App for App { ui.add_space(8.0); ui.horizontal(|ui| { if ui.button(t!("common-cancel")).clicked() { do_revert = true; close = true; } - if ui.add(egui::Button::new(t!("modal-net-use", subnet = &suggestion)) - .fill(Color32::from_rgb(60, 90, 140))).clicked() + if ui.add(crate::extra_ui::filled_button(t!("modal-net-use", subnet = &suggestion), Color32::from_rgb(60, 90, 140))).clicked() { do_suggest = true; close = true; } - if ui.add(egui::Button::new(t!("modal-net-override")) - .fill(Color32::from_rgb(140, 90, 40))).clicked() + if ui.add(crate::extra_ui::filled_button(t!("modal-net-override"), Color32::from_rgb(140, 90, 40))).clicked() { close = true; } @@ -3555,8 +3577,7 @@ impl eframe::App for App { ui.label(RichText::new(capture_access::permission_hint()).weak()); ui.add_space(8.0); ui.horizontal(|ui| { - if ui.add(egui::Button::new(t!("modal-pcap-enable")) - .fill(Color32::from_rgb(60, 90, 140))).clicked() + if ui.add(crate::extra_ui::filled_button(t!("modal-pcap-enable"), Color32::from_rgb(60, 90, 140))).clicked() { do_enable = true; } @@ -3597,8 +3618,7 @@ impl eframe::App for App { ui.horizontal(|ui| { if ui.button(t!("common-cancel")).clicked() { choice = MissingChoice::Cancel; } if ui.button(t!("modal-missing-edit")).clicked() { choice = MissingChoice::EditDisks; } - if ui.add(egui::Button::new(t!("modal-missing-detach")) - .fill(Color32::from_rgb(60, 90, 140))).clicked() + if ui.add(crate::extra_ui::filled_button(t!("modal-missing-detach"), Color32::from_rgb(60, 90, 140))).clicked() { choice = MissingChoice::Detach; } @@ -3682,8 +3702,7 @@ impl eframe::App for App { ui.add_space(4.0); ui.horizontal(|ui| { if ui.button(t!("common-cancel")).clicked() { chd_choice = ChdGrantChoice::Cancel; } - if ui.add(egui::Button::new(t!("modal-grant-start-anyway")) - .fill(Color32::from_rgb(60, 90, 140))).clicked() + if ui.add(crate::extra_ui::filled_button(t!("modal-grant-start-anyway"), Color32::from_rgb(60, 90, 140))).clicked() { chd_choice = ChdGrantChoice::StartAnyway; } diff --git a/iris-gui/src/summary.rs b/iris-gui/src/summary.rs index 0a5667d5e..27a917afb 100644 --- a/iris-gui/src/summary.rs +++ b/iris-gui/src/summary.rs @@ -50,6 +50,17 @@ pub fn drives(cfg: &MachineConfig) -> Vec { out } +/// `path` as the summary shows it: relative to the machine folder when it is +/// in it (the folder is the working directory, so a relative path already +/// is), else as written. The full path is the label's tooltip. +pub fn shown_path(path: &str, machine_dir: Option<&std::path::Path>) -> String { + let p = std::path::Path::new(path); + match machine_dir.and_then(|dir| p.strip_prefix(dir).ok()) { + Some(rel) if !rel.as_os_str().is_empty() => rel.to_string_lossy().into_owned(), + _ => path.to_string(), + } +} + /// The summary's Network row. #[derive(Debug, Clone, PartialEq, Eq)] pub enum Network { @@ -251,6 +262,17 @@ mod tests { assert!(expansion_paths(&cfg).is_empty()); } + #[test] + fn paths_in_the_machine_folder_are_shown_relative() { + let dir = std::path::Path::new("/m/o2"); + assert_eq!(shown_path("disks/root.img", Some(dir)), "disks/root.img"); + assert_eq!(shown_path("/m/o2/disks/root.img", Some(dir)), "disks/root.img"); + assert_eq!(shown_path("/m/o2b/x.img", Some(dir)), "/m/o2b/x.img"); + assert_eq!(shown_path("/elsewhere/x.iso", Some(dir)), "/elsewhere/x.iso"); + assert_eq!(shown_path("/m/o2", Some(dir)), "/m/o2"); + assert_eq!(shown_path("/m/o2/x", None), "/m/o2/x"); + } + #[test] fn network_row_follows_the_mode() { let mut cfg = parse("[machine]\nprofile = \"o2_ip32\"\n");