From c60de4ab875de457f14d0c80770728b1278cf99f Mon Sep 17 00:00:00 2001 From: Xoshbin Date: Sun, 15 Nov 2026 17:44:21 +0300 Subject: [PATCH 1/3] feat(clipboard): allow custom display title renaming for clipboard items MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add SQLite migration 12 adding `custom_title` to `clipboard_items` with FTS indexing and sync support - Implement `clipboard-history:rename` action (shortcut: ⇧⌘E / Mod+Shift+E) - Unify Action Panel navigation stack to support inline prompt views and submenus without unmounting - Support step-by-step Escape unwinding (clear input -> return to action list preserving search query -> clear query -> close panel) - Wire Window Management layout renaming to the unified prompt service Closes #1009 --- .../crates/asyar-storage/src/clipboard.rs | 155 +++++++- .../crates/asyar-storage/src/clipboard_fts.rs | 54 ++- .../crates/asyar-storage/src/migrations.rs | 51 +++ .../src-tauri/examples/clipboard_perf.rs | 1 + .../src-tauri/examples/seed_clipboard.rs | 1 + .../src-tauri/src/commands/handlers.rs | 1 + asyar-launcher/src-tauri/src/permissions.rs | 5 + .../src-tauri/src/storage/commands.rs | 18 + .../clipboard-history/DefaultView.svelte | 14 +- .../clipboard-history/index.test.ts | 27 ++ .../clipboard-history/index.ts | 37 +- .../clipboard-history/state.svelte.test.ts | 43 +++ .../clipboard-history/state.svelte.ts | 54 +++ .../window-management/ManageView.svelte | 32 +- .../window-management/ManageView.test.ts | 97 +++++ .../window-management/index.ts | 2 +- asyar-launcher/src/components/index.ts | 1 + .../layout/ActionListPopup.navigation.test.ts | 188 ++++++++++ .../components/layout/ActionListPopup.svelte | 342 +++++++++++++++--- .../layout/ActionPromptPopover.svelte | 230 ++++++++++++ .../layout/ActionPromptPopover.test.ts | 99 +++++ .../src/lib/ipc/clipboardHistoryCommands.ts | 6 + .../src/lib/keyboard/launcherKeyboard.test.ts | 19 + .../src/lib/keyboard/launcherKeyboard.ts | 14 +- asyar-launcher/src/locales/en.json | 5 + asyar-launcher/src/locales/fr.json | 5 + asyar-launcher/src/locales/pt-BR.json | 5 + asyar-launcher/src/locales/zh-CN.json | 5 + asyar-launcher/src/locales/zh-Hant.json | 5 + asyar-launcher/src/routes/+page.svelte | 12 + .../services/action/actionService.svelte.ts | 35 ++ .../clipboard/clipboardHistoryService.ts | 13 + .../stores/clipboardHistoryStore.svelte.ts | 16 + .../services/extension/ExtensionIpcRouter.ts | 1 + .../services/ClipboardHistoryServiceProxy.ts | 4 + .../src/services/IClipboardHistoryService.ts | 2 + asyar-sdk/src/types/ClipboardType.ts | 4 + 37 files changed, 1513 insertions(+), 90 deletions(-) create mode 100644 asyar-launcher/src/built-in-features/window-management/ManageView.test.ts create mode 100644 asyar-launcher/src/components/layout/ActionListPopup.navigation.test.ts create mode 100644 asyar-launcher/src/components/layout/ActionPromptPopover.svelte create mode 100644 asyar-launcher/src/components/layout/ActionPromptPopover.test.ts diff --git a/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard.rs b/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard.rs index 13cfad599..df17727fe 100644 --- a/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard.rs +++ b/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard.rs @@ -46,6 +46,9 @@ pub struct ClipboardItem { /// alphanumeric+underscore so no escaping is required. #[serde(default, skip_serializing_if = "Option::is_none")] pub redacted_kinds: Option>, + /// Optional user-assigned display title that overrides the raw content preview. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub custom_title: Option, } /// Hot-path list payload — decrypts `preview` only, never `content`. @@ -66,6 +69,9 @@ pub struct ClipboardListItem { pub source_app: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub redacted_kinds: Option>, + /// Optional user-assigned display title that overrides the raw content preview. + #[serde(default, skip_serializing_if = "Option::is_none")] + pub custom_title: Option, } /// Opaque pagination cursor. Comparisons use tuple semantics @@ -351,6 +357,24 @@ pub fn init_table(conn: &Connection) -> Result<(), AppError> { ) .map_err(|e| AppError::Database(format!("Failed to create idx_clipboard_hash: {e}")))?; + // Migration: add custom_title column if it doesn't exist yet. + let custom_title_exists: bool = conn + .query_row( + "SELECT COUNT(*) FROM pragma_table_info('clipboard_items') WHERE name='custom_title'", + [], + |row| row.get::<_, i32>(0), + ) + .map(|c| c > 0) + .unwrap_or(false); + + if !custom_title_exists { + conn.execute( + "ALTER TABLE clipboard_items ADD COLUMN custom_title TEXT", + [], + ) + .map_err(|e| AppError::Database(format!("Failed to add custom_title column: {e}")))?; + } + Ok(()) } @@ -367,17 +391,19 @@ pub fn add_item( content: Option, preview: Option, content_hash: Option>, + custom_title: Option, } let existing: Option = conn .query_row( - "SELECT content, preview, content_hash FROM clipboard_items WHERE id = ?1", + "SELECT content, preview, content_hash, custom_title FROM clipboard_items WHERE id = ?1", params![item.id], |r| { Ok(ExistingRow { content: r.get(0)?, preview: r.get(1)?, content_hash: r.get(2)?, + custom_title: r.get(3)?, }) }, ) @@ -391,6 +417,10 @@ pub fn add_item( Some(p) if !p.is_empty() => encrypt_opt(Some(p), master_key)?, _ => existing.as_ref().and_then(|e| e.preview.clone()), }; + let encrypted_custom_title = match item.custom_title.as_deref() { + Some(t) if !t.is_empty() => encrypt_opt(Some(t), master_key)?, + _ => existing.as_ref().and_then(|e| e.custom_title.clone()), + }; let content_hash = if item .content .as_deref() @@ -404,8 +434,8 @@ pub fn add_item( conn.execute( "INSERT OR REPLACE INTO clipboard_items - (id, item_type, content, preview, created_at, favorite, metadata, source_app, redacted_kinds, content_hash) - VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10)", + (id, item_type, content, preview, created_at, favorite, metadata, source_app, redacted_kinds, content_hash, custom_title) + VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11)", params![ item.id, item.item_type, @@ -417,6 +447,7 @@ pub fn add_item( item.source_app.as_ref().map(|m| serde_json::to_string(m).unwrap_or_default()), encode_redacted_kinds(&item.redacted_kinds), content_hash, + encrypted_custom_title, ], ) .map_err(|e| AppError::Database(format!("Failed to add clipboard item: {e}")))?; @@ -431,7 +462,7 @@ pub fn add_item( pub fn get_all(conn: &Connection, master_key: &[u8; 32]) -> Result, AppError> { let mut stmt = conn .prepare( - "SELECT id, item_type, content, preview, created_at, favorite, metadata, source_app, redacted_kinds + "SELECT id, item_type, content, preview, created_at, favorite, metadata, source_app, redacted_kinds, custom_title FROM clipboard_items ORDER BY created_at DESC", ) @@ -454,7 +485,7 @@ pub fn get_recent( limit: usize, master_key: &[u8; 32], ) -> Result, AppError> { - let select_cols = "SELECT id, item_type, content, preview, created_at, favorite, metadata, source_app, redacted_kinds"; + let select_cols = "SELECT id, item_type, content, preview, created_at, favorite, metadata, source_app, redacted_kinds, custom_title"; // Favorites — all of them, newest first. let mut fav_stmt = conn @@ -762,7 +793,7 @@ pub fn export_for_sync( ) -> Result { let probe_limit = (limit as i64).saturating_add(1); let select = "SELECT id, item_type, content, preview, created_at, favorite, \ - metadata, source_app, redacted_kinds FROM clipboard_items"; + metadata, source_app, redacted_kinds, custom_title FROM clipboard_items"; let mut probe: Vec = match cursor { Some(c) => conn @@ -817,7 +848,7 @@ pub fn get_item( ) -> Result, AppError> { let result = conn.query_row( "SELECT id, item_type, content, preview, created_at, favorite, - metadata, source_app, redacted_kinds + metadata, source_app, redacted_kinds, custom_title FROM clipboard_items WHERE id = ?1", params![id], row_to_item_factory(master_key), @@ -908,6 +939,49 @@ pub fn toggle_favorite(conn: &Connection, id: &str) -> Result { Ok(new_val) } +/// Set a custom display title for an item, or remove it if `title` is `None` or empty. +/// Encrypted under `master_key` at rest. +pub fn set_custom_title( + conn: &Connection, + id: &str, + title: Option<&str>, + master_key: &[u8; 32], +) -> Result<(), AppError> { + let encrypted = match title.map(str::trim).filter(|s| !s.is_empty()) { + Some(t) => encrypt_opt(Some(t), master_key)?, + None => None, + }; + conn.execute( + "UPDATE clipboard_items SET custom_title = ?1 WHERE id = ?2", + params![encrypted, id], + ) + .map_err(|e| AppError::Database(format!("Failed to set custom title: {e}")))?; + Ok(()) +} + +/// FTS-aware wrapper for `set_custom_title`. +pub fn set_custom_title_with_fts( + conn: &Connection, + id: &str, + title: Option<&str>, + master_key: &[u8; 32], + fts: &ClipboardFts, +) -> Result<(), AppError> { + set_custom_title(conn, id, title, master_key)?; + if let Some(item) = get_item(conn, id, master_key)? { + let source_app_text = + crate::clipboard_fts::extract_source_app_text(item.source_app.as_ref()); + fts.upsert_full( + &item.id, + item.preview.as_deref(), + item.content.as_deref(), + Some(&source_app_text), + item.custom_title.as_deref(), + )?; + } + Ok(()) +} + /// Tombstone the item in the cloud-sync journal then hard-delete it from /// `clipboard_items`. Order matters: tombstone first so the journal row is /// always present before the item disappears from the primary table. @@ -1060,7 +1134,7 @@ pub fn cleanup( /// decrypt-and-deserialise logic lives in one place. SELECT must project /// columns in this exact order: /// id, item_type, content, preview, created_at, favorite, -/// metadata, source_app, redacted_kinds +/// metadata, source_app, redacted_kinds, custom_title fn row_to_item_factory( master_key: &[u8; 32], ) -> impl Fn(&rusqlite::Row<'_>) -> rusqlite::Result + '_ { @@ -1070,6 +1144,7 @@ fn row_to_item_factory( let redacted_kinds_str: Option = row.get(8)?; let raw_content: Option = row.get(2)?; let raw_preview: Option = row.get(3)?; + let raw_custom_title: Option = row.get(9)?; Ok(ClipboardItem { id: row.get(0)?, item_type: row.get(1)?, @@ -1080,13 +1155,14 @@ fn row_to_item_factory( metadata: metadata_str.and_then(|s| serde_json::from_str(&s).ok()), source_app: source_app_str.and_then(|s| serde_json::from_str(&s).ok()), redacted_kinds: decode_redacted_kinds(redacted_kinds_str), + custom_title: decrypt_opt(raw_custom_title, master_key), }) } } /// Row → ClipboardListItem mapper. SELECT must project columns in this exact order: /// id, item_type, preview, created_at, favorite, -/// metadata, source_app, redacted_kinds +/// metadata, source_app, redacted_kinds, custom_title fn list_row_to_item_factory( master_key: &[u8; 32], ) -> impl Fn(&rusqlite::Row<'_>) -> rusqlite::Result + '_ { @@ -1095,6 +1171,7 @@ fn list_row_to_item_factory( let source_app_str: Option = row.get(6)?; let redacted_kinds_str: Option = row.get(7)?; let raw_preview: Option = row.get(2)?; + let raw_custom_title: Option = row.get(8)?; Ok(ClipboardListItem { id: row.get(0)?, item_type: row.get(1)?, @@ -1104,6 +1181,7 @@ fn list_row_to_item_factory( metadata: metadata_str.and_then(|s| serde_json::from_str(&s).ok()), source_app: source_app_str.and_then(|s| serde_json::from_str(&s).ok()), redacted_kinds: decode_redacted_kinds(redacted_kinds_str), + custom_title: decrypt_opt(raw_custom_title, master_key), }) } } @@ -1129,7 +1207,7 @@ pub fn find_duplicate( // file path, not free text, and content_hash is NULL for image rows. let result = conn.query_row( "SELECT id, item_type, content, preview, created_at, favorite, - metadata, source_app, redacted_kinds + metadata, source_app, redacted_kinds, custom_title FROM clipboard_items WHERE item_type = ?1 AND id = ?2", params![item_type, id], row_to_item_factory(master_key), @@ -1150,7 +1228,7 @@ pub fn find_duplicate( let result = conn.query_row( "SELECT id, item_type, content, preview, created_at, favorite, - metadata, source_app, redacted_kinds + metadata, source_app, redacted_kinds, custom_title FROM clipboard_items WHERE item_type = ?1 AND content_hash = ?2 LIMIT 1", @@ -1175,9 +1253,9 @@ const MAX_HISTORY_ITEMS: usize = 50_000; /// Shared SELECT column list for `ClipboardListItem` queries. Columns must /// match the index expectations of `list_row_to_item_factory` exactly: /// 0=id, 1=item_type, 2=preview, 3=created_at, 4=favorite, -/// 5=metadata, 6=source_app, 7=redacted_kinds +/// 5=metadata, 6=source_app, 7=redacted_kinds, 8=custom_title const LIST_SELECT_COLS: &str = - "SELECT id, item_type, preview, created_at, favorite, metadata, source_app, redacted_kinds"; + "SELECT id, item_type, preview, created_at, favorite, metadata, source_app, redacted_kinds, custom_title"; /// Atomically record a new clipboard capture: pub type IconResolver<'a> = &'a dyn Fn(&str, &Path) -> Option; @@ -1223,6 +1301,9 @@ pub fn record_capture( if dup.favorite { new_item.favorite = true; } + if new_item.custom_title.is_none() && dup.custom_title.is_some() { + new_item.custom_title = dup.custom_title; + } // We discard the returned DeleteResult here — the captured item // is the same one being re-inserted, so its image path (if any) // remains valid. @@ -1260,11 +1341,12 @@ pub fn record_capture_with_fts( } // New row is in the DB now — index it. let source_app_text = crate::clipboard_fts::extract_source_app_text(item.source_app.as_ref()); - fts.upsert_with_source_app( + fts.upsert_full( &res.inserted_id, item.preview.as_deref(), item.content.as_deref(), Some(&source_app_text), + item.custom_title.as_deref(), )?; // Evicted ids from cleanup must come out of FTS too. fts.delete_many(&res.evicted_ids)?; @@ -1308,11 +1390,12 @@ pub fn apply_synced_item_with_fts( if applied { let source_app_text = crate::clipboard_fts::extract_source_app_text(item.source_app.as_ref()); - fts.upsert_with_source_app( + fts.upsert_full( &item.id, item.preview.as_deref(), item.content.as_deref(), Some(&source_app_text), + item.custom_title.as_deref(), )?; } Ok(applied) @@ -1463,6 +1546,7 @@ mod tests { metadata: None, source_app: None, redacted_kinds: None, + custom_title: None, } } @@ -1494,6 +1578,44 @@ mod tests { assert!(items[0].redacted_kinds.is_none()); } + #[test] + fn test_set_custom_title_encrypted_and_round_trip() { + let conn = setup(); + let key = test_key(); + let item = make_item("1", "cd ~/projects && grok", false); + add_item(&conn, &item, &key).unwrap(); + + // 1. Set custom title + set_custom_title(&conn, "1", Some("💠 AGENTS 💠"), &key).unwrap(); + + // 2. Verify stored in SQLite is encrypted + let raw_title: String = conn + .query_row( + "SELECT custom_title FROM clipboard_items WHERE id = '1'", + [], + |r| r.get(0), + ) + .unwrap(); + assert_ne!(raw_title, "💠 AGENTS 💠"); + assert!(cipher::is_encrypted_value(&raw_title)); + + // 3. Verify get_item returns decrypted custom_title + let fetched = get_item(&conn, "1", &key).unwrap().unwrap(); + assert_eq!(fetched.custom_title.as_deref(), Some("💠 AGENTS 💠")); + + // 4. Verify list_initial returns decrypted custom_title in ClipboardListItem + let initial = list_initial(&conn, 10, &key, None).unwrap(); + assert_eq!( + initial.recent[0].custom_title.as_deref(), + Some("💠 AGENTS 💠") + ); + + // 5. Clearing title sets it back to None + set_custom_title(&conn, "1", Some(" "), &key).unwrap(); + let cleared = get_item(&conn, "1", &key).unwrap().unwrap(); + assert!(cleared.custom_title.is_none()); + } + #[test] fn test_init_table_idempotent_adds_redacted_kinds() { // Pre-create with the old schema (no redacted_kinds column). @@ -1884,6 +2006,7 @@ mod tests { metadata: None, source_app: None, redacted_kinds: None, + custom_title: None, }; add_item(&conn, &empty_item, &key).unwrap(); @@ -2366,7 +2489,7 @@ mod tests { let row: ClipboardListItem = conn .query_row( "SELECT id, item_type, preview, created_at, favorite, - metadata, source_app, redacted_kinds + metadata, source_app, redacted_kinds, custom_title FROM clipboard_items WHERE id = '1'", [], list_row_to_item_factory(&key), diff --git a/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard_fts.rs b/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard_fts.rs index 8ecb62997..83c5c55f8 100644 --- a/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard_fts.rs +++ b/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard_fts.rs @@ -40,7 +40,7 @@ pub fn rebuild_from_disk( let mut stmt = conn .prepare( - "SELECT id, item_type, content, preview, content_hash, source_app \ + "SELECT id, item_type, content, preview, content_hash, source_app, custom_title \ FROM clipboard_items ORDER BY created_at DESC, id DESC", ) .map_err(|e| AppError::Database(format!("FTS rebuild prepare: {e}")))?; @@ -52,6 +52,7 @@ pub fn rebuild_from_disk( raw_preview: Option, existing_hash: Option>, raw_source_app: Option, + raw_custom_title: Option, } let rows: Vec = stmt @@ -63,6 +64,7 @@ pub fn rebuild_from_disk( raw_preview: r.get(3)?, existing_hash: r.get(4)?, raw_source_app: r.get(5)?, + raw_custom_title: r.get(6)?, }) }) .map_err(|e| AppError::Database(format!("FTS rebuild query: {e}")))? @@ -86,12 +88,20 @@ pub fn rebuild_from_disk( Some(v.to_string()) } }); + let custom_title = row.raw_custom_title.as_deref().and_then(|v| { + if cipher::is_encrypted_value(v) { + cipher::decrypt(v, master_key).ok() + } else { + Some(v.to_string()) + } + }); let source_app_text = extract_source_app_text_from_json_str(row.raw_source_app.as_deref()); - fts.upsert_with_source_app( + fts.upsert_full( &row.id, preview.as_deref(), content.as_deref(), Some(&source_app_text), + custom_title.as_deref(), )?; if row.existing_hash.is_none() && row.item_type != "image" { @@ -175,7 +185,7 @@ impl ClipboardFts { conn.execute_batch( "CREATE VIRTUAL TABLE fts_clipboard USING fts5( clip_id UNINDEXED, - preview, content, source_app, + preview, content, source_app, custom_title, prefix='2 3', tokenize='unicode61 remove_diacritics 2' ); @@ -197,7 +207,7 @@ impl ClipboardFts { preview: Option<&str>, content: Option<&str>, ) -> Result<(), AppError> { - self.upsert_with_source_app(id, preview, content, None) + self.upsert_full(id, preview, content, None, None) } /// Insert or replace the FTS row for a clipboard id, including `source_app` metadata. @@ -207,18 +217,31 @@ impl ClipboardFts { preview: Option<&str>, content: Option<&str>, source_app: Option<&str>, + ) -> Result<(), AppError> { + self.upsert_full(id, preview, content, source_app, None) + } + + /// Insert or replace the FTS row for a clipboard id, including `source_app` and `custom_title` metadata. + pub fn upsert_full( + &self, + id: &str, + preview: Option<&str>, + content: Option<&str>, + source_app: Option<&str>, + custom_title: Option<&str>, ) -> Result<(), AppError> { let rowid = rowid_for(id); let conn = self.conn.lock().map_err(|_| AppError::Lock)?; conn.execute( - "INSERT OR REPLACE INTO fts_clipboard(rowid, clip_id, preview, content, source_app) \ - VALUES (?1, ?2, ?3, ?4, ?5)", + "INSERT OR REPLACE INTO fts_clipboard(rowid, clip_id, preview, content, source_app, custom_title) \ + VALUES (?1, ?2, ?3, ?4, ?5, ?6)", params![ rowid, id, preview.unwrap_or(""), content.unwrap_or(""), - source_app.unwrap_or("") + source_app.unwrap_or(""), + custom_title.unwrap_or(""), ], ) .map_err(|e| AppError::Database(format!("FTS upsert: {e}")))?; @@ -520,6 +543,22 @@ mod tests { let hits = fts.search("vscode cloudflare", 10).unwrap(); assert_eq!(hits, vec!["id-1".to_string()]); } + + #[test] + fn test_search_matches_custom_title() { + let fts = ClipboardFts::new_in_memory().unwrap(); + fts.upsert_full( + "cmd-1", + Some("curl https://api.internal"), + Some("curl https://api.internal/auth -H Token"), + Some("Terminal"), + Some("💠 AGENTS 💠"), + ) + .unwrap(); + + let hits = fts.search("agents", 10).unwrap(); + assert_eq!(hits, vec!["cmd-1".to_string()]); + } } #[cfg(test)] @@ -547,6 +586,7 @@ mod rebuild_tests { metadata: None, source_app: None, redacted_kinds: None, + custom_title: None, } } diff --git a/asyar-launcher/src-tauri/crates/asyar-storage/src/migrations.rs b/asyar-launcher/src-tauri/crates/asyar-storage/src/migrations.rs index d0c849478..c2d5a2da5 100644 --- a/asyar-launcher/src-tauri/crates/asyar-storage/src/migrations.rs +++ b/asyar-launcher/src-tauri/crates/asyar-storage/src/migrations.rs @@ -80,6 +80,11 @@ pub const MIGRATIONS: &[Migration] = &[ name: "runs_history_quiet_success", up: migration_11_runs_history_quiet_success, }, + Migration { + version: 12, + name: "clipboard_custom_title", + up: migration_12_clipboard_custom_title, + }, ]; /// Bring `conn` up to the newest ledger version. Idempotent. @@ -317,6 +322,30 @@ fn migration_11_runs_history_quiet_success(conn: &Connection) -> Result<(), AppE Ok(()) } +/// Adds `clipboard_items.custom_title` (#1009). The column was first patched into +/// `clipboard::init_table`, which only baseline calls, so every database +/// already stamped past v1 never received it. Guarded because fresh and v0 +/// databases get it from baseline's `CREATE TABLE`. +fn migration_12_clipboard_custom_title(conn: &Connection) -> Result<(), AppError> { + let exists: bool = conn + .query_row( + "SELECT COUNT(*) FROM pragma_table_info('clipboard_items') WHERE name='custom_title'", + [], + |row| row.get::<_, i32>(0), + ) + .map(|c| c > 0) + .unwrap_or(false); + + if !exists { + conn.execute( + "ALTER TABLE clipboard_items ADD COLUMN custom_title TEXT", + [], + ) + .map_err(|e| AppError::Database(format!("Failed to add custom_title column: {e}")))?; + } + Ok(()) +} + /// Extends `cloud_sync_e2ee_local` mirror with: /// - `mode` ("passphrase" default for existing rows, "device-key" for new) /// - `kcv` (BLOB nullable for device-key HMAC-SHA256 check value) @@ -683,6 +712,28 @@ mod tests { assert_eq!(quiet, 0, "existing runs must stay loud"); } + #[test] + fn stamped_db_without_clipboard_custom_title_gets_the_column() { + let conn = Connection::open_in_memory().unwrap(); + run_ledger(&conn, &MIGRATIONS[..11]).unwrap(); + assert_eq!(user_version(&conn), 11); + // Simulate an install stamped past baseline whose clipboard_items predates + // `custom_title` — baseline's `init_table` never replays for it. + conn.execute_batch( + "ALTER TABLE clipboard_items DROP COLUMN custom_title; + INSERT INTO clipboard_items + (id, item_type, content, preview, created_at, favorite) + VALUES ('c1', 'text', 'enc_content', 'enc_preview', 1000.0, 0);", + ) + .unwrap(); + assert!(!column_names(&conn, "clipboard_items").contains(&"custom_title".to_string())); + + run(&conn).unwrap(); + + assert_eq!(user_version(&conn), MIGRATIONS.last().unwrap().version); + assert!(column_names(&conn, "clipboard_items").contains(&"custom_title".to_string())); + } + #[test] fn version_four_db_adds_search_engine_tables_without_losing_existing_rows() { let conn = Connection::open_in_memory().unwrap(); diff --git a/asyar-launcher/src-tauri/examples/clipboard_perf.rs b/asyar-launcher/src-tauri/examples/clipboard_perf.rs index 36fcb425a..3f9c9d09a 100644 --- a/asyar-launcher/src-tauri/examples/clipboard_perf.rs +++ b/asyar-launcher/src-tauri/examples/clipboard_perf.rs @@ -41,6 +41,7 @@ fn make_text_item(i: u32, base_ms: f64) -> ClipboardItem { metadata: None, source_app: None, redacted_kinds: None, + custom_title: None, } } diff --git a/asyar-launcher/src-tauri/examples/seed_clipboard.rs b/asyar-launcher/src-tauri/examples/seed_clipboard.rs index eb44a80ae..d4a0a922a 100644 --- a/asyar-launcher/src-tauri/examples/seed_clipboard.rs +++ b/asyar-launcher/src-tauri/examples/seed_clipboard.rs @@ -119,6 +119,7 @@ fn make_item(i: u32, base_time: f64) -> ClipboardItem { "bundleId": "dev.seed.clipboard", })), redacted_kinds: None, + custom_title: None, } } diff --git a/asyar-launcher/src-tauri/src/commands/handlers.rs b/asyar-launcher/src-tauri/src/commands/handlers.rs index f84087cf5..9bb457d45 100644 --- a/asyar-launcher/src-tauri/src/commands/handlers.rs +++ b/asyar-launcher/src-tauri/src/commands/handlers.rs @@ -150,6 +150,7 @@ macro_rules! storage_commands { $crate::storage::commands::clipboard_record_capture, $crate::storage::commands::clipboard_apply_synced, $crate::storage::commands::clipboard_toggle_favorite, + $crate::storage::commands::clipboard_set_custom_title, $crate::storage::commands::clipboard_delete_item, $crate::storage::commands::clipboard_clear_non_favorites, $crate::commands::clipboard_markup::clipboard_strip_html, diff --git a/asyar-launcher/src-tauri/src/permissions.rs b/asyar-launcher/src-tauri/src/permissions.rs index 990a6a1d7..10cdff2c6 100644 --- a/asyar-launcher/src-tauri/src/permissions.rs +++ b/asyar-launcher/src-tauri/src/permissions.rs @@ -222,6 +222,7 @@ fn get_required_permission(call_type: &str) -> Option<&'static str> { "asyar:api:clipboard:toggleItemFavorite" => Some("clipboard-history:manage"), "asyar:api:clipboard:deleteItem" => Some("clipboard-history:manage"), "asyar:api:clipboard:clearNonFavorites" => Some("clipboard-history:manage"), + "asyar:api:clipboard:setItemCustomTitle" => Some("clipboard-history:manage"), // Notifications "asyar:api:feedback:sendBackground" => Some("notifications:send"), "asyar:api:feedback:dismissBackground" => Some("notifications:send"), @@ -1245,6 +1246,10 @@ mod tests { get_required_permission("asyar:api:clipboard:clearNonFavorites"), Some("clipboard-history:manage") ); + assert_eq!( + get_required_permission("asyar:api:clipboard:setItemCustomTitle"), + Some("clipboard-history:manage") + ); } #[test] diff --git a/asyar-launcher/src-tauri/src/storage/commands.rs b/asyar-launcher/src-tauri/src/storage/commands.rs index 17559c871..43c64cb51 100644 --- a/asyar-launcher/src-tauri/src/storage/commands.rs +++ b/asyar-launcher/src-tauri/src/storage/commands.rs @@ -179,6 +179,24 @@ pub fn clipboard_toggle_favorite( Ok(super::clipboard::toggle_favorite(&conn, &id)?) } +#[tauri::command] +pub fn clipboard_set_custom_title( + id: String, + title: Option, + store: State<'_, DataStore>, + keystore: State<'_, KeystoreState>, + fts: State<'_, Arc>, +) -> Result<(), AppError> { + let conn = store.conn()?; + Ok(super::clipboard::set_custom_title_with_fts( + &conn, + &id, + title.as_deref(), + keystore.master_key(), + fts.inner(), + )?) +} + #[tauri::command] pub fn clipboard_delete_item( id: String, diff --git a/asyar-launcher/src/built-in-features/clipboard-history/DefaultView.svelte b/asyar-launcher/src/built-in-features/clipboard-history/DefaultView.svelte index f00f5bb69..842ceccd5 100644 --- a/asyar-launcher/src/built-in-features/clipboard-history/DefaultView.svelte +++ b/asyar-launcher/src/built-in-features/clipboard-history/DefaultView.svelte @@ -46,6 +46,7 @@ import { t } from '../../services/i18n'; import { appListen } from '../../lib/ipc/bridgeEvents'; import { viewManager } from '../../services/extension/viewManager.svelte'; + import { actionService } from '../../services/action/actionService.svelte'; const detailDateFormat = new Intl.DateTimeFormat(undefined, { month: 'long', @@ -498,7 +499,10 @@ } } - function getItemTitle(item: { type: string; preview?: string }) { + function getItemTitle(item: { type: string; preview?: string; customTitle?: string }) { + if (item.customTitle?.trim()) { + return item.customTitle.trim(); + } const preview = item.preview ?? ''; if (!preview) return item.type === 'image' ? 'Image' : item.type === 'files' ? 'Files' : 'Empty'; @@ -1169,6 +1173,14 @@ ({ registerAction: vi.fn(), unregisterAction: vi.fn(), setExtensionForwarder: vi.fn(), + openPrompt: vi.fn(), + closePrompt: vi.fn(), }, })); @@ -78,6 +80,10 @@ vi.mock('./state.svelte', () => ({ items: [], filteredItems: [], selectedItem: null, + isRenaming: false, + startRename: vi.fn(), + cancelRename: vi.fn(), + saveRename: vi.fn(), moveSelection: vi.fn(), moveSelectionAndExtend: vi.fn(), handleItemAction: vi.fn(), @@ -458,8 +464,11 @@ describe('Action registration', () => { expect(actionIds).toContain('clipboard-history:paste-as-plain-text'); expect(actionIds).toContain('clipboard-history:delete'); expect(actionIds).toContain('clipboard-history:clear-multi-selection'); + expect(actionIds).toContain('clipboard-history:rename'); const byId = (id: string) => registerCalls.find((call) => call[0].id === id)?.[0] as any; + expect(byId('clipboard-history:rename')?.shortcut).toBe('Mod+Shift+E'); + expect(byId('clipboard-history:rename')?.icon).toBe('icon:pencil'); expect(byId('clipboard-history:paste')?.shortcut).toBe('Enter'); expect(byId('clipboard-history:copy')?.shortcut).toBe('Mod+Enter'); expect(byId('clipboard-history:toggle-html-view')?.shortcut).toBe('Mod+Shift+H'); @@ -1349,3 +1358,21 @@ it('restores clipboard actions when returning from a child view', async () => { expect.objectContaining({ id: 'clipboard-history:save-as-snippet' }), ); }); + +describe('Action: clipboard-history:rename', () => { + it('triggers startRename on clipboardViewState when executed', async () => { + const { actionService } = await import('../../services/action/actionService.svelte'); + const { clipboardViewState } = await import('./state.svelte'); + + vi.mocked(actionService.registerAction).mockClear(); + await extension.viewActivated('clipboard-history/DefaultView'); + + const renameAction = vi + .mocked(actionService.registerAction) + .mock.calls.find((c) => c[0].id === 'clipboard-history:rename')?.[0]; + + expect(renameAction).toBeDefined(); + await renameAction?.execute(); + expect(clipboardViewState.startRename).toHaveBeenCalled(); + }); +}); diff --git a/asyar-launcher/src/built-in-features/clipboard-history/index.ts b/asyar-launcher/src/built-in-features/clipboard-history/index.ts index 50cee0f6c..59f246b9d 100644 --- a/asyar-launcher/src/built-in-features/clipboard-history/index.ts +++ b/asyar-launcher/src/built-in-features/clipboard-history/index.ts @@ -1,6 +1,6 @@ import { t } from '../../services/i18n'; import { getHostPlatform } from '../../lib/keyboard/hostPlatform'; -import { clipboardViewState, fetchFullItemForId } from './state.svelte'; +import { clipboardViewState, fetchFullItemForId, getItemTitle } from './state.svelte'; import DefaultView from './DefaultView.svelte'; // Import renamed component import { actionService } from '../../services/action/actionService.svelte'; import { logService } from '../../services/log/logService'; @@ -201,9 +201,8 @@ class ClipboardHistoryExtension implements Extension { private async handleKeydown(event: KeyboardEvent) { if (!this.inView) return; - // We can't easily check filteredItems.length here without importing the state - // But the state is already initialized. const state = clipboardViewState; + if (state.isRenaming) return; if (!state.filteredItems.length) return; if ( @@ -478,6 +477,37 @@ class ClipboardHistoryExtension implements Extension { }, }); + actionService.registerAction({ + id: 'clipboard-history:rename', + title: t('features.clipboard.act.rename'), + label: t('features.clipboard.act.rename'), + description: t('features.clipboard.act.rename_desc'), + icon: 'icon:pencil', + shortcut: 'Mod+Shift+E', + category: 'clipboard-action', + extensionId: 'clipboard-history', + context: ActionContext.EXTENSION_VIEW, + visible: () => Boolean(clipboardViewState.selectedItem), + execute: async () => { + const item = clipboardViewState.selectedItem; + if (!item) return; + clipboardViewState.startRename(); + actionService.openPrompt({ + title: t('features.clipboard.ui.rename_title') || 'Rename Entry...', + value: item.customTitle ?? (item.preview ? getItemTitle(item) : ''), + placeholder: t('features.clipboard.ui.rename_placeholder') || 'Enter custom title...', + contextLabel: t('features.clipboard.title') || 'Clipboard History', + icon: 'clipboard', + onsave: async (newTitle) => { + await clipboardViewState.saveRename(newTitle); + }, + oncancel: () => { + clipboardViewState.cancelRename(); + }, + }); + }, + }); + actionService.registerAction({ id: 'clipboard-history:delete', title: 'Delete', @@ -570,6 +600,7 @@ class ClipboardHistoryExtension implements Extension { actionService.unregisterAction('clipboard-history:reveal'); actionService.unregisterAction('clipboard-history:open-in-browser'); actionService.unregisterAction('clipboard-history:save-as-snippet'); + actionService.unregisterAction('clipboard-history:rename'); actionService.unregisterAction('clipboard-history:delete'); actionService.unregisterAction('clipboard-history:clear-multi-selection'); actionService.unregisterAction('clipboard-history:ask-ai-about-this'); diff --git a/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.test.ts b/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.test.ts index 094f28bba..a6c3e05d7 100644 --- a/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.test.ts +++ b/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.test.ts @@ -1012,3 +1012,46 @@ describe('search token filtering and onSearchChanged', () => { expect(clipboardHistoryStore.loadInitial).toHaveBeenCalledWith(100); }); }); + +describe('rename state management', () => { + it('manages rename lifecycle and updates custom title', async () => { + const mockService = { + setItemCustomTitle: vi.fn().mockResolvedValue(true), + }; + const mockContext = { + getService: vi.fn((name: string) => { + if (name === 'clipboard') return mockService; + return {}; + }), + }; + + clipboardViewState.initializeServices(mockContext as any); + clipboardViewState.setItems([ + { + id: 'item-1', + type: 'text' as any, + preview: 'Original text', + createdAt: 1000, + favorite: false, + }, + ]); + + clipboardViewState.selectedItemId = 'item-1'; + expect(clipboardViewState.isRenaming).toBe(false); + + clipboardViewState.startRename(); + expect(clipboardViewState.isRenaming).toBe(true); + expect(clipboardViewState.renamingItemId).toBe('item-1'); + + await clipboardViewState.saveRename('My Custom Title'); + expect(mockService.setItemCustomTitle).toHaveBeenCalledWith('item-1', 'My Custom Title'); + expect(clipboardViewState.isRenaming).toBe(false); + expect(clipboardViewState.renamingItemId).toBeNull(); + expect(clipboardViewState.items[0].customTitle).toBe('My Custom Title'); + + clipboardViewState.startRename(clipboardViewState.items[0]); + expect(clipboardViewState.isRenaming).toBe(true); + clipboardViewState.cancelRename(); + expect(clipboardViewState.isRenaming).toBe(false); + }); +}); diff --git a/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.ts b/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.ts index 4c2c0be70..c01817a85 100644 --- a/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.ts +++ b/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.ts @@ -19,11 +19,28 @@ import { openerService } from '../../services/opener/openerService'; import { getHostPlatform } from '../../lib/keyboard/hostPlatform'; import { IMAGE_EXT_RE, parseFilePaths } from './filePreview'; +export function getItemTitle(item: { + type: string; + preview?: string; + customTitle?: string; +}): string { + if (item.customTitle?.trim()) { + return item.customTitle.trim(); + } + const preview = item.preview ?? ''; + if (!preview) { + return item.type === 'image' ? 'Image' : item.type === 'files' ? 'Files' : 'Empty'; + } + return preview.substring(0, 200).replace(/\n/g, ' ').trim() || 'Empty'; +} + export class ClipboardViewStateClass { searchQuery = $state(''); lastSearch = $state(Date.now()); items = $state([]); selectedItemId = $state(null); + isRenaming = $state(false); + renamingItemId = $state(null); /** Ordered multi-selection (Cmd/Ctrl+Click, Cmd/Ctrl+Arrow) — append-on-add, * independent of the single `selectedItemId` cursor above. Used by * `pasteMergedSelection` to merge-paste in selection order. */ @@ -272,6 +289,43 @@ export class ClipboardViewStateClass { } } + startRename(item?: ClipboardHistoryItem | null) { + const target = item ?? this.selectedItem; + if (!target) return; + this.renamingItemId = target.id; + this.isRenaming = true; + } + + cancelRename() { + this.isRenaming = false; + this.renamingItemId = null; + } + + async saveRename(newTitle: string) { + if (!this.renamingItemId) return; + const id = this.renamingItemId; + await this.setCustomTitle(id, newTitle); + this.cancelRename(); + } + + async setCustomTitle(itemId: string, title?: string | null): Promise { + if (!this.clipboardService) { + this.logService?.error('Clipboard service not initialized in setCustomTitle'); + return false; + } + try { + const ok = await this.clipboardService.setItemCustomTitle(itemId, title); + if (ok) { + const trimmed = title?.trim() || undefined; + this.items = this.items.map((i) => (i.id === itemId ? { ...i, customTitle: trimmed } : i)); + } + return ok; + } catch (error) { + this.logService?.error(`Error setting custom title for ${itemId}: ${error}`); + return false; + } + } + async deleteItem(itemId: string): Promise { if (!this.clipboardService) { this.logService?.error('Clipboard service not initialized in deleteItem'); diff --git a/asyar-launcher/src/built-in-features/window-management/ManageView.svelte b/asyar-launcher/src/built-in-features/window-management/ManageView.svelte index c2948ab49..f93710f2e 100644 --- a/asyar-launcher/src/built-in-features/window-management/ManageView.svelte +++ b/asyar-launcher/src/built-in-features/window-management/ManageView.svelte @@ -5,8 +5,12 @@ import { windowManagementService } from '../../services/windowManagement/windowManagementService'; import { feedbackService } from '../../services/feedback/feedbackService.svelte'; import { actionService } from '../../services/action/actionService.svelte'; - import { viewManager } from '../../services/extension/viewManager.svelte'; - import { applyCustomLayout, deleteLayout, syncLayoutToIndex } from './layoutLifecycle'; + import { + applyCustomLayout, + deleteLayout, + renameLayout, + syncLayoutToIndex, + } from './layoutLifecycle'; import type { IStorageService } from 'asyar-sdk/contracts'; import { ActionContext } from 'asyar-sdk/contracts'; import { t } from '../../services/i18n'; @@ -52,7 +56,24 @@ const layout = layouts.find((l) => l.id === id); if (!layout) return; windowManagementState.startRename(id); - viewManager.navigateToView('window-management/RenameLayoutView', { searchable: false }); + actionService.openPrompt({ + title: t('features.window_management.rename_layout_title'), + value: layout.name, + placeholder: t('features.window_management.rename_layout_placeholder'), + contextLabel: t('features.window_management.title'), + icon: 'window', + onsave: async (newName) => { + const trimmed = newName.trim(); + if (trimmed) { + await renameLayout(id, trimmed, store ?? windowManagementState.store ?? undefined); + await feedbackService.showHUD(`Renamed to "${trimmed}"`); + } + windowManagementState.clearRename(); + }, + oncancel: () => { + windowManagementState.clearRename(); + }, + }); } async function handleDelete(id: string) { @@ -103,8 +124,8 @@ actionService.registerAction({ id: 'window-management:rename-layout', title: t('features.window_management.ui.rename_title', { name }), - icon: 'icon:edit', - shortcut: 'Mod+R', + icon: 'icon:pencil', + shortcut: 'Mod+Shift+E', extensionId: 'window-management', category: 'window-management', context: ActionContext.EXTENSION_VIEW, @@ -132,6 +153,7 @@ }); onDestroy(() => { + windowManagementState.clearRename(); actionService.unregisterAction('window-management:save-current-window'); actionService.unregisterAction('window-management:apply-layout'); actionService.unregisterAction('window-management:rename-layout'); diff --git a/asyar-launcher/src/built-in-features/window-management/ManageView.test.ts b/asyar-launcher/src/built-in-features/window-management/ManageView.test.ts new file mode 100644 index 000000000..8d52e90c7 --- /dev/null +++ b/asyar-launcher/src/built-in-features/window-management/ManageView.test.ts @@ -0,0 +1,97 @@ +/** @vitest-environment jsdom */ +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { render, screen, fireEvent } from '@testing-library/svelte'; +import ManageView from './ManageView.svelte'; +import { windowManagementState } from './state.svelte'; +import { actionService } from '../../services/action/actionService.svelte'; +import { renameLayout } from './layoutLifecycle'; + +vi.mock('@tauri-apps/api/core', () => ({ + invoke: vi.fn().mockResolvedValue(undefined), + transformCallback: vi.fn(() => 0), +})); + +vi.mock('@tauri-apps/api/event', () => ({ + listen: vi.fn().mockResolvedValue(() => {}), + emit: vi.fn().mockResolvedValue(undefined), +})); + +vi.mock('./layoutLifecycle', () => ({ + applyCustomLayout: vi.fn().mockResolvedValue(undefined), + deleteLayout: vi.fn().mockResolvedValue(undefined), + renameLayout: vi.fn().mockResolvedValue(undefined), + syncLayoutToIndex: vi.fn().mockResolvedValue(undefined), +})); + +vi.mock('../../services/windowManagement/windowManagementService', () => ({ + windowManagementService: { + getWindowBounds: vi.fn().mockResolvedValue({ x: 0, y: 0, width: 1440, height: 900 }), + }, +})); + +vi.mock('../../services/feedback/feedbackService.svelte', () => ({ + feedbackService: { + showHUD: vi.fn().mockResolvedValue(undefined), + report: vi.fn().mockResolvedValue(undefined), + }, +})); + +describe('WindowManagement ManageView', () => { + beforeEach(() => { + windowManagementState.customLayouts = [ + { id: 'l1', name: 'Work Grid', bounds: { x: 0, y: 0, width: 1200, height: 800 } }, + ]; + windowManagementState.setIndex(0); + }); + + afterEach(() => { + windowManagementState.reset(); + vi.restoreAllMocks(); + }); + + it('registers Mod+Shift+E rename action for selected layout', () => { + render(ManageView); + + const renameAction = actionService + .getAllActions() + .find((a) => a.id === 'window-management:rename-layout'); + + expect(renameAction).toBeDefined(); + expect(renameAction?.shortcut).toBe('Mod+Shift+E'); + expect(renameAction?.icon).toBe('icon:pencil'); + }); + + it('opens prompt on rename action and saves new name', async () => { + render(ManageView); + + const renameAction = actionService + .getAllActions() + .find((a) => a.id === 'window-management:rename-layout'); + + expect(windowManagementState.renamingLayoutId).toBeNull(); + await renameAction?.execute(); + expect(windowManagementState.renamingLayoutId).toBe('l1'); + + expect(actionService.activePrompt).toBeDefined(); + expect(actionService.activePrompt?.value).toBe('Work Grid'); + + await actionService.activePrompt?.onsave('Coding Split'); + + expect(renameLayout).toHaveBeenCalledWith('l1', 'Coding Split', undefined); + expect(windowManagementState.renamingLayoutId).toBeNull(); + }); + + it('cancels renaming when prompt is cancelled', async () => { + render(ManageView); + + const renameAction = actionService + .getAllActions() + .find((a) => a.id === 'window-management:rename-layout'); + + await renameAction?.execute(); + expect(windowManagementState.renamingLayoutId).toBe('l1'); + + actionService.activePrompt?.oncancel?.(); + expect(windowManagementState.renamingLayoutId).toBeNull(); + }); +}); diff --git a/asyar-launcher/src/built-in-features/window-management/index.ts b/asyar-launcher/src/built-in-features/window-management/index.ts index 1242ca9d0..350c1c35b 100644 --- a/asyar-launcher/src/built-in-features/window-management/index.ts +++ b/asyar-launcher/src/built-in-features/window-management/index.ts @@ -236,7 +236,7 @@ class WindowManagementExtension implements Extension { private handleKeydown(event: KeyboardEvent): void { if (!this.inView) return; - if (isAnyModalOpen(document)) return; + if (windowManagementState.renamingLayoutId || isAnyModalOpen(document)) return; const layouts = windowManagementState.customLayouts; if (!layouts.length) return; diff --git a/asyar-launcher/src/components/index.ts b/asyar-launcher/src/components/index.ts index 8287fedbd..22757a76e 100644 --- a/asyar-launcher/src/components/index.ts +++ b/asyar-launcher/src/components/index.ts @@ -32,6 +32,7 @@ export { default as FeedbackMessage } from './feedback/FeedbackMessage.svelte'; // Layout export { default as ActionListPopup } from './layout/ActionListPopup.svelte'; +export { default as ActionPromptPopover } from './layout/ActionPromptPopover.svelte'; export { default as AppBar } from './layout/AppBar.svelte'; export { default as BottomActionBar } from './layout/BottomActionBar.svelte'; export { default as BottomBarButton } from './layout/BottomBarButton.svelte'; diff --git a/asyar-launcher/src/components/layout/ActionListPopup.navigation.test.ts b/asyar-launcher/src/components/layout/ActionListPopup.navigation.test.ts new file mode 100644 index 000000000..f3f5ef413 --- /dev/null +++ b/asyar-launcher/src/components/layout/ActionListPopup.navigation.test.ts @@ -0,0 +1,188 @@ +// @vitest-environment jsdom +import { render, fireEvent } from '@testing-library/svelte'; +import { tick } from 'svelte'; +import { describe, expect, it, vi, beforeEach } from 'vitest'; +import ActionListPopup from './ActionListPopup.svelte'; +import { actionService } from '../../services/action/actionService.svelte'; + +vi.mock('../../services/log/logService', () => ({ logService: { debug: vi.fn() } })); +vi.mock('../../services/i18n', () => ({ t: (key: string) => key })); +vi.mock('../../services/action/invokeAction', () => ({ + invokeAction: vi.fn(async (action) => { + await action.execute(); + }), +})); + +const action = (id: string, label: string, execute: () => void | Promise = vi.fn()) => ({ + id, + label, + displayCategory: 'Default', + execute, +}); + +describe('ActionListPopup navigation stack', () => { + beforeEach(() => { + actionService.activePrompt = null; + actionService.panelSearchQuery = ''; + vi.clearAllMocks(); + }); + + it('escapes through action search clearing before closing', async () => { + const onclose = vi.fn(); + const { getByPlaceholderText } = render(ActionListPopup, { + props: { + availableActions: [action('copy', 'Copy'), action('rename', 'Rename')], + onclose, + }, + }); + + const searchInput = getByPlaceholderText( + 'dialogs.action_list.search_placeholder', + ) as HTMLInputElement; + await fireEvent.input(searchInput, { target: { value: 'ren' } }); + expect(searchInput.value).toBe('ren'); + + // First Esc clears search query + await fireEvent.keyDown(searchInput, { key: 'Escape' }); + expect(searchInput.value).toBe(''); + expect(onclose).not.toHaveBeenCalled(); + + // Second Esc closes popup + await fireEvent.keyDown(searchInput, { key: 'Escape' }); + expect(onclose).toHaveBeenCalledTimes(1); + }); + + it('navigates into prompt view, unwinds Escape stack step-by-step preserving action search query', async () => { + const onclose = vi.fn(); + const oncancel = vi.fn(); + const onsave = vi.fn(); + + const renameAction = action('rename', 'Rename Entry', () => { + actionService.openPrompt({ + title: 'Rename Entry...', + value: 'My Old Item', + placeholder: 'Enter new title...', + contextLabel: 'Clipboard History', + onsave, + oncancel, + }); + }); + + const { getByPlaceholderText, queryByPlaceholderText } = render(ActionListPopup, { + props: { + availableActions: [action('copy', 'Copy'), renameAction], + onclose, + }, + }); + + const searchInput = getByPlaceholderText( + 'dialogs.action_list.search_placeholder', + ) as HTMLInputElement; + await fireEvent.input(searchInput, { target: { value: 'ren' } }); + expect(searchInput.value).toBe('ren'); + + // Press Enter to select the rename action + await fireEvent.keyDown(searchInput, { key: 'Enter' }); + await tick(); + + // Now prompt view is active! + const promptInput = getByPlaceholderText('Enter new title...') as HTMLInputElement; + expect(promptInput).toBeTruthy(); + expect(promptInput.value).toBe('My Old Item'); + + // Type something in prompt + await fireEvent.input(promptInput, { target: { value: 'Edited Title' } }); + expect(promptInput.value).toBe('Edited Title'); + + // Step 1: Escape with text in prompt clears prompt input + await fireEvent.keyDown(promptInput, { key: 'Escape' }); + expect(promptInput.value).toBe(''); + expect(oncancel).not.toHaveBeenCalled(); + expect(queryByPlaceholderText('Enter new title...')).toBeTruthy(); + + // Step 2: Escape with empty prompt cancels prompt and returns to action list + await fireEvent.keyDown(promptInput, { key: 'Escape' }); + await tick(); + expect(oncancel).toHaveBeenCalledTimes(1); + expect(queryByPlaceholderText('Enter new title...')).toBeNull(); + + // The action search input is back and its search query "ren" is STILL INTACT! + const restoredSearchInput = getByPlaceholderText( + 'dialogs.action_list.search_placeholder', + ) as HTMLInputElement; + expect(restoredSearchInput).toBeTruthy(); + expect(restoredSearchInput.value).toBe('ren'); + expect(onclose).not.toHaveBeenCalled(); + + // Step 3: Escape clears action search input "ren" -> "" + await fireEvent.keyDown(restoredSearchInput, { key: 'Escape' }); + expect(restoredSearchInput.value).toBe(''); + expect(onclose).not.toHaveBeenCalled(); + + // Step 4: Escape closes ActionListPopup + await fireEvent.keyDown(restoredSearchInput, { key: 'Escape' }); + expect(onclose).toHaveBeenCalledTimes(1); + }); + + it('handles direct prompt opening without action list stack', async () => { + const onclose = vi.fn(); + const oncancel = vi.fn(); + const onsave = vi.fn(); + + actionService.activePrompt = { + title: 'Rename Directly', + value: 'Direct Value', + placeholder: 'Type direct...', + onsave, + oncancel, + }; + + const { getByPlaceholderText } = render(ActionListPopup, { + props: { + availableActions: [], + onclose, + }, + }); + + const promptInput = getByPlaceholderText('Type direct...') as HTMLInputElement; + expect(promptInput.value).toBe('Direct Value'); + + // Esc with text clears input + await fireEvent.keyDown(promptInput, { key: 'Escape' }); + expect(promptInput.value).toBe(''); + expect(oncancel).not.toHaveBeenCalled(); + expect(onclose).not.toHaveBeenCalled(); + + // Esc with empty input cancels and closes popup immediately + await fireEvent.keyDown(promptInput, { key: 'Escape' }); + expect(oncancel).toHaveBeenCalledTimes(1); + expect(onclose).toHaveBeenCalledTimes(1); + }); + + it('saves and closes on Enter in prompt view', async () => { + const onclose = vi.fn(); + const onsave = vi.fn(); + + actionService.activePrompt = { + title: 'Rename Directly', + value: 'Direct Value', + placeholder: 'Type direct...', + onsave, + oncancel: vi.fn(), + }; + + const { getByPlaceholderText } = render(ActionListPopup, { + props: { + availableActions: [], + onclose, + }, + }); + + const promptInput = getByPlaceholderText('Type direct...') as HTMLInputElement; + await fireEvent.input(promptInput, { target: { value: 'Brand New Title' } }); + await fireEvent.keyDown(promptInput, { key: 'Enter' }); + + expect(onsave).toHaveBeenCalledWith('Brand New Title'); + expect(onclose).toHaveBeenCalledTimes(1); + }); +}); diff --git a/asyar-launcher/src/components/layout/ActionListPopup.svelte b/asyar-launcher/src/components/layout/ActionListPopup.svelte index a1797de47..aeabe7f93 100644 --- a/asyar-launcher/src/components/layout/ActionListPopup.svelte +++ b/asyar-launcher/src/components/layout/ActionListPopup.svelte @@ -3,17 +3,35 @@ import Input from '../base/Input.svelte'; import LauncherListRow from '../list/LauncherListRow.svelte'; import EmptyState from '../feedback/EmptyState.svelte'; + import KeyboardHint from '../base/KeyboardHint.svelte'; + import Icon from '../base/Icon.svelte'; import { invokeAction } from '../../services/action/invokeAction'; - import type { ApplicationAction } from '../../services/action/actionService.svelte'; + import { + actionService, + type ApplicationAction, + type ActionPromptConfig, + } from '../../services/action/actionService.svelte'; import { filterActions } from './actionFilter'; import { scrollSelectedIntoView, resetListScroll } from '../../lib/listScroll'; import { useListSelection } from '../../lib/listSelection.svelte'; import { groupActionsForDisplay } from './actionListOrdering'; import { toResolvedIcon } from '../../lib/icon'; import { t } from '../../services/i18n'; + import { tick } from 'svelte'; type ActionForDisplay = ApplicationAction & { displayCategory: string }; + type ActionStackEntry = + | { + type: 'actions'; + title?: string; + actions?: ActionForDisplay[]; + } + | { + type: 'prompt'; + config: ActionPromptConfig; + }; + let { availableActions = [], selectedItemName = null, @@ -28,12 +46,27 @@ let showHeader = $derived(!inExtensionView && !!selectedItemName); - let searchQuery = $state(''); + let searchQuery = $state(actionService.panelSearchQuery); + $effect(() => { + actionService.panelSearchQuery = searchQuery; + }); - let filteredForSearch = $derived(filterActions(availableActions, searchQuery)); + let promptText = $state(actionService.activePrompt?.value ?? ''); - let groupedActions = $derived(groupActionsForDisplay(filteredForSearch)); + let viewStack = $state( + actionService.activePrompt + ? [{ type: 'prompt', config: actionService.activePrompt }] + : [{ type: 'actions' }], + ); + let currentView = $derived(viewStack[viewStack.length - 1]); + + let activeActionList = $derived( + currentView?.type === 'actions' && currentView.actions ? currentView.actions : availableActions, + ); + + let filteredForSearch = $derived(filterActions(activeActionList, searchQuery)); + let groupedActions = $derived(groupActionsForDisplay(filteredForSearch)); let flatActions = $derived(groupedActions.flatMap((g) => g.actions)); let popupRef = $state(); @@ -41,8 +74,6 @@ $effect(() => { let settleFrame: number | undefined; - // Force a paint of the pre-transition state before flipping to settled; - // cleanup also covers rapid ⌘K toggles that unmount between frames. const paintFrame = requestAnimationFrame(() => { settleFrame = requestAnimationFrame(() => (entering = false)); }); @@ -76,14 +107,82 @@ } }); + // Watch for prompts opened via actionService.openPrompt(...) + $effect(() => { + const prompt = actionService.activePrompt; + if (prompt) { + const isAlreadyOnTop = + viewStack.length > 0 && + viewStack[viewStack.length - 1].type === 'prompt' && + (viewStack[viewStack.length - 1] as any).config === prompt; + if (!isAlreadyOnTop) { + promptText = prompt.value ?? ''; + viewStack = [...viewStack, { type: 'prompt', config: prompt }]; + void tick().then(() => { + const input = popupRef?.querySelector('.prompt-body input') as HTMLInputElement | null; + input?.focus({ preventScroll: true }); + input?.select(); + }); + } + } + }); + function handleKeydown(event: KeyboardEvent) { + if (currentView?.type === 'prompt') { + if (event.key === 'Escape') { + event.preventDefault(); + event.stopPropagation(); + if (promptText.length > 0) { + promptText = ''; + } else { + const config = currentView.config; + config.oncancel?.(); + actionService.activePrompt = null; + viewStack = viewStack.slice(0, -1); + if (viewStack.length === 0) { + closePopup(); + } else { + void tick().then(() => { + popupRef + ?.querySelector('.action-search input') + ?.focus({ preventScroll: true }); + }); + } + } + return; + } + + if (event.key === 'Enter') { + event.preventDefault(); + event.stopPropagation(); + const config = currentView.config; + const valToSave = promptText; + actionService.activePrompt = null; + closePopup(); + void config.onsave(valToSave); + return; + } + + return; + } + if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); - // Esc clears the filter first, then closes on the next press. + // Esc clears the filter first, then closes or pops stack if (searchQuery.length > 0) { searchQuery = ''; + actionService.panelSearchQuery = ''; + } else if (viewStack.length > 1) { + viewStack = viewStack.slice(0, -1); + searchQuery = ''; + void tick().then(() => { + popupRef + ?.querySelector('.action-search input') + ?.focus({ preventScroll: true }); + }); } else { + actionService.panelSearchQuery = ''; closePopup(); } return; @@ -115,12 +214,28 @@ const action = flatActions.find((a) => a.id === actionId); if (!action) return; - // Close the popup BEFORE awaiting the confirm dialog so the user can't - // pick a second action while the dialog is up. The dialog is rendered - // by the global DialogHost; it doesn't need this popup to stay open. - closePopup(); + if ((action as any).children?.length) { + viewStack = [ + ...viewStack, + { + type: 'actions', + title: action.label, + actions: (action as any).children, + }, + ]; + searchQuery = ''; + return; + } + + if (action.confirm && !action.confirmInExecute) { + closePopup(); + } await invokeAction(action); + + if (!actionService.activePrompt) { + closePopup(); + } } function closePopup() { @@ -128,15 +243,41 @@ onclose?.(); } + function onWindowMousedown(e: MouseEvent) { + const target = e.target as Node | null; + if (target && !popupRef?.contains(target)) { + if (currentView?.type === 'prompt') { + currentView.config.oncancel?.(); + actionService.activePrompt = null; + } + closePopup(); + } + } + + $effect(() => { + window.addEventListener('mousedown', onWindowMousedown); + return () => window.removeEventListener('mousedown', onWindowMousedown); + }); + $effect(() => { const timer = setTimeout(() => { - popupRef?.querySelector('input')?.focus({ preventScroll: true }); + if (currentView?.type === 'prompt') { + const input = popupRef?.querySelector('.prompt-body input') as HTMLInputElement | null; + input?.focus({ preventScroll: true }); + input?.select(); + } else { + popupRef + ?.querySelector('.action-search input') + ?.focus({ preventScroll: true }); + } }, 50); popupRef?.addEventListener('keydown', handleKeydown); return () => { clearTimeout(timer); popupRef?.removeEventListener('keydown', handleKeydown); - searchQuery = ''; + if (!actionService.activePrompt) { + actionService.panelSearchQuery = ''; + } }; }); @@ -148,49 +289,87 @@ tabindex="-1" role="dialog" aria-modal="true" - aria-labelledby="action-list-heading" + aria-labelledby={currentView?.type === 'prompt' ? 'action-prompt-heading' : 'action-list-heading'} > -

