Skip to content

fix(v3/darwin): add effectiveZoomButtonState and fix runtime NSWindowZoomButton conflict#5455

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

fix(v3/darwin): add effectiveZoomButtonState and fix runtime NSWindowZoomButton conflict#5455
taliesin-ai wants to merge 1 commit into
wailsapp:masterfrom
taliesin-ai:agent/engineer-mac/d332c3e8-v2

Conversation

@taliesin-ai

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

Copy link
Copy Markdown
Collaborator

Summary

  • Adds effectiveZoomButtonState(a, b ButtonState) ButtonState helper that returns the more restrictive of two ButtonState values (Hidden > Disabled > Enabled)
  • Both setMaximiseButtonState and setFullscreenButtonState now call this helper, so neither can silently override the other at runtime — the "more restrictive wins" contract holds regardless of call order
  • Removes the incorrect startup guard if options.FullscreenButtonState != ButtonEnabled in run() — it was wrong (a runtime SetFullscreenButtonState(ButtonEnabled) call could undo a MaximiseButtonState: ButtonDisabled) and is no longer needed since reconciliation is in the setters
  • Adds TestEffectiveZoomButtonState with 13 subtests covering all ButtonState combinations plus commutativity checks

Background

MaximiseButtonState and FullscreenButtonState both target NSWindowZoomButton (the green traffic-light button). In master, whichever setter runs last wins. This PR makes both setters always enforce the more restrictive of the two settings, both at startup and at runtime.

Test results

go vet ./pkg/application/... → clean
TestEffectiveZoomButtonState → 13/13 PASS

Closes #5319

CC @leaanthony

Summary by CodeRabbit

Bug Fixes

  • Fixed macOS window button state handling to properly reconcile fullscreen and maximise button behaviors, preventing conflicts when both modes are configured.

Review Change Stack

…omButton conflict

Both setMaximiseButtonState and setFullscreenButtonState now call
effectiveZoomButtonState so the more restrictive of the two settings
always wins at runtime (Hidden > Disabled > Enabled).

The previous startup-only guard `if FullscreenButtonState != ButtonEnabled`
was incorrect: it skipped setFullscreenButtonState when ButtonEnabled,
so a runtime SetFullscreenButtonState(ButtonEnabled) call could silently
un-grey a button that MaximiseButtonState had disabled. The setters now
handle reconciliation, making a single setMaximiseButtonState call at
startup sufficient.

Adds TestEffectiveZoomButtonState: 13 subtests covering all ButtonState
combinations plus commutativity verification.

Closes wailsapp#5319
@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: 72529ac2-6eeb-4d56-baed-9dcfbde32fca

📥 Commits

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

📒 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

macOS window button state handling is updated to reconcile fullscreen and maximise modes that both target NSWindowZoomButton. A new effective-state helper selects the more restrictive state; both button setters now compute and apply this effective state instead of raw states. Window initialization is refactored to delegate fullscreen reconciliation through setMaximiseButtonState.

Changes

Button State Reconciliation on macOS

Layer / File(s) Summary
Effective state computation and validation
v3/pkg/application/webview_window_options.go, v3/pkg/application/webview_window_options_test.go
effectiveZoomButtonState helper returns the more restrictive ButtonState when comparing two states. Table-driven test validates all ButtonState combinations (enabled, disabled, hidden) and verifies commutativity.
Setter reconciliation with effective state
v3/pkg/application/webview_window_darwin.go
setFullscreenButtonState and setMaximiseButtonState now compute effective state using the helper and pass the computed value to Cocoa layer, resolving the last-writer-wins conflict on NSWindowZoomButton.
Window initialization refactoring
v3/pkg/application/webview_window_darwin.go
Removed explicit setFullscreenButtonState call during window setup and reordered initialization so setMaximiseButtonState becomes responsible for reconciling both fullscreen and maximise states.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • wailsapp/wails#5224: The retrieved PR introduces FullscreenButtonState and the new setFullscreenButtonState flow (including darwin init), and the main PR further refines webview_window_darwin.go's setFullscreenButtonState/setMaximiseButtonState logic to reconcile fullscreen vs maximise on the shared NSWindowZoomButton via effectiveZoomButtonState.

Suggested labels

reviewed ✅

Suggested reviewers

  • leaanthony

Poem

🐰 Two buttons map to one, oh what a tangled web,
But now with effective state, we pick the more strict thread,
Max and fullscreen reconciled through clever computation,
No more silent conflicts in macOS window creation! 🪟✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is comprehensive and well-structured, covering summary, background, and test results. However, the PR description template requires specific sections (Type of change checklist, How Has This Been Tested with platform checkboxes, and other checklists) that are not filled in. Complete the PR description by selecting appropriate options in the Type of change, How Has This Been Tested, and Checklist sections as specified in the repository template.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main changes: adding effectiveZoomButtonState helper and fixing the NSWindowZoomButton conflict on macOS.
Linked Issues check ✅ Passed All objectives from issue #5319 are met: effectiveZoomButtonState helper added, setMaximiseButtonState and setFullscreenButtonState updated to reconcile states, incorrect startup guard removed, and comprehensive tests added covering all ButtonState combinations.
Out of Scope Changes check ✅ Passed All changes in the PR are directly related to resolving the NSWindowZoomButton conflict and implementing the FullscreenButtonState feature as specified in issue #5319. No out-of-scope modifications detected.

✏️ 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

Superseded by #5467 (merged 2026-05-16), which landed the same effectiveZoomButtonState helper and runtime reconciliation.

@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