Skip to content

Make View menu zoom items context-aware for terminal font size#1989

Open
anthhub wants to merge 4 commits intomanaflow-ai:mainfrom
anthhub:feat/context-aware-zoom-menu
Open

Make View menu zoom items context-aware for terminal font size#1989
anthhub wants to merge 4 commits intomanaflow-ai:mainfrom
anthhub:feat/context-aware-zoom-menu

Conversation

@anthhub
Copy link
Copy Markdown
Contributor

@anthhub anthhub commented Mar 23, 2026

Summary

  • View > Zoom In/Out/Actual Size menu items now dispatch to terminal font size control when a terminal panel is focused, and to browser zoom when a browser panel is focused
  • Added increaseFontSizeFocusedTerminal(), decreaseFontSizeFocusedTerminal(), resetFontSizeFocusedTerminal() methods to TabManager (parallel to existing browser zoom methods)
  • Keyboard shortcut behavior (Cmd+=/−/0) is unchanged — still routed to Ghostty at the key event level via AppDelegate

Test plan

  • Build with ./scripts/reload.sh --tag font-zoom
  • Focus a terminal panel → click View > Zoom In → font size increases
  • Focus a terminal panel → click View > Zoom Out → font size decreases
  • Focus a terminal panel → click View > Actual Size → font size resets
  • Focus a browser panel → same menu items control browser zoom (existing behavior preserved)
  • Cmd+=/−/0 keyboard shortcuts continue to work as before in both contexts

🤖 Generated with Claude Code


Summary by cubic

Make the View > Zoom menu context-aware: Zoom In/Out/Actual Size change terminal font size when a terminal is focused, or browser zoom when a browser is focused. All Zoom menu actions now beep on failure; keyboard shortcuts (Cmd+=, Cmd−, Cmd+0) are unchanged.

  • New Features

    • Route menu actions based on focused panel (terminal font size vs. browser zoom).
    • Added TabManager methods: increaseFontSizeFocusedTerminal, decreaseFontSizeFocusedTerminal, resetFontSizeFocusedTerminal.
  • Bug Fixes

    • Consistent error feedback: both terminal and browser zoom beep on failure.

Written for commit 3ea6c5d. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Zoom In/Out and Actual Size now adjust terminal font size when a terminal is focused.
    • Zoom commands automatically target the active terminal or the browser as appropriate.
  • Bug Fixes

    • Menu commands produce an audible alert if a terminal font-size change cannot be applied.

The Zoom In/Out/Actual Size menu items previously only controlled browser
zoom. Now they dispatch to terminal font size when a terminal panel is
focused, matching the existing Cmd+=/−/0 keyboard shortcut behavior that
was already routed to Ghostty at the key event level.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 23, 2026

@anthhub is attempting to deploy a commit to the Manaflow Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 23, 2026

Greptile Summary

This PR makes the View menu zoom actions context-aware: when a terminal panel is focused, Zoom In/Out/Actual Size now adjust the terminal font size via Ghostty binding actions instead of the browser zoom level. When a browser panel is focused the existing behavior is preserved. The change is minimal and well-scoped.

Key changes:

  • Three new TabManager methods (increaseFontSizeFocusedTerminal, decreaseFontSizeFocusedTerminal, resetFontSizeFocusedTerminal) mirror the existing browser zoom methods and call selectedTerminalPanel?.performBindingAction(...) with standard Ghostty action strings (increase_font_size:1, decrease_font_size:1, reset_font_size).
  • The three View menu buttons in cmuxApp.swift now branch on selectedTerminalPanel != nil before dispatching, consistent with how other context-aware actions work throughout the file.
  • No changes to keyboard shortcut routing (handled upstream in AppDelegate).

Confidence Score: 5/5

  • Safe to merge — small, focused change that follows established patterns with no identified bugs.
  • Both new TabManager methods and the dispatch logic in cmuxApp.swift are symmetric with existing browser-zoom counterparts and use the same performBindingAction mechanism already used throughout the codebase. The routing condition (selectedTerminalPanel != nil) correctly mirrors focusedBrowserPanel's nil-check semantics. Silent failure on return value is consistent with the pre-existing behavior of these exact buttons. No tests are broken and no new edge cases are introduced.
  • No files require special attention.

Important Files Changed

