Repository navigation
feat: v1.4.1 — add Edit → Find menu items for Cmd+F discoverability - #55
Conversation
nesquena
left a comment
There was a problem hiding this comment.
Verified on Mac agent at tip ea6702d.
Build/test results
swift build -c release— Build complete (2.50s, 0 warnings)swift test— 22/22 passedbash build.sh—.appbuilt, ad-hoc signed, installed to/Applications
Scope: 37/-0 across 2 files (CHANGELOG + AppDelegate). Pure addition, no existing code touched. Branch is fix/find-menu-item rather than sprint-v1-4-1 — worth noting but fine for a scoped hotfix.
Code review
Menu structure follows macOS convention. Edit menu now has a separator + "Find" item with a submenu containing Find… / Find Next / Find Previous — matching Safari/TextEdit. Parent "Find" item has action: nil, keyEquivalent: "" (expands submenu only). Correct.
Key equivalent encoding:
- Find… —
keyEquivalent: "f"(lowercase) → ⌘F - Find Next —
keyEquivalent: "g"(lowercase) → ⌘G - Find Previous —
keyEquivalent: "G"(uppercase) plus explicitkeyEquivalentModifierMask = [.command, .shift]→ ⌘⇧G
The explicit modifier mask on Find Previous is slightly redundant (uppercase "G" alone would make AppKit infer Shift), but belt-and-suspenders doesn't hurt and makes the intent unambiguous. Correct either way.
Menu ↔ performKeyEquivalent interaction. With the browser frontmost, BrowserWindow.performKeyEquivalent still runs first in the event dispatch chain and consumes ⌘F/⌘G/⌘⇧G before the menu gets a chance. The menu items provide discoverability (the item shows up in the menu bar with its shortcut) but when the window is key they also provide a redundant second handler. Both paths end at the same onFind / onFindNext / onFindPrev closures → same toggleFindBar / findNext(forward:) invocation — no divergence, no double-fire.
When the browser isn't frontmost (e.g., Preferences is open), performKeyEquivalent on the front window doesn't match, and the menu's key-equivalent dispatch takes over, routing to openFind on AppDelegate → browserWindow?.window as? BrowserWindow).onFind?(). That's a behaviour gain: ⌘F now works from any app window, not just when the browser is focused. Reasonable for a single-window app.
The forwarding cast (browserWindow?.window as? BrowserWindow)?.onFind?() is a safe downcast: BrowserWindowController.window is an NSWindow but the instance is always BrowserWindow (the custom subclass). When browserWindow is nil (splash phase, reconnect), the chain short-circuits — the menu click is a benign no-op rather than a crash. For strict correctness the items could be disabled via NSMenuValidation during those phases, but the no-op is harmless.
Action routing — the menu items use #selector(openFind) with no explicit target, so AppKit sends the action up the responder chain and AppDelegate (NSApp's delegate, chain terminus) picks it up via its @objc func openFind / findNext / findPrev. Standard AppKit idiom.
Non-blocking follow-ups
None this round. Pure UX/discoverability addition with no behaviour change to the actual find logic.
Ready to merge and tag v1.4.1.
Summary
Follow-up to v1.4.0 (#54): adds Edit → Find → Find… to the menu bar so Cmd+F is discoverable via the standard macOS menu convention.
What changed
AppDelegate.setupMenu()— added a Find submenu under Edit:The three menu actions (
openFind,findNext,findPrev) forward directly to theBrowserWindow's existingonFind/onFindNext/onFindPrevclosures — no changes toBrowserWindowController.Pre-merge checklist (for Mac agent)
Smoke test: launch app, check Edit menu has Find → Find… (Cmd+F), Find Next (Cmd+G), Find Previous (Cmd+Shift+G). Click Find… to confirm it opens the bar.
Closes #37 (menu discoverability aspect — the bar itself shipped in v1.4.0).