Revert the desktop hotkey: a new crate needs a Cargo.lock this machine cannot write
Android / Build, or is the channel already serving this? (push) Successful in 3s
CI & Build / Build now, or wait for Android? (push) Successful in 4s
Android / Kotlin + Rust (APK) (push) Skipped
CI & Build / Python lint (push) Successful in 3s
Desktop (Tauri) / Build, or is the channel already serving this? (push) Successful in 3s
CI & Build / TypeScript typecheck (push) Successful in 7s
CI & Build / Python tests (push) Successful in 10s
CI & Build / integration (push) Successful in 19s
CI & Build / Build & push image (push) Successful in 36s
Desktop (Tauri) / Windows installer (cross-compiled) (push) Successful in 1m52s
Desktop (Tauri) / Tauri desktop (Linux) (push) Successful in 4m7s
Desktop (Tauri) / Update manifest (push) Successful in 4s

`42e06da` added `tauri-plugin-global-shortcut` to Cargo.toml without updating
Cargo.lock, and every cargo invocation in CI passes `--locked`. Both desktop
jobs failed on the same line before compiling anything:

    error: cannot update the lock file ... because --locked was passed

So this says nothing about whether the code is right — clippy never ran. The
gate did exactly its job.

There is no Rust toolchain on this workstation (rule 10 — CI verifies), and a
lockfile is the one artifact CI is deliberately forbidden to generate. Hand-
writing the entries is not a real option: it needs the exact checksum and the
whole transitive tree, and a wrong checksum fails harder than a missing one.

