From e8fbde1f61a8894ea83363da27dbecc31da06c0b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 04:10:33 -0800 Subject: [PATCH 1/7] ui: add Help search for tools, commands, and tutorials --- crates/ui-egui/src/menus.rs | 3 - crates/ui-egui/src/menus/run.rs | 1 + crates/ui-egui/src/menus/tests.rs | 111 +++++++++++ crates/ui-egui/src/menus/tree.rs | 4 +- crates/ui-egui/src/menus/ui_commands.rs | 19 ++ crates/ui-egui/src/panels.rs | 2 + crates/ui-egui/src/panels/discover.rs | 238 ++++++++++++++++++++++++ crates/ui-egui/src/state.rs | 4 + docs/mcp.md | 25 +++ docs/ui-parity.md | 1 + 10 files changed, 403 insertions(+), 5 deletions(-) create mode 100644 crates/ui-egui/src/panels/discover.rs diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 4e2d80bb45..053eb63d79 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -37,9 +37,6 @@ fn cp(label: &'static str, id: &'static str, p: Value) -> Item { fn todo(label: &'static str) -> Item { Item::Todo(label, "") } -fn todos(label: &'static str, sc: &'static str) -> Item { - Item::Todo(label, sc) -} fn sub(label: &'static str, items: Vec) -> Item { Item::Sub(label, items) } diff --git a/crates/ui-egui/src/menus/run.rs b/crates/ui-egui/src/menus/run.rs index b4e1c668ac..3b265ad5fe 100644 --- a/crates/ui-egui/src/menus/run.rs +++ b/crates/ui-egui/src/menus/run.rs @@ -115,6 +115,7 @@ pub fn run_ui_command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option Vec<(&'static str, Vec)> { c("VectorCraft on getartcraft.com", "help.appPage"), c("VectorCraft on GitHub", "help.github"), Sep, - todos("VectorCraft Help…", "F1"), + c("VectorCraft Help…", "help.discover"), c("Safe Mode…", "help.safeMode"), c("Copy Troubleshooting Info", "help.copyTroubleshootingInfo"), Sep, diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 677b804720..d8c44286b0 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -873,6 +873,25 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ ("help.about", "About VectorCraft", "", "{}"), ("help.checkForUpdates", "Check for Updates…", "", "{}"), ("help.commandPalette", "Search Commands…", "Cmd+Shift+/", "{}"), + ( + "help.discover", + "VectorCraft Help…", + "F1", + "{query?: string (at most 1024 characters, VectorCraft's limit)} show the Help panel without toggling it closed; a supplied query searches tools, menu commands, and built-in tutorials; omission keeps the current search. Returns {query, results: [{kind: tool|command|tutorial, id, label, path, shortcut}], selected: index|null}", + ), + ( + "help.discover.search", + "Search", + "", + "{query: string (at most 1024 characters, VectorCraft's limit)} search tools, menu commands, and built-in tutorials and show the Help panel; empty or whitespace-only text clears the results. Returns the help.discover result", + ), + ( + "help.discover.choose", + "Select", + "", + "{index: zero-based result index} show a tool's location, a tutorial's steps in Help, or a command's menu path and shortcut without running it; an invalid index is an error. Returns {result: chosen result, location: tool location, tutorial id, or command path}", + ), + ("help.discover.back", "Back", "", "{} return from a Help result to its search results without changing the query"), ( "help.safeMode", "Safe Mode…", diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index aa07b13a90..5fb91c3978 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -17,6 +17,7 @@ pub mod color_guide; pub mod color_themes; pub mod color_wheel; pub mod css_properties; +pub mod discover; pub mod doc_info; pub mod flattener_preview; pub mod glyphs; @@ -188,6 +189,7 @@ pub fn show_icon_panel(app: &mut VectorcraftApp, ui: &mut Ui, id: &str) { three_d::ID => three_d::show(app, ui), script_console::ID => script_console::show(app, ui), learn::ID => learn::show(app, ui), + discover::ID => discover::show(app, ui), crate::addons::cleanup::ID => crate::addons::cleanup::show(app, ui), crate::addons::color::ID => crate::addons::color::show(app, ui), crate::addons::packaging::ID => crate::addons::packaging::show(app, ui), diff --git a/crates/ui-egui/src/panels/discover.rs b/crates/ui-egui/src/panels/discover.rs new file mode 100644 index 0000000000..33df5c2db7 --- /dev/null +++ b/crates/ui-egui/src/panels/discover.rs @@ -0,0 +1,238 @@ +//! Help searches the tools, menu commands, and built-in tutorials. + +use egui::Ui; +use serde::Serialize; +use serde_json::{Value, json}; + +use crate::{VectorcraftApp, menus}; + +pub const ID: &str = "discover"; +const MAX_QUERY: usize = 1024; + +#[derive(Clone, Debug, Serialize)] +pub struct Hit { + pub kind: &'static str, + pub id: String, + pub label: String, + pub path: Vec, + pub shortcut: String, +} + +#[derive(Clone, Debug, Default)] +pub struct View { + pub query: String, + pub results: Vec, + pub selected: Option, + pub focus: bool, +} + +fn matches(query: &str, text: &str) -> bool { + let text = text.to_lowercase(); + query.split_whitespace().all(|word| text.contains(word)) +} + +fn search(app: &VectorcraftApp, query: &str) -> Vec { + let query = query.trim().to_lowercase(); + if query.is_empty() { + return Vec::new(); + } + let mut hits = Vec::new(); + let lang = crate::i18n::current(); + for tool in vectorcraft_tools::catalog::all_tools() { + let label = crate::i18n::tr(lang, tool.label); + if matches(&query, &format!("{} {label} {}", tool.label, tool.id)) { + hits.push(Hit { + kind: "tool", + id: tool.id.into(), + label: label.into(), + path: vec![], + shortcut: crate::shortcut_editor::tool_shortcut(tool.id).unwrap_or_default().into(), + }); + } + } + for entry in menus::menu_entries(app) { + let Some(id) = entry.command else { continue }; + let label = crate::i18n::tr(lang, &entry.label); + let path: Vec = entry.path.iter().map(|part| crate::i18n::tr(lang, part).into()).collect(); + if matches(&query, &format!("{} {label} {} {} {id}", entry.label, entry.path.join(" "), path.join(" "))) { + hits.push(Hit { kind: "command", id, label: label.into(), path, shortcut: entry.shortcut }); + } + } + for skill in super::learn::catalog::SKILLS { + for tutorial in skill.tutorials { + if matches(&query, &format!("{} {} {}", skill.title, tutorial.title, tutorial.id)) { + hits.push(Hit { + kind: "tutorial", + id: tutorial.id.into(), + label: tutorial.title.into(), + path: vec![skill.title.into()], + shortcut: String::new(), + }); + } + } + } + hits +} + +fn results(app: &VectorcraftApp) -> Value { + json!({"query": app.ui.discover.query, "results": app.ui.discover.results, "selected": app.ui.discover.selected}) +} + +fn set_query(app: &mut VectorcraftApp, query: &str) { + app.ui.discover.results = search(app, query); + app.ui.discover.query = query.into(); + app.ui.discover.selected = None; +} + +pub(crate) fn command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option> { + let spec = menus::UI_COMMANDS.iter().find(|spec| spec.0 == id && id.starts_with("help.discover"))?; + if let Err(e) = vectorcraft_engine::cmd::params::check_keys(id, spec.3, p) { + return Some(Err(e.to_string())); + } + Some(match id { + "help.discover" | "help.discover.search" => { + let query = match p.get("query") { + Some(Value::String(query)) => Some(query.as_str()), + None if id == "help.discover" => None, + _ => { + let key = "query"; + return Some(Err(format!("`{key}` must be a string"))); + } + }; + if let Some(query) = query { + if query.chars().take(MAX_QUERY + 1).count() > MAX_QUERY { + let label = "query"; + let max = MAX_QUERY; + return Some(Err(format!("{label} must be at most {max} characters"))); + } + set_query(app, query); + } + app.ui.discover.focus = true; + crate::panel_docking::reveal_panel(app, ID).map(|_| results(app)) + } + "help.discover.choose" => { + let hit = p + .get("index") + .and_then(Value::as_u64) + .and_then(|i| usize::try_from(i).ok()) + .and_then(|i| app.ui.discover.results.get(i).cloned().map(|hit| (i, hit))); + let Some((index, hit)) = hit else { + return Some(Err("index out of range".into())); + }; + let outcome = match hit.kind { + "tool" => app.run("learn.locateTool", json!({"tool": hit.id})), + "tutorial" => Ok(json!({"tutorial": hit.id})), + _ => Ok(json!({"command": hit.id, "path": hit.path, "shortcut": hit.shortcut})), + }; + outcome.and_then(|outcome| { + crate::panel_docking::reveal_panel(app, ID)?; + app.ui.discover.selected = Some(index); + app.ui.discover.focus = true; + Ok(json!({"result": hit, "location": outcome})) + }) + } + "help.discover.back" => { + app.ui.discover.selected = None; + app.ui.discover.focus = true; + Ok(results(app)) + } + _ => return None, + }) +} + +pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { + let mut query = app.ui.discover.query.clone(); + let field = ui.add(egui::TextEdit::singleline(&mut query).char_limit(MAX_QUERY).hint_text(tl!("Search")).desired_width(f32::INFINITY)); + if std::mem::take(&mut app.ui.discover.focus) { + field.request_focus(); + } + if field.changed() + && let Err(e) = app.run("help.discover.search", json!({"query": query})) + { + app.status(e); + } + if (field.has_focus() || field.lost_focus()) + && !app.session.tool_busy() + && !app.session.tool_composing() + && ui.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) + { + if let Err(e) = app.run("window.panel.close", json!({"panel": ID})) { + app.status(e); + } + return; + } + let mut chosen = None; + let mut home = false; + let mut back = false; + let mut locate = None; + ui.horizontal(|ui| { + home = ui.button(tl!("Home")).clicked(); + if app.ui.discover.selected.is_some() { + back = ui.button(tl!("Back")).clicked(); + } + }); + crate::widgets::divider(ui); + if let Some(hit) = app.ui.discover.selected.and_then(|i| app.ui.discover.results.get(i)) { + ui.heading(&hit.label); + if !hit.path.is_empty() { + ui.label(hit.path.join(" › ")); + } + if !hit.shortcut.is_empty() { + ui.label(menus::pretty_shortcut(&hit.shortcut)); + } + if hit.kind == "tutorial" + && let Some((_, tutorial)) = super::learn::catalog::tutorial(&hit.id) + { + for (index, step) in tutorial.steps.iter().enumerate() { + ui.label(format!("{}. {}", index + 1, step.plain())); + if let Some(tool) = step.tool + && let Some(info) = vectorcraft_tools::tool_info(tool) + && ui.link(crate::i18n::tr(crate::i18n::current(), info.label)).clicked() + { + locate = Some(tool); + } + } + } + } else { + egui::ScrollArea::vertical().id_salt("discover-results").show(ui, |ui| { + if app.ui.discover.results.is_empty() && !query.trim().is_empty() { + ui.label(tl!("No results")); + } + for kind in ["tool", "command", "tutorial"] { + let label = match kind { + "tool" => tl!("Tools"), + "command" => tl!("Search Commands…"), + _ => tl!("Learn"), + }; + let mut heading = false; + for (index, hit) in app.ui.discover.results.iter().enumerate().filter(|(_, h)| h.kind == kind) { + if !heading { + crate::widgets::subheader(ui, label); + heading = true; + } + if ui.selectable_label(false, &hit.label).on_hover_text(hit.path.join(" › ")).clicked() { + chosen = Some(index); + } + } + } + }); + } + if home { + if let Err(e) = app.run("help.discover.search", json!({"query": ""})) { + app.status(e); + } + } else if back { + if let Err(e) = app.run("help.discover.back", json!({})) { + app.status(e); + } + } else if let Some(index) = chosen + && let Err(e) = app.run("help.discover.choose", json!({"index": index})) + { + app.status(e); + } + if let Some(tool) = locate + && let Err(e) = app.run("learn.locateTool", json!({"tool": tool})) + { + app.status(e); + } +} diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index ac241a5ebd..ea962600cb 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -225,6 +225,7 @@ pub const ICON_PANELS: &[(&str, &str, &str)] = &[ (crate::panels::variables::ID, "Variables", "chart-column"), (crate::panels::script_console::ID, "Script Console", "message-circle"), (crate::panels::learn::ID, "Learn", "graduation-cap"), + (crate::panels::discover::ID, "VectorCraft Help…", "search"), (crate::addons::cleanup::ID, "Artwork Cleanup", "sparkles"), (crate::addons::color::ID, "Color Effects", "sun"), (crate::addons::packaging::ID, "Fold Lines", "scissors"), @@ -421,6 +422,8 @@ pub struct UiState { /// The Learn panel's tab, skill and tutorial, kept while the app runs. #[serde(skip)] pub learn: crate::panels::learn::View, + #[serde(skip)] + pub discover: crate::panels::discover::View, /// The tool whose place a Learn tutorial step's link shows (`learn.locateTool`), while its mark /// is on screen. Not saved. #[serde(skip)] @@ -1154,6 +1157,7 @@ impl Default for UiState { color_settings_scroll: false, find_font_in: String::new(), learn: Default::default(), + discover: Default::default(), learn_locate: None, learn_practice: Default::default(), learn_progress: Default::default(), diff --git a/docs/mcp.md b/docs/mcp.md index a27f99feba..0ab865a7a9 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3256,6 +3256,31 @@ own layout rules. {"name":"invoke_menu","arguments":{"command":"window.toolbar.dock","params":{"name":"Toolbar 1","side":"left","order":0}}} ``` +## Help search + +Help › VectorCraft Help… and F1 show the Help panel. `help.discover {query?}` opens it without +toggling it closed. A supplied string searches tools, menu commands, and VectorCraft's built-in +tutorials. Omitting `query` preserves the current search. Empty or whitespace-only text clears +the results. VectorCraft limits a query to 1024 characters and rejects a longer supplied string. + +`help.discover.search {query}` runs the same search and shows the panel. Both commands return +`{query, results: [{kind, id, label, path, shortcut}], selected}`. `kind` is `tool`, `command`, or +`tutorial`; `selected` is a zero-based result index or `null`. Search matches all the query's +words without regard to case, using translated tool and command labels as well as their English +labels, ids, and menu paths. Tutorial text remains in English. + +`help.discover.choose {index}` shows that result. A tool result marks its toolbar location without +choosing the tool. A command result shows its menu path and current shortcut without running it. +A tutorial result shows its numbered steps; a tool link in a step marks that tool's location. +The reply is `{result, location}`, with the chosen result and the tool-location reply, tutorial +id, or command path. An invalid index returns an error and preserves the selected result. + +Home clears the search. Back and `help.discover.back {}` return to its results with the query +preserved. Escape in the search field closes the panel. Escape on the canvas still cancels an +active tool operation. The panel uses the existing tool-location marks; command guidance is a +menu path. Articles, Quick Actions, personalized recommendations, and Discover preferences are +not included. + ## Learn panel Window › Learn and the Explore tutorials button beside the search field at the right end of the app bar show and hide diff --git a/docs/ui-parity.md b/docs/ui-parity.md index b312abae1b..5e695beb66 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -399,6 +399,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po |---|---|---| | Effect > Warp Options: style previews, orientation choices and percent controls | done | #1760; focused input, mixed-style and history checks passed; original captures reviewed. No geometry or optional Properties changes. | | Command search: Up and Down move through the results, Enter runs the highlighted one | done | #1798 (#1757) | +| Help › VectorCraft Help… and F1 show in-app search for tools, menu commands, and built-in tutorials. Tool results mark their toolbar location; command results show their menu path and shortcut without running them; tutorial results show their steps. Home clears the search, Back returns to the results, and Escape in the search field closes the panel. | partial | [Public source](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-with-discover-panel.html); `help.discover`, `help.discover.search`, `help.discover.choose`, `help.discover.back`; `menus::tests::help_f1_opens_discover_without_a_document`. Articles, Quick Actions, and Discover preferences are not implemented. Menu-path text instead of a menu location marker is VectorCraft's current guidance. | | Learn panel: Window › Learn and Explore tutorials on the app bar open it; For you holds a Quick skill guide card, Skills lists VectorCraft's own skills with progress rings that fill and counts of tutorials finished, a tutorial shows its numbered steps with a check box each that marks the step done once its sample is open, a finished tutorial has a check mark, Back goes up a level; a tool's name in a step is a link that marks the tool where the toolbars show it (its button, its group's flyout, a torn-off strip, a toolbar made with New Toolbar or the All Tools drawer) without choosing it; View more opens the tutorial's practice sample as a new untitled document, Finish tutorial then marks it finished with all its steps, and Next Up shows the next tutorial in the same skill; Reset progress clears the progress (no video) | done | [the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `learn.list`, `learn.tab`, `learn.skills`, `learn.skill`, `learn.show`, `learn.back`, `learn.locateTool`, `learn.openSample`, `learn.markStep`, `learn.finish`, `learn.next`, `learn.resetProgress`; the mark's look and 3-second lifetime, marking steps by hand, keeping the progress in the preferences and Reset progress are VectorCraft's own rules; `panels::learn::tests`, `toolbar::tests` | | Pathfinder panel: a group selected alone counts its nested shapes, so an expanded stroked object keeps the Shape Modes enabled | done | #1642 (#1635) | | Selected Grid Repeat shows row, column and corner handles and spacing sliders; bounding-box handles take priority where they meet | done | #2691, `tools/src/repeat_grid.rs`; [public behavior reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html); drags preview and commit `object.repeat.options` as one undo step, Escape cancels; a selected Radial Repeat shows an instances handle below it (16 px of drag per instance, 1 to 1,000) and a radius handle on its circle the same way (`tools/src/repeat_radial.rs`; [public behavior reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/create-radial-repeats.html)), and a splitter on its circle that hides the instances it is dragged back past while the others keep their places, and shows them again when dragged forward (its place half a step past the last instance shown and its limit of one instance shown are VectorCraft's own rules) | From 387dc9049a625a8cbbf060f1e6ff9b3164b4e340 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 04:54:50 -0800 Subject: [PATCH 2/7] Help: a result shows the shortcut as it is now Help kept each result's shortcut, label and menu path from the moment of the search. After a shortcut changed, reopening Help or choosing a kept result still showed and returned the old binding, and a change of the interface language left the old labels in place. The kept results now take the current shortcuts, labels and menu paths when Help reopens, when a result is chosen or shown, and when the panel draws after a change. The query, the order of the results and the selected result stay as they were. --- crates/ui-egui/src/menus/tests.rs | 35 ++++++++++++++++ crates/ui-egui/src/panels/discover.rs | 59 ++++++++++++++++++++++++++- docs/mcp.md | 4 +- 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index 696d50d63f..d4703034ea 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -112,6 +112,41 @@ fn discover_rejects_invalid_search_and_selection_parameters() { assert!(app.run("help.discover.choose", json!({"index": 0})).is_err()); } +#[test] +fn discover_results_show_the_current_shortcut_and_language_after_a_change() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + let found = app.run("help.discover.search", json!({"query": "file.newDialog"})).unwrap(); + let index = found["results"].as_array().unwrap().iter().position(|hit| hit["id"] == "file.newDialog").unwrap(); + assert_eq!(found["results"][index]["shortcut"], "Cmd+N"); + app.run("help.discover.choose", json!({"index": index})).unwrap(); + app.run("window.panel.close", json!({"panel": "discover"})).unwrap(); + app.run("shortcuts.set", json!({"id": "file.newDialog", "shortcut": "Cmd+Alt+Shift+F9"})).unwrap(); + + let reopened = app.run("help.discover", json!({})).unwrap(); + assert_eq!(reopened["query"], "file.newDialog"); + assert_eq!(reopened["selected"], index); + assert_eq!(reopened["results"][index]["id"], "file.newDialog"); + assert_eq!(reopened["results"][index]["shortcut"], "Cmd+Alt+Shift+F9"); + let picked = app.run("help.discover.choose", json!({"index": index})).unwrap(); + assert_eq!(picked["result"]["shortcut"], "Cmd+Alt+Shift+F9"); + assert_eq!(picked["location"]["shortcut"], "Cmd+Alt+Shift+F9"); + + app.run("shortcuts.set", json!({"id": "file.newDialog", "shortcut": "Cmd+Alt+Shift+F8"})).unwrap(); + let text = crate::tests_labels::painted_text(&mut app, crate::panels::discover::show); + assert!(text.contains(&pretty_shortcut("Cmd+Alt+Shift+F8")), "{text}"); + assert!(!text.contains(&pretty_shortcut("Cmd+Alt+Shift+F9")), "{text}"); + + let de = crate::i18n::Lang::from_code("de").unwrap(); + assert_ne!(crate::i18n::tr(de, "New…"), "New…"); + crate::i18n::set_current(de); + let back = app.run("help.discover.back", json!({})).unwrap(); + crate::i18n::set_current(crate::i18n::Lang::EN); + assert_eq!(back["query"], "file.newDialog"); + assert_eq!(back["results"][index]["label"], crate::i18n::tr(de, "New…")); + assert_eq!(back["results"][index]["path"][0], crate::i18n::tr(de, "File")); + crate::shortcut_editor::sync(&crate::state::UiState::default()); +} + #[test] fn help_bar_toggle_is_independent_and_saved_in_workspaces() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); diff --git a/crates/ui-egui/src/panels/discover.rs b/crates/ui-egui/src/panels/discover.rs index 33df5c2db7..c5eaa78eea 100644 --- a/crates/ui-egui/src/panels/discover.rs +++ b/crates/ui-egui/src/panels/discover.rs @@ -16,6 +16,14 @@ pub struct Hit { pub label: String, pub path: Vec, pub shortcut: String, + /// The English label and menu path that `label` and `path` translate, and a command's menu + /// params, kept to bring a retained result up to date ([`refresh`]). + #[serde(skip)] + english_label: String, + #[serde(skip)] + english_path: Vec, + #[serde(skip)] + params: Value, } #[derive(Clone, Debug, Default)] @@ -24,6 +32,8 @@ pub struct View { pub results: Vec, pub selected: Option, pub focus: bool, + /// The shortcut generation and language the results were last brought up to date for. + current_for: Option<(u64, crate::i18n::Lang)>, } fn matches(query: &str, text: &str) -> bool { @@ -31,6 +41,35 @@ fn matches(query: &str, text: &str) -> bool { query.split_whitespace().all(|word| text.contains(word)) } +fn now() -> (u64, crate::i18n::Lang) { + (crate::shortcut_editor::GENERATION.load(std::sync::atomic::Ordering::Relaxed), crate::i18n::current()) +} + +/// Updates the retained results' labels, menu paths and shortcuts after a shortcut or the UI +/// language changes, keeping the query, the results' order and the selected result. +fn refresh(app: &mut VectorcraftApp) { + let stamp = now(); + if app.ui.discover.current_for == Some(stamp) { + return; + } + let lang = stamp.1; + for hit in &mut app.ui.discover.results { + match hit.kind { + "tool" => { + hit.label = crate::i18n::tr(lang, &hit.english_label).into(); + hit.shortcut = crate::shortcut_editor::tool_shortcut(&hit.id).unwrap_or_default().into(); + } + "command" => { + hit.label = crate::i18n::tr(lang, &hit.english_label).into(); + hit.path = hit.english_path.iter().map(|part| crate::i18n::tr(lang, part).into()).collect(); + hit.shortcut = menus::item_shortcut(&hit.id, &hit.params).or_else(|| menus::shortcut_of(&hit.id)).unwrap_or_default().into(); + } + _ => {} + } + } + app.ui.discover.current_for = Some(stamp); +} + fn search(app: &VectorcraftApp, query: &str) -> Vec { let query = query.trim().to_lowercase(); if query.is_empty() { @@ -47,6 +86,9 @@ fn search(app: &VectorcraftApp, query: &str) -> Vec { label: label.into(), path: vec![], shortcut: crate::shortcut_editor::tool_shortcut(tool.id).unwrap_or_default().into(), + english_label: tool.label.into(), + english_path: vec![], + params: Value::Null, }); } } @@ -55,7 +97,16 @@ fn search(app: &VectorcraftApp, query: &str) -> Vec { let label = crate::i18n::tr(lang, &entry.label); let path: Vec = entry.path.iter().map(|part| crate::i18n::tr(lang, part).into()).collect(); if matches(&query, &format!("{} {label} {} {} {id}", entry.label, entry.path.join(" "), path.join(" "))) { - hits.push(Hit { kind: "command", id, label: label.into(), path, shortcut: entry.shortcut }); + hits.push(Hit { + kind: "command", + id, + label: label.into(), + path, + shortcut: entry.shortcut, + english_label: entry.label, + english_path: entry.path, + params: entry.params, + }); } } for skill in super::learn::catalog::SKILLS { @@ -67,6 +118,9 @@ fn search(app: &VectorcraftApp, query: &str) -> Vec { label: tutorial.title.into(), path: vec![skill.title.into()], shortcut: String::new(), + english_label: tutorial.title.into(), + english_path: vec![skill.title.into()], + params: Value::Null, }); } } @@ -79,6 +133,7 @@ fn results(app: &VectorcraftApp) -> Value { } fn set_query(app: &mut VectorcraftApp, query: &str) { + app.ui.discover.current_for = Some(now()); app.ui.discover.results = search(app, query); app.ui.discover.query = query.into(); app.ui.discover.selected = None; @@ -89,6 +144,7 @@ pub(crate) fn command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option { let query = match p.get("query") { @@ -141,6 +197,7 @@ pub(crate) fn command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option Date: Tue, 17 Nov 2026 06:29:23 -0800 Subject: [PATCH 3/7] MCP: ui_catalog.rs lists the Help search commands Regenerated with cargo xtask ui-commands. --- crates/mcp/src/ui_catalog.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index b6da21331e..b9e6b904cf 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -872,6 +872,25 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ ("help.about", "About VectorCraft", "", "{}"), ("help.checkForUpdates", "Check for Updates…", "", "{}"), ("help.commandPalette", "Search Commands…", "Cmd+Shift+/", "{}"), + ( + "help.discover", + "VectorCraft Help…", + "F1", + "{query?: string (at most 1024 characters, VectorCraft's limit)} show the Help panel without toggling it closed; a supplied query searches tools, menu commands, and built-in tutorials; omission keeps the current search. Returns {query, results: [{kind: tool|command|tutorial, id, label, path, shortcut}], selected: index|null}", + ), + ( + "help.discover.search", + "Search", + "", + "{query: string (at most 1024 characters, VectorCraft's limit)} search tools, menu commands, and built-in tutorials and show the Help panel; empty or whitespace-only text clears the results. Returns the help.discover result", + ), + ( + "help.discover.choose", + "Select", + "", + "{index: zero-based result index} show a tool's location, a tutorial's steps in Help, or a command's menu path and shortcut without running it; an invalid index is an error. Returns {result: chosen result, location: tool location, tutorial id, or command path}", + ), + ("help.discover.back", "Back", "", "{} return from a Help result to its search results without changing the query"), ( "help.safeMode", "Safe Mode…", From 739243b660a9ace0d53fb28ecba1e6c9727c754d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 07:05:07 -0800 Subject: [PATCH 4/7] Help: choosing a hidden tool says why it cannot be shown When Tab or Presentation Mode hides the toolbars, choosing a tool in the Help panel, or a tool's link in a tutorial Help shows, marks nothing. The panel now puts the reason learn.locateTool returns in the status bar. The two reasons get rows in every complete-message catalog, and the message scan reads unavailable(tool, reason) so later reasons need rows too. --- crates/ui-egui/src/i18n/ca.tsv | 2 + crates/ui-egui/src/i18n/cs.tsv | 2 + crates/ui-egui/src/i18n/da.tsv | 2 + crates/ui-egui/src/i18n/de.tsv | 2 + crates/ui-egui/src/i18n/el.tsv | 2 + crates/ui-egui/src/i18n/es.tsv | 2 + crates/ui-egui/src/i18n/fi.tsv | 2 + crates/ui-egui/src/i18n/fr.tsv | 2 + crates/ui-egui/src/i18n/hi.tsv | 2 + crates/ui-egui/src/i18n/hu.tsv | 2 + crates/ui-egui/src/i18n/it.tsv | 2 + crates/ui-egui/src/i18n/ja.tsv | 2 + crates/ui-egui/src/i18n/ka.tsv | 2 + crates/ui-egui/src/i18n/ko.tsv | 2 + crates/ui-egui/src/i18n/nl.tsv | 2 + crates/ui-egui/src/i18n/pl.tsv | 2 + crates/ui-egui/src/i18n/pt-br.tsv | 2 + crates/ui-egui/src/i18n/ru.tsv | 2 + crates/ui-egui/src/i18n/sv.tsv | 2 + crates/ui-egui/src/i18n/tests.rs | 4 +- crates/ui-egui/src/i18n/tr.tsv | 2 + crates/ui-egui/src/i18n/uk.tsv | 2 + crates/ui-egui/src/i18n/vi.tsv | 2 + crates/ui-egui/src/i18n/zh-hans.tsv | 2 + crates/ui-egui/src/i18n/zh-hant.tsv | 2 + crates/ui-egui/src/menus/tests.rs | 59 +++++++++++++++++++++++++++ crates/ui-egui/src/panels/discover.rs | 26 ++++++++---- 27 files changed, 128 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 90944f45f6..727b5a270b 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -6889,6 +6889,8 @@ liquify-list-end {0}, {1} {0} i {1} @msg {path}: {e} {path}: {e} @msg {status} ({e}) {status} ({e}) @msg {tool} isn't in a toolbar group of several tools {tool} no forma part d’un grup de diverses eines a la barra d’eines +@msg Presentation Mode hides the toolbars: change the screen mode to show them el Mode de presentació amaga les barres d’eines: canvieu el mode de pantalla per mostrar-les +@msg Tab has hidden the toolbars: press Tab to show them Tab ha amagat les barres d’eines: premeu Tab per mostrar-les @msg “{_1}” asks for a heavy budget (each run up to {minutes} minutes and {times} times the usual instructions): a person has to approve it in the desktop app, or pass `allowHeavy: true` in a session started with --allow-plugin-grants «{_1}» demana un pressupost elevat (cada execució fins a {minutes} minuts i {times} vegades les instruccions habituals): una persona l’ha d’aprovar a l’aplicació d’escriptori, o passa `allowHeavy: true` en una sessió iniciada amb --allow-plugin-grants # Plug-in host messages: manifests, modules, runs and plug-in output @msg `name` must be 1-64 printable characters `name` ha de tenir 1-64 caràcters imprimibles diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 12329012e5..10615cf747 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -5767,6 +5767,8 @@ liquify-list-end {0}, {1} {0} a {1} @msg Reload the page to go on (changes not saved yet may be lost). Pokračujte obnovením stránky (dosud neuložené změny se mohou ztratit). @msg tool (a tool id) is required tool (ID nástroje) je povinný @msg {tool} isn't in a toolbar group of several tools {tool} není ve skupině panelu nástrojů s více nástroji +@msg Presentation Mode hides the toolbars: change the screen mode to show them Režim prezentace skrývá panely nástrojů: zobrazíte je změnou režimu obrazovky +@msg Tab has hidden the toolbars: press Tab to show them Klávesa Tab skryla panely nástrojů: zobrazíte je stisknutím klávesy Tab @msg onto must name a panel floating in another group onto musí určovat panel plovoucí v jiné skupině @msg below and above must name a panel floating in another group below a above musí určovat panel plovoucí v jiné skupině @msg give only one of onto, below and above zadejte jen jedno z onto, below a above diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 92e755911e..ee3b24857b 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -7896,6 +7896,8 @@ imageTrace Outline Kontur @msg Reload the page to go on (changes not saved yet may be lost). Genindlæs siden for at fortsætte (ændringer, der endnu ikke er gemt, kan gå tabt). @msg tool (a tool id) is required tool (et værktøj-id) er påkrævet @msg {tool} isn't in a toolbar group of several tools {tool} er ikke i en værktøjsgruppe med flere værktøjer +@msg Presentation Mode hides the toolbars: change the screen mode to show them Præsentationstilstand skjuler værktøjslinjerne: skift skærmtilstand for at vise dem +@msg Tab has hidden the toolbars: press Tab to show them Tab har skjult værktøjslinjerne: tryk på Tab for at vise dem @msg onto must name a panel floating in another group onto skal angive et panel, der flyder i en anden gruppe @msg below and above must name a panel floating in another group below og above skal angive et panel, der flyder i en anden gruppe @msg give only one of onto, below and above angiv kun én af onto, below og above diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index c903dc4fa5..730bf84e29 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -5370,6 +5370,8 @@ liquify-list-end {0}, {1} {0} und {1} @msg Reload the page to go on (changes not saved yet may be lost). Laden Sie die Seite neu, um fortzufahren (noch nicht gespeicherte Änderungen können verloren gehen). @msg tool (a tool id) is required tool (eine Werkzeug-ID) ist erforderlich @msg {tool} isn't in a toolbar group of several tools {tool} gehört zu keiner Werkzeuggruppe mit mehreren Werkzeugen +@msg Presentation Mode hides the toolbars: change the screen mode to show them der Präsentationsmodus blendet die Werkzeugleisten aus: Ändern Sie den Bildschirmmodus, um sie anzuzeigen +@msg Tab has hidden the toolbars: press Tab to show them die Tabulatortaste hat die Werkzeugleisten ausgeblendet: Drücken Sie die Tabulatortaste, um sie anzuzeigen @msg onto must name a panel floating in another group onto muss ein Bedienfeld nennen, das in einer anderen Gruppe schwebt @msg below and above must name a panel floating in another group below und above müssen ein Bedienfeld nennen, das in einer anderen Gruppe schwebt @msg give only one of onto, below and above nur eines von onto, below und above angeben diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 8d9aa619c1..119e5cb341 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -5422,6 +5422,8 @@ digits Malayalam Μαλαγιάλαμ @msg Reload the page to go on (changes not saved yet may be lost). Ανανεώστε τη σελίδα για να συνεχίσετε (οι μη αποθηκευμένες αλλαγές ενδέχεται να χαθούν). @msg tool (a tool id) is required απαιτείται tool (αναγνωριστικό εργαλείου) @msg {tool} isn't in a toolbar group of several tools το {tool} δεν ανήκει σε ομάδα πολλών εργαλείων της γραμμής εργαλείων +@msg Presentation Mode hides the toolbars: change the screen mode to show them η Λειτουργία παρουσίασης κρύβει τις γραμμές εργαλείων: αλλάξτε τη λειτουργία οθόνης για να εμφανιστούν +@msg Tab has hidden the toolbars: press Tab to show them το Tab έκρυψε τις γραμμές εργαλείων: πατήστε Tab για να εμφανιστούν @msg onto must name a panel floating in another group το onto πρέπει να ορίζει πίνακα που αιωρείται σε άλλη ομάδα @msg below and above must name a panel floating in another group τα below και above πρέπει να ορίζουν πίνακα που αιωρείται σε άλλη ομάδα @msg give only one of onto, below and above δώστε μόνο ένα από τα onto, below και above diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 8e79de7aee..d25f043f16 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -5475,6 +5475,8 @@ liquify-list-end {0}, {1} {0}, {1} @msg Reload the page to go on (changes not saved yet may be lost). Vuelve a cargar la página para continuar (los cambios que aún no se guardaron podrían perderse). @msg tool (a tool id) is required se requiere tool (un id de herramienta) @msg {tool} isn't in a toolbar group of several tools {tool} no está en un grupo de la barra de herramientas con varias herramientas +@msg Presentation Mode hides the toolbars: change the screen mode to show them el Modo de presentación oculta las barras de herramientas: cambie el modo de pantalla para mostrarlas +@msg Tab has hidden the toolbars: press Tab to show them Tab ha ocultado las barras de herramientas: pulse Tab para mostrarlas @msg onto must name a panel floating in another group onto debe nombrar un panel que flote en otro grupo @msg below and above must name a panel floating in another group below y above deben nombrar un panel que flote en otro grupo @msg give only one of onto, below and above indica solo uno de onto, below y above diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index ca31405019..532bd35660 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -5691,6 +5691,8 @@ liquify-list-end {0}, {1} {0} ja {1} @msg Reload the page to go on (changes not saved yet may be lost). Lataa sivu uudelleen jatkaaksesi (tallentamattomat muutokset voivat kadota). @msg tool (a tool id) is required tool (työkalun tunnus) vaaditaan @msg {tool} isn't in a toolbar group of several tools {tool} ei ole usean työkalun työkaluriviryhmässä +@msg Presentation Mode hides the toolbars: change the screen mode to show them Esitystila piilottaa työkalurivit: tuo ne näkyviin vaihtamalla näyttötilaa +@msg Tab has hidden the toolbars: press Tab to show them Tab on piilottanut työkalurivit: tuo ne näkyviin painamalla Tab-näppäintä @msg onto must name a panel floating in another group onto-arvon on nimettävä toisessa ryhmässä kelluva paneeli @msg below and above must name a panel floating in another group below- ja above-arvojen on nimettävä toisessa ryhmässä kelluva paneeli @msg give only one of onto, below and above anna vain yksi arvoista onto, below ja above diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index f58e367ede..ab0ad4b85f 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -5433,6 +5433,8 @@ liquify-list-end {0}, {1} {0} et {1} @msg Reload the page to go on (changes not saved yet may be lost). Rechargez la page pour continuer (les modifications non encore enregistrées risquent d’être perdues). @msg tool (a tool id) is required tool (un identifiant d’outil) est obligatoire @msg {tool} isn't in a toolbar group of several tools {tool} ne fait pas partie d’un groupe de plusieurs outils dans la barre d’outils +@msg Presentation Mode hides the toolbars: change the screen mode to show them pour afficher les barres d’outils masquées par le Mode Présentation, changez de mode d’affichage +@msg Tab has hidden the toolbars: press Tab to show them pour afficher les barres d’outils masquées par Tab, appuyez sur Tab @msg onto must name a panel floating in another group onto doit désigner un panneau flottant dans un autre groupe @msg below and above must name a panel floating in another group below et above doivent désigner un panneau flottant dans un autre groupe @msg give only one of onto, below and above indiquez un seul de onto, below et above diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index dbf4c2ded9..a0c921b47e 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -6184,6 +6184,8 @@ antiAlias Sharp शार्प @msg {std} files embed their fonts, and the file would have one that isn't {std} फ़ाइलें अपने फ़ॉन्ट एम्बेड करती हैं, और इस फ़ाइल में एक ऐसा फ़ॉन्ट होता जो एम्बेड नहीं है @msg {target} is the file this document was read from, and reading it left things out ({what}): writing over it would lose them for good. Write another file instead, or pass acknowledgeLoss: true to replace it anyway यह डॉक्यूमेंट {target} से पढ़ा गया था और पढ़ते समय कुछ चीज़ें छूट गईं ({what}): उसी फ़ाइल पर लिखने से वे स्थायी रूप से खो जाएँगी। दूसरी फ़ाइल लिखें या फिर भी बदलने के लिए acknowledgeLoss: true दें @msg {tool} isn't in a toolbar group of several tools {tool} कई टूल्स के टूलबार समूह में नहीं है +@msg Presentation Mode hides the toolbars: change the screen mode to show them प्रस्तुति मोड टूलबार्स छिपाता है: उन्हें दिखाने के लिए स्क्रीन मोड बदलें +@msg Tab has hidden the toolbars: press Tab to show them Tab ने टूलबार्स छिपा दिए हैं: उन्हें दिखाने के लिए Tab दबाएँ @msg {ty} brushes need selected art (or params.{k}) {ty} ब्रश के लिए सिलेक्टेड आर्टवर्क (या params.{k}) चाहिए @msg {v} is not an asset id {v} एक परिसंपत्ति आईडी नहीं है @msg {what} can't be intertwined {what} अंतर नहीं किया जा सकता है diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 8cff443416..b914268434 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -6247,6 +6247,8 @@ liquify-list-end {0}, {1} {0} és {1} @msg {path}: {e} {path}: {e} @msg {status} ({e}) {status} ({e}) @msg {tool} isn't in a toolbar group of several tools az eszköz nincs többeszközös eszköztár-csoportban: {tool} +@msg Presentation Mode hides the toolbars: change the screen mode to show them a Bemutató mód elrejti az eszköztárakat: a megjelenítésükhöz váltson képernyőmódot +@msg Tab has hidden the toolbars: press Tab to show them a Tab elrejtette az eszköztárakat: a megjelenítésükhöz nyomja meg a Tab billentyűt @msg the compressed file unpacks to more than VectorCraft reads ({_1} MB of document, {_2} MB per image) a tömörített fájl kicsomagolva nagyobb lenne, mint amennyit a VectorCraft beolvas ({_1} MB dokumentum, képenként {_2} MB) @msg the document is too large to save compressed ({0}): save it with Use Compression off a dokumentum túl nagy a tömörített mentéshez ({0}): mentsd a Tömörítés használata beállítás kikapcsolásával @msg the file stopped being read (please report this bug) a fájl beolvasása megszakadt (kérjük, jelentsd ezt a hibát) diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index fa27956034..2208c490e0 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -5503,6 +5503,8 @@ liquify-list-end {0}, {1} {0} e {1} @msg Reload the page to go on (changes not saved yet may be lost). Ricarica la pagina per continuare (le modifiche non ancora salvate potrebbero andare perse). @msg tool (a tool id) is required tool (un id di strumento) è obbligatorio @msg {tool} isn't in a toolbar group of several tools {tool} non fa parte di un gruppo di più strumenti nella barra degli strumenti +@msg Presentation Mode hides the toolbars: change the screen mode to show them la Modalità presentazione nasconde le barre degli strumenti: cambia la modalità schermo per mostrarle +@msg Tab has hidden the toolbars: press Tab to show them Tab ha nascosto le barre degli strumenti: premi Tab per mostrarle @msg onto must name a panel floating in another group onto deve indicare un pannello mobile in un altro gruppo @msg below and above must name a panel floating in another group below e above devono indicare un pannello mobile in un altro gruppo @msg give only one of onto, below and above indica solo uno tra onto, below e above diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index d50e53c366..0e95e7ff5c 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -5610,6 +5610,8 @@ liquify-list-end {0}, {1} {0}、{1} @msg the {tool} tool has no options {tool} ツールにはオプションがありません @msg unknown tool `{tool}` `{tool}` は不明なツールです @msg {tool} isn't in a toolbar group of several tools {tool} は複数のツールからなるツールグループに含まれていません +@msg Presentation Mode hides the toolbars: change the screen mode to show them プレゼンテーションモードではツールバーが表示されません: 表示するにはスクリーンモードを変更してください +@msg Tab has hidden the toolbars: press Tab to show them Tab でツールバーが非表示になっています: 表示するには Tab キーを押してください @msg no such document 指定されたドキュメントが見つかりません @msg {_1}: not saved, so not closed {_1}: 保存されていないため、閉じませんでした @msg `{name}` is a built-in workspace; choose another name `{name}` は組み込みのワークスペースなので、別の名前を指定してください diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 775771803e..d39c9a891c 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -7250,6 +7250,8 @@ font-technology Variable ცვლადი @msg Reload the page to go on (changes not saved yet may be lost). გასაგრძელებლად გადატვირთეთ გვერდი (ჯერ შეუნახავი ცვლილებები შეიძლება დაიკარგოს). @msg tool (a tool id) is required tool (ხელსაწყოს id) აუცილებელია @msg {tool} isn't in a toolbar group of several tools {tool} რამდენიმე ხელსაწყოს მქონე ხელსაწყოთა ჯგუფში არ არის +@msg Presentation Mode hides the toolbars: change the screen mode to show them პრეზენტაციის რეჟიმი მალავს ხელსაწყოთა ზოლებს: მათ საჩვენებლად შეცვალეთ ეკრანის რეჟიმი +@msg Tab has hidden the toolbars: press Tab to show them Tab-მა დამალა ხელსაწყოთა ზოლები: მათ საჩვენებლად დააჭირეთ Tab-ს @msg onto must name a panel floating in another group onto უნდა ასახელებდეს სხვა ჯგუფში მცურავ პანელს @msg below and above must name a panel floating in another group below და above უნდა ასახელებდეს სხვა ჯგუფში მცურავ პანელს @msg give only one of onto, below and above მიუთითეთ მხოლოდ ერთი: onto, below ან above diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 34b9d70651..90898cf21f 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -5537,6 +5537,8 @@ liquify-list-end {0}, {1} {0} 및 {1} @msg the {tool} tool has no options {tool} 도구에는 옵션이 없습니다 @msg unknown tool `{tool}` 알 수 없는 도구 `{tool}` @msg {tool} isn't in a toolbar group of several tools {tool}은(는) 여러 도구가 있는 도구 모음 그룹에 속하지 않습니다 +@msg Presentation Mode hides the toolbars: change the screen mode to show them 프레젠테이션 모드에서는 도구 모음이 숨겨집니다: 표시하려면 화면 모드를 변경하세요 +@msg Tab has hidden the toolbars: press Tab to show them Tab으로 도구 모음이 숨겨졌습니다: 표시하려면 Tab을 누르세요 @msg no such document 해당 문서가 없습니다 @msg {_1}: not saved, so not closed {_1}: 저장되지 않아 닫지 않았습니다 @msg `{name}` is a built-in workspace; choose another name `{name}`은(는) 기본 제공 작업 영역입니다: 다른 이름을 선택하세요 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index a09dc37538..e8057c93c7 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -5770,6 +5770,8 @@ imageTrace Outline Contour @msg Reload the page to go on (changes not saved yet may be lost). Laad de pagina opnieuw om door te gaan (nog niet opgeslagen wijzigingen kunnen verloren gaan). @msg tool (a tool id) is required tool (een gereedschaps-id) is vereist @msg {tool} isn't in a toolbar group of several tools {tool} zit niet in een werkbalkgroep met meerdere gereedschappen +@msg Presentation Mode hides the toolbars: change the screen mode to show them Presentatiemodus verbergt de werkbalken: wijzig de schermmodus om ze te tonen +@msg Tab has hidden the toolbars: press Tab to show them Tab heeft de werkbalken verborgen: druk op Tab om ze te tonen @msg onto must name a panel floating in another group onto moet een zwevend paneel in een andere groep benoemen @msg below and above must name a panel floating in another group below en above moeten een zwevend paneel in een andere groep benoemen @msg give only one of onto, below and above geef slechts één van onto, below en above diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 6af64a9b47..540441bc7b 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -5593,6 +5593,8 @@ liquify-list-end {0}, {1} {0} i {1} @msg Reload the page to go on (changes not saved yet may be lost). Odśwież stronę, aby kontynuować (niezapisane zmiany mogą zostać utracone). @msg tool (a tool id) is required wymagane jest tool (identyfikator narzędzia) @msg {tool} isn't in a toolbar group of several tools {tool} nie należy do grupy kilku narzędzi na pasku narzędzi +@msg Presentation Mode hides the toolbars: change the screen mode to show them Tryb prezentacji ukrywa paski narzędzi: zmień tryb ekranu, aby je pokazać +@msg Tab has hidden the toolbars: press Tab to show them klawisz Tab ukrył paski narzędzi: naciśnij Tab, aby je pokazać @msg onto must name a panel floating in another group onto musi wskazywać panel pływający w innej grupie @msg below and above must name a panel floating in another group below i above muszą wskazywać panel pływający w innej grupie @msg give only one of onto, below and above podaj tylko jedno z: onto, below, above diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 6130764f9e..fdb3f57efe 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -4774,6 +4774,8 @@ axis Both Ambos @msg Reload the page to go on (changes not saved yet may be lost). Recarregue a página para continuar (alterações ainda não salvas podem ser perdidas). @msg tool (a tool id) is required tool (um id de ferramenta) é obrigatório @msg {tool} isn't in a toolbar group of several tools {tool} não está em um grupo de barra de ferramentas com várias ferramentas +@msg Presentation Mode hides the toolbars: change the screen mode to show them o Modo de Apresentação oculta as barras de ferramentas: altere o modo de tela para mostrá-las +@msg Tab has hidden the toolbars: press Tab to show them Tab ocultou as barras de ferramentas: pressione Tab para mostrá-las @msg onto must name a panel floating in another group onto deve nomear um painel flutuante em outro grupo @msg below and above must name a panel floating in another group below e above devem nomear um painel flutuante em outro grupo @msg give only one of onto, below and above informe apenas um entre onto, below e above diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 858f684750..b8fe10a712 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -5499,6 +5499,8 @@ liquify-list-end {0}, {1} {0} и {1} @msg Reload the page to go on (changes not saved yet may be lost). Перезагрузите страницу, чтобы продолжить (ещё не сохранённые изменения могут быть потеряны). @msg tool (a tool id) is required требуется tool (идентификатор инструмента) @msg {tool} isn't in a toolbar group of several tools {tool} не входит в группу панели инструментов из нескольких инструментов +@msg Presentation Mode hides the toolbars: change the screen mode to show them Режим презентации скрывает панели инструментов: чтобы показать их, смените режим экрана +@msg Tab has hidden the toolbars: press Tab to show them клавиша Tab скрыла панели инструментов: чтобы показать их, нажмите Tab @msg onto must name a panel floating in another group onto должен называть панель, плавающую в другой группе @msg below and above must name a panel floating in another group below и above должны называть панель, плавающую в другой группе @msg give only one of onto, below and above укажите только один из onto, below и above diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 4ef57fa56d..6bc05b5681 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -5363,6 +5363,8 @@ liquify-list-end {0}, {1} {0} och {1} @msg Reload the page to go on (changes not saved yet may be lost). Läs in sidan igen för att fortsätta (ändringar som inte sparats än kan gå förlorade). @msg tool (a tool id) is required tool (ett verktygs-id) krävs @msg {tool} isn't in a toolbar group of several tools {tool} ingår inte i en verktygsgrupp med flera verktyg +@msg Presentation Mode hides the toolbars: change the screen mode to show them Presentationsläge döljer verktygsfälten: byt skärmläge för att visa dem +@msg Tab has hidden the toolbars: press Tab to show them Tab har dolt verktygsfälten: tryck på Tab för att visa dem @msg onto must name a panel floating in another group onto måste ange en panel som flyter i en annan grupp @msg below and above must name a panel floating in another group below och above måste ange en panel som flyter i en annan grupp @msg give only one of onto, below and above ange bara en av onto, below och above diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index b65a17bb56..dc98abcf8c 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -5569,7 +5569,8 @@ const MESSAGE_MARKERS: &[&str] = &[".status(", "ui.status = ", "status = ", "Oth /// a plug-in returned), and the script interpreter's methods that throw an error at a script: /// `.type_error(msg)`, `.throw(kind, msg)` and the XPath evaluator's `.error(msg)`, with the reasons /// it gives for a property it cannot define or assign (`.reject_bool(throw, key, why)` and -/// `.reject(throw, key, why)`). A helper that starts with `.` is a method of any receiver; any other +/// `.reject(throw, key, why)`), and the interface's `unavailable(tool, reason)` (a tool's place that +/// no toolbar can show, which Help puts in the status bar). A helper that starts with `.` is a method of any receiver; any other /// is a function, not a type's own function of the same name (`Grays::param(C, p)`). const ERROR_HELPERS: &[(&str, &str, usize)] = &[ ("engine", "bad(", 1), @@ -5592,6 +5593,7 @@ const ERROR_HELPERS: &[(&str, &str, usize)] = &[ ("js", ".error(", 0), ("js", ".reject_bool(", 2), ("js", ".reject(", 2), + ("ui-egui", "unavailable(", 1), ]; /// Error variants whose first argument is a name, not a message: a command id diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 847c8982d1..a2e74c6166 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -5192,6 +5192,8 @@ liquify-list-end {0}, {1} {0} ve {1} @msg Reload the page to go on (changes not saved yet may be lost). Devam etmek için sayfayı yeniden yükleyin (henüz kaydedilmemiş değişiklikler kaybolabilir). @msg tool (a tool id) is required tool (bir araç kimliği) gerekli @msg {tool} isn't in a toolbar group of several tools {tool} çeşitli araçlardan oluşan bir araç çubuğu grubunda değil +@msg Presentation Mode hides the toolbars: change the screen mode to show them Sunum Modu araç çubuklarını gizler: göstermek için ekran modunu değiştirin +@msg Tab has hidden the toolbars: press Tab to show them Tab araç çubuklarını gizledi: göstermek için Tab tuşuna basın @msg onto must name a panel floating in another group onto başka bir grupta yüzen bir paneli adlandırmalıdır @msg below and above must name a panel floating in another group below ve above başka bir grupta yüzen bir paneli adlandırmalıdır @msg give only one of onto, below and above onto, below ve above değerlerinden yalnızca birini verin diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index b060de8119..aae65d3062 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -5487,6 +5487,8 @@ liquify-list-end {0}, {1} {0} і {1} @msg Reload the page to go on (changes not saved yet may be lost). Перезавантажте сторінку, щоб продовжити (незбережені зміни можуть бути втрачені). @msg tool (a tool id) is required потрібно tool (ідентифікатор інструменту) @msg {tool} isn't in a toolbar group of several tools {tool} не входить до групи панелі інструментів з кількох інструментів +@msg Presentation Mode hides the toolbars: change the screen mode to show them Режим презентації приховує панелі інструментів: щоб показати їх, змініть режим екрану +@msg Tab has hidden the toolbars: press Tab to show them клавіша Tab приховала панелі інструментів: щоб показати їх, натисніть Tab @msg onto must name a panel floating in another group onto має називати панель, що плаває в іншій групі @msg below and above must name a panel floating in another group below і above мають називати панель, що плаває в іншій групі @msg give only one of onto, below and above вкажіть лише один із onto, below і above diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 3f2c2db581..aac4c499b2 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -6035,6 +6035,8 @@ liquify-list-end {0}, {1} {0} và {1} @msg {path}: {e} {path}: {e} @msg {status} ({e}) {status} ({e}) @msg {tool} isn't in a toolbar group of several tools {tool} không nằm trong nhóm thanh công cụ có nhiều công cụ +@msg Presentation Mode hides the toolbars: change the screen mode to show them Chế độ trình bày ẩn các thanh công cụ: hãy đổi chế độ màn hình để hiện chúng +@msg Tab has hidden the toolbars: press Tab to show them phím Tab đã ẩn các thanh công cụ: nhấn Tab để hiện chúng Load EPS into Clipboard Tải EPS vào bảng tạm @msg an image of {w} × {h} pixels is too large to draw ảnh {w} × {h} điểm ảnh quá lớn nên không thể vẽ @msg {path}: not a PNG, JPEG, WebP, TIFF or BMP image {path}: không phải ảnh PNG, JPEG, WebP, TIFF hay BMP diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index e5a2c7c3d9..53c812407c 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -5286,6 +5286,8 @@ liquify-list-end {0}, {1} {0}和{1} @msg the {tool} tool has no options {tool} 工具没有选项 @msg unknown tool `{tool}` 未知工具 `{tool}` @msg {tool} isn't in a toolbar group of several tools {tool} 不在包含多个工具的工具栏组中 +@msg Presentation Mode hides the toolbars: change the screen mode to show them 演示模式会隐藏工具栏:请更改屏幕模式以显示工具栏 +@msg Tab has hidden the toolbars: press Tab to show them Tab 已隐藏工具栏:请按 Tab 以显示工具栏 @msg no such document 没有此文档 @msg {_1}: not saved, so not closed {_1}:未保存,因此未关闭 @msg `{name}` is a built-in workspace; choose another name `{name}` 是内置工作区;请选择其他名称 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 44bdef3d15..9162aad233 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2823,6 +2823,8 @@ liquify-list-end {0}, {1} {0}和{1} @msg the {tool} tool has no options {tool} 工具沒有選項 @msg unknown tool `{tool}` 未知的工具 `{tool}` @msg {tool} isn't in a toolbar group of several tools {tool} 不在包含多個工具的工具列群組中 +@msg Presentation Mode hides the toolbars: change the screen mode to show them 簡報模式會隱藏工具列:請變更螢幕模式以顯示工具列 +@msg Tab has hidden the toolbars: press Tab to show them Tab 已隱藏工具列:請按 Tab 以顯示工具列 @msg no such document 沒有這個文件 @msg {_1}: not saved, so not closed {_1}:未儲存,因此未關閉 @msg `{name}` is a built-in workspace; choose another name `{name}` 是內建工作區;請選擇其他名稱 diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index d4703034ea..21ba570e5d 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -93,6 +93,65 @@ fn help_f1_opens_discover_without_a_document() { assert!(crate::panel_docking::showing(&app.ui, "discover")); } +/// With the toolbars hidden by Tab, choosing a tool in Help, or a tool's link in a tutorial Help +/// shows, marks nothing and the status bar says why. +#[test] +fn discover_says_why_a_tool_cannot_be_marked() { + fn texts(ctx: &egui::Context, app: &mut VectorcraftApp, events: Vec) -> Vec<(String, egui::Rect)> { + let mut out = ctx.run_ui(egui::RawInput { events, ..Default::default() }, |ui| crate::panels::discover::show(app, ui)); + out.textures_delta.clear(); + fn collect(s: &egui::Shape, out: &mut Vec<(String, egui::Rect)>) { + match s { + egui::Shape::Text(t) => out.push((t.galley.text().to_string(), t.visual_bounding_rect())), + egui::Shape::Vec(v) => v.iter().for_each(|s| collect(s, out)), + _ => {} + } + } + let mut texts = vec![]; + for c in &out.shapes { + collect(&c.shape, &mut texts); + } + texts + } + fn click(ctx: &egui::Context, app: &mut VectorcraftApp, label: &str) { + texts(ctx, app, vec![]); + let drawn = texts(ctx, app, vec![]); + let pos = drawn.iter().find(|(t, _)| t == label).unwrap_or_else(|| panic!("`{label}` not drawn: {drawn:?}")).1.center(); + let button = |pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + for e in [egui::Event::PointerMoved(pos), button(true), button(false)] { + texts(ctx, app, vec![e]); + } + } + crate::i18n::set_current(crate::i18n::Lang::EN); + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + app.run("window.dock", json!({})).unwrap(); + assert!(app.ui.tab_hid.is_some() && !app.ui.toolbar); + let reason = app.run("learn.locateTool", json!({"tool": "rectangle"})).unwrap()["reason"].as_str().unwrap().to_string(); + let ctx = egui::Context::default(); + theme::install_fonts(&ctx); + + let found = app.run("help.discover.search", json!({"query": "rectangle"})).unwrap(); + let hit = found["results"].as_array().unwrap().iter().find(|hit| hit["kind"] == "tool" && hit["id"] == "rectangle").unwrap().clone(); + app.status(""); + click(&ctx, &mut app, hit["label"].as_str().unwrap()); + assert_eq!(app.ui.discover.selected.map(|i| app.ui.discover.results[i].id.as_str()), Some("rectangle")); + assert!(app.ui.learn_locate.is_none()); + assert_eq!(app.ui.status, reason); + + let (tutorial, tool) = crate::panels::learn::catalog::SKILLS + .iter() + .flat_map(|skill| skill.tutorials.iter()) + .find_map(|t| t.steps.iter().find_map(|s| s.tool).map(|tool| (t, tool))) + .unwrap(); + let found = app.run("help.discover.search", json!({"query": tutorial.title})).unwrap(); + let index = found["results"].as_array().unwrap().iter().position(|hit| hit["kind"] == "tutorial" && hit["id"] == tutorial.id).unwrap(); + app.run("help.discover.choose", json!({"index": index})).unwrap(); + app.status(""); + click(&ctx, &mut app, vectorcraft_tools::tool_info(tool).unwrap().label); + assert!(app.ui.learn_locate.is_none()); + assert_eq!(app.ui.status, reason); +} + #[test] fn discover_rejects_invalid_search_and_selection_parameters() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); diff --git a/crates/ui-egui/src/panels/discover.rs b/crates/ui-egui/src/panels/discover.rs index c5eaa78eea..9a08d2d0c7 100644 --- a/crates/ui-egui/src/panels/discover.rs +++ b/crates/ui-egui/src/panels/discover.rs @@ -282,14 +282,24 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { if let Err(e) = app.run("help.discover.back", json!({})) { app.status(e); } - } else if let Some(index) = chosen - && let Err(e) = app.run("help.discover.choose", json!({"index": index})) - { - app.status(e); + } else if let Some(index) = chosen { + match app.run("help.discover.choose", json!({"index": index})) { + Ok(picked) => status_reason(app, &picked["location"]), + Err(e) => app.status(e), + } } - if let Some(tool) = locate - && let Err(e) = app.run("learn.locateTool", json!({"tool": tool})) - { - app.status(e); + if let Some(tool) = locate { + match app.run("learn.locateTool", json!({"tool": tool})) { + Ok(located) => status_reason(app, &located), + Err(e) => app.status(e), + } + } +} + +/// A `learn.locateTool` reply that could not mark its tool (`location: "unavailable"`) shows its +/// `reason` in the status bar. +fn status_reason(app: &mut VectorcraftApp, located: &Value) { + if let Some(reason) = located.get("reason").and_then(Value::as_str) { + app.status(reason); } } From b778279d6f81bc22fd07a37a32330b2c72f547ba Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 07:27:00 -0800 Subject: [PATCH 5/7] Help: kept command results follow their menu items A kept command result now takes its menu item's current label and menu path when the menu state changes, so Show Grid reads Hide Grid once the grid shows, and a command that no menu lists any more drops out. The results are brought up to date only when the menus' state hash changes, with the menu entries looked up by command and params. Help commands reject parameters that are not an object. --- crates/ui-egui/src/menus/tests.rs | 22 +++++++++++++ crates/ui-egui/src/native_menu.rs | 2 +- crates/ui-egui/src/panels/discover.rs | 47 +++++++++++++++++++++------ docs/mcp.md | 8 +++-- 4 files changed, 66 insertions(+), 13 deletions(-) diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index 21ba570e5d..205817891c 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -166,11 +166,33 @@ fn discover_rejects_invalid_search_and_selection_parameters() { for index in [json!(-1), json!(1.5), json!(1000000), json!("0"), Value::Null] { assert!(app.run("help.discover.choose", json!({"index": index})).is_err()); } + for params in [json!(5), json!("rectangle"), json!([1]), json!(true)] { + for id in ["help.discover", "help.discover.search", "help.discover.choose", "help.discover.back"] { + assert!(app.run(id, params.clone()).is_err(), "{id} {params}"); + } + assert_eq!(app.ui.discover.query, before); + } app.run("help.discover.search", json!({"query": " "})).unwrap(); assert!(app.ui.discover.results.is_empty()); assert!(app.run("help.discover.choose", json!({"index": 0})).is_err()); } +/// A kept command result follows its menu item: Show Grid reads Hide Grid once the grid shows. +#[test] +fn discover_command_results_follow_their_menu_label() { + crate::i18n::set_current(crate::i18n::Lang::EN); + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({})).unwrap(); + let found = app.run("help.discover.search", json!({"query": "view.grid"})).unwrap(); + let index = found["results"].as_array().unwrap().iter().position(|hit| hit["id"] == "view.grid" && hit["path"][0] == "View").unwrap(); + assert_eq!(found["results"][index]["label"], "Show Grid"); + app.run("help.discover.choose", json!({"index": index})).unwrap(); + app.run("view.grid", json!({})).unwrap(); + let back = app.run("help.discover", json!({})).unwrap(); + assert_eq!(back["selected"], index); + assert_eq!(back["results"][index]["label"], "Hide Grid"); +} + #[test] fn discover_results_show_the_current_shortcut_and_language_after_a_change() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); diff --git a/crates/ui-egui/src/native_menu.rs b/crates/ui-egui/src/native_menu.rs index 510131be0e..40ebc46ba5 100644 --- a/crates/ui-egui/src/native_menu.rs +++ b/crates/ui-egui/src/native_menu.rs @@ -610,7 +610,7 @@ pub fn sync(app: &mut VectorcraftApp, ctx: &egui::Context) { /// interaction is open (for example a move, scale or shape drag, a dialog's or the font menu's /// preview, or a typing session), the revision, which each of its previews changes, is left out: /// the hash changes as the interaction begins and as it ends. -fn state_hash(app: &VectorcraftApp, input: Option) -> u64 { +pub(crate) fn state_hash(app: &VectorcraftApp, input: Option) -> u64 { let mut h = DefaultHasher::new(); input.hash(&mut h); app.run_count.hash(&mut h); diff --git a/crates/ui-egui/src/panels/discover.rs b/crates/ui-egui/src/panels/discover.rs index 9a08d2d0c7..2b38e16591 100644 --- a/crates/ui-egui/src/panels/discover.rs +++ b/crates/ui-egui/src/panels/discover.rs @@ -32,8 +32,9 @@ pub struct View { pub results: Vec, pub selected: Option, pub focus: bool, - /// The shortcut generation and language the results were last brought up to date for. - current_for: Option<(u64, crate::i18n::Lang)>, + /// The menu state ([`crate::native_menu::state_hash`]: commands run, shortcuts, the language, + /// recent files and more) the results were last brought up to date for. + current_for: Option, } fn matches(query: &str, text: &str) -> bool { @@ -41,32 +42,55 @@ fn matches(query: &str, text: &str) -> bool { query.split_whitespace().all(|word| text.contains(word)) } -fn now() -> (u64, crate::i18n::Lang) { - (crate::shortcut_editor::GENERATION.load(std::sync::atomic::Ordering::Relaxed), crate::i18n::current()) +fn now(app: &VectorcraftApp) -> u64 { + crate::native_menu::state_hash(app, None) } -/// Updates the retained results' labels, menu paths and shortcuts after a shortcut or the UI -/// language changes, keeping the query, the results' order and the selected result. +/// Updates the retained results' labels, menu paths and shortcuts after the menu state changes (a +/// command, a shortcut or the UI language), keeping the query, the results' order and the selected +/// result. A command result takes its menu item's current label and place (Show Grid becomes Hide +/// Grid), and leaves the results when no menu lists it any more, such as a recent file that was +/// removed. fn refresh(app: &mut VectorcraftApp) { - let stamp = now(); + let stamp = now(app); if app.ui.discover.current_for == Some(stamp) { return; } - let lang = stamp.1; - for hit in &mut app.ui.discover.results { + let lang = crate::i18n::current(); + let entries = if app.ui.discover.results.iter().any(|hit| hit.kind == "command") { menus::menu_entries(app) } else { Vec::new() }; + let mut by_command: std::collections::HashMap<(&str, String), Vec<&menus::MenuEntry>> = std::collections::HashMap::new(); + for entry in &entries { + if let Some(id) = entry.command.as_deref() { + by_command.entry((id, entry.params.to_string())).or_default().push(entry); + } + } + let selected = app.ui.discover.selected.take(); + let mut kept = Vec::with_capacity(app.ui.discover.results.len()); + for (index, mut hit) in std::mem::take(&mut app.ui.discover.results).into_iter().enumerate() { match hit.kind { "tool" => { hit.label = crate::i18n::tr(lang, &hit.english_label).into(); hit.shortcut = crate::shortcut_editor::tool_shortcut(&hit.id).unwrap_or_default().into(); } "command" => { + let same = by_command.get(&(hit.id.as_str(), hit.params.to_string())).map_or(&[][..], Vec::as_slice); + let Some(entry) = same.iter().find(|e| e.path == hit.english_path).or_else(|| same.first()) else { + continue; + }; + hit.english_label = entry.label.clone(); + hit.english_path = entry.path.clone(); hit.label = crate::i18n::tr(lang, &hit.english_label).into(); hit.path = hit.english_path.iter().map(|part| crate::i18n::tr(lang, part).into()).collect(); hit.shortcut = menus::item_shortcut(&hit.id, &hit.params).or_else(|| menus::shortcut_of(&hit.id)).unwrap_or_default().into(); } _ => {} } + if selected == Some(index) { + app.ui.discover.selected = Some(kept.len()); + } + kept.push(hit); } + app.ui.discover.results = kept; app.ui.discover.current_for = Some(stamp); } @@ -133,7 +157,7 @@ fn results(app: &VectorcraftApp) -> Value { } fn set_query(app: &mut VectorcraftApp, query: &str) { - app.ui.discover.current_for = Some(now()); + app.ui.discover.current_for = Some(now(app)); app.ui.discover.results = search(app, query); app.ui.discover.query = query.into(); app.ui.discover.selected = None; @@ -141,6 +165,9 @@ fn set_query(app: &mut VectorcraftApp, query: &str) { pub(crate) fn command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option> { let spec = menus::UI_COMMANDS.iter().find(|spec| spec.0 == id && id.starts_with("help.discover"))?; + if !(p.is_object() || p.is_null()) { + return Some(Err("`params` must be an object".into())); + } if let Err(e) = vectorcraft_engine::cmd::params::check_keys(id, spec.3, p) { return Some(Err(e.to_string())); } diff --git a/docs/mcp.md b/docs/mcp.md index 4b440d4f8b..fcc78d8a40 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3269,13 +3269,17 @@ the results. VectorCraft limits a query to 1024 characters and rejects a longer words without regard to case, using translated tool and command labels as well as their English labels, ids, and menu paths. Tutorial text remains in English. After a shortcut or the interface language changes, the kept results show the current shortcuts, labels, and menu paths, with the -query and the selected result unchanged. +query and the selected result unchanged. A command result also shows its menu item's current +label (Show Grid becomes Hide Grid), and a command that no menu lists any more, such as a removed +recent file, drops out of the results. Parameters other than an object are an error. `help.discover.choose {index}` shows that result. A tool result marks its toolbar location without choosing the tool. A command result shows its menu path and current shortcut without running it. A tutorial result shows its numbered steps; a tool link in a step marks that tool's location. The reply is `{result, location}`, with the chosen result and the tool-location reply, tutorial -id, or command path. An invalid index returns an error and preserves the selected result. +id, or command path. An invalid index returns an error and preserves the selected result. When a +tool cannot be marked because Tab or Presentation Mode hides the toolbars, the panel shows the +tool-location reply's `reason` in the status bar. Home clears the search. Back and `help.discover.back {}` return to its results with the query preserved. Escape in the search field closes the panel. Escape on the canvas still cancels an From 5a96aff5daf4a7dbc7d9ce5456b2a52bd40ecf85 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 07:44:19 -0800 Subject: [PATCH 6/7] Help: command results use the labels their menus show MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Help now searches and shows a command by the label its menu draws in the UI language, so Effect > Pathfinder > Add is found as Réunion in French. menus::shown_label holds the menus' item-label rule, and the menu bar and Help both call it. --- crates/ui-egui/src/menus.rs | 3 ++- crates/ui-egui/src/menus/entries.rs | 16 +++++++++++----- crates/ui-egui/src/menus/tests.rs | 23 +++++++++++++++++++++++ crates/ui-egui/src/panels/discover.rs | 6 +++--- docs/mcp.md | 4 ++-- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 053eb63d79..fcd975a2ae 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -62,7 +62,8 @@ pub(crate) use bar::{home_key, home_showing}; use bar::{menu_body, pointer_reaches_title}; pub use context::{context_items, context_menu_body, ruler_menu_body, ruler_unit_items}; pub use entries::{ - InsertableItem, MenuEntry, Row, context_entries, entry, insertable, insertable_items, menu_entries, plays_in_app, pretty_shortcut, shown_shortcut, + InsertableItem, MenuEntry, Row, context_entries, entry, insertable, insertable_items, menu_entries, plays_in_app, pretty_shortcut, shown_label, + shown_shortcut, }; pub(crate) use invoke::graph_dialog; #[cfg(test)] diff --git a/crates/ui-egui/src/menus/entries.rs b/crates/ui-egui/src/menus/entries.rs index 953b5b58f4..f79a9a6518 100644 --- a/crates/ui-egui/src/menus/entries.rs +++ b/crates/ui-egui/src/menus/entries.rs @@ -53,11 +53,7 @@ pub fn entry<'a>(app: &VectorcraftApp, it: &'a Item) -> Option> { Entry::Item(Row { command: Some((id, p)), source: label, - label: effect_item_label(id, p) - .or_else(|| unlock_item_label(app, id, p, crate::i18n::current())) - .or_else(|| spelling_item_label(id, p)) - .unwrap_or_else(|| display_label(app, id, label)) - .into(), + label: shown_label(app, id, p, label).into(), shortcut: item_shortcut(id, p), enabled, checked, @@ -66,6 +62,16 @@ pub fn entry<'a>(app: &VectorcraftApp, it: &'a Item) -> Option> { }) } +/// The label of the menu item that runs `id` with `p` and reads `label` in English, as the menus +/// draw it in the UI language: an effect's own name (Pathfinder › Add), an object's name, a +/// spelling suggestion, or [`display_label`]. +pub fn shown_label(app: &VectorcraftApp, id: &str, p: &Value, label: &str) -> String { + effect_item_label(id, p) + .or_else(|| unlock_item_label(app, id, p, crate::i18n::current())) + .or_else(|| spelling_item_label(id, p)) + .unwrap_or_else(|| display_label(app, id, label)) +} + /// `Cmd+Shift+]` → `⇧⌘]` on macOS, `Ctrl+Shift+]` elsewhere. pub fn pretty_shortcut(s: &str) -> String { if s.is_empty() { diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index 205817891c..4a25841b5b 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -193,6 +193,29 @@ fn discover_command_results_follow_their_menu_label() { assert_eq!(back["results"][index]["label"], "Hide Grid"); } +/// Help finds a command by the label its menu shows in the UI language, also where the menu names +/// an effect by its own id (Effect › Pathfinder › Add reads Réunion in French). +#[test] +fn discover_finds_commands_by_their_shown_menu_label() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + let fr = crate::i18n::Lang::from_code("fr").unwrap(); + let shown = crate::i18n::tr_id(fr, "pathfinder.add", "Add"); + assert_ne!(shown, crate::i18n::tr(fr, "Add")); + crate::i18n::set_current(fr); + let found = app.run("help.discover.search", json!({"query": shown})); + let effect = crate::i18n::tr(fr, "Effect").to_string(); + crate::i18n::set_current(crate::i18n::Lang::EN); + let found = found.unwrap(); + let hits = found["results"].as_array().unwrap(); + assert!( + hits.iter().any(|hit| hit["kind"] == "command" + && hit["id"].as_str().is_some_and(|id| id.starts_with("effect.")) + && hit["label"] == shown + && hit["path"][0] == effect), + "{found}" + ); +} + #[test] fn discover_results_show_the_current_shortcut_and_language_after_a_change() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); diff --git a/crates/ui-egui/src/panels/discover.rs b/crates/ui-egui/src/panels/discover.rs index 2b38e16591..0f3816ca1b 100644 --- a/crates/ui-egui/src/panels/discover.rs +++ b/crates/ui-egui/src/panels/discover.rs @@ -79,7 +79,7 @@ fn refresh(app: &mut VectorcraftApp) { }; hit.english_label = entry.label.clone(); hit.english_path = entry.path.clone(); - hit.label = crate::i18n::tr(lang, &hit.english_label).into(); + hit.label = menus::shown_label(app, &hit.id, &hit.params, &hit.english_label); hit.path = hit.english_path.iter().map(|part| crate::i18n::tr(lang, part).into()).collect(); hit.shortcut = menus::item_shortcut(&hit.id, &hit.params).or_else(|| menus::shortcut_of(&hit.id)).unwrap_or_default().into(); } @@ -118,13 +118,13 @@ fn search(app: &VectorcraftApp, query: &str) -> Vec { } for entry in menus::menu_entries(app) { let Some(id) = entry.command else { continue }; - let label = crate::i18n::tr(lang, &entry.label); + let label = menus::shown_label(app, &id, &entry.params, &entry.label); let path: Vec = entry.path.iter().map(|part| crate::i18n::tr(lang, part).into()).collect(); if matches(&query, &format!("{} {label} {} {} {id}", entry.label, entry.path.join(" "), path.join(" "))) { hits.push(Hit { kind: "command", id, - label: label.into(), + label, path, shortcut: entry.shortcut, english_label: entry.label, diff --git a/docs/mcp.md b/docs/mcp.md index fcc78d8a40..257657eaa8 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3266,8 +3266,8 @@ the results. VectorCraft limits a query to 1024 characters and rejects a longer `help.discover.search {query}` runs the same search and shows the panel. Both commands return `{query, results: [{kind, id, label, path, shortcut}], selected}`. `kind` is `tool`, `command`, or `tutorial`; `selected` is a zero-based result index or `null`. Search matches all the query's -words without regard to case, using translated tool and command labels as well as their English -labels, ids, and menu paths. Tutorial text remains in English. After a shortcut or the interface +words without regard to case, using translated tool labels, command labels as their menus show +them, and the English labels, ids, and menu paths. Tutorial text remains in English. After a shortcut or the interface language changes, the kept results show the current shortcuts, labels, and menu paths, with the query and the selected result unchanged. A command result also shows its menu item's current label (Show Grid becomes Hide Grid), and a command that no menu lists any more, such as a removed From 2d1832394a0dea0dd7ce3cc770f781e9fe3a97c5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 07:59:10 -0800 Subject: [PATCH 7/7] Help: result paths name the menus as they are drawn A command result's menu path now reads as the menus draw it in the UI language: plug-in submenus and Scripts folders keep their own names. menu_entries carries that shown path beside the English one. Outside macOS, items that only the VectorCraft application menu lists are left out of Help, since the window's menu bar has no such menu. --- crates/ui-egui/src/menus.rs | 2 ++ crates/ui-egui/src/menus/entries.rs | 18 ++++++++++---- crates/ui-egui/src/menus/tests.rs | 34 +++++++++++++++++++++++++++ crates/ui-egui/src/panels/discover.rs | 8 +++++-- docs/mcp.md | 4 +++- 5 files changed, 59 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index fcd975a2ae..c382be06b2 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -61,6 +61,8 @@ pub(crate) use bar::{home_key, home_showing}; #[cfg(test)] use bar::{menu_body, pointer_reaches_title}; pub use context::{context_items, context_menu_body, ruler_menu_body, ruler_unit_items}; +#[cfg(test)] +use entries::flatten; pub use entries::{ InsertableItem, MenuEntry, Row, context_entries, entry, insertable, insertable_items, menu_entries, plays_in_app, pretty_shortcut, shown_label, shown_shortcut, diff --git a/crates/ui-egui/src/menus/entries.rs b/crates/ui-egui/src/menus/entries.rs index f79a9a6518..8c92fbc071 100644 --- a/crates/ui-egui/src/menus/entries.rs +++ b/crates/ui-egui/src/menus/entries.rs @@ -115,13 +115,17 @@ pub struct MenuEntry { pub params: Value, pub enabled: bool, pub shortcut: String, + /// `path` as the menus draw it in the UI language: a plug-in's submenu and a Scripts folder + /// keep their names. + #[serde(skip)] + pub shown_path: Vec, } /// Flattened menu for `ui.menu.list`. pub fn menu_entries(app: &VectorcraftApp) -> Vec { let mut out = vec![]; for (title, items) in menu_tree_named(app.session.prefs.font_names_in_english) { - flatten(app, vec![title.to_string()], &items, &mut out); + flatten(app, vec![title.to_string()], vec![crate::i18n::t(title).to_string()], &items, &mut out); } out } @@ -129,7 +133,7 @@ pub fn menu_entries(app: &VectorcraftApp) -> Vec { /// Flattened canvas context menu for `ui.contextMenu.list` (paths are its submenus). pub fn context_entries(app: &VectorcraftApp) -> Vec { let mut out = vec![]; - flatten(app, vec![], &context_items(app), &mut out); + flatten(app, vec![], vec![], &context_items(app), &mut out); out } @@ -251,7 +255,7 @@ pub fn insertable_items(english_names: bool) -> Vec { out } -fn flatten(app: &VectorcraftApp, path: Vec, items: &[Item], out: &mut Vec) { +pub(super) fn flatten(app: &VectorcraftApp, path: Vec, shown: Vec, items: &[Item], out: &mut Vec) { for it in items { match it { Item::Cmd(l, id, p) => { @@ -272,6 +276,7 @@ fn flatten(app: &VectorcraftApp, path: Vec, items: &[Item], out: &mut Ve params: p.clone(), enabled, shortcut: item_shortcut(id, p).or_else(|| shortcut_of(id)).unwrap_or("").to_string(), + shown_path: shown.clone(), }) } Item::Todo(l, sc) => out.push(MenuEntry { @@ -281,11 +286,16 @@ fn flatten(app: &VectorcraftApp, path: Vec, items: &[Item], out: &mut Ve params: Value::Null, enabled: false, shortcut: sc.to_string(), + shown_path: shown.clone(), }), Item::Sub(l, ch) => { let mut p = path.clone(); p.push(l.to_string()); - flatten(app, p, ch, out); + // The menus draw a plug-in's submenu and a Scripts folder by their own names ([`entry`]). + let mut s = shown.clone(); + let own = super::labels::holds_plugin_commands(ch) || crate::scripts_menu::is_folder(ch); + s.push(if own { l.to_string() } else { crate::i18n::t(l).to_string() }); + flatten(app, p, s, ch, out); } _ => {} } diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index 4a25841b5b..d5991d8b20 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -193,6 +193,40 @@ fn discover_command_results_follow_their_menu_label() { assert_eq!(back["results"][index]["label"], "Hide Grid"); } +/// A menu entry's shown path translates the menus' own names and keeps a Scripts folder's name, as +/// the menus draw it; Help shows that path. +#[test] +fn menu_entry_shown_paths_keep_script_folder_names() { + let app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + let de = crate::i18n::Lang::from_code("de").unwrap(); + assert_ne!(crate::i18n::tr(de, "File"), "File"); + let script = json!({"path": "File/a.jsx"}); + let folder = vec![Item::Cmd("a", crate::scripts_menu::COMMAND, script)]; + let items = vec![Item::Sub("Scripts", vec![Item::Sub("File", folder), Item::Cmd("Other Script…", "ui.runScript", Value::Null)])]; + let mut out = vec![]; + crate::i18n::set_current(de); + flatten(&app, vec!["File".into()], vec![crate::i18n::t("File").into()], &items, &mut out); + crate::i18n::set_current(crate::i18n::Lang::EN); + let script = out.iter().find(|e| e.command.as_deref() == Some(crate::scripts_menu::COMMAND)).unwrap(); + assert_eq!(script.path, ["File", "Scripts", "File"]); + assert_eq!(script.shown_path, [crate::i18n::tr(de, "File"), crate::i18n::tr(de, "Scripts"), "File"]); +} + +/// Outside macOS the window's menu bar has no VectorCraft menu, so Help lists no command under it. +#[test] +fn discover_leaves_out_menus_the_window_does_not_show() { + crate::i18n::set_current(crate::i18n::Lang::EN); + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), crate::Services::default()); + let app_menu: Vec = + menu_entries(&app).into_iter().filter(|e| e.path.first().is_some_and(|t| t == "VectorCraft")).filter_map(|e| e.command).collect(); + assert!(!app_menu.is_empty()); + for id in app_menu { + let found = app.run("help.discover.search", json!({"query": id})).unwrap(); + let listed = found["results"].as_array().unwrap().iter().any(|hit| hit["path"][0] == "VectorCraft"); + assert_eq!(listed, cfg!(target_os = "macos"), "{id}: {found}"); + } +} + /// Help finds a command by the label its menu shows in the UI language, also where the menu names /// an effect by its own id (Effect › Pathfinder › Add reads Réunion in French). #[test] diff --git a/crates/ui-egui/src/panels/discover.rs b/crates/ui-egui/src/panels/discover.rs index 0f3816ca1b..1c3fd12262 100644 --- a/crates/ui-egui/src/panels/discover.rs +++ b/crates/ui-egui/src/panels/discover.rs @@ -80,7 +80,7 @@ fn refresh(app: &mut VectorcraftApp) { hit.english_label = entry.label.clone(); hit.english_path = entry.path.clone(); hit.label = menus::shown_label(app, &hit.id, &hit.params, &hit.english_label); - hit.path = hit.english_path.iter().map(|part| crate::i18n::tr(lang, part).into()).collect(); + hit.path = entry.shown_path.clone(); hit.shortcut = menus::item_shortcut(&hit.id, &hit.params).or_else(|| menus::shortcut_of(&hit.id)).unwrap_or_default().into(); } _ => {} @@ -118,8 +118,12 @@ fn search(app: &VectorcraftApp, query: &str) -> Vec { } for entry in menus::menu_entries(app) { let Some(id) = entry.command else { continue }; + // The menu bar in the window has no VectorCraft menu; only the native macOS bar shows it. + if !cfg!(target_os = "macos") && entry.path.first().is_some_and(|title| title == "VectorCraft") { + continue; + } let label = menus::shown_label(app, &id, &entry.params, &entry.label); - let path: Vec = entry.path.iter().map(|part| crate::i18n::tr(lang, part).into()).collect(); + let path = entry.shown_path; if matches(&query, &format!("{} {label} {} {} {id}", entry.label, entry.path.join(" "), path.join(" "))) { hits.push(Hit { kind: "command", diff --git a/docs/mcp.md b/docs/mcp.md index 257657eaa8..768ba4c530 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3267,7 +3267,9 @@ the results. VectorCraft limits a query to 1024 characters and rejects a longer `{query, results: [{kind, id, label, path, shortcut}], selected}`. `kind` is `tool`, `command`, or `tutorial`; `selected` is a zero-based result index or `null`. Search matches all the query's words without regard to case, using translated tool labels, command labels as their menus show -them, and the English labels, ids, and menu paths. Tutorial text remains in English. After a shortcut or the interface +them, and the English labels, ids, and menu paths. A result's `path` names the menus as they are +drawn, with plug-in submenus and Scripts folders under their own names. Outside macOS, items of +the VectorCraft application menu, which only the macOS menu bar shows, are left out. Tutorial text remains in English. After a shortcut or the interface language changes, the kept results show the current shortcuts, labels, and menu paths, with the query and the selected result unchanged. A command result also shows its menu item's current label (Show Grid becomes Hide Grid), and a command that no menu lists any more, such as a removed