Contextual Task Bar: Bar Actions drops a three-period ending, null visible is an error

More Options › Bar Actions now leaves out a final "..." from an item's
name, as it already leaves out a final "…". A name that ends in one
period keeps it.

window.taskBar.actions now fails on a `visible` of null, as its params
text and docs/mcp.md say it does for any value that is not true or
false, and leaves every action as it is. An omitted `visible` still
toggles the action.
This commit is contained in:
dotCooCoo committed 2026-11-19 01:52:33 -08:00
1 parent fe426f9bac
commit d15d0e8170
3 files changed
+23 -4

No files matched your search

+5 -2
View File
@@ -704,9 +704,12 @@ fn action_id(cmd: &str, params: &serde_json::Value) -> Option<&'static str> {
}
/// The name More Options › Bar Actions lists for the bar's item `label`: without a field's colon
/// (a full-width one too), the space some languages put before it, or a final ellipsis.
/// (a full-width one too), the space some languages put before it, or a final ellipsis (`…` or
/// `...`).
pub(crate) fn bar_action_name(label: &str) -> &str {
label.trim_end().trim_end_matches([':', ':', '…']).trim_end()
let label = label.trim_end();
let label = label.strip_suffix("...").unwrap_or(label);
label.trim_end_matches([':', ':', '…']).trim_end()
}
/// Reads the Contextual Task Bar's actions and chips that are off, as kept in the preferences. Ids
+9 -1
View File
@@ -640,7 +640,15 @@ fn run_ui_part6(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option<Result<
Ok(Value::Null)
}
// More Options › Bar Actions: one of the bar's actions or chips on or off.
"window.taskBar.actions" => match (s("action").filter(|a| crate::canvas::is_task_bar_action(a)), opt_bool(p, "visible")) {
// A `visible` of null is an error, as any other value that is not true or false is; only
// an omitted one toggles.
"window.taskBar.actions" => match (
s("action").filter(|a| crate::canvas::is_task_bar_action(a)),
match p.get("visible") {
Some(Value::Null) => Err("`visible` must be true or false".to_string()),
_ => opt_bool(p, "visible"),
},
) {
(None, _) => {
let ids = crate::canvas::TASK_BAR_ACTIONS.iter().map(|a| a.0).chain(crate::canvas::TASK_BAR_CHIPS);
Err(format!("`action` must be one of {}", ids.collect::<Vec<_>>().join(", ")))
+9 -1
View File
@@ -1677,7 +1677,13 @@ fn bar_action_ids_are_distinct() {
fn bar_actions_refuse_bad_params() {
let mut app = app();
show_action(&mut app, "group", false);
for p in [json!({"action": "teleport"}), json!({}), json!({"action": 3}), json!({"action": "unite", "visible": "yes"})] {
for p in [
json!({"action": "teleport"}),
json!({}),
json!({"action": 3}),
json!({"action": "unite", "visible": "yes"}),
json!({"action": "unite", "visible": null}),
] {
assert!(app.run("window.taskBar.actions", p.clone()).is_err(), "{p}");
}
let err = app.run("window.taskBar.actions", json!({"action": "teleport"})).unwrap_err();
@@ -2021,4 +2027,6 @@ fn bar_actions_list_names_without_a_colon_or_an_ellipsis() {
assert_eq!(canvas::bar_action_name(label), name, "{code}: {label:?}");
}
assert_eq!(canvas::bar_action_name("Duplicate"), "Duplicate");
assert_eq!(canvas::bar_action_name("Tool Options..."), "Tool Options");
assert_eq!(canvas::bar_action_name("Offset Path."), "Offset Path.");
}