emdash icon indicating copy to clipboard operation
emdash copied to clipboard

feat(ui): compact title bar for Windows

Open Drakaniia opened this issue 5 months ago • 4 comments

Description

Implements a compact title bar mode that integrates the window controls with the menu bar on Windows/Linux platforms, reducing vertical chrome at the top of the app window. On macOS, preserves the existing native title bar behavior with traffic light controls.

The implementation includes:

  • Platform-specific window chrome configuration with hidden title bar on Windows
  • Custom React-based menu bar component that matches the native menu structure
  • Typed menu action system for consistent behavior across platforms
  • Test coverage for all new functionality

Related issues

Fixes #2499

Testing

Ran the complete local merge gate:

  • [x] pnpm run format - Code formatting check passed
  • [x] pnpm run lint - Linting rules passed
  • [x] pnpm run typecheck - TypeScript compilation passed
  • [x] pnpm run test - All unit tests passed including new test suites

Manual testing:

  • [x] Verified compact menu bar appears on Windows (simulated via platform detection)
  • [x] Confirmed macOS behavior unchanged (native title bar preserved)
  • [x] Tested all menu actions work correctly (settings, quit, edit operations, etc.)

Screenshot

before: {2593D570-D3A9-4D79-92ED-4A4E892F11E9}

after: {65BA7B12-C5FA-4CEF-A7C1-20E9A1D62197}

Checklist
  • [x] I kept this PR small and focused
  • [x] I ran a self-review before opening this PR
  • [x] I ran the relevant local checks or explained why not
  • [x] I updated docs when behavior or setup changed
  • [x] I added or updated tests when behavior changed, or explained why not
  • [x] I only added comments where the logic is not obvious
  • [x] I used Conventional Commits for commit messages and, when possible, the PR title

Implementation Notes:

  • Uses Electron's titleBarOverlay API for Windows to achieve the compact layout
  • Menu actions are abstracted into testable functions with dependency injection
  • Platform detection ensures cross-platform compatibility
  • Added 8 new test files with comprehensive coverage of the menu system
  • Preserves all existing keyboard shortcuts and menu functionality

Drakaniia avatar Jun 13 '26 04:06 Drakaniia

Hi @Drakaniia - thank you for opening this PR - is this ready for review?

arnestrickmann avatar Jun 15 '26 17:06 arnestrickmann

@arnestrickmann, Yes, it's ready for review. The changes have only been tested on Windows devices so far, but I'll open it for review now. I'd appreciate any comment on these changes..

Drakaniia avatar Jun 16 '26 00:06 Drakaniia

Greptile Summary

Introduces a compact title bar for Windows that merges the native window controls with a custom React menu bar, reducing vertical chrome. macOS retains its existing traffic-light behaviour; Linux is left unchanged.

  • window-chrome.ts centralises platform-specific BrowserWindow options — hidden title bar with titleBarOverlay on win32, hiddenInset on darwin, empty on linux — and spreads them into createMainWindow.
  • compact-menu-bar.tsx renders the full menu tree (COMPACT_APP_MENU) as a fixed React bar with click-outside/resize dismissal and hover-driven submenus; menu actions are dispatched via the new rpc.app.performCompactMenuAction endpoint.
  • menu-actions.ts / menu-action-context.ts implement the action dispatch with constructor-injected dependencies for clean unit-testability; eight new test files cover window chrome, action routing, and the menu-tree structure.

Confidence Score: 5/5

Safe to merge; the change is additive and platform-gated, with no impact on macOS or Linux users.

The implementation is well-structured with dependency injection, proper platform guards, and comprehensive test coverage across all new modules. The only issue found is a cosmetic shortcut label typo in the zoom-in menu hint, which has no functional impact.

app-menu.ts — the zoom-in shortcut label should be corrected before release so users see the right hint.

Important Files Changed

Filename Overview
apps/emdash-desktop/src/shared/app-menu.ts Defines the shared compact-menu data model, action IDs, and COMPACT_APP_MENU tree; minor display bug: zoom-in shortcut label is 'Ctrl^+' instead of 'Ctrl++'
apps/emdash-desktop/src/main/app/window-chrome.ts New platform-specific window-chrome helper; correctly applies titleBarOverlay on win32, traffic-light offset on darwin, and no-op on linux
apps/emdash-desktop/src/main/app/menu-actions.ts Pure action-dispatch logic with injected context; all fields required, testable without Electron, covers all declared action IDs
apps/emdash-desktop/src/main/app/menu-action-context.ts Wires production Electron dependencies into the menu-action context; clean delegation with no business logic
apps/emdash-desktop/src/renderer/app/compact-menu-bar.tsx Custom React menu bar for Windows; includes click-outside/resize dismissal, hover-based submenu, and drag-region management
apps/emdash-desktop/src/renderer/app/workspace.tsx Adds platform guard to conditionally render CompactMenuBar and apply paddingTop offset on Windows; structural change is minimal and correct
apps/emdash-desktop/src/main/core/app/controller.ts Adds performCompactMenuAction RPC handler with consistent error-wrapping pattern; properly wired through existing app controller
apps/emdash-desktop/src/main/app/window.ts Replaces inline platform ternary with getWindowChromeOptions spread; adds setMenuBarVisibility(false) on win32 to hide native menu bar

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant User
    participant CompactMenuBar as CompactMenuBar (renderer)
    participant RPC as rpc.app (IPC)
    participant Controller as appController (main)
    participant MenuActionCtx as menu-action-context (main)
    participant MenuActions as executeCompactMenuAction (main)
    participant Electron as Electron APIs

    User->>CompactMenuBar: clicks menu button
    CompactMenuBar->>CompactMenuBar: setOpenMenu(label)
    User->>CompactMenuBar: clicks action item
    CompactMenuBar->>CompactMenuBar: setOpenMenu(null)
    CompactMenuBar->>RPC: performCompactMenuAction(actionId)
    RPC->>Controller: performCompactMenuAction(actionId)
    Controller->>MenuActionCtx: performCompactMenuAction(actionId)
    MenuActionCtx->>MenuActions: executeCompactMenuAction(actionId, context)
    MenuActions->>Electron: "app.quit() / shell.openExternal() / webContents.* / events.emit()"
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant User
    participant CompactMenuBar as CompactMenuBar (renderer)
    participant RPC as rpc.app (IPC)
    participant Controller as appController (main)
    participant MenuActionCtx as menu-action-context (main)
    participant MenuActions as executeCompactMenuAction (main)
    participant Electron as Electron APIs

    User->>CompactMenuBar: clicks menu button
    CompactMenuBar->>CompactMenuBar: setOpenMenu(label)
    User->>CompactMenuBar: clicks action item
    CompactMenuBar->>CompactMenuBar: setOpenMenu(null)
    CompactMenuBar->>RPC: performCompactMenuAction(actionId)
    RPC->>Controller: performCompactMenuAction(actionId)
    Controller->>MenuActionCtx: performCompactMenuAction(actionId)
    MenuActionCtx->>MenuActions: executeCompactMenuAction(actionId, context)
    MenuActions->>Electron: "app.quit() / shell.openExternal() / webContents.* / events.emit()"

Reviews (5): Last reviewed commit: "fix(compact-menu): address code review i..." | Re-trigger Greptile

greptile-apps avatar Jun 16 '26 00:06 greptile-apps