Skip to content

fix(v3/darwin): add effectiveZoomButtonState to resolve NSWindowZoomButton conflict#5457

Closed
taliesin-ai wants to merge 1 commit into
wailsapp:masterfrom
taliesin-ai:agent/engineer-mac/3fd103fd
Closed

fix(v3/darwin): add effectiveZoomButtonState to resolve NSWindowZoomButton conflict#5457
taliesin-ai wants to merge 1 commit into
wailsapp:masterfrom
taliesin-ai:agent/engineer-mac/3fd103fd

Conversation

@taliesin-ai

@taliesin-ai taliesin-ai commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Problem

MaximiseButtonState and FullscreenButtonState both target NSWindowZoomButton on macOS. The current implementation has a last-writer-wins bug: whichever setter runs last overwrites the other, and the startup guard (if options.FullscreenButtonState != ButtonEnabled) means a runtime SetMaximiseButtonState call can silently undo an earlier FullscreenButtonState: ButtonHidden setting.

This was flagged by the Copilot reviewer in PR #5319 (three unresolved threads).

Fix

Add effectiveZoomButtonState(a, b ButtonState) ButtonState — returns max(a, b) using the integer ordering Enabled(0) < Disabled(1) < Hidden(2). Both setMaximiseButtonState and setFullscreenButtonState now call it before writing to NSWindowZoomButton, making the two setters order-independent at both startup and runtime.

The startup guard if options.FullscreenButtonState != ButtonEnabled is removed; reconciliation now happens inside each setter.

Verification

  • go vet ./v3/pkg/application/... — clean
  • TestEffectiveZoomButtonState — 13/13 PASS (all ButtonState combos + commutativity)

Closes #5319
Closes #5455

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue on macOS where the window maximize and fullscreen button states could override each other, preventing correct button configuration when both were set.
  • Tests

    • Added unit tests to verify correct button state handling across all possible maximize and fullscreen combinations.

Review Change Stack

…nState+FullscreenButtonState conflict

Both MaximiseButtonState and FullscreenButtonState target NSWindowZoomButton on
macOS. Without reconciliation, whichever setter runs last wins — breaking the
intended precedence when both options are set.

This commit adds effectiveZoomButtonState(a, b ButtonState) ButtonState which
returns the more restrictive value (Hidden > Disabled > Enabled). Both
setMaximiseButtonState and setFullscreenButtonState now call it before writing
to NSWindowZoomButton, making the two setters order-independent at runtime.

The startup path in run() is simplified: the FullscreenButtonState guard
(if options.FullscreenButtonState != ButtonEnabled) is removed since the setters
now handle reconciliation internally.

TestEffectiveZoomButtonState added (13 subtests covering all ButtonState
combinations plus commutativity).

Addresses the three unresolved Copilot review threads on PR wailsapp#5319.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1e9cfe72-d724-43f5-9a5a-c22283f3d6ec

📥 Commits

Reviewing files that changed from the base of the PR and between 99617cc and e1e5e21.

📒 Files selected for processing (3)
  • v3/pkg/application/webview_window_darwin.go
  • v3/pkg/application/webview_window_options.go
  • v3/pkg/application/webview_window_options_test.go

Walkthrough

This PR fixes macOS window button state handling by introducing an effectiveZoomButtonState helper that ensures the more restrictive of maximize and fullscreen button states always takes precedence at both startup and runtime, eliminating previous silent overrides.

Changes

macOS Zoom Button State Reconciliation

Layer / File(s) Summary
Effective zoom button state helper and validation
v3/pkg/application/webview_window_options.go, v3/pkg/application/webview_window_options_test.go
Introduced effectiveZoomButtonState(a, b) helper returning the more restrictive ButtonState (Hidden > Disabled > Enabled). Test suite covers all combinations and validates commutativity.
macOS setter implementations
v3/pkg/application/webview_window_darwin.go
Both setFullscreenButtonState and setMaximiseButtonState now compute their effective state using the helper, ensuring neither can override the other regardless of call order.
Window button state initialization wiring
v3/pkg/application/webview_window_darwin.go
Window initialization now unconditionally applies fullscreen state after maximize state with explicit reconciliation comments, removing the prior conditional logic that enabled unintended overrides.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • wailsapp/wails#5224: Introduced the tri-state setFullscreenButtonState API and macOS setter entry points that this PR now reconciles with maximize state via the helper function.

Suggested labels

reviewed ✅

Poem

🐰 A button stood green on the macOS bar,
Two settings fought for its control from afar,
Till effectiveZoomButtonState came to decree:
The more restrictive one wins, let the conflicts be free!
No more silent overrides in the dark of the night,
Now reconciliation runs—and everything's right! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding effectiveZoomButtonState to resolve the NSWindowZoomButton conflict on macOS, which directly matches the primary objective.
Description check ✅ Passed The PR description provides a clear problem statement, explains the fix, includes verification results, and references linked issues, covering the essential information.
Linked Issues check ✅ Passed The PR fully addresses both #5319 and #5455: it adds effectiveZoomButtonState helper, updates both setters to use it for order-independent reconciliation, removes the incorrect startup guard, and includes comprehensive test coverage validating all ButtonState combinations.
Out of Scope Changes check ✅ Passed All changes are focused on resolving the NSWindowZoomButton conflict; the modifications to webview_window_darwin.go, webview_window_options.go, and tests are directly aligned with the stated objectives.

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

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

@leaanthony

Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

@leaanthony

Copy link
Copy Markdown
Member

Superseded by #5467 (merged 2026-05-16), which landed the same effectiveZoomButtonState helper and runtime reconciliation. Conflicts are because those lines are already on master.

@leaanthony leaanthony closed this May 17, 2026
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.

2 participants