Filename Overview
Sources/TabManager.swift Adds three new @discardableResult methods (increaseFontSizeFocusedTerminal, decreaseFontSizeFocusedTerminal, resetFontSizeFocusedTerminal) that mirror the existing browser zoom methods, using selectedTerminalPanel?.performBindingAction(...) with Ghostty action strings consistent with the rest of the codebase.
Sources/cmuxApp.swift Updates the three View menu zoom buttons to dispatch to terminal font-size actions when a terminal panel is focused (selectedTerminalPanel != nil) and to browser zoom otherwise; keyboard shortcuts (.keyboardShortcut) are unchanged.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["User clicks View > Zoom In / Out / Actual Size\n(or Cmd+= / − / 0)"] --> B{selectedTerminalPanel != nil?}
    B -- "Yes (terminal focused)" --> C["manager.increaseFontSizeFocusedTerminal()\nmanager.decreaseFontSizeFocusedTerminal()\nmanager.resetFontSizeFocusedTerminal()"]
    B -- "No (browser or no panel focused)" --> D["manager.zoomInFocusedBrowser()\nmanager.zoomOutFocusedBrowser()\nmanager.resetZoomFocusedBrowser()"]
    C --> E["TerminalPanel.performBindingAction()\nincrease_font_size:1 / decrease_font_size:1 / reset_font_size"]
    D --> F["BrowserPanel.zoomIn() / .zoomOut() / .resetZoom()"]
    E --> G["Ghostty surface updates font size"]
    F --> H["Browser engine updates zoom level"]
Loading

Reviews (1): Last reviewed commit: "Make View menu zoom items context-aware ..." | Re-trigger Greptile

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5f8c5f26-372c-4b0e-9a41-d41c0ad01705

📥 Commits

Reviewing files that changed from the base of the PR and between 982094b and 3ea6c5d.

📒 Files selected for processing (1)
  • Sources/cmuxApp.swift
✅ Files skipped from review due to trivial changes (1)
  • Sources/cmuxApp.swift

📝 Walkthrough

Walkthrough

Three TabManager methods were added to adjust/reset the focused terminal panel's font size. Menu handlers for "Zoom In", "Zoom Out", and "Actual Size" now route to terminal font-size methods when a terminal is focused and fall back to browser zoom otherwise; handlers beep if terminal action fails.

Changes

Cohort / File(s) Summary
Terminal Font Size Control
Sources/TabManager.swift
Added three @discardableResult methods: increaseFontSizeFocusedTerminal(), decreaseFontSizeFocusedTerminal(), and resetFontSizeFocusedTerminal() that call selectedTerminalPanel?.performBindingAction(...) and return false when no focused terminal panel exists.
Zoom Command Routing
Sources/cmuxApp.swift
Updated "Zoom In", "Zoom Out", and "Actual Size" menu handlers to check activeTabManager.selectedTerminalPanel != nil; if true, call the new terminal font-size methods (and beep when they return false), otherwise call existing browser zoom/reset methods.

Sequence Diagram

sequenceDiagram
    actor User
    participant Menu as Menu Command Handler
    participant TabMgr as TabManager
    participant Term as TerminalPanel
    participant Browser as BrowserView

    User->>Menu: Trigger Zoom In / Out / Actual Size
    Menu->>TabMgr: check activeTabManager.selectedTerminalPanel
    alt Terminal focused
        Menu->>TabMgr: increase/decrease/resetFontSizeFocusedTerminal()
        TabMgr->>Term: performBindingAction("increase_font_size:1"/"decrease_font_size:1"/"reset_font_size")
        Term-->>TabMgr: success/failure (Bool)
        TabMgr-->>Menu: Bool
    else Browser focused
        Menu->>TabMgr: zoomIn/zoomOut/resetZoomFocusedBrowser()
        TabMgr->>Browser: apply zoom change
    end
    alt returned false
        Menu->>Menu: NSSound.beep()
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 I hop between panes with a twitch and cheer,
I nudge the fonts up, then coax them down near,
Focus decides which window gets the light,
A tiny beep if the change took no flight,
Hooray — pixels shifted, rabbit-approved delight!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the main changes and test plan, but is missing the required Testing section structure, demo video, review trigger block, and checklist items from the template. Add proper Testing section header, include a demo video link, add the Review Trigger code block with bot mentions, and populate the checklist items to match the repository template.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: making View menu zoom items context-aware to control terminal font size based on focused panel.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
Sources/cmuxApp.swift (1)

745-773: Optional cleanup: extract shared zoom dispatch helper to reduce repetition.

All three handlers duplicate the same branch shape; a tiny helper would reduce maintenance risk.

♻️ Proposed refactor
+    private func performContextAwareZoom(
+        terminalAction: (TabManager) -> Bool,
+        browserAction: (TabManager) -> Bool
+    ) {
+        let manager = activeTabManager
+        if manager.selectedTerminalPanel != nil {
+            _ = terminalAction(manager)
+        } else {
+            _ = browserAction(manager)
+        }
+    }
...
                 Button(String(localized: "menu.view.zoomIn", defaultValue: "Zoom In")) {
-                    let manager = activeTabManager
-                    if manager.selectedTerminalPanel != nil {
-                        _ = manager.increaseFontSizeFocusedTerminal()
-                    } else {
-                        _ = manager.zoomInFocusedBrowser()
-                    }
+                    performContextAwareZoom(
+                        terminalAction: { $0.increaseFontSizeFocusedTerminal() },
+                        browserAction: { $0.zoomInFocusedBrowser() }
+                    )
                 }
...
                 Button(String(localized: "menu.view.zoomOut", defaultValue: "Zoom Out")) {
-                    let manager = activeTabManager
-                    if manager.selectedTerminalPanel != nil {
-                        _ = manager.decreaseFontSizeFocusedTerminal()
-                    } else {
-                        _ = manager.zoomOutFocusedBrowser()
-                    }
+                    performContextAwareZoom(
+                        terminalAction: { $0.decreaseFontSizeFocusedTerminal() },
+                        browserAction: { $0.zoomOutFocusedBrowser() }
+                    )
                 }
...
                 Button(String(localized: "menu.view.actualSize", defaultValue: "Actual Size")) {
-                    let manager = activeTabManager
-                    if manager.selectedTerminalPanel != nil {
-                        _ = manager.resetFontSizeFocusedTerminal()
-                    } else {
-                        _ = manager.resetZoomFocusedBrowser()
-                    }
+                    performContextAwareZoom(
+                        terminalAction: { $0.resetFontSizeFocusedTerminal() },
+                        browserAction: { $0.resetZoomFocusedBrowser() }
+                    )
                 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Sources/cmuxApp.swift` around lines 745 - 773, These three Button actions
duplicate the same branching logic; extract a small helper function (e.g.,
dispatchZoomAction(on activeTabManager: TabManager, terminalAction: ()->Void,
browserAction: ()->Void) or a method on activeTabManager) that checks
selectedTerminalPanel and calls either increaseFontSizeFocusedTerminal /
decreaseFontSizeFocusedTerminal / resetFontSizeFocusedTerminal or
zoomInFocusedBrowser / zoomOutFocusedBrowser / resetZoomFocusedBrowser
accordingly, then replace each Button body to call that helper with the
appropriate terminal and browser action identifiers
(increaseFontSizeFocusedTerminal, zoomInFocusedBrowser,
decreaseFontSizeFocusedTerminal, zoomOutFocusedBrowser,
resetFontSizeFocusedTerminal, resetZoomFocusedBrowser).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Sources/cmuxApp.swift`:
- Around line 745-773: These three Button actions duplicate the same branching
logic; extract a small helper function (e.g., dispatchZoomAction(on
activeTabManager: TabManager, terminalAction: ()->Void, browserAction: ()->Void)
or a method on activeTabManager) that checks selectedTerminalPanel and calls
either increaseFontSizeFocusedTerminal / decreaseFontSizeFocusedTerminal /
resetFontSizeFocusedTerminal or zoomInFocusedBrowser / zoomOutFocusedBrowser /
resetZoomFocusedBrowser accordingly, then replace each Button body to call that
helper with the appropriate terminal and browser action identifiers
(increaseFontSizeFocusedTerminal, zoomInFocusedBrowser,
decreaseFontSizeFocusedTerminal, zoomOutFocusedBrowser,
resetFontSizeFocusedTerminal, resetZoomFocusedBrowser).

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4d7503c4-8653-44d0-a5d6-e9d93576fad6

📥 Commits

Reviewing files that changed from the base of the PR and between 0c4415c and ec17783.

📒 Files selected for processing (2)
  • Sources/TabManager.swift
  • Sources/cmuxApp.swift

anthhub and others added 2 commits March 23, 2026 19:53
Matches the pattern used by other View menu items (Toggle Developer
Tools, Show JavaScript Console) that beep on failure.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Only add beep feedback for terminal font size actions (new behavior).
Browser zoom branches preserve the original silent-on-failure behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Sources/cmuxApp.swift">

<violation number="1" location="Sources/cmuxApp.swift:750">
P2: Browser zoom View-menu actions now ignore failure return values, causing silent no-ops instead of user feedback when no focused browser can handle zoom.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Browser zoom operations silently discarded failures while terminal zoom
operations beeped. Unify both paths to beep on failure using a shared
success/fail pattern, which also reduces the branching duplication.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@anthhub
Copy link
Copy Markdown
Contributor Author

anthhub commented Mar 29, 2026

Hey @lawrencecchen @austinywang — just wanted to check in on this one. I have a handful of open PRs stacking up (17 total at this point 😅) and would love to get some of the smaller ones moving if you have a chance to take a look. Happy to rebase or address any feedback. No rush on the bigger ones, but stuff like this, #1998, and #2144 should be pretty straightforward to review. Thanks!

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.

1 participant