{t('actions_popup.sr_heading')}

- -
- {#if showHeader} - - {/if} - {#snippet iconSpacer()}{/snippet} - {#each groupedActions as { actions: groupActions }, groupIndex} - {@const groupHasIcons = groupActions.some((a) => toResolvedIcon(a.icon))} -
- {#each groupActions as action} - {@const flatIndex = flatActions.indexOf(action)} -
- handleActionSelect(action.id)} - data-index={flatIndex} - tabindex="-1" - icon={action.icon} - extensionId={action.extensionId} - leading={groupHasIcons && !toResolvedIcon(action.icon) ? iconSpacer : undefined} - title={action.label} - shortcut={action.shortcut} - shortcutPlacement="trailing" - /> + {#if currentView?.type === 'prompt'} + {@const config = currentView.config} +
+

{config.title}

+
+ +
+ +
+ + - - + +
+ {:else} +

{t('actions_popup.sr_heading')}

+ +
+ {#if showHeader} + + {/if} + {#snippet iconSpacer()}{/snippet} + {#each groupedActions as { actions: groupActions }, groupIndex} + {@const groupHasIcons = groupActions.some((a) => toResolvedIcon(a.icon))} +
+ {#each groupActions as action} + {@const flatIndex = flatActions.indexOf(action)} +
+ handleActionSelect(action.id)} + data-index={flatIndex} + tabindex="-1" + icon={action.icon} + extensionId={action.extensionId} + leading={groupHasIcons && !toResolvedIcon(action.icon) ? iconSpacer : undefined} + title={action.label} + shortcut={action.shortcut} + shortcutPlacement="trailing" + /> +
+ {/each} +
+ {:else} + + {/each} +
+ + + {/if}
diff --git a/asyar-launcher/src/components/layout/ActionPromptPopover.svelte b/asyar-launcher/src/components/layout/ActionPromptPopover.svelte new file mode 100644 index 000000000..052d87a68 --- /dev/null +++ b/asyar-launcher/src/components/layout/ActionPromptPopover.svelte @@ -0,0 +1,230 @@ + + + + + diff --git a/asyar-launcher/src/components/layout/ActionPromptPopover.test.ts b/asyar-launcher/src/components/layout/ActionPromptPopover.test.ts new file mode 100644 index 000000000..b46984a1d --- /dev/null +++ b/asyar-launcher/src/components/layout/ActionPromptPopover.test.ts @@ -0,0 +1,99 @@ +// @vitest-environment jsdom +import { render, fireEvent } from '@testing-library/svelte'; +import { tick } from 'svelte'; +import { describe, expect, it, vi } from 'vitest'; +import ActionPromptPopover from './ActionPromptPopover.svelte'; + +vi.mock('../../services/i18n', () => ({ t: (key: string) => key })); + +describe('ActionPromptPopover', () => { + it('renders title, input with initial value, and footer hints', () => { + const { getByRole, getByDisplayValue, getByText } = render(ActionPromptPopover, { + props: { + title: 'Rename Entry...', + value: 'My Old Name', + contextLabel: 'Clipboard History', + onsave: vi.fn(), + oncancel: vi.fn(), + }, + }); + + expect(getByRole('dialog')).toBeTruthy(); + expect(getByText('Rename Entry...')).toBeTruthy(); + expect(getByDisplayValue('My Old Name')).toBeTruthy(); + expect(getByText('Clipboard History')).toBeTruthy(); + }); + + it('calls onsave with the updated text when Enter is pressed', async () => { + const onsave = vi.fn(); + const { getByRole } = render(ActionPromptPopover, { + props: { + title: 'Rename Entry...', + value: 'Old Title', + onsave, + oncancel: vi.fn(), + }, + }); + + const input = getByRole('textbox') as HTMLInputElement; + await fireEvent.input(input, { target: { value: 'New Custom Title' } }); + await fireEvent.keyDown(input, { key: 'Enter' }); + + expect(onsave).toHaveBeenCalledWith('New Custom Title'); + }); + + it('clears input on first Escape, then calls oncancel on second Escape', async () => { + const oncancel = vi.fn(); + const { getByRole } = render(ActionPromptPopover, { + props: { + title: 'Rename Entry...', + value: 'Old Title', + onsave: vi.fn(), + oncancel, + }, + }); + + const input = getByRole('textbox') as HTMLInputElement; + expect(input.value).toBe('Old Title'); + + // First Escape: clears the text + await fireEvent.keyDown(input, { key: 'Escape' }); + expect(input.value).toBe(''); + expect(oncancel).not.toHaveBeenCalled(); + + // Second Escape: cancels / closes + await fireEvent.keyDown(input, { key: 'Escape' }); + expect(oncancel).toHaveBeenCalledTimes(1); + }); + + it('calls oncancel immediately on Escape when input is already empty', async () => { + const oncancel = vi.fn(); + const { getByRole } = render(ActionPromptPopover, { + props: { + title: 'Rename Entry...', + value: '', + onsave: vi.fn(), + oncancel, + }, + }); + + const input = getByRole('textbox'); + await fireEvent.keyDown(input, { key: 'Escape' }); + expect(oncancel).toHaveBeenCalledTimes(1); + }); + + it('calls oncancel on mousedown outside the popover', async () => { + const oncancel = vi.fn(); + render(ActionPromptPopover, { + props: { + title: 'Rename Entry...', + value: 'Old Title', + onsave: vi.fn(), + oncancel, + }, + }); + + await fireEvent.mouseDown(document.body); + expect(oncancel).toHaveBeenCalled(); + }); +}); diff --git a/asyar-launcher/src/lib/ipc/clipboardHistoryCommands.ts b/asyar-launcher/src/lib/ipc/clipboardHistoryCommands.ts index f96373fbb..5ba6c2b3e 100644 --- a/asyar-launcher/src/lib/ipc/clipboardHistoryCommands.ts +++ b/asyar-launcher/src/lib/ipc/clipboardHistoryCommands.ts @@ -15,6 +15,7 @@ export interface StoredClipboardItem { metadata?: Record; sourceApp?: Record; redactedKinds?: string[]; + customTitle?: string; } export interface StoredClipboardListItem { @@ -26,6 +27,7 @@ export interface StoredClipboardListItem { metadata?: Record; sourceApp?: Record; redactedKinds?: string[]; + customTitle?: string; } export interface ClipboardCursor { @@ -178,3 +180,7 @@ export async function clipboardDeleteItem(id: string): Promise { return invokeSafe('clipboard_clear_non_favorites'); } + +export async function clipboardSetCustomTitle(id: string, title?: string | null): Promise { + return invokeSafe('clipboard_set_custom_title', { id, title: title ?? null }); +} diff --git a/asyar-launcher/src/lib/keyboard/launcherKeyboard.test.ts b/asyar-launcher/src/lib/keyboard/launcherKeyboard.test.ts index 671c1ebc5..a77114679 100644 --- a/asyar-launcher/src/lib/keyboard/launcherKeyboard.test.ts +++ b/asyar-launcher/src/lib/keyboard/launcherKeyboard.test.ts @@ -725,6 +725,25 @@ describe('launcherKeyboard characterization tests', () => { handleGlobalKeydown(e2); expect(accessoryRef.togglePopover).toHaveBeenCalledTimes(2); }); + + it('bails early for navigation keys when an .action-prompt-popover is present in the DOM', () => { + (document as any).querySelector = (selector: string) => + selector === '.action-prompt-popover' ? ({} as Element) : null; + const deps = createMockDeps(); + const { handleGlobalKeydown } = createKeyboardHandlers(deps); + + try { + const escEvent = createKeyEvent('Escape'); + handleGlobalKeydown(escEvent); + expect(escEvent.preventDefault).not.toHaveBeenCalled(); + + const enterEvent = createKeyEvent('Enter'); + handleGlobalKeydown(enterEvent); + expect(enterEvent.preventDefault).not.toHaveBeenCalled(); + } finally { + (document as any).querySelector = () => null; + } + }); }); describe('Cmd/Ctrl+, Open Settings', () => { diff --git a/asyar-launcher/src/lib/keyboard/launcherKeyboard.ts b/asyar-launcher/src/lib/keyboard/launcherKeyboard.ts index 2b79c2e3b..c28eed68d 100644 --- a/asyar-launcher/src/lib/keyboard/launcherKeyboard.ts +++ b/asyar-launcher/src/lib/keyboard/launcherKeyboard.ts @@ -442,15 +442,21 @@ export function createKeyboardHandlers(deps: KeyboardDeps) { if (event.isComposing) { return; } - // Searchbar accessory popover open: bail for navigation keys so the - // popover's own keydown handler (Escape/Arrow/Enter/Tab) wins. The - // launcher's listener is registered window+capture at page mount and + // Searchbar accessory popover (⌘P) or action prompt popover (e.g. rename) open: + // bail for navigation keys so the popover's own keydown handler (Escape/Enter/Arrow/Tab) + // wins. The launcher's listener is registered window+capture at page mount and // would otherwise fire first (DOM same-target capture listeners run in // registration order), turning Escape-to-close-popover into Escape- // navigates-back. ⌘Q / ⌘P / ⌘K / ⌘, still go through below — those are // launcher-level shortcuts that should keep working with the popover up. if ( - searchBarAccessoryService.popoverOpen && + (searchBarAccessoryService.popoverOpen || + actionService.activePrompt !== null || + Boolean( + typeof document !== 'undefined' && + (document.querySelector('.action-prompt-popover') || + document.querySelector('.action-popup')), + )) && ['Escape', 'ArrowUp', 'ArrowDown', 'Enter', 'Tab'].includes(event.key) && !event.metaKey && !event.ctrlKey diff --git a/asyar-launcher/src/locales/en.json b/asyar-launcher/src/locales/en.json index 9b8dc91f5..0bebe8615 100644 --- a/asyar-launcher/src/locales/en.json +++ b/asyar-launcher/src/locales/en.json @@ -1067,6 +1067,8 @@ "clear_history_desc": "Remove all non-favorite clipboard items", "copy_text_from_image": "Copy Text from Image", "copy_text_from_image_desc": "Extract and copy text from this image to clipboard", + "rename": "Rename Entry...", + "rename_desc": "Set a custom display title for this clipboard item", "open_preview_desc": "Open this image or file in the default viewer", "reveal_desc": "Show this file in the system file manager" }, @@ -1099,6 +1101,9 @@ "words": "Words", "dimensions": "Dimensions", "size": "Size", + "rename_title": "Rename Entry...", + "rename_placeholder": "Enter custom title...", + "custom_title": "Custom Title", "copied": "Copied" } }, diff --git a/asyar-launcher/src/locales/fr.json b/asyar-launcher/src/locales/fr.json index 54aa1c046..0976789be 100644 --- a/asyar-launcher/src/locales/fr.json +++ b/asyar-launcher/src/locales/fr.json @@ -1067,6 +1067,8 @@ "clear_history_desc": "Supprimer tous les éléments non favoris", "copy_text_from_image": "Copier le texte de l'image", "copy_text_from_image_desc": "Extraire et copier le texte de cette image dans le presse-papiers", + "rename": "Renommer l'entrée...", + "rename_desc": "Définir un titre d'affichage personnalisé pour cet élément du presse-papiers", "open_preview_desc": "Ouvrir cette image ou ce fichier dans le visualiseur par défaut", "reveal_desc": "Afficher ce fichier dans le gestionnaire de fichiers du système" }, @@ -1099,6 +1101,9 @@ "words": "Mots", "dimensions": "Dimensions", "size": "Taille", + "rename_title": "Renommer l'entrée...", + "rename_placeholder": "Saisir un titre personnalisé...", + "custom_title": "Titre personnalisé", "copied": "Copié" } }, diff --git a/asyar-launcher/src/locales/pt-BR.json b/asyar-launcher/src/locales/pt-BR.json index 85981d304..2d15ca4a4 100644 --- a/asyar-launcher/src/locales/pt-BR.json +++ b/asyar-launcher/src/locales/pt-BR.json @@ -1067,6 +1067,8 @@ "clear_history_desc": "Remover todos os itens não favoritos da área de transferência", "copy_text_from_image": "Copiar texto da imagem", "copy_text_from_image_desc": "Extrair e copiar texto desta imagem para a área de transferência", + "rename": "Renomear entrada...", + "rename_desc": "Definir um título de exibição personalizado para este item da área de transferência", "open_preview_desc": "Abrir esta imagem ou arquivo no visualizador padrão", "reveal_desc": "Mostrar este arquivo no gerenciador de arquivos do sistema" }, @@ -1099,6 +1101,9 @@ "words": "Palavras", "dimensions": "Dimensões", "size": "Tamanho", + "rename_title": "Renomear entrada...", + "rename_placeholder": "Digite o título personalizado...", + "custom_title": "Título personalizado", "copied": "Copiado" } }, diff --git a/asyar-launcher/src/locales/zh-CN.json b/asyar-launcher/src/locales/zh-CN.json index 2eab0e994..41b451e2b 100644 --- a/asyar-launcher/src/locales/zh-CN.json +++ b/asyar-launcher/src/locales/zh-CN.json @@ -1067,6 +1067,8 @@ "clear_history_desc": "移除所有非收藏的剪贴板项目", "copy_text_from_image": "从图像复制文本", "copy_text_from_image_desc": "提取此图像中的文本并复制到剪贴板", + "rename": "重命名条目...", + "rename_desc": "为此剪贴板项目设置自定义显示标题", "open_preview_desc": "在默认查看器中打开此图像或文件", "reveal_desc": "在系统文件管理器中显示此文件" }, @@ -1099,6 +1101,9 @@ "words": "字数", "dimensions": "尺寸", "size": "大小", + "rename_title": "重命名条目...", + "rename_placeholder": "输入自定义标题...", + "custom_title": "自定义标题", "copied": "已复制" } }, diff --git a/asyar-launcher/src/locales/zh-Hant.json b/asyar-launcher/src/locales/zh-Hant.json index 40da0ac74..ec7d7b9b7 100644 --- a/asyar-launcher/src/locales/zh-Hant.json +++ b/asyar-launcher/src/locales/zh-Hant.json @@ -1067,6 +1067,8 @@ "clear_history_desc": "移除所有非最愛的剪貼簿項目", "copy_text_from_image": "從影像複製文字", "copy_text_from_image_desc": "擷取此影像中的文字並複製到剪貼簿", + "rename": "重新命名項目...", + "rename_desc": "為此剪貼簿項目設定自訂顯示標題", "open_preview_desc": "在預設檢視器中開啟此影像或檔案", "reveal_desc": "在系統檔案管理員中顯示此檔案" }, @@ -1099,6 +1101,9 @@ "words": "字數", "dimensions": "尺寸", "size": "大小", + "rename_title": "重新命名項目...", + "rename_placeholder": "輸入自訂標題...", + "custom_title": "自訂標題", "copied": "已複製" } }, diff --git a/asyar-launcher/src/routes/+page.svelte b/asyar-launcher/src/routes/+page.svelte index badf3c6e6..30168f0ba 100644 --- a/asyar-launcher/src/routes/+page.svelte +++ b/asyar-launcher/src/routes/+page.svelte @@ -151,11 +151,23 @@ function handleActionPanelClose() { isActionPanelOpen = false; + actionService.activePrompt = null; + actionService.panelSearchQuery = ''; if (!controller.assignShortcutTarget && !controller.assignAliasTarget) { keyboard.restoreSearchFocus({ select: true }); } } + $effect(() => { + actionService.setPanelOpener(() => { + actionService.refreshFiltered(); + isActionPanelOpen = true; + }); + return () => { + actionService.setPanelOpener(undefined); + }; + }); + // Ensure switching from a scrolled root results list into a full-pane view // starts at scrollTop 0 (each view owns its own internal scroller). $effect(() => { diff --git a/asyar-launcher/src/services/action/actionService.svelte.ts b/asyar-launcher/src/services/action/actionService.svelte.ts index 0c135b473..abb5f1686 100644 --- a/asyar-launcher/src/services/action/actionService.svelte.ts +++ b/asyar-launcher/src/services/action/actionService.svelte.ts @@ -72,6 +72,18 @@ function buildMacosConfirmMessage(appName: string, scan: UninstallScanResult): s return lines.join(' '); } +export interface ActionPromptConfig { + title: string; + value?: string; + placeholder?: string; + contextLabel?: string; + icon?: string; + saveLabel?: string; + cancelLabel?: string; + onsave: (val: string) => Promise | void; + oncancel?: () => void; +} + // This interface might need adjustment if ApplicationAction should also use the enum export interface ApplicationAction { id: string; @@ -139,6 +151,29 @@ export class ActionService implements IActionService { // Svelte 5 reactive state public filteredActions = $state([]); + public panelSearchQuery = $state(''); + public openedFromActionPanel = $state(false); + public activePrompt = $state(null); + private panelOpener?: () => void; + + public setPanelOpener(fn?: () => void) { + this.panelOpener = fn; + } + + public openActionPanel() { + this.panelOpener?.(); + } + + public openPrompt(config: ActionPromptConfig) { + this.activePrompt = config; + this.openActionPanel(); + } + + public closePrompt() { + const prompt = this.activePrompt; + this.activePrompt = null; + prompt?.oncancel?.(); + } /** * Primary action for the active extension view, shown in BottomActionBar with diff --git a/asyar-launcher/src/services/clipboard/clipboardHistoryService.ts b/asyar-launcher/src/services/clipboard/clipboardHistoryService.ts index 56b3fb238..d974b032f 100644 --- a/asyar-launcher/src/services/clipboard/clipboardHistoryService.ts +++ b/asyar-launcher/src/services/clipboard/clipboardHistoryService.ts @@ -747,6 +747,19 @@ export class ClipboardHistoryService implements IClipboardHistoryService { } } + /** + * Set custom display title of a history item + */ + public async setItemCustomTitle(itemId: string, title?: string | null): Promise { + try { + await clipboardHistoryStore.setCustomTitle(itemId, title); + return true; + } catch (error) { + logService.error(`Error setting item custom title: ${error}`); + return false; + } + } + /** * Delete an item from history */ diff --git a/asyar-launcher/src/services/clipboard/stores/clipboardHistoryStore.svelte.ts b/asyar-launcher/src/services/clipboard/stores/clipboardHistoryStore.svelte.ts index 7ed5c7fef..69c48bb1a 100644 --- a/asyar-launcher/src/services/clipboard/stores/clipboardHistoryStore.svelte.ts +++ b/asyar-launcher/src/services/clipboard/stores/clipboardHistoryStore.svelte.ts @@ -8,6 +8,7 @@ import { clipboardGetItem, clipboardRecordCapture, clipboardToggleFavorite, + clipboardSetCustomTitle, clipboardDeleteItem, clipboardClearNonFavorites, type StoredClipboardItem, @@ -234,6 +235,21 @@ export class ClipboardHistoryStoreClass { this.#notify({ type: 'upsert', itemId: id }); } + async setCustomTitle(id: string, title?: string | null): Promise { + const trimmed = title?.trim() || null; + await clipboardSetCustomTitle(id, trimmed); + + const updateItem = (item: ListItem): ListItem => + item.id === id ? { ...item, customTitle: trimmed ?? undefined } : item; + + this.favorites = this.favorites.map(updateItem); + this.recent = this.recent.map(updateItem); + if (this.searchResults) { + this.searchResults = this.searchResults.map(updateItem); + } + this.#notify({ type: 'upsert', itemId: id }); + } + async deleteHistoryItem(id: string): Promise { const res = await clipboardDeleteItem(id); this.favorites = this.favorites.filter((i) => i.id !== id); diff --git a/asyar-launcher/src/services/extension/ExtensionIpcRouter.ts b/asyar-launcher/src/services/extension/ExtensionIpcRouter.ts index f6b29ac77..97981b455 100644 --- a/asyar-launcher/src/services/extension/ExtensionIpcRouter.ts +++ b/asyar-launcher/src/services/extension/ExtensionIpcRouter.ts @@ -113,6 +113,7 @@ export const METHOD_PARAM_SCHEMAS: Record = { 'clipboard:toggleItemFavorite': ['itemId'], 'clipboard:deleteItem': ['itemId'], 'clipboard:clearNonFavorites': [], + 'clipboard:setItemCustomTitle': ['itemId', 'title'], 'clipboard:readCurrentText': [], 'clipboard:stripHtml': ['html'], 'clipboard:stripRtf': ['rtf'], diff --git a/asyar-sdk/src/services/ClipboardHistoryServiceProxy.ts b/asyar-sdk/src/services/ClipboardHistoryServiceProxy.ts index 0e6c23496..776c9a480 100644 --- a/asyar-sdk/src/services/ClipboardHistoryServiceProxy.ts +++ b/asyar-sdk/src/services/ClipboardHistoryServiceProxy.ts @@ -73,6 +73,10 @@ export class ClipboardHistoryServiceProxy return this.broker.invoke('clipboard:clearNonFavorites'); } + setItemCustomTitle(itemId: string, title?: string | null): Promise { + return this.broker.invoke('clipboard:setItemCustomTitle', { itemId, title }); + } + normalizeImageData(content: string): string { if (content.startsWith('data:image')) return content; return `data:image/png;base64,${content}`; diff --git a/asyar-sdk/src/services/IClipboardHistoryService.ts b/asyar-sdk/src/services/IClipboardHistoryService.ts index 3761d49d1..34dc77d90 100644 --- a/asyar-sdk/src/services/IClipboardHistoryService.ts +++ b/asyar-sdk/src/services/IClipboardHistoryService.ts @@ -25,6 +25,8 @@ export interface IClipboardHistoryService { toggleItemFavorite(itemId: string): Promise; deleteItem(itemId: string): Promise; clearNonFavorites(): Promise; + /** Set or clear a custom display title for a clipboard item. */ + setItemCustomTitle(itemId: string, title?: string | null): Promise; normalizeImageData(content: string): string; isValidImageData(content: string): boolean; readCurrentClipboard(): Promise<{ type: ClipboardItemType; content: string }>; diff --git a/asyar-sdk/src/types/ClipboardType.ts b/asyar-sdk/src/types/ClipboardType.ts index b464a5c57..38060e440 100644 --- a/asyar-sdk/src/types/ClipboardType.ts +++ b/asyar-sdk/src/types/ClipboardType.ts @@ -55,4 +55,8 @@ export interface ClipboardHistoryItem { * (pre-redaction) content is NOT stored. */ redactedKinds?: string[]; + /** + * Optional user-assigned display title that overrides the raw content preview. + */ + customTitle?: string; } From 12d7f4c2bdc6e364b29c7ec98d6c833a8d65a3c1 Mon Sep 17 00:00:00 2001 From: Xoshbin Date: Sun, 15 Nov 2026 17:52:05 +0300 Subject: [PATCH 2/3] docs(clipboard): document rename action and custom title SDK support --- docs/guide/features/clipboard-history.md | 2 ++ docs/guide/keyboard-shortcuts.md | 19 ++++++++++--------- .../sdk/clipboard-history-service.md | 2 ++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/guide/features/clipboard-history.md b/docs/guide/features/clipboard-history.md index ea87d199c..8d2bc1425 100644 --- a/docs/guide/features/clipboard-history.md +++ b/docs/guide/features/clipboard-history.md @@ -55,6 +55,7 @@ When browsing without search words, filters run against your local SQLite histor | Copy to Clipboard | `⌘↵` (`Ctrl+↵`) | | Paste as Plain Text | `⌃⌘↵` (`Ctrl+Shift+↵`) | | Pin / Unpin (Toggle Favorite) | `⌘.` (`Ctrl+.`) | +| Rename Entry | `⇧⌘E` (`Ctrl+Shift+E`) | | Open in Browser (URL items) | `⌘O` (`Ctrl+O`) | | Save as Snippet | `⌘S` (`Ctrl+S`) | | Ask AI about this | `⌘I` (`Ctrl+I`) | @@ -71,6 +72,7 @@ When browsing without search words, filters run against your local SQLite histor - **Copy to Clipboard** (`⌘↵`) — copies the selected item back to your system clipboard. - **Paste as Plain Text** (`⌃⌘↵` / `Ctrl+Shift+↵`) — strips formatting before pasting. - **Pin / Unpin** (`⌘.`) — pins or unpins the selected item. Favourites are never deleted by "Clear Clipboard History". +- **Rename Entry** (`⇧⌘E` / `Ctrl+Shift+E`) — sets a custom display title for the selected item. Custom titles appear in the list and detail preview, are indexed for full-text search, and leave the underlying raw content intact for pasting. To reset to the original preview title, save an empty name. - **Toggle HTML Rendered / Source** — switches the detail pane between rendered HTML and raw source (useful for HTML or RTF items). - **Open in Browser** (`⌘O`) — opens a selected URL item in your default browser. - **Save as Snippet** (`⌘S`) — sends the selected text item directly to the Snippets editor so you can give it a keyword. diff --git a/docs/guide/keyboard-shortcuts.md b/docs/guide/keyboard-shortcuts.md index a40cf4a41..0fbe09e56 100644 --- a/docs/guide/keyboard-shortcuts.md +++ b/docs/guide/keyboard-shortcuts.md @@ -100,6 +100,7 @@ Built-in features declare Raycast-aligned shortcuts while their view is active. | `⌃⌘↵` (`Ctrl+Shift+↵` Win/Ln) | Paste as plain text | | `⌘↑` / `⌘↓` | Extend selection for merged paste | | `⌘.` | Pin / Unpin the selected item | +| `⇧⌘E` (`Ctrl+Shift+E` Win/Ln) | Rename selected item | | `⌘O` | Open URL item in browser | | `⌘S` | Save text item as snippet | | `⌘I` | Ask AI about selected text | @@ -121,15 +122,15 @@ Built-in features declare Raycast-aligned shortcuts while their view is active. **Window Management** -| Shortcut | What it does | -| -------- | ----------------------------------------------- | -| `↵` | Switch to selected window / Apply saved layout | -| `⌘W` | Close the selected window | -| `⌘⇧C` | Copy the window title | -| `⌘N` | Save the current window layout (Manage Layouts) | -| `⌘R` | Rename the selected layout | -| `⌃X` | Delete the selected layout (with confirmation) | -| `⌘K` | Open actions for the selected window or layout | +| Shortcut | What it does | +| ----------------------------- | ----------------------------------------------- | +| `↵` | Switch to selected window / Apply saved layout | +| `⌘W` | Close the selected window | +| `⌘⇧C` | Copy the window title | +| `⌘N` | Save the current window layout (Manage Layouts) | +| `⇧⌘E` (`Ctrl+Shift+E` Win/Ln) | Rename the selected layout | +| `⌃X` | Delete the selected layout (with confirmation) | +| `⌘K` | Open actions for the selected window or layout | **File Search** diff --git a/docs/reference/sdk/clipboard-history-service.md b/docs/reference/sdk/clipboard-history-service.md index 2782355d4..7b0a37668 100644 --- a/docs/reference/sdk/clipboard-history-service.md +++ b/docs/reference/sdk/clipboard-history-service.md @@ -33,6 +33,7 @@ interface IClipboardHistoryService { // Manage history (requires clipboard-history:manage) toggleItemFavorite(itemId: string): Promise; + setItemCustomTitle(itemId: string, customTitle?: string | null): Promise; deleteItem(itemId: string): Promise; clearNonFavorites(): Promise; @@ -87,6 +88,7 @@ interface ClipboardHistoryItem { favorite: boolean; metadata?: ClipboardItemMetadata; sourceApp?: ClipboardSourceApp; + customTitle?: string; } ``` From dce2823664eb96d6c8e9c69cbc6384a13f022b70 Mon Sep 17 00:00:00 2001 From: Xoshbin Date: Sun, 15 Nov 2026 18:56:54 +0300 Subject: [PATCH 3/3] fix(clipboard): address review feedback on rename and action panel navigation - Index inherited custom title in FTS when deduping duplicate captures - Sync custom title dynamically in the clipboard detail metadata pane - Fix global Escape handling when focus is outside the action popup - Ensure action prompts cancel cleanly when action panel closes - Guard against IME composition on Enter in prompt inputs - Refresh active search results after renaming an item --- .../src-tauri/crates/asyar-storage/src/clipboard.rs | 4 +++- asyar-launcher/src/bindings.ts | 1 + .../clipboard-history/DefaultView.svelte | 6 ++++-- .../built-in-features/clipboard-history/index.ts | 6 +++--- .../clipboard-history/state.svelte.ts | 13 +++++++++++-- .../window-management/ManageView.svelte | 13 ++++++++----- .../src/components/layout/ActionListPopup.svelte | 6 +++--- .../components/layout/ActionPromptPopover.svelte | 8 +++++--- asyar-launcher/src/lib/keyboard/launcherKeyboard.ts | 6 ++++-- asyar-launcher/src/routes/+page.svelte | 2 +- .../stores/clipboardHistoryStore.svelte.ts | 1 + 11 files changed, 44 insertions(+), 22 deletions(-) diff --git a/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard.rs b/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard.rs index df17727fe..2a37249ed 100644 --- a/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard.rs +++ b/asyar-launcher/src-tauri/crates/asyar-storage/src/clipboard.rs @@ -149,6 +149,7 @@ pub struct CaptureResult { pub inserted_id: String, pub replaced_id: Option, pub favorite: bool, + pub custom_title: Option, pub evicted_ids: Vec, } @@ -1318,6 +1319,7 @@ pub fn record_capture( inserted_id: new_item.id, replaced_id, favorite: new_item.favorite, + custom_title: new_item.custom_title, evicted_ids, }) } @@ -1346,7 +1348,7 @@ pub fn record_capture_with_fts( item.preview.as_deref(), item.content.as_deref(), Some(&source_app_text), - item.custom_title.as_deref(), + res.custom_title.as_deref(), )?; // Evicted ids from cleanup must come out of FTS too. fts.delete_many(&res.evicted_ids)?; diff --git a/asyar-launcher/src/bindings.ts b/asyar-launcher/src/bindings.ts index 25542fbcb..1daf88377 100644 --- a/asyar-launcher/src/bindings.ts +++ b/asyar-launcher/src/bindings.ts @@ -130,6 +130,7 @@ export type CaptureResult = { insertedId: string, replacedId: string | null, favorite: boolean, + customTitle: string | null, evictedIds: string[], }; diff --git a/asyar-launcher/src/built-in-features/clipboard-history/DefaultView.svelte b/asyar-launcher/src/built-in-features/clipboard-history/DefaultView.svelte index 842ceccd5..4f9f0f6ec 100644 --- a/asyar-launcher/src/built-in-features/clipboard-history/DefaultView.svelte +++ b/asyar-launcher/src/built-in-features/clipboard-history/DefaultView.svelte @@ -1170,14 +1170,16 @@ {clipboardViewState.selectedIds.length} items selected · Enter to merge & paste
{:else if selectedFullItem} + {@const customTitle = + clipboardViewState.selectedItem?.customTitle ?? selectedFullItem.customTitle} { await clipboardViewState.saveRename(newTitle); diff --git a/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.ts b/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.ts index c01817a85..be1f7c37d 100644 --- a/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.ts +++ b/asyar-launcher/src/built-in-features/clipboard-history/state.svelte.ts @@ -304,8 +304,14 @@ export class ClipboardViewStateClass { async saveRename(newTitle: string) { if (!this.renamingItemId) return; const id = this.renamingItemId; - await this.setCustomTitle(id, newTitle); - this.cancelRename(); + try { + const ok = await this.setCustomTitle(id, newTitle); + if (!ok) { + await feedbackService.showHUD(t('common.error')); + } + } finally { + this.cancelRename(); + } } async setCustomTitle(itemId: string, title?: string | null): Promise { @@ -318,6 +324,9 @@ export class ClipboardViewStateClass { if (ok) { const trimmed = title?.trim() || undefined; this.items = this.items.map((i) => (i.id === itemId ? { ...i, customTitle: trimmed } : i)); + if (this.searchQuery.trim()) { + void onSearchChanged(this.searchQuery); + } } return ok; } catch (error) { diff --git a/asyar-launcher/src/built-in-features/window-management/ManageView.svelte b/asyar-launcher/src/built-in-features/window-management/ManageView.svelte index f93710f2e..5fce15077 100644 --- a/asyar-launcher/src/built-in-features/window-management/ManageView.svelte +++ b/asyar-launcher/src/built-in-features/window-management/ManageView.svelte @@ -63,12 +63,15 @@ contextLabel: t('features.window_management.title'), icon: 'window', onsave: async (newName) => { - const trimmed = newName.trim(); - if (trimmed) { - await renameLayout(id, trimmed, store ?? windowManagementState.store ?? undefined); - await feedbackService.showHUD(`Renamed to "${trimmed}"`); + try { + const trimmed = newName.trim(); + if (trimmed) { + await renameLayout(id, trimmed, store ?? windowManagementState.store ?? undefined); + await feedbackService.showHUD(`Renamed to "${trimmed}"`); + } + } finally { + windowManagementState.clearRename(); } - windowManagementState.clearRename(); }, oncancel: () => { windowManagementState.clearRename(); diff --git a/asyar-launcher/src/components/layout/ActionListPopup.svelte b/asyar-launcher/src/components/layout/ActionListPopup.svelte index aeabe7f93..c3741e582 100644 --- a/asyar-launcher/src/components/layout/ActionListPopup.svelte +++ b/asyar-launcher/src/components/layout/ActionListPopup.svelte @@ -471,7 +471,7 @@ .prompt-title { font-size: var(--font-size-sm); - font-weight: 500; + font-weight: var(--font-weight-medium); color: var(--text-primary); margin: 0; user-select: none; @@ -486,7 +486,7 @@ align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-4); - min-height: 32px; + min-height: var(--size-xl); background: transparent; border-top: 1px solid var(--popup-divider); user-select: none; @@ -513,7 +513,7 @@ } .context-text { - font-weight: 500; + font-weight: var(--font-weight-medium); } .footer-actions { diff --git a/asyar-launcher/src/components/layout/ActionPromptPopover.svelte b/asyar-launcher/src/components/layout/ActionPromptPopover.svelte index 052d87a68..60a660b2c 100644 --- a/asyar-launcher/src/components/layout/ActionPromptPopover.svelte +++ b/asyar-launcher/src/components/layout/ActionPromptPopover.svelte @@ -92,6 +92,8 @@ }); function handleKeydown(event: KeyboardEvent) { + if (event.isComposing) return; + if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); @@ -177,7 +179,7 @@ .prompt-title { font-size: var(--font-size-sm); - font-weight: 500; + font-weight: var(--font-weight-medium); color: var(--text-primary); margin: 0; user-select: none; @@ -192,7 +194,7 @@ align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-4); - min-height: 32px; + min-height: var(--size-xl); background: transparent; border-top: 1px solid var(--popup-divider); user-select: none; @@ -219,7 +221,7 @@ } .context-text { - font-weight: 500; + font-weight: var(--font-weight-medium); } .footer-actions { diff --git a/asyar-launcher/src/lib/keyboard/launcherKeyboard.ts b/asyar-launcher/src/lib/keyboard/launcherKeyboard.ts index c28eed68d..8e16eda64 100644 --- a/asyar-launcher/src/lib/keyboard/launcherKeyboard.ts +++ b/asyar-launcher/src/lib/keyboard/launcherKeyboard.ts @@ -452,10 +452,12 @@ export function createKeyboardHandlers(deps: KeyboardDeps) { if ( (searchBarAccessoryService.popoverOpen || actionService.activePrompt !== null || + Boolean( + typeof document !== 'undefined' && document.querySelector('.action-prompt-popover'), + ) || Boolean( typeof document !== 'undefined' && - (document.querySelector('.action-prompt-popover') || - document.querySelector('.action-popup')), + (document.activeElement as HTMLElement | null)?.closest?.('.action-popup'), )) && ['Escape', 'ArrowUp', 'ArrowDown', 'Enter', 'Tab'].includes(event.key) && !event.metaKey && diff --git a/asyar-launcher/src/routes/+page.svelte b/asyar-launcher/src/routes/+page.svelte index 30168f0ba..0db84eb83 100644 --- a/asyar-launcher/src/routes/+page.svelte +++ b/asyar-launcher/src/routes/+page.svelte @@ -151,7 +151,7 @@ function handleActionPanelClose() { isActionPanelOpen = false; - actionService.activePrompt = null; + actionService.closePrompt(); actionService.panelSearchQuery = ''; if (!controller.assignShortcutTarget && !controller.assignAliasTarget) { keyboard.restoreSearchFocus({ select: true }); diff --git a/asyar-launcher/src/services/clipboard/stores/clipboardHistoryStore.svelte.ts b/asyar-launcher/src/services/clipboard/stores/clipboardHistoryStore.svelte.ts index 69c48bb1a..a1a45e0a1 100644 --- a/asyar-launcher/src/services/clipboard/stores/clipboardHistoryStore.svelte.ts +++ b/asyar-launcher/src/services/clipboard/stores/clipboardHistoryStore.svelte.ts @@ -184,6 +184,7 @@ export class ClipboardHistoryStoreClass { metadata: stored.metadata, sourceApp: stored.sourceApp, redactedKinds: stored.redactedKinds, + customTitle: (res.customTitle ?? stored.customTitle) || undefined, }; const evicted = new Set(res.evictedIds); if (!evicted.has(newRow.id)) {