host: the palette commands of site tabs are the host's (tab_commands, tab_run_command)
tab_commands keeps the list each site tab reported (validated by plugins::commands, accepted only from a tab on the site's origin), clears it when a new document starts, tells the shell, and checks the shell-only tab_run_command: only a command that tab reported, only while it is on the site. tab_run_command joins commands::SHELL (guard checked by assert_host_guards); the app's tab_report hands its `commands` to tab_commands::reported. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6b37744226
commit
d40bf273bd
4 changed files with 84 additions and 0 deletions
|
|
@ -940,6 +940,14 @@ async fn features_set(webview: Webview, app: AppHandle, features: serde_json::Ma
|
|||
set_features(&app, features)
|
||||
}
|
||||
|
||||
/// Runs a plugin's palette command in tab `id`: only a command that tab reported, only while it is
|
||||
/// on the site. The command's code runs in the page; the tab gets keyboard focus for what it opens.
|
||||
#[tauri::command]
|
||||
async fn tab_run_command(webview: Webview, app: AppHandle, id: String, command: String) -> Result<(), String> {
|
||||
shell_only(&webview)?;
|
||||
crate::tab_commands::run(&app, &id, &command)
|
||||
}
|
||||
|
||||
/// The onboarding mode: what was chosen, whether the first-run screen was answered, and whether
|
||||
/// this app was set up before modes existed.
|
||||
#[tauri::command]
|
||||
|
|
@ -1126,6 +1134,7 @@ fn tab_builder(app: &AppHandle, hooks: &Arc<dyn SiteHooks>, tab: &NewTab, url: U
|
|||
}
|
||||
let finished = matches!(payload.event(), PageLoadEvent::Finished);
|
||||
if !finished {
|
||||
crate::tab_commands::cleared(app, tab.label());
|
||||
load_hooks.page_started(app, &tab);
|
||||
// An engine that resets page zoom on navigation still shows this tab's.
|
||||
host::restore_tab_zoom(app, &tab);
|
||||
|
|
@ -1239,6 +1248,7 @@ fn host_handler() -> impl Fn(tauri::ipc::Invoke<Wry>) -> bool + Send + Sync + 's
|
|||
mode_set,
|
||||
settings_get,
|
||||
settings_set,
|
||||
tab_run_command,
|
||||
tab_shortcut,
|
||||
tab_link_drag,
|
||||
open_panel
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue