Skip to content

Take menu colours and icons from the entry, not its English label - #864

Draft
Havunen wants to merge 1 commit into
devfrom
claude/project-thread-gds2nf
Draft

Havunen wants to merge 1 commit into
devfrom
claude/project-thread-gds2nf

Conversation

@Havunen

@Havunen Havunen commented Dec 3, 2026

Copy link
Copy Markdown
Member

Requested by Sampo · project thread

Translation plan item GC-5: menus stop working out colours and icons from English labels.

What changes

view/menu_presentation.rs used to colour every context menu entry by reading its label. "Delete", "Drop" and "Remove" were red, "Push" and "Stage" green, "Pull", "Discard" and "Force" amber. Entries without an icon could also get one from words such as "Open", "Copy" or "Tag". A translated label would lose all of this.

Now:

  • Colour comes from the entry's icon (icon_tone: bin and tab-close are red, warning, down arrow and minus are amber, up arrow and plus are green). Where an action's colour differs from its icon, action_tone names that action: force push and force-drop are red; discarding a file, folder, hunk or lines is amber; pushing tags, pushing LFS objects and creating a worktree are green; the explorer's Trash stays neutral.
  • Icon comes from the entry's icon alone.
  • The repository tab menu's Close stays neutral through a new sparse ContextMenuModel::entry_tones, the same pattern as entry_tooltips. The repository picker's "Close repository" uses the same action and stays red.

Behaviour changes, on purpose

  • The branch picker, repository picker and push upstream remote picker no longer colour rows from user data. Before this change, a branch named remove-old-api, a repository under a folder named Push, or a remote named delete-me turned red or green.
  • Extension entries (hosted menus, ref-menu items, extension commands) still take their colours and inferred icons from their labels, because the extension API has no way to give a tone yet. That code is isolated in extension_label_tone and extension_label_icon, and can go when the extension API carries a tone, which fits with making extension labels translatable (GC-7). Pro's menus are unaffected by this PR.

How I checked nothing else moved

Before deleting the old functions I added a temporary hook (not in this diff) to ContextMenuModel::new and context_menu_model. It compared the old and new presentation of every entry built while the whole gitcomet-ui-gpui lib suite ran: 52,746 entries. The first run found 398 differences across 13 labels, and I added the action_tone arms above for them. On the final run, the only differences were the tab menu's "Close", which the renderer overrides through entry_tones, and a test entry labelled "Action" whose action opens the worktree prompt.

Verification

  • cargo fmt --all --check
  • cargo clippy --locked -p gitcomet-ui-gpui --lib --tests -- -D warnings
  • cargo test -p gitcomet-ui-gpui --lib: 4,434 passed, 25 ignored (Linux x86_64, no display). Two source-scanning tests fail when the binary is run from the repository root instead of the crate directory; both pass from the crate directory.
  • Not run: the other two clippy --locked commands in CONTRIBUTING.md (this diff only touches gitcomet-ui-gpui), the Windows and macOS suites, and a visual check of the menus.
  • New tests: a_host_entry_looks_the_same_whatever_its_label_says (the plan's "done when": a host entry's colour and icon don't change when its label becomes "حذف", "Löschen", "削除" or "Удалить"), actions_whose_colour_is_not_their_icons_say_so, icons_imply_their_tones, and closing_a_tab_is_not_painted_as_destructive. The first fails if label inference comes back.

AI disclosure

Written with Claude Code (Claude Opus 5.5) at the maintainer's request, as part of the translation plan. Per AI_POLICY.md, this needs a human review before merging.


Generated by Claude Code

Context menus chose each entry's colour, and for some entries its icon,
by reading the English label: "Delete" was red, "Push" green, "Discard"
amber. A translated label would lose all of that, and a branch, remote
or path whose name happened to contain such a word was coloured as if it
were a command.

The colour now comes from the entry's icon, or from its action where the
two differ (force push, discards, pushing tags or LFS objects, creating a
worktree, the explorer's Trash). The repository tab menu's Close keeps its
neutral colour through a per-entry tone on the menu model. The icon comes
from the entry's icon alone. Every entry the UI test suite builds looks
the same as before.

The branch, repository and remote pickers no longer colour their rows
from branch names, paths and remote names. Extension entries keep their
label-based colours until the extension API can carry a tone.

Part of the translation plan, item GC-5.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EyikHLk97MikZ7pMjMWX8i
@Havunen Havunen self-assigned this Dec 3, 2026
@cla-assistant

cla-assistant Bot commented Dec 3, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
@cla-assistant

cla-assistant Bot commented Dec 3, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants