Skip to content

Fix Settings window focus under Stage Manager - #2833

Open
KGBos wants to merge 7 commits into
steipete:mainfrom
KGBos:fix/settings-stage-manager
Open

Fix Settings window focus under Stage Manager#2833
KGBos wants to merge 7 commits into
steipete:mainfrom
KGBos:fix/settings-stage-manager

Conversation

@KGBos

@KGBos KGBos commented Aug 10, 2026

Copy link
Copy Markdown

Summary

  • Keep the Settings window on the active Stage Manager stage/Space with .moveToActiveSpace + .fullScreenAuxiliary.
  • When Dock promotion detects a newly presented Settings/Sparkle dialog, key/order only that window so an already-open Settings window cannot cover a Check for Updates alert.
  • Changelog note lives under 0.49.3 — Unreleased (not the shipped 0.49.1 section).
  • Add focused tests for Space collection behavior and newly-presented window ID filtering.

Review follow-ups addressed

  • Focus only newly presented windows (DockIconPolicyDecision.newlyPresentedWindowIDs)
  • Remove retrospective 0.49.1 changelog hunk; add 0.49.3 Unreleased note
  • Focused tests: 19 passed (SettingsWindowAppearanceTests|DockIconPolicyDecisionTests|SettingsWindowOpeningTests)
  • Stage Manager real-behavior proof (fresh adhoc release build of this branch, commit dc646188)

Stage Manager proof (fresh build dc646188)

Stage Manager GloballyEnabled=1. Bundle com.steipete.codexbar.

Step visible frontmost activationPolicy isActive windows
launch accessory (1) false
open Settings true regular (0) true Menu Bar
close Settings false false accessory (1) false keepalive only
reopen Settings true true regular (0) true Menu Bar focused

Runtime log: https://gist.github.com/KGBos/75194a39a7c964de17ed14d79d98b371

Test plan

  • With Stage Manager on, open Settings from the menu bar: window appears, becomes regular activation, interactive.
  • Close Settings and reopen: returns accessory on close; Settings focuses again on reopen.
  • Dock promotion fronts only newly presented eligible windows (unit coverage + code path).
  • swift test --filter 'SettingsWindowAppearanceTests|DockIconPolicyDecisionTests|SettingsWindowOpeningTests' — 19 passed.

@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 10, 2026
@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed August 13, 2026, 4:28 PM ET / 20:28 UTC.

ClawSweeper review

What this changes

The PR keeps Settings on the active Stage Manager Space and fronts only newly presented Settings or Sparkle update windows during Dock promotion.

Merge readiness

⚠️ Ready for maintainer review - 5 items remain

Keep open for maintainer review: the focused Stage Manager proof is credible, but replacing the complete window-behavior mask needs an explicit compatibility decision beyond the tested open/close/reopen path. Likely related people: steipete, recent app/release-history contributor (medium confidence).

Priority: P2
Reviewed head: 3c871133ab9b1de1112ab0a780cc92dfe762db34
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused implementation and real runtime proof are strong, with one remaining compatibility decision outside the covered Stage Manager path.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The PR supplies an after-fix fresh-build Stage Manager open/close/reopen trace and linked runtime log showing the intended activation and focus recovery.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The PR supplies an after-fix fresh-build Stage Manager open/close/reopen trace and linked runtime log showing the intended activation and focus recovery.
Evidence reviewed 5 items PR implementation: The proposed helper assigns Settings an exact collection-behavior mask containing move-to-active-Space and full-screen auxiliary behavior, then applies it during registration and appearance.
Compatibility scope: The same helper replaces, rather than augments, the complete AppKit collection-behavior OptionSet; its supplied test deliberately verifies removal of all-Spaces and full-screen-primary flags.
After-fix runtime proof: The PR body records a fresh branch build with Stage Manager enabled and shows Settings becoming active, returning to accessory mode after close, and focusing again on reopen; it links a runtime log.
Findings None None.
Security None None.

How this fits together

CodexBar is a macOS menu-bar app that temporarily uses regular-app activation while Settings or update dialogs are present. The Dock policy observes AppKit windows, then chooses Space behavior, activation, and focus for those dialogs.

flowchart LR
A[Menu bar action] --> B[Settings or update window]
B --> C[Window appearance bridge]
C --> D[Dock policy]
D --> E[Space and focus decision]
E --> F[Interactive dialog]
Loading

Decision needed

Question Recommendation
Should Settings intentionally replace its entire AppKit collection-behavior mask with active-Space/full-screen-auxiliary behavior, including for existing full-screen and multi-Space users? Preserve broader behavior where compatible: Narrow the mask change to the flags required for Stage Manager and add coverage for the retained full-screen or Space behavior.

Why: The branch proves the Stage Manager path but not the broader behavior displaced by an exact OptionSet replacement; that compatibility tradeoff needs product ownership rather than automated inference.

Before merge

  • Resolve merge risk (P1) - Replacing the complete collection-behavior mask may change uncommon existing full-screen or multi-Space behavior; the supplied proof covers Stage Manager open, close, and reopen only.
  • Resolve merge risk (P1) - Only focused tests are reported, so the repository-required full-suite result remains unverified.
  • Resolve merge risk (P1) - Local source and history inspection was unavailable because read-only commands failed in the sandbox. This does not invalidate the contributor’s supplied runtime proof.
  • Complete next step (P2) - A maintainer must decide the intended compatibility contract for the complete collection-behavior replacement; no safe autonomous repair can choose that policy.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch surface 5 files affected; app sources +53/-1, tests +54, release notes +1 The change is focused, with test growth matching the production behavior added.

Merge-risk options

Maintainer options:

  1. Verify the complete Space-policy change (recommended)
    Before merging, confirm Settings behavior in full-screen and multi-Space setups and decide whether the exact replacement is intentional.
  2. Accept the Stage Manager-first policy
    Merge with explicit owner acceptance that existing Settings collection behavior is replaced by the active-Space auxiliary-window policy.

Technical review

Best possible solution:

Retain the narrow active-Space fix only after confirming the intended full-screen and multi-Space behavior, then validate the final head with the repository’s full test suite.

Do we have a high-confidence way to reproduce the issue?

No high-confidence current-main reproduction was independently established: the PR provides after-fix Stage Manager runtime evidence, but not a before-fix current-main failure trace.

Is this the best way to solve the issue?

Unclear: the active-Space approach is a plausible narrow fix, but wholesale replacement of collection behavior needs compatibility confirmation or a more preserving implementation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against daf02ae7a7a4.

Labels

Label justifications:

  • P2: This is a bounded macOS Settings focus fix whose unverified compatibility impact is limited to affected Space and full-screen setups.
  • merge-risk: 🚨 compatibility: The PR intentionally replaces an existing AppKit window-behavior set, which can alter how established multi-Space or full-screen setups behave after upgrade.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The PR supplies an after-fix fresh-build Stage Manager open/close/reopen trace and linked runtime log showing the intended activation and focus recovery.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR supplies an after-fix fresh-build Stage Manager open/close/reopen trace and linked runtime log showing the intended activation and focus recovery.

Evidence

What I checked:

  • PR implementation: The proposed helper assigns Settings an exact collection-behavior mask containing move-to-active-Space and full-screen auxiliary behavior, then applies it during registration and appearance. (Sources/CodexBar/PreferencesView.swift, 3c871133ab9b)
  • Compatibility scope: The same helper replaces, rather than augments, the complete AppKit collection-behavior OptionSet; its supplied test deliberately verifies removal of all-Spaces and full-screen-primary flags. (Tests/CodexBarTests/SettingsWindowAppearanceTests.swift, 3c871133ab9b)
  • After-fix runtime proof: The PR body records a fresh branch build with Stage Manager enabled and shows Settings becoming active, returning to accessory mode after close, and focusing again on reopen; it links a runtime log. (3c871133ab9b)
  • Validation coverage: The supplied validation reports 19 focused tests, while repository guidance asks for make test before handoff; no full-suite result is included in the review context. (AGENTS.md, 3c871133ab9b)
  • Inspection limitation: Read-only local inspection could not execute because the sandbox terminated commands with bwrap: loopback: Failed RTM_NEWADDR: Operation not permitted; current-main source and git-history provenance were therefore not independently checked.

Likely related people:

  • steipete: Authored the branch commit that moved the Stage Manager release note and the latest merge of main into this branch, making them the strongest available routing candidate for the present app/release context. (role: recent area contributor; confidence: medium; commits: da1bca22c818, 3c871133ab9b; files: CHANGELOG.md, Sources/CodexBar/DockIconController.swift, Sources/CodexBar/PreferencesView.swift)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm intended full-screen and multi-Space behavior for the exact collection-behavior replacement.
  • Run and report the repository-required make test result for the final head.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-08-10T06:46:32.071Z sha e7e1c50 :: needs real behavior proof before merge. :: [P2] Focus only newly presented windows | [P2] Remove the retrospective 0.49.1 release note
  • reviewed 2026-08-10T14:59:48.844Z sha dc64618 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-10T15:03:44.854Z sha dc64618 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T15:57:21.329Z sha dc64618 :: needs changes before merge. :: [P1] Rebase the duplicate 0.49.3 changelog section
  • reviewed 2026-08-12T17:36:27.543Z sha c6a5917 :: needs maintainer review before merge. :: none

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7e1c5022c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

self.isAwaitingPresentedWindow = false
self.ensureRegularPolicy(activate: hasNewPresentedWindow)
if hasNewPresentedWindow {
for item in describedWindows where presentedWindowIDs.contains(ObjectIdentifier(item.window)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Re-key only the newly presented window

When Settings is already visible and the user opens a Sparkle dialog via About → Check for Updates, hasNewPresentedWindow becomes true for the new Sparkle window, but this loop orders every recognized window—including the existing Settings window—to the front. Because the iteration order of NSApp.windows does not identify which window was newly presented, Settings can become key again and cover the update dialog. Preserve the ID difference computed before updating self.presentedWindowIDs and present only those newly added windows.

Useful? React with 👍 / 👎.

KGBos and others added 2 commits August 10, 2026 07:41
Keep Settings on the active Space and key it when Dock promotion presents the window.

Co-authored-by: Cursor <cursoragent@cursor.com>
Limit Dock promotion fronting to the newly detected window set so an update alert is not covered by Settings, and move the changelog note to 0.49.3 Unreleased.

Co-authored-by: Cursor <cursoragent@cursor.com>
@KGBos
KGBos force-pushed the fix/settings-stage-manager branch from e7e1c50 to dc64618 Compare August 10, 2026 14:55
@KGBos

KGBos commented Aug 10, 2026

Copy link
Copy Markdown
Author

Addressed ClawSweeper / Codex review:

  1. Focus only newly presented windowsreevaluatePolicy now captures newlyPresentedWindowIDs before updating stored state and fronts only that delta.
  2. Changelog — removed the retrospective 0.49.1 line; note is under ## 0.49.3 — Unreleased.
  3. Proof — Stage Manager open/close/reopen on a freshly packaged build of this branch: failed to collect files for posting: failed to upload /tmp/codexbar-ui/proof-open.png: binary file not supported

Focused tests: 19 passed.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 10, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@KGBos

KGBos commented Aug 10, 2026

Copy link
Copy Markdown
Author

Follow-up: runtime proof log gist (screenshots are local; table is in the PR body):

https://gist.github.com/KGBos/75194a39a7c964de17ed14d79d98b371

Fresh package commit: dc646188

@clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 10, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown

ClawSweeper status: review started.

I am starting a fresh review of this pull request: Fix Settings window focus under Stage Manager This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants