Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web,desktop): unify themed context menus with icons, warning tones, and text actions #7998

Closedbberka(GitHub profile, opens in a new tab)wants to merge 6 commits intomain fromrefs/pull/7998/headopened View on GitHub

What Changed

  • Themed Context Menus on Desktop: Switched Desktop context menu invocations to use the styled glassmorphic context menu, bringing icon and color theme parity between web and desktop clients.
  • Semantic Tones & Archive Warning: Added optional tone?: "neutral" | "destructive" | "warning" to ContextMenuItem / Schema contracts. Applied amber warning tone (var(--warning-foreground)) to Archive actions and preserved red destructive tone for Delete.
  • Missing Action Icons: Added semantic Lucide-style SVG icons (archive, mail-open, refresh-cw, scissors, clipboard, check-check, circle-check, clock, pencil, pin, copy, etc.) across sidebar actions, thread action menus, and file browser entries.
  • Global Text Context Menu: Added a lightweight handler for inputs, textareas, and active text selections showing styled Cut, Copy, Paste, and Select All. Empty space right-clicks remain unintercepted.
  • Electron Native Parity: Kept native context menu handling for Electron-exclusive features (spellcheck dictionary suggestions, Copy Link, and Copy Image).

Why

  1. Desktop & Web Discrepancy: On desktop, context menus fell back to native OS popups which stripped Lucide icons, section headers, and theme colors.
  2. Visual Hierarchy: Archive and Delete are different operations; styling Archive with a distinct amber warning tone prevents accidental destructive confusion.
  3. Consistent Text Editing: Right-clicking text inputs or highlighted text previously lacked styled menu actions matching the glass theme.

UI Changes

Context MenuBeforeAfter
Thread ActionsPlain text without icons or warning tonesGlass menu with Lucide icons, amber Archive, red Delete
Text Selection / InputsDefault OS menu or no actionStyled Cut, Copy, Paste, Select All with icons
Empty Area ClickUnhandled / default OS popupCleanly ignored (no empty menu popup)
(Attach before/after screenshots here when submitting)

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes
image electron_z1QTl6oCi8

Note

Medium Risk Changes right-click and clipboard behavior across desktop and web; desktop app menus no longer use the native bridge, though native menus remain for spellcheck, links, images, and in-webview text editing.

Overview Unifies app context menus on web and desktop by routing localApi.contextMenu.show through the glassmorphic web fallback instead of desktopBridge.showContextMenu, so thread/sidebar/file menus keep Lucide icons, separators, and styling on Electron.

Adds optional tone on ContextMenuItem (neutral / destructive / warning) and wires semantic icons through sidebar bulk actions, thread action menus, and file browser entries. The fallback renderer gains keyboard navigation, tone-aware row/icon styling, and expanded icon paths.

On desktop, DesktopWindow only pops a native menu when it has Electron-specific or text-editing items (spellcheck, Copy Link, Copy Image, cut/copy/paste); otherwise it preventDefaults so the renderer can show themed menus. installGlobalTextContextMenu (browser-only, skipped when desktopBridge is present) adds styled Cut/Copy/Paste/Select all for inputs, textareas, contenteditable, and plain text selection.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 9da8543aa85c6cdc99193f904f1e9ce0751edf23. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Unify web and desktop context menus with icons, warning tones, and text actions

  • Desktop context menu builder in DesktopWindow.ts now adds native text-editing actions and image copy only when applicable, and shows the menu only if it has items.
  • Web fallback context menu in contextMenuFallback.ts gains keyboard navigation, tone-aware styling, and a new installGlobalTextContextMenu hook for native-like text editing actions in browsers.
  • Adds an optional tone property to ContextMenuItem in ipc.ts and assigns semantic icons to thread, sidebar, and file context menu items.
  • Behavioral Change: localApi.ts always renders context menus using the web fallback instead of delegating to desktopBridge.showContextMenu. Desktop empty-space right-clicks now call event.preventDefault() and delegate to the renderer without showing a native menu.
Macroscope summarized 9da8543.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: e3644d3a-b42d-46f3-a134-67014a0d4b7b

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. @@ -36,7 +36,4 @@
      3636 items: readonly ContextMenuItem<T>[],
      3737 position?: { x: number; y: number },
      3838 ): Promise<T | null> => {
      39- if (window.desktopBridge) {
      40- return window.desktopBridge.showContextMenu(items, position) as Promise<T | null>;
      41- }
      4239 return showContextMenuFallback(items, position);
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium src/localApi.ts:39

      Electron contextMenu.show now uses showContextMenuFallback, whose keyboard handling only dismisses on Escape and does not support navigation or activation, so desktop users cannot select menu actions by keyboard. Route Electron through window.desktopBridge.showContextMenu and keep the fallback for non-Electron browsers.

      Suggested change
      39- return showContextMenuFallback(items, position);
      39+ if (window.desktopBridge) {
      40+ return window.desktopBridge.showContextMenu(items, position) as Promise<T | null>;
      41+ }
      42+ return showContextMenuFallback(items, position);
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/web/src/localApi.ts around line 39:
      
      Electron `contextMenu.show` now uses `showContextMenuFallback`, whose keyboard handling only dismisses on `Escape` and does not support navigation or activation, so desktop users cannot select menu actions by keyboard. Route Electron through `window.desktopBridge.showContextMenu` and keep the fallback for non-Electron browsers.
    4. UI consistency review of the themed context-menu changes. Four findings, all in apps/web/src/contextMenuFallback.ts: one interaction/Electron regression (the global handler cancels the gesture the desktop native menu still depends on), one CSS ownership issue (inline glass/shadow overriding the shared dropdown-glass utility, with no dark-mode shadow), and two smaller tone-resolution issues.

      Posted via Macroscope — UI Consistency
      @@ -473,0 +602,21 @@
      602+ hasInputSelection = end > start;
      603+ } catch {
      604+ hasInputSelection = false;
      605+ }
      606+ hasValue = input.value.length > 0;
      607+ } else if (isContentEditable && target instanceof HTMLElement) {
      608+ hasValue = (target.textContent ?? "").length > 0;
      609+ }
      610+
      611+ const hasSelection = isEditable
      612+ ? isInputElement || isTextAreaElement
      613+ ? hasInputSelection
      614+ : hasWindowSelection
      615+ : hasWindowSelection;
      616+
      617+ // Only show our menu if right-clicking an editable element OR there is text selected.
      618+ if (!isEditable && !hasSelection) {
      619+ return;
      620+ }
      621+
      622+ event.preventDefault();
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      This cancels the contextmenu event for every editable target, which also cancels Chromium's context-menu request to the browser process — so window.webContents.on("context-menu", …) in DesktopWindow.ts never fires for editable text. That is exactly where the desktop side of this PR keeps its "Electron-exclusive" items (spellcheck suggestions, and Copy Link / Copy Image when the click lands on editable content), so those become unreachable in the desktop app; in the other direction, if the main-process handler does still run, the user gets the native menu and the themed menu from one right-click.

      Suggest making one owner per gesture: either let the desktop bridge forward its native-only entries (suggestions / Copy Link / Copy Image) into the themed menu before it is shown, or skip interception when those native-only entries apply and keep the native path there. Worth a focused test for the Electron branch either way.

      Posted via Macroscope — UI Consistency
    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This is a broad runtime change that replaces desktop menu routing and adds browser-wide clipboard and text-editing interception, rather than a cosmetic context-menu update. The Electron/renderer ownership boundary and irreversible clipboard failure path leave material user-facing risk that is not sufficiently bounded for unattended approval.

      Not approved because:

      • 2 blocking correctness issues found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. Two consistency findings on the new context-menu tone/icon work. The earlier notes about the desktop contextmenu interception, the inline glass overrides, the archive-id tone heuristic, and the disabled-icon tone all look addressed.

      Posted via Macroscope — UI Consistency
    7. @@ -473,0 +755,21 @@
      755+
      756+ if (!clicked) {
      757+ return;
      758+ }
      759+
      760+ if (clicked === "cut") {
      761+ if (isInputElement || isTextAreaElement) {
      762+ const input = target as HTMLInputElement | HTMLTextAreaElement;
      763+ try {
      764+ const start = inputSelection?.start ?? input.selectionStart ?? 0;
      765+ const end = inputSelection?.end ?? input.selectionEnd ?? 0;
      766+ const text = input.value.slice(start, end);
      767+ if (text) {
      768+ try {
      769+ await navigator.clipboard.writeText(text);
      770+ } catch {
      771+ document.execCommand("copy");
      772+ }
      773+ input.setRangeText("", start, end, "end");
      774+ input.dispatchEvent(new Event("input", { bubbles: true }));
      775+ }
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High src/contextMenuFallback.ts:767

      When navigator.clipboard.writeText() rejects and document.execCommand("copy") returns false, cut still removes the selected input text, causing irreversible data loss. The fallback result is ignored before setRangeText; only delete the range after copying succeeds.

      Suggested change
      767- if (text) {
      768- try {
      769- await navigator.clipboard.writeText(text);
      770- } catch {
      771- document.execCommand("copy");
      772- }
      773- input.setRangeText("", start, end, "end");
      774- input.dispatchEvent(new Event("input", { bubbles: true }));
      775- }
      767+ if (text) {
      768+ let copied = false;
      769+ try {
      770+ await navigator.clipboard.writeText(text);
      771+ copied = true;
      772+ } catch {
      773+ copied = document.execCommand("copy");
      774+ }
      775+ if (copied) {
      776+ input.setRangeText("", start, end, "end");
      777+ input.dispatchEvent(new Event("input", { bubbles: true }));
      778+ }
      779+ }
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/web/src/contextMenuFallback.ts around lines 767-775:
      
      When `navigator.clipboard.writeText()` rejects and `document.execCommand("copy")` returns `false`, `cut` still removes the selected input text, causing irreversible data loss. The fallback result is ignored before `setRangeText`; only delete the range after copying succeeds.
    8. One finding: the bulk snooze submenu in Sidebar.tsx is the only preset list left without icons, so the same snooze presets render with clock icons from the per-thread menu and without them from the multi-select menu.

      Previously flagged items look resolved at this head: resolveItemTone now reads only the explicit tone (no archive id heuristic), Archive is no longer amber, disabled rows mute their icon with the label, the inline icon size/opacity block is gone so the size-4.5 … sm:size-4 classes own geometry again, the popup now uses the shared shadow-[0_16px_40px_-18px_…] dark:shadow-[0_18px_44px_-18px_…] pair from ui/menu.tsx/ui/select.tsx/ui/popover.tsx instead of an inline light-only glass override, and the global text menu is installed only when there is no desktopBridge, so Electron's context-menu handler still owns spellcheck and Copy Link.

      Posted via Macroscope — UI Consistency
      @@ -2854,12 +2854,13 @@
      28542854 const clicked = await settlePromise(() =>
      28552855 api.contextMenu.show(
      28562856 [
      2857- { id: "settle", label: `Settle (${count})` },
      2857+ { id: "settle", label: `Settle (${count})`, icon: "circle-check" },
      28582858 ...(canSnoozeSelection
      28592859 ? [
      28602860 {
      28612861 id: "snooze",
      28622862 label: `Snooze (${count})`,
      2863+ icon: "clock",
      28632864 children: snoozePresets.map((preset) => ({
      28642865 id: `snooze:${preset.id}`,
      28652866 label: `${preset.label} (${preset.whenLabel})`,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      The multi-select Snooze (n) parent now carries icon: "clock", but its preset children still have no icon, while the per-thread menu gives each preset icon: "clock" (threadActionMenu.logic.ts). Since rows are a flex list with gap-2 and no reserved icon column, the same preset submenu renders icon-less labels when opened from a multi-selection and iconed labels when opened from a single thread. Suggest matching the per-thread submenu.

      Suggested change
      2864- children: snoozePresets.map((preset) => ({
      2865- id: `snooze:${preset.id}`,
      2866- label: `${preset.label} (${preset.whenLabel})`,
      2864+ children: snoozePresets.map((preset) => ({
      2865+ id: `snooze:${preset.id}`,
      2866+ label: `${preset.label} (${preset.whenLabel})`,
      2867+ icon: "clock",
      Posted via Macroscope — UI Consistency
    9. Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 9da8543aa85c6cdc99193f904f1e9ce0751edf23. Configure [here](https://www.cursor.com/dashboard/bugbot).
      @@ -182,3 +248,13 @@
      182248 return false;
      183249 }
      184250
      251+function findContentEditableHost(element: HTMLElement): HTMLElement | null {
      252+ for (let current: HTMLElement | null = element; current; current = current.parentElement) {
      253+ const contentEditable = current.getAttribute("contenteditable");
      254+ if (contentEditable !== null) {
      255+ return contentEditable.toLowerCase() === "false" || !current.isContentEditable
      256+ ? null
      257+ : current;
      258+ }
      259+ }
      260+ return null;

      Chip clicks miss edit menu

      Medium Severity

      findContentEditableHost returns null as soon as it sees contenteditable="false", and does not keep walking to a parent editor. Composer mention and skill chips use that attribute inside the Lexical ContentEditable, so right-clicks on those chips are treated as non-editable and skip Cut/Paste (or fall through to the native menu) even though they sit in an editable field.

      Additional Locations (1)
      Fix in Cursor Fix in Web
      Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 9da8543aa85c6cdc99193f904f1e9ce0751edf23. Configure [here](https://www.cursor.com/dashboard/bugbot).
    10. One consistency gap found in the icon pass: the multi-select snooze submenu is the only preset list left without icons, while its single-thread counterpart gained icon: "clock" in this PR. Everything else in the diff (tone resolution, disabled icon muting, shared dropdown shadow, desktop/renderer split) now lines up with the shared Menu primitive and the dropdown-glass surface contract.

      Posted via Macroscope — UI Consistency
      @@ -2854,12 +2854,13 @@
      28542854 const clicked = await settlePromise(() =>
      28552855 api.contextMenu.show(
      28562856 [
      2857- { id: "settle", label: `Settle (${count})` },
      2857+ { id: "settle", label: `Settle (${count})`, icon: "circle-check" },
      28582858 ...(canSnoozeSelection
      28592859 ? [
      28602860 {
      28612861 id: "snooze",
      28622862 label: `Snooze (${count})`,
      2863+ icon: "clock",
      28632864 children: snoozePresets.map((preset) => ({
      28642865 id: `snooze:${preset.id}`,
      28652866 label: `${preset.label} (${preset.whenLabel})`,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      The snooze presets in the multi-select menu are the only submenu items left without an icon: buildThreadActionMenuItems now gives the identical presets icon: "clock" (threadActionMenu.logic.ts:90-94), so the same list renders with a leading clock from a single-thread right-click and without one here. Since the fallback renderer only inserts the icon element when item.icon is set, these rows also lose the leading icon column and their labels sit further left than every other row in the menu. Suggest matching the parent item's icon.

      Suggested change
      2866- label: `${preset.label} (${preset.whenLabel})`,
      2866+ label: `${preset.label} (${preset.whenLabel})`,
      2867+ icon: "clock",
      Posted via Macroscope — UI Consistency
    11. closing this version as part of the pr cleanup at the request of @StiensWout. we are not taking this combined context-menu change forward in its current form.

      thanks for the contribution. if you disagree with this decision, you are welcome to open a new pr, link back to this one, and explain why the proposed changes should be reconsidered.

Sign in to join this conversation.