Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG-PUBLIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@snaphub/desktop",
"version": "0.5.0",
"version": "0.5.1",
"private": true,
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
65 changes: 45 additions & 20 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion apps/desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
40 changes: 39 additions & 1 deletion apps/desktop/src/components/CompletionToolbar.test.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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(<CompletionToolbar {...props} state="working" />));

// 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<Element | null>((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(<CompletionToolbar {...props} state="save-pending" />), 0);
});
expect(focusedAtCommit).toBe(screen.getByRole("button", { name: "Retry save" }));
} finally {
Reflect.set(globalThis, "IS_REACT_ACT_ENVIRONMENT", actEnvironment);
act(() => root.unmount());
container.remove();
}
});
});
6 changes: 4 additions & 2 deletions apps/desktop/src/components/CompletionToolbar.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -26,7 +26,9 @@ export function CompletionToolbar({
const retryButtonRef = useRef<HTMLButtonElement>(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 <body>.
useLayoutEffect(() => {
if (state === "save-pending") retryButtonRef.current?.focus();
}, [state]);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snaphub",
"version": "0.5.0",
"version": "0.5.1",
"private": true,
"packageManager": "[email protected]",
"scripts": {
Expand Down
Loading