From e6818e029ee158a3748b7c5e128dca7008d171b8 Mon Sep 17 00:00:00 2001 From: "mula.liu" Date: Sun, 1 Nov 2026 12:02:24 +0800 Subject: [PATCH] feat(ui): drop onto a button, and read the panels again Three changes to the main window, requested together. A file drop is now aimed. The three buttons are the only drop targets and the button you release on is the action it runs; a release anywhere else on the panel runs nothing and says so, instead of opening an action ring nobody asked for. This replaces the old fallback in both delivery paths - the DOM handler and the native webview drop - because two routes to the same gesture must not have two different rules. dropFiles therefore takes a required action rather than an optional one, and the actions ring is still reachable from the Shift-drag gesture and from a file type with no convertible formats. Recent rows can be dragged back onto those buttons. A row leaves Shift as a real file drag, so one gesture can be reported twice, once by the DOM and once by the native events, and which arrives first depends on the engine; recentDrag.landed lets only the first through. The hint under the buttons names the affordance, which is otherwise invisible, and all three buttons light up as candidates for as long as any drag is in flight - a native one via dragging, an internal one via rowDragging, since a row drag inside the webview does not raise native events. Type sizes are on one ladder now (--text-3xs to --text-hero) instead of being invented per rule, which is how the settings drawer drifted down to 7-8px. 92 declarations under 12px became one. The drawer is wider, its tabs are pills, and the runtime, share, setup and radial surfaces moved onto the same scale. The capture-behaviour setting is removed: the CaptureAfter enum, its field, its command and its UI. A finished capture always shows the result card, falling back to the editor when a card window cannot be created. Stored settings that still carry captureAfter load unchanged, because the struct does not deny unknown fields. Also dropped 23 i18n keys no surface used, one dead re-export in history.ts, and a stale .home-drop p rule that was outranking the new hint and sizing it as body copy. tsconfig now turns on noUnusedLocals, noUnusedParameters and noFallthroughCasesInSwitch, which is what keeps the dead imports from coming back; the tree already passes all three. --- src-tauri/src/capture.rs | 18 +- src-tauri/src/lib.rs | 1 - src-tauri/src/recording.rs | 14 +- src-tauri/src/settings.rs | 31 -- src/components/MainWindow.tsx | 235 ++++++--- src/components/SetupPanel.tsx | 6 +- src/components/UpdatePanel.tsx | 22 +- src/i18n.ts | 66 +-- src/lib/api.ts | 2 - src/lib/history.ts | 4 - src/styles.css | 937 +++++++++++++++++++-------------- src/types.ts | 2 - tsconfig.json | 3 + 13 files changed, 739 insertions(+), 602 deletions(-) diff --git a/src-tauri/src/capture.rs b/src-tauri/src/capture.rs index 240b3a3..36ca5f8 100644 --- a/src-tauri/src/capture.rs +++ b/src-tauri/src/capture.rs @@ -529,19 +529,13 @@ fn finish_capture( Ok(output.to_string_lossy().to_string()) } -/// Route a finished capture per the Capture-after setting. The card is allowed to -/// fail silently: a screenshot that saved is more important than an overlay that -/// could not be built, and the file is already on disk and copied by then. +/// Show the result card for a finished capture. The card is allowed to fail +/// silently: a screenshot that saved is more important than an overlay that could +/// not be built, and the file is already on disk and copied by then. The editor is +/// the fallback so a capture is never left with no way to act on it. fn hand_off(app: &AppHandle, output: &Path) { - match settings::load(app).capture_after { - settings::CaptureAfter::Editor => { - let _ = editor::show_editor(app, output); - } - settings::CaptureAfter::Card => { - if result_card::show(app, output).is_err() { - let _ = editor::show_editor(app, output); - } - } + if result_card::show(app, output).is_err() { + let _ = editor::show_editor(app, output); } } diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index eda3d68..9055a9f 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -422,7 +422,6 @@ pub fn run() { settings::set_autostart, settings::check_output_access, settings::set_language, - settings::set_capture_after, settings::set_update_check_enabled, settings::set_setup_reviewed, settings::get_wedge_orders, diff --git a/src-tauri/src/recording.rs b/src-tauri/src/recording.rs index 30c78da..3bc9f76 100644 --- a/src-tauri/src/recording.rs +++ b/src-tauri/src/recording.rs @@ -402,15 +402,11 @@ pub fn stop(app: &AppHandle, state: &AppState) -> Result, output: session.output.to_string_lossy().to_string(), started_at: session.started_at, }; - match crate::settings::load(app).capture_after { - crate::settings::CaptureAfter::Editor => { - editor::show_recording_editor(app, &info)?; - } - crate::settings::CaptureAfter::Card => { - if crate::result_card::show(app, Path::new(&info.output)).is_err() { - editor::show_recording_editor(app, &info)?; - } - } + // The card carries the recording's own Copy / Pin / Edit / Send buttons; the + // editor is the fallback so a finished recording is never left with no way to + // act on it. + if crate::result_card::show(app, Path::new(&info.output)).is_err() { + editor::show_recording_editor(app, &info)?; } crate::history::publish_result( app, diff --git a/src-tauri/src/settings.rs b/src-tauri/src/settings.rs index 6bb8ef0..f356154 100644 --- a/src-tauri/src/settings.rs +++ b/src-tauri/src/settings.rs @@ -25,16 +25,6 @@ pub struct SwitchUpdate { pub autostart: Option, } -/// What happens the instant a capture is saved. The card keeps the shot out of the -/// way but one click from Copy / Pin / Edit / Send; the editor opens it directly. -#[derive(Debug, Clone, Copy, Default, Deserialize, PartialEq, Eq, Serialize)] -#[serde(rename_all = "lowercase")] -pub enum CaptureAfter { - #[default] - Card, - Editor, -} - #[derive(Debug, Clone, Copy, Default, Deserialize, PartialEq, Eq, Serialize)] #[serde(rename_all = "lowercase")] pub enum FileOutputMode { @@ -59,8 +49,6 @@ pub struct AppSettings { pub autostart: bool, /// UI language, "" until the user picks one. Unset follows the system. pub language: String, - /// Card or editor, chosen right after a screenshot or recording is written. - pub capture_after: CaptureAfter, /// Ask the git release branch for a newer build once a day. pub update_check_enabled: bool, /// Last startup probe as a unix day, so the daily check survives restarts. @@ -86,7 +74,6 @@ impl Default for AppSettings { share_enabled: true, autostart: false, language: String::new(), - capture_after: CaptureAfter::default(), update_check_enabled: true, last_update_check_day: 0, wedge_orders: HashMap::new(), @@ -107,7 +94,6 @@ pub struct SettingsSnapshot { pub share_enabled: bool, pub autostart: bool, pub language: String, - pub capture_after: CaptureAfter, pub update_check_enabled: bool, pub update_feed_url: String, pub wedge_orders: HashMap>, @@ -299,7 +285,6 @@ pub fn snapshot(app: &AppHandle) -> Result { // Report what the OS actually has registered, not what we last wrote. autostart: crate::autostart::is_enabled(), language: settings.language.clone(), - capture_after: settings.capture_after, update_check_enabled: settings.update_check_enabled, update_feed_url: crate::update::manifest_url(), wedge_orders: settings.wedge_orders.clone(), @@ -380,22 +365,6 @@ pub fn update_check_due(app: &AppHandle, interval: std::time::Duration) -> bool elapsed_days >= (interval.as_secs() / 86_400).max(1) as i64 } -#[tauri::command] -pub async fn set_capture_after( - app: AppHandle, - after: CaptureAfter, -) -> Result { - tauri::async_runtime::spawn_blocking(move || { - update_settings(&app, |settings| { - settings.capture_after = after; - Ok(()) - })?; - snapshot(&app) - }) - .await - .map_err(|error| error.to_string())? -} - /// Close the guided first-run flow. The checks themselves are re-runnable from /// Settings, so dismissing the flow loses nothing. #[tauri::command] diff --git a/src/components/MainWindow.tsx b/src/components/MainWindow.tsx index 2113c40..2c12c29 100644 --- a/src/components/MainWindow.tsx +++ b/src/components/MainWindow.tsx @@ -22,6 +22,7 @@ import { FileOutput, LoaderCircle, Maximize, + MoveRight, Pin, Presentation, RefreshCw, @@ -37,7 +38,14 @@ import { Wrench, X, } from "lucide-react"; -import { useEffect, useMemo, useRef, useState, type CSSProperties } from "react"; +import { + useEffect, + useMemo, + useRef, + useState, + type CSSProperties, + type DragEvent, +} from "react"; import { getInitialLang, publishLang, useI18n } from "../i18n"; import { api } from "../lib/api"; import { hitTestDropTarget, toWindowPoint } from "../lib/dropTargets"; @@ -75,7 +83,6 @@ const FALLBACK_SETTINGS: AppSettings = { dragEnabled: true, shareEnabled: true, autostart: false, - captureAfter: "card", defaultFileOutputDir: "~/Downloads/Shift", defaultScreenshotDir: "~/Pictures/Shift", defaultRecordingDir: "~/Movies/Shift", @@ -154,13 +161,13 @@ function RecentThumb({ item }: { item: RecentItem }) { return ( {item.kind === "image" ? ( - + ) : item.kind === "video" ? ( - + ) : item.kind === "text" ? ( - + ) : ( - + )} ); @@ -198,12 +205,12 @@ function OutputLocation({ ) : null}
- + {path}
@@ -717,7 +794,7 @@ export function MainWindow() { void spring("record", () => api.startCapture("recording").then(() => undefined)) } > - {busy === "record" ? : } + {busy === "record" ? : } {t("record")} {IS_MAC ? "⌥⇧3" : "Alt+Shift+3"} @@ -726,7 +803,7 @@ export function MainWindow() { title={t("settings")} onClick={() => setSettingsOpen((value) => !value)} > - +
@@ -779,7 +856,13 @@ export function MainWindow() { })}

{dragging ? t("homeDropRelease") : t("homeDropTitle")}

-
+ {/* While any drag is in flight all three buttons show as candidates, so the + aim is visible before the pointer reaches one. */} +
@@ -804,9 +887,9 @@ export function MainWindow() { onClick={() => void spring("tools", () => chooseFiles("tools"))} > {busy === "tools" ? ( - + ) : ( - + )} {t("fileTools")} @@ -817,16 +900,20 @@ export function MainWindow() { }} onClick={() => void spring("ocr", chooseOcr)} > - {busy === "ocr" ? : } + {busy === "ocr" ? : } {t("ocr")}
+

+ + {t("homeDropHint")} +