Skip to content

Show keybinding in tooltips for controls that have one #64

Description

@MasonRhodesDev

ActionTooltip (desktop/src/app.rs:617) and its helper action_tooltip_view(label, cx) (desktop/src/app.rs:2393) are used at many sites (app.rs, custom_actions_modal.rs, left_sidebar.rs, ...) but only render a label. Extend them so controls backed by a configurable ShortcutAction (core/src/shortcuts.rs) also show the current binding — e.g. "New Task ⌘T" or "Previous Tab Ctrl+Shift+[".

Proposed shape: a trait on GUI elements that expresses "this element is the handle for feature X", rather than a parallel helper. Anything that implements the trait picks up the tooltip's shortcut chip automatically and stays in sync with the user-configurable binding.

Sketch:

trait WithShortcut {
    fn with_shortcut(self, action: ShortcutAction) -> Self;
}

…implemented for the element types we pass to .tooltip(...). Internally it attaches the ShortcutAction to the element so the tooltip renderer can resolve the live binding via project_store.ui.shortcuts.binding_for(action) and pretty-print via keybinding_token_label (desktop/src/shortcuts.rs:143). The shortcut chip renders dim/monospace to the right of the label.

Callers update from:
.tooltip(|_w, cx| Self::action_tooltip_view("New Task", cx))
to:
.tooltip(|_w, cx| Self::action_tooltip_view("New Task", cx))
.with_shortcut(ShortcutAction::NewTask)

Update the existing .tooltip(...) sites whose controls correspond to a ShortcutAction (NewTask, NewTabInCurrentTask, CloseCurrentTab, Next/PreviousTab, Next/PreviousTask, CycleProjects, and once #62 lands — ZoomIn/Out/Reset). Label-only tooltips for controls with no shortcut stay as-is.

Naming and trait surface TBD — the point is that the shortcut annotation lives on the element, not in a parallel helper.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions