From 2abfef6a7caa30d0169284d957ae4c66ff0d412e Mon Sep 17 00:00:00 2001 From: poli0981 <127664709+poli0981@users.noreply.github.com> Date: Thu, 13 Aug 2026 21:33:28 +0700 Subject: [PATCH] fix(ui): one window, one way back, and a sidebar that stops mid-plan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four things from the first real click-through of the installed build. **Two "Back to packages" buttons after a successful run.** `PdSummarySheet` renders `plan.done` from its `onDone`, and the panel rendered a second one beneath it. The panel's is now shown only when there is no sheet — a run that failed before producing an `ExecutionSummary` has an error row and nothing else, and without a button that phase is a dead end. Worth naming *why* no test caught it: `PdSummarySheet` has its own tests and `PdPlanPanel` had none, so the two had never been rendered together. `PdPlanPanel.test.tsx` now does exactly that, and it was checked against the bug — reverting just the panel change makes it fail with "expected 2 to have length 1". Adding it exposed a second gap: `ipcMock` had no `reportBugUrl`, which `PdErrorRow` asks for on mount, so any screen containing an error was untestable. **No single instance.** Five launches gave five windows — which is five `AppState`s over one machine: five `Sessions` slots, each certain it owned the mutation in flight, and five `PD-RES-003` guards that cannot see each other. `tauri-plugin-single-instance` is registered **first**, before any plugin that could take a lock, and the handler unminimizes before focusing: focusing a minimized window leaves it minimized, and the user's second launch appears to do nothing. Added without the `deep-link` feature `cargo add` selects by default — PipDock registers no deep links, and it pulls three crates into the audit surface for nothing. **The sidebar is disabled while a plan owns the content area.** Navigating away left the plan parked in Rust with nothing on screen driving it, and the next Update answered `PD-RES-003` about a plan the user could no longer see. `App.tsx` already refuses `Ctrl+1..8` while the guard dialog is open; this is that rule applied to the panel and to the mouse. **The window is bounded and cannot be maximized.** `maxWidth`/`maxHeight` at 1600×1100 with `maximizable: false` and `fullscreen: false`. The layout is a fixed sidebar plus one scrolling column; stretched across a 4K panel it is a column of text with a metre of empty surface. Co-Authored-By: Claude Opus 5 --- Cargo.lock | 17 ++++++++ src-tauri/Cargo.toml | 4 ++ src-tauri/src/lib.rs | 15 +++++++ src-tauri/tauri.conf.json | 4 ++ ui/src/components/PdSidebar.tsx | 15 ++++++- ui/src/screens/PdPlanPanel.test.tsx | 66 +++++++++++++++++++++++++++++ ui/src/screens/PdPlanPanel.tsx | 10 ++++- ui/src/stores/index.ts | 1 + ui/src/test/ipc.ts | 4 ++ 9 files changed, 132 insertions(+), 4 deletions(-) create mode 100644 ui/src/screens/PdPlanPanel.test.tsx diff --git a/Cargo.lock b/Cargo.lock index eac70b2..f2093c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3179,6 +3179,7 @@ dependencies = [ "tauri-plugin-clipboard-manager", "tauri-plugin-dialog", "tauri-plugin-opener", + "tauri-plugin-single-instance", "tokio", "tokio-util", "tracing", @@ -4693,6 +4694,22 @@ dependencies = [ "zbus", ] +[[package]] +name = "tauri-plugin-single-instance" +version = "2.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3214becf9ef5783c0ae99a3bb25adf5353a7a16ebf53e74b909e29205735c6c" +dependencies = [ + "serde", + "serde_json", + "tauri", + "thiserror 2.0.19", + "tokio", + "tracing", + "windows-sys 0.60.2", + "zbus", +] + [[package]] name = "tauri-runtime" version = "2.11.3" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 42e18ab..926de4b 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -34,6 +34,10 @@ tokio = { version = "1", features = ["rt-multi-thread"] } # `plan_cancel` trips the same `CancellationToken` the core threads through `exec`. tokio-util = "0.7" tracing = "0.1" +# One window, always. Launching PipDock again focuses the window that exists rather than opening +# a second one — two of them would be two `Sessions` slots over one set of environments, each +# certain it owned the mutation in flight. +tauri-plugin-single-instance = "2.4.3" tracing-subscriber = { version = "0.3", features = ["env-filter"] } [dev-dependencies] diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 258587f..a8536cf 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -36,6 +36,21 @@ pub fn run() { use tauri::Manager as _; tauri::Builder::default() + // **First, before every other plugin.** The single-instance handler has to be registered + // before anything that could take a lock or open the store, because a second launch runs + // this far and then hands off — and the reason it must hand off at all is that two windows + // would be two `AppState`s over one machine: two `Sessions` slots, each certain it owned + // the mutation in flight, and two `PD-RES-003` guards that cannot see each other. + .plugin(tauri_plugin_single_instance::init(|app, _argv, _cwd| { + // Focus the window that already exists. Restoring first matters: a minimized window + // that is only focused stays minimized, and the user sees their second launch do + // nothing at all. + if let Some(window) = app.get_webview_window("main") { + let _ = window.unminimize(); + let _ = window.show(); + let _ = window.set_focus(); + } + })) .plugin(tauri_plugin_dialog::init()) .plugin(tauri_plugin_opener::init()) .plugin(tauri_plugin_clipboard_manager::init()) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 89f1199..6a9b219 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -17,7 +17,11 @@ "height": 760, "minWidth": 900, "minHeight": 560, + "maxWidth": 1600, + "maxHeight": 1100, "resizable": true, + "maximizable": false, + "fullscreen": false, "theme": "Dark" } ], diff --git a/ui/src/components/PdSidebar.tsx b/ui/src/components/PdSidebar.tsx index b52a7ce..80a15d4 100644 --- a/ui/src/components/PdSidebar.tsx +++ b/ui/src/components/PdSidebar.tsx @@ -1,7 +1,7 @@ import { useTranslation } from 'react-i18next' import { NAV_KEYS, type NavKey } from '@/components/nav' -import { useEnvStore, useUiStore } from '@/stores' +import { PANEL_PHASES, useEnvStore, usePlanStore, useUiStore } from '@/stores' /** Tabs whose screens land in a later milestone. Kept in place, not hidden. */ const NOT_YET: readonly NavKey[] = ['security'] @@ -12,6 +12,12 @@ const NOT_YET: readonly NavKey[] = ['security'] * `Ctrl+1..8` maps to `NAV_KEYS` positionally, which is why that order is load-bearing. Tabs * without a screen yet stay in place and stay focusable rather than being hidden: hiding them * would renumber every shortcut after them, and the user would relearn the map twice. + * + * **Every tab is disabled while a plan owns the content area.** `PdPlanPanel` replaces `
` + * for the whole of a preview, an execution and its summary; navigating away left the plan parked + * in Rust with nothing on screen driving it, and the user's next Update answered `PD-RES-003` + * about a plan they could no longer see. `App.tsx` already refuses `Ctrl+1..8` while the guard + * dialog is open, for the same reason — this is that rule applied to the panel and to the mouse. */ export function PdSidebar() { const { t } = useTranslation() @@ -19,6 +25,8 @@ export function PdSidebar() { const setNav = useUiStore((s) => s.setNav) // UI-SPEC §3's layout sketch shows `Updates (7)`. A primitive, so this selector is stable. const updatesCount = useEnvStore((s) => s.updatesCount) + // A boolean rather than the phase, so an unrelated phase change does not re-render the sidebar. + const planBusy = usePlanStore((s) => PANEL_PHASES.has(s.phase)) return (