Skip to content

✨ Add opt-in automatic initial window placement - #1195

Open
Mars-den wants to merge 9 commits into
mrkai77:developfrom
Mars-den:automatic-initial-placement-76
Open

Mars-den wants to merge 9 commits into
mrkai77:developfrom
Mars-den:automatic-initial-placement-76

Conversation

@Mars-den

@Mars-den Mars-den commented Oct 31, 2026 •

Copy link
Copy Markdown

Description

Adds opt-in initial window placement for #76. In Settings -> Behavior -> Window -> Initial Window Placement -> Configure…, choose an app and set the size and position of its new windows using Loop’s custom action editor. Removing the app removes its rule.

Loop observes configured apps and applies each rule to new standard, resizable windows on their current display. Windows already open when observation starts stay in place. Placement skips excluded apps, minimized and fullscreen windows, and native multi-tab groups. It reuses Loop’s resize and size-constraint handling without activating the app or adding an Undo entry.

Placement follows the same screen-edge behavior as custom actions. With zero padding, X at 80% and width at 50% produces a frame covering the rightmost 20% of the usable display.

Context and earlier PR

I had not received a reply to my proposed approach in #76, so I continued with a small local implementation one evening. During that work, Codex misread my request to “get this over with” as a request to finish and publish quickly. I meant to make small steps toward the result. It published #1194 before I had reviewed and approved it. That PR was closed and its branch was removed. I am sorry for the noise; I take responsibility for what I submit.

The Finder-specific diagnosis in my earlier comment also needs correction: another Loop build was running with its own Finder rule. Those tests did not establish a Finder initialization bug. I repeated the Finder checks with only the development build running.

How has this been tested?

  • After merging develop, the macOS Debug build passed and all six focused placement tests passed. They cover display bounds, clipping at the right edge, explicit zero dimensions, accessibility readiness retries, bounded waiting, and cancellation.
  • On one physical display, I tested the configuration list and editor, new Finder windows, native tabs, exclusions, first-window placement after a fresh app launch, and clipping at the right edge. Secondary-display coordinates are covered by an automated geometry test.
  • Only the focused suite was rerun after the merge. Placement happens after window creation, so movement can be visible. If a window takes too long to expose its accessibility properties, Loop skips placement.

Checklist

  • I have personally reviewed all submitted code.
  • Corresponding documentation is included.
  • No unrelated source changes are included.

Please describe to which degree, if any, an LLM was used in creating this pull request.

OpenAI Codex generated and revised and tested this change with me. I have personally reviewed all of the new code and the demonstrated behavior.

Mars-den and others added 3 commits November 21, 2026 23:07
Skip automatic placement when a direct accessibility tab group contains multiple tabs. Bound child accessibility calls and document the conservative exclusion of new or restored multi-tab windows.

AI-assisted with OpenAI ChatGPT. Manually reviewed and approved by the author; author verified behavior with Finder and Ghostty.
- Use the existing setFrameSynchronously instead of changing it, and let handleSizeConstrainedWindow correct the position
- Leave anchoredFrame unchanged, as it runs for every resize
- Drop the README section for the hidden initialWindowFrames key
@mrkai77
mrkai77 force-pushed the automatic-initial-placement-76 branch from d53648b to 03751f1 Compare November 22, 2026 05:11

@mrkai77 mrkai77 left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Hey, thanks for this, and for posting the proposal on #76 first! Sorry I didn't get back to you on it sooner. The overall structure is pretty much what I had in mind; a separate observer for configured apps, leaving existing windows alone, and reusing the existing resize primitives instead of branching through the action pipeline.

I rebased this onto develop and pushed a small commit on top:

  • Dropped the changes to Window.setFrameSynchronously. #1190 just restructured that code, and place already reads the frame back afterwards, so the failure return wasn't needed. It now uses the existing setter and lets handleSizeConstrainedWindow correct the position.
  • Reverted the anchoredFrame change. Keeping the title bar on screen for windows larger than the display is a good idea, but anchoredFrame runs for every resize, so I'd rather take that as its own PR if you're up for it!
  • Removed the README section, since the README is user-facing and this isn't configurable without defaults write yet.

On your question about scope: I'd like the settings UI to be part of this PR, since right now there's no way for users to turn this on. A couple of other things:

  • Could you match the rest of the codebase's style a bit more? Mainly splitting up the dense one-line guards and the multi-statement lines in start(), and adding the usual file headers to the new files.
  • A short doc comment on initialWindowFrames describing what it stores would be nice to have.

Since I force-pushed, please reset your local branch to the updated one before pushing again. Thanks again!

@mrkai77
mrkai77 marked this pull request as draft November 22, 2026 05:14
- Expand dense guards and observer setup
- Add headers to the new Swift files
- Clarify what initialWindowFrames stores

AI-assisted with OpenAI Codex for the style edits and verification.
Use a single modal to manage apps and edit their initial window frames with the existing custom action editor.

AI-assisted with OpenAI Codex for implementation and build verification.
Fit the requested frame before applying inner padding and pass explicit zero dimensions through to the window setter. Cover both cases with placement tests.

Use the custom editor defaults, share the app exclusion check, and disable drag reordering in the placement list.

AI-assisted with OpenAI Codex for implementation and verification.
Use the shared padded target and verify that the right-edge placement matches a custom action. AI-assisted with OpenAI Codex for implementation and testing.
@Mars-den

Copy link
Copy Markdown
Author

Thanks for the review and rebase, The settings UI is now under Behavior -> Window. I kept initial placement consistent with custom actions at screen edges. For example, with zero padding, a preset starting at X = 80% with width = 50% gets clipped to the rightmost 20% of the screen.
Would you prefer to keep that behavior, or shift the window left to X = 50% so it keeps its requested width? If you prefer shifting, should that apply only to initial placement here, or would you also like the behavior changed globally for custom actions in a separate PR?

@Mars-den
Mars-den marked this pull request as ready for review November 24, 2026 23:16

This branch has not been deployed

No deployments
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