Reverted rather than left red, because a red `dev` blocks everything behind it
and the Android half of #1899 is green and unaffected at c8318c3. The work is
intact in 42e06da and comes back with `git revert 5e0c...` once the lockfile
exists — nothing here needs rewriting.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K3MMqUtzX1TJgA1oypvm1c
This commit is contained in:
2026-09-01 09:10:33 -04:00
co-authored by Claude Opus 5
parent 42e06da576
commit 10ea15bef0
9 changed files with 3 additions and 511 deletions
-5
View File
@@ -64,8 +64,3 @@ tauri-plugin-log = "2"
# the plugin declares android support level "none", which is why the Android client
# gets a server-served update path instead (Scribe note 2725).
tauri-plugin-updater = "2"
# The system-wide quick-capture hotkey. Desktop only by nature — Android has no
# concept of a global shortcut, and its half of this feature is a share-sheet
# intent filter instead.
tauri-plugin-global-shortcut = "2"
+2 -2
View File
@@ -1,7 +1,7 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Core capability for the ThoughtSync windows: the board and the quick-capture window.",
"windows": ["main", "capture"],
"description": "Core capability for the main ThoughtSync window.",
"windows": ["main"],
"permissions": ["core:default"]
}
-229
View File
@@ -1,229 +0,0 @@
//! Quick capture: a system-wide hotkey that opens a small window to type into.
//!
//! The point is capture WITHOUT the app. Bringing the whole board forward to write
//! one line is the friction this removes, so the shortcut opens a small window of
//! its own rather than focusing `main` — and that window closes itself the moment
//! the note is saved.
//!
//! ## Why the shortcut is configurable, and why it starts unset
//!
//! A global shortcut is the one setting in this app that can collide with software
//! it knows nothing about. Whatever default is picked is a key combination taken
//! away from something on somebody's machine, silently, at install time. So there
//! is no default: the feature is off until someone chooses a combination, and
//! choosing one is how it turns on. [`SUGGESTED`] is offered by the UI as a
//! starting point, not applied on its behalf.
//!
//! ## Failure has to be visible
//!
//! Registering can fail — the combination may already be held by the window
//! manager or another app, and on Wayland a compositor may refuse global grabs
//! outright. A hotkey that quietly does nothing is worse than one that was never
//! offered, because there is nothing to look at and nothing to fix. So the stored
//! shortcut and the LIVE registration are reported separately: see
//! [`CaptureShortcut`].
use serde::{Deserialize, Serialize};
use tauri::{AppHandle, Emitter, Manager, State, WebviewUrl, WebviewWindowBuilder};
use tauri_plugin_global_shortcut::{GlobalShortcutExt, Shortcut, ShortcutState};
use thoughtsync_core::local::{store, Db};
const SHORTCUT_PREF: &str = "capture_shortcut";
/// The window the hotkey opens. Also the label the capability file grants to.
pub const CAPTURE_WINDOW: &str = "capture";
/// What the UI offers as a starting point. NOT applied automatically — see above.
///
/// `CommandOrControl+Shift+N`: the Command/Control split is Tauri's own portable
/// spelling, and Shift+N is rare enough to be free on most desktops while still
/// meaning "new" to the person pressing it.
pub const SUGGESTED: &str = "CommandOrControl+Shift+N";
/// Emitted to the main window after a capture is saved, so the board reloads.
///
/// The two windows hold separate copies of the frontend and therefore separate
/// Pinia stores; nothing in the capture window's store can reach the board's. The
/// note is already in SQLite by the time this fires — this only says "look again".
pub const CAPTURED_EVENT: &str = "thoughtsync://captured";
/// The stored shortcut and whether it is actually live.
///
/// Two fields rather than one because they genuinely disagree: a combination can
/// be saved and refuse to register, and the person needs to be told which of those
/// they are looking at. `registered: false` with a non-empty `shortcut` is the
/// "something else already has this" case.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CaptureShortcut {
/// The stored combination, or empty when quick capture is off.
pub shortcut: String,
/// Whether the OS accepted it. Always false when `shortcut` is empty.
pub registered: bool,
}
fn stored(db: &Db) -> Result<String, String> {
let conn = db.0.lock().map_err(|e| e.to_string())?;
Ok(store::pref(&conn, SHORTCUT_PREF)
.map_err(|e| e.to_string())?
.unwrap_or_default())
}
/// Open (or focus) the capture window.
///
/// Reused rather than recreated: holding one window and showing it is what makes
/// the second press feel instant, and it means a half-typed capture survives the
/// window being dismissed and reopened.
///
/// `always_on_top` and `center` because this is summoned over whatever you were
/// doing — a capture window that opens behind the app you called it from has
/// failed at the only thing it does.
fn open_capture_window(app: &AppHandle) {
if let Some(window) = app.get_webview_window(CAPTURE_WINDOW) {
let _ = window.show();
let _ = window.unminimize();
let _ = window.set_focus();
return;
}
// `index.html?capture=1` rather than a `/capture` path: the bundled assets are
// served as files, so a path with no file behind it is a 404 in the production
// build even though it routes fine under the dev server. A query string is
// carried through untouched and the router reads it on boot.
let built = WebviewWindowBuilder::new(
app,
CAPTURE_WINDOW,
WebviewUrl::App("index.html?capture=1".into()),
)
.title("Quick capture")
.inner_size(520.0, 220.0)
.min_inner_size(360.0, 160.0)
.resizable(true)
.always_on_top(true)
.center()
.skip_taskbar(true)
.build();
match built {
Ok(window) => {
let _ = window.set_focus();
}
// Never a panic and never fatal: failing to open a capture window must not
// take down an app whose board is working fine.
Err(e) => log::error!("could not open the capture window: {e}"),
}
}
/// Register `shortcut`, replacing whatever was live.
///
/// Unregisters everything first rather than tracking the previous binding: this
/// app owns exactly one global shortcut, so "all of ours" and "the old one" are
/// the same set, and keeping a copy of it is one more thing to get out of step.
fn register(app: &AppHandle, shortcut: &str) -> Result<(), String> {
let manager = app.global_shortcut();
let _ = manager.unregister_all();
if shortcut.is_empty() {
return Ok(());
}
let parsed: Shortcut = shortcut
.parse()
.map_err(|_| format!("'{shortcut}' is not a shortcut this system understands."))?;
manager
.on_shortcut(parsed, |app, _shortcut, event| {
// Pressed only. Without this the window is opened on the press AND on
// the release, and the second one lands on the window the first opened.
if event.state == ShortcutState::Pressed {
open_capture_window(app);
}
})
.map_err(|e| format!("Something else on this system is already using it ({e})."))
}
/// Restore the stored shortcut at startup.
///
/// Best-effort by construction: a combination that worked when it was chosen can
/// be taken by something installed later, and the app must still open. The failure
/// is logged and the UI will show it as not registered when the settings screen is
/// next opened.
pub fn restore(app: &AppHandle, db: &Db) {
let shortcut = match stored(db) {
Ok(s) if !s.is_empty() => s,
Ok(_) => return,
Err(e) => {
log::warn!("could not read the capture shortcut: {e}");
return;
}
};
match register(app, &shortcut) {
Ok(()) => log::info!("quick capture is on: {shortcut}"),
Err(e) => log::warn!("quick capture shortcut '{shortcut}' did not register: {e}"),
}
}
#[tauri::command]
pub fn capture_shortcut_get(app: AppHandle, db: State<'_, Db>) -> Result<CaptureShortcut, String> {
let shortcut = stored(&db)?;
// Asked of the manager rather than remembered from startup: the answer can
// have changed since, and a settings screen that reports a stale success is
// the exact thing this pair of fields exists to prevent.
let registered = !shortcut.is_empty()
&& shortcut
.parse::<Shortcut>()
.map(|s| app.global_shortcut().is_registered(s))
.unwrap_or(false);
Ok(CaptureShortcut {
shortcut,
registered,
})
}
/// Store a shortcut and make it live, or clear it with an empty string.
///
/// Registers BEFORE storing, so a combination the system refuses is not written
/// down as though it worked — the person would reopen the settings and find it
/// listed as their shortcut while nothing happened when they pressed it.
#[tauri::command]
pub fn capture_shortcut_set(
shortcut: String,
app: AppHandle,
db: State<'_, Db>,
) -> Result<CaptureShortcut, String> {
let wanted = shortcut.trim().to_string();
register(&app, &wanted)?;
let conn = db.0.lock().map_err(|e| e.to_string())?;
store::set_pref(&conn, SHORTCUT_PREF, &wanted).map_err(|e| e.to_string())?;
log::info!(
"quick capture shortcut {}",
if wanted.is_empty() {
"cleared".to_string()
} else {
format!("set to {wanted}")
}
);
Ok(CaptureShortcut {
shortcut: wanted.clone(),
registered: !wanted.is_empty(),
})
}
/// Hide the capture window and tell the board to reload.
///
/// Hidden rather than closed so the next press has a window to show instead of one
/// to build. Called after a save and on Escape alike; `saved` is what decides
/// whether the board is told to look again.
#[tauri::command]
pub fn capture_done(saved: bool, app: AppHandle) -> Result<(), String> {
if let Some(window) = app.get_webview_window(CAPTURE_WINDOW) {
window.hide().map_err(|e| e.to_string())?;
}
if saved {
if let Some(main) = app.get_webview_window("main") {
// Failure here is cosmetic — the note is saved either way and the board
// will show it on its next load — so it is logged, not raised.
if let Err(e) = main.emit(CAPTURED_EVENT, ()) {
log::warn!("could not tell the board about a capture: {e}");
}
}
}
Ok(())
}
-11
View File
@@ -9,7 +9,6 @@
//! remains here is the Tauri command surface (`commands`), desktop integration
//! (menu-entry install for the Linux AppImage), the in-app updater, and boot.
mod capture;
mod commands;
mod integration;
mod update;
@@ -81,10 +80,6 @@ pub fn run() {
// build without a signing key still starts normally and simply reports that
// updates aren't configured.
.plugin(tauri_plugin_updater::Builder::new().build())
// The quick-capture hotkey. Registering the combination itself happens in
// `setup`, once the store is open and can be asked which one to use — the
// plugin only has to exist before then.
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
// Attachment bytes are served to the webview from the local blob store
// (M10.7f). Registered on the BUILDER because a scheme has to exist before
// the webview is created; the directory it reads from arrives later, in
@@ -123,9 +118,6 @@ pub fn run() {
// in this directory saying which one the user picked (issue 2183).
update::adopt_installer_channel(&db, &dir);
sweep_local_trash(&db);
// Before the store is handed to the app: `restore` needs to read the
// stored shortcut out of it, and after `manage` the Db has moved.
capture::restore(app.handle(), &db);
app.manage(db);
// Attachment bytes live beside the database, filed by content hash, so a
// synced image is readable with no network (M10.7d).
@@ -184,9 +176,6 @@ pub fn run() {
update::update_channel_set,
update::update_check,
update::update_install,
capture::capture_shortcut_get,
capture::capture_shortcut_set,
capture::capture_done,
])
.run(tauri::generate_context!())
.expect("error while running the ThoughtSync desktop app");