Skip to content

The desktop app has the Mac app's Edit and Window menus and a Core Log, and greys out Chats items it can't do - #243

Merged
pitis merged 6 commits into
mainfrom
feat/desktop-menus
Nov 28, 2026
Merged

pitis merged 6 commits into
mainfrom
feat/desktop-menus

Conversation

@pitis

@pitis pitis commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

What changed

Chats menu greys what it can't do. On macOS, GPUI enables a menu item only if its action is handled on the focused element's way; the Chats actions were app-wide handlers, so every item stayed enabled and silently did nothing. They now sit on the window's root (navigate::chats_actions) while they can act, following the Mac app's ChatCommands rules:

  • Search in Chat, Focus Composer and Close Chat need an open chat;
  • Attach Files… is off in a message request or while editing;
  • the whole menu is off when a dialog or sheet is over the chats or another screen shows (the desktop's existing can_search, which the shortcuts already waited for).

The shortcuts work exactly when the item is enabled. To keep them reachable when no text field has the keys (at launch, after a chat closes), the root holds a zero-area focus anchor (the pattern the chat column already uses for selected text), and focus that is lost falls back to it (on_focus_lost, with a redraw GPUI doesn't do itself).

macOS menus (main.rs), after SwiftUI's standard ones:

  • Hush: About Hush, Settings…, Hide Hush ⌘H, Hide Others ⌥⌘H, Show All, Quit Hush.
  • Edit: Undo, Redo, Cut, Copy, Paste, Select All. These are the text fields' own actions (OsAction), so they act on the focused field and grey without one. Copy is the exception: it stays on, because gpui-kit's root also copies selected message text. macOS adds Emoji & Symbols to this menu itself (The desktop app reacts with any emoji, and on macOS its Edit menu inserts emoji in the composer #242); there is one Edit menu.
  • Window: Minimize ⌘M, Zoom, Close Window ⌘W, Core Log.

Close Window works as in the Mac app, where About, the Core Log and Settings are windows of their own:

About: GPUI has no About panel, and the standard AppKit one would read "hush" with no version from this unbundled binary. So it's a small sheet: Hush, "Version 0.1.0 (core 0.1.0)".

Core Log (core_log.rs), as the Mac's CoreLogView:

  • keeps the core's last 200 errors with their times, newest first, or "No errors"; the times follow the 12/24-hour clock, as bubble times do;
  • Copy All copies them oldest first with ISO 8601 times;
  • like the Mac app, it keeps them when the core starts over (relink or unlink).

It's a sheet over the window, opened from Window ▸ Core Log and from a "Core Log…" button at the foot of Settings, since Windows and Linux have no menu bar.

Side effect fixed: an action that isn't available no longer swallows its keystroke, so ⌥↓ reached the stories viewer's ↓. That viewer's arrows now ignore modifiers (the existing stories test caught it).

Not done / limits

  • shortcut: a dialog over the chats doesn't hold the window against ⌘W the way a sheet does on the Mac.

How it was tested

Test-first: the_chats_menu_offers_only_what_can_act asks GPUI what a macOS menu asks (App::is_action_available). With the old app-wide handlers it failed at "while editing", because Attach Files was offered. It also covers:

  • the keys working after a dialog's Esc;
  • the Window menu staying offered.

Also added:

  • the_core_log_keeps_the_cores_errors_and_gives_the_keys_back: core errors are logged; Edit's items follow the focused field; Settings and the chats wait for the sheet; Esc and Return close it; a notification's click closes it; over Settings, Esc and ⌘W close one layer at a time; ⌘W closes the window when no core is open;
  • close_window_closes_as_the_close_button_does: with the core open, ⌘W keeps the window and app running. It fails if the hook is bypassed;
  • a unit test for the 200 limit, the row ids and Copy All's text;
  • an assertion that the Core Log survives a restart.

Gate, from core/:

  • cargo fmt --check: pass
  • cargo clippy --all-targets -q -- -D warnings: pass
  • cargo clippy --all-targets --features hush-desktop/snapshot -q -- -D warnings: pass
  • cargo test --features hush-desktop/snapshot -q: pass (293 desktop, 537 core)

The Swift leg (xcodebuild) was skipped because nothing in app/ changed.

Snapshots, light and dark, looked at: core-log, core-log-empty, about (new demo screens) and settings (the new Core Log… button). The menu bar itself can't be captured headless; the availability tests stand in for it.

Closes #229

…g, and greys out Chats items it can't do

The Chats menu's actions now sit on the window's root while they can act, so GPUI
greys an item (and its keys do nothing) when it can't: Search in Chat, Focus Composer
and Close Chat need an open chat, Attach Files is off in a request or while editing,
and the whole menu waits for a dialog or another screen. A focus anchor on the root
keeps those actions reachable when no field has the keys.

macOS gets Hush's About, Hide, Hide Others and Show All, an Edit menu over the focused
text field, and a Window menu with Minimize, Zoom, Close Window and Core Log. The Core
Log keeps the core's last 200 errors with their times, and Settings opens it on every
platform.
…us fallback, Settings under the log, a restart keeping it; comments corrected
@pitis

pitis commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

Review (pr-review-toolkit: code, tests, comments, types)

There were no Critical findings. Each finding and what was done:

Important

  1. ⌘W under the Core Log, About or Settings closed the window, which then quit the app. The errors you opened the log to read and any unsaved profile edits went with it. Fixed: ⌘W now closes the sheet first, then Settings, as the Mac app's ⌘W closes those windows. Under Back Up or Restore (a sheet on its window in the Mac app) it does nothing. Tests: Esc and ⌘W over Settings each close one layer at a time.
  2. ⌘W skipped the close button's should-close step. Fixed now that Closing the desktop app's window keeps it running, as the Mac app does #240 has merged. ⌘W calls running::closing (made pub(super)) before remove_window, so it does exactly what the close button does: hides while the core is open, and closes and quits otherwise. New test close_window_closes_as_the_close_button_does, which fails if the hook is bypassed.
  3. Core Log rows had positional ids. A selected error's highlight moved to another row each time a new error came in. Fixed: each error keeps its number as its row id, and the unit test checks it.

Suggestions and test gaps

  • Return with Copy All focused also closed the sheet. Fixed: Return closes the sheet only while the sheet itself has the keys, as Group Info does.
  • The test's "Settings waits for the sheet" assertion proved nothing (no handler was registered). Fixed: the test registers settings::shortcut.
  • Focus fallback after a dialog's Esc. Now tested twice in a row: the keys still move between chats and ⌘K still reaches search.
  • Window menu items stay offered under a dialog and on the link screen. Now asserted.
  • The Core Log survives a restart. Now asserted in a_failed_relink_starts_over_too_and_says_so.
  • A notification's click closes the sheet and gives the keys to the chat. Now asserted.
  • ⌘W is tested with the real keystroke on macOS. ⌥↑ is now covered in the stories test alongside ⌥↓.
  • Comments: the Edit menu's note on Copy, which Root always handles; "the chat-switching ones land in the composer"; the doc on the root focus handle; the stories arrow note; "Done, Esc or Return"; the restart doc (the Core Log and tray stay); "no field focused yet" in the test. The PR body's claim about Copy is corrected too.

Declined

  • A click test for Copy All: the button only writes CoreLog::text(), which is unit-tested, and a headless click needs element bounds for one line of wiring.
  • Offering About and the Core Log while no window is active: both are sheets inside the window. With the window hidden there is nowhere to show them, and the Dock and tray bring it back.
  • An explicit Emoji & Symbols item: macOS adds it to the menu named Edit (The desktop app reacts with any emoji, and on macOS its Edit menu inserts emoji in the composer #242). Exactly one Edit menu remains after the merge.

Merged from main: #241 (the Core Log's times follow the 12/24-hour clock, as bubble times do), #242 (one Edit menu, carrying its note) and #240 (⌘W goes through its hook).

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.

The desktop app has the Mac app's Edit and Window menus and a Core Log, and greys out Chats items it can't do

1 participant