diff --git a/CHANGELOG-PUBLIC.md b/CHANGELOG-PUBLIC.md index fb1c05d..5d51e14 100644 --- a/CHANGELOG-PUBLIC.md +++ b/CHANGELOG-PUBLIC.md @@ -2,6 +2,13 @@ User-facing changes only, grouped by date under Added / Improved / Fixed. +## 0.5.1 — 2026-11-20 + +### Fixed + +- Reopening CapKit from the system tray after closing it no longer shows a second title bar and a pale, washed-out window. +- After a failed save, the Retry save button gets keyboard focus immediately. + ## 0.5.0 — 2026-11-20 ### Added diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 3ee4893..8941b41 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -1,6 +1,6 @@ { "name": "@snaphub/desktop", - "version": "0.5.0", + "version": "0.5.1", "private": true, "type": "module", "scripts": { diff --git a/apps/desktop/src-tauri/Cargo.lock b/apps/desktop/src-tauri/Cargo.lock index 83af404..3bac2f5 100644 --- a/apps/desktop/src-tauri/Cargo.lock +++ b/apps/desktop/src-tauri/Cargo.lock @@ -616,7 +616,7 @@ dependencies = [ [[package]] name = "capkit-desktop" -version = "0.5.0" +version = "0.5.1" dependencies = [ "ab_glyph", "arboard", diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 941f63b..3e770d7 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "capkit-desktop" -version = "0.5.0" +version = "0.5.1" description = "CapKit lightweight desktop toolkit to capture, record, and showcase" authors = ["CapKit"] edition = "2024" diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rs index db0a6d3..e137e0c 100644 --- a/apps/desktop/src-tauri/src/lib.rs +++ b/apps/desktop/src-tauri/src/lib.rs @@ -1817,22 +1817,37 @@ fn show_dashboard(app: &AppHandle) -> Result<(), SnaphubError> { return Ok(()); } - WebviewWindowBuilder::new( - app, - "dashboard", - WebviewUrl::App(PathBuf::from("index.html")), - ) - .title("CapKit") - .inner_size(1120.0, 780.0) - .min_inner_size(900.0, 640.0) - .center() - .resizable(true) - .visible(false) - .build() - .map_err(|error| SnaphubError::Window(error.to_string()))?; + // Closing destroys the dashboard to keep the resident process small, so this rebuild must + // match the first launch exactly: same config entry (undecorated, transparent, hidden until + // the page is ready) and the same glass. A hand-written builder drifted from tauri.conf.json + // and reopened with the native title bar over an opaque window. + let config = dashboard_window_config(&app.config().app.windows) + .ok_or_else(|| SnaphubError::Window("tauri.conf.json has no dashboard window".into()))?; + let window = WebviewWindowBuilder::from_config(app, config) + .and_then(WebviewWindowBuilder::build) + .map_err(|error| SnaphubError::Window(error.to_string()))?; + apply_dashboard_glass(&window); Ok(()) } +/// The dashboard's entry in `tauri.conf.json`, used for both the first launch and every reopen. +fn dashboard_window_config( + windows: &[tauri::utils::config::WindowConfig], +) -> Option<&tauri::utils::config::WindowConfig> { + windows.iter().find(|window| window.label == "dashboard") +} + +/// Frosted glass behind the dashboard. The page asks `dashboard_supports_glass` and stays +/// opaque where the blur is unavailable. +fn apply_dashboard_glass(window: &tauri::WebviewWindow) { + #[cfg(target_os = "windows")] + if let Ok(hwnd) = window.hwnd() { + platform::windows_glass::apply_blur(hwnd.0); + } + #[cfg(not(target_os = "windows"))] + let _ = window; +} + /* -------------------------------------------------------------------------- */ /* Recording */ /* -------------------------------------------------------------------------- */ @@ -3031,13 +3046,8 @@ pub fn run() { .set_notes_images_directory(notes.images_directory()); app.manage(notes); - // Frosted glass behind the dashboard. The page asks `dashboard_supports_glass` - // and stays opaque where the blur is unavailable. - #[cfg(target_os = "windows")] - if let Some(window) = app.get_webview_window("dashboard") - && let Ok(hwnd) = window.hwnd() - { - platform::windows_glass::apply_blur(hwnd.0); + if let Some(window) = app.get_webview_window("dashboard") { + apply_dashboard_glass(&window); } if launched_in_background() @@ -3656,4 +3666,19 @@ mod window_config_tests { assert_eq!(capture["shadow"].as_bool(), Some(false)); assert_eq!(capture["decorations"].as_bool(), Some(false)); } + + /// Reopening the dashboard after Close rebuilds it from this same entry; it must stay + /// undecorated (the page draws its own title bar) and transparent (for the glass). + #[test] + fn dashboard_reopens_from_its_undecorated_transparent_config() { + let config: tauri::utils::config::Config = + serde_json::from_str(include_str!("../tauri.conf.json")) + .expect("Tauri config should parse"); + let dashboard = super::dashboard_window_config(&config.app.windows) + .expect("Tauri config should contain a dashboard window"); + + assert!(!dashboard.decorations); + assert!(dashboard.transparent); + assert!(!dashboard.visible); + } } diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index eb3fca9..7dad772 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "CapKit", - "version": "0.5.0", + "version": "0.5.1", "identifier": "com.snaphub.desktop", "build": { "beforeDevCommand": "pnpm dev", diff --git a/apps/desktop/src/components/CompletionToolbar.test.tsx b/apps/desktop/src/components/CompletionToolbar.test.tsx index 5188eae..5ee5314 100644 --- a/apps/desktop/src/components/CompletionToolbar.test.tsx +++ b/apps/desktop/src/components/CompletionToolbar.test.tsx @@ -1,4 +1,5 @@ -import { cleanup, fireEvent, render, screen } from "@testing-library/react"; +import { act, cleanup, fireEvent, render, screen } from "@testing-library/react"; +import { createRoot } from "react-dom/client"; import { afterEach, describe, expect, it, vi } from "vitest"; import { defaultToolbarActions, @@ -141,3 +142,40 @@ describe("completionRailItems", () => { expect(items.map((item) => [item.label, item.shortcut])).toEqual([["Copy", "C"]]); }); }); + +describe("CompletionToolbar retry focus", () => { + it("focuses Retry save in the same commit that shows it", async () => { + const container = document.createElement("div"); + document.body.append(container); + const props = { + diagnostic: undefined, + items: [], + statusMessage: "", + statusSide: "right", + onRetrySave: (): void => undefined, + } as const; + const root = createRoot(container); + act(() => root.render()); + + // Leave act so React schedules effects as it does in the app, then read focus when the DOM + // mutates — the moment a user (or findByRole) first sees the button. + const actEnvironment: unknown = Reflect.get(globalThis, "IS_REACT_ACT_ENVIRONMENT"); + Reflect.set(globalThis, "IS_REACT_ACT_ENVIRONMENT", false); + try { + const focusedAtCommit = await new Promise((resolve) => { + const observer = new MutationObserver(() => { + if (container.querySelector("button") === null) return; + observer.disconnect(); + resolve(document.activeElement); + }); + observer.observe(container, { childList: true, subtree: true }); + setTimeout(() => root.render(), 0); + }); + expect(focusedAtCommit).toBe(screen.getByRole("button", { name: "Retry save" })); + } finally { + Reflect.set(globalThis, "IS_REACT_ACT_ENVIRONMENT", actEnvironment); + act(() => root.unmount()); + container.remove(); + } + }); +}); diff --git a/apps/desktop/src/components/CompletionToolbar.tsx b/apps/desktop/src/components/CompletionToolbar.tsx index bd3c2fa..b7fa729 100644 --- a/apps/desktop/src/components/CompletionToolbar.tsx +++ b/apps/desktop/src/components/CompletionToolbar.tsx @@ -1,4 +1,4 @@ -import { useEffect, useRef } from "react"; +import { useLayoutEffect, useRef } from "react"; import type { RailItem } from "./captureActions"; import { Refresh } from "./icons"; import { ToolButton } from "./ToolButton"; @@ -26,7 +26,9 @@ export function CompletionToolbar({ const retryButtonRef = useRef(null); const disabled = state !== "idle"; - useEffect(() => { + // Layout effect, not a passive one: focus must land in the commit that shows Retry save, or + // keyboard users (and a test reading focus on that commit) briefly find it on . + useLayoutEffect(() => { if (state === "save-pending") retryButtonRef.current?.focus(); }, [state]); diff --git a/package.json b/package.json index 192f5e1..f848289 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "snaphub", - "version": "0.5.0", + "version": "0.5.1", "private": true, "packageManager": "pnpm@11.14.0", "scripts": {