PaperWM.spoon icon indicating copy to clipboard operation
PaperWM.spoon copied to clipboard

`focus_prev`/`focus_next` misbehave with ChatGPT Atlas (Chromium-based apps)

Open jvaldiviezo9 opened this issue 7 months ago • 5 comments

Summary

When PaperWM.spoon manages a space that contains ChatGPT Atlas windows, focus_prev / focus_next behave erratically:

  • Cycling forward (right) mostly works.
  • Cycling backward (left) leaves windows stuck off-screen — only a one-pixel indicator at the left screen_margin is visible.

Steps to reproduce

  1. Open two or more ChatGPT Atlas windows in the same space (enough for the tiled strip to exceed the canvas width).
  2. Bind:
    focus_prev = {{"alt", "cmd"}, "k"},
    focus_next = {{"alt", "cmd"}, "j"},
    
  3. Press alt+cmd+j a few times — focus moves forward, strip scrolls.
  4. Press alt+cmd+k to cycle back — focus changes, but the newly focused window ends up parked off-screen at the left margin. No visible rearrangement.

Environment

  • Hammerspoon (current)
  • PaperWM.spoon at commit e9e78a6
  • ChatGPT Atlas — Chromium-based, bundleID = com.openai.atlas, draws its own chrome (no native titlebar)

Below, I provide some context given by an AI check that might help.

=======================

Hypothesis (AI Generated)

The issue looks like it has two layers:

1. Window filter excludes Chromium apps

The default filter (config.lua:57-62) requires:

hasTitlebar = true,
allowRoles  = "AXStandardWindow",

ChatGPT Atlas windows report role = AXWindow, subrole = AXStandardWindow, standard = true, but because they use custom chrome they appear to fail the hasTitlebar check. Since events.lua:370-374 subscribes to window_filter for windowFocused/etc., excluded windows never emit events to PaperWM — so focus_prev/next call :focus() but no retile follows.

2. tileSpace only clamps the anchor, doesn't scroll

Even after loosening the filter so Atlas is admitted, left-direction cycling still parks the newly focused window off-canvas. tileSpace (tiling.lua:111-117) takes the anchor window's current frame and only clamps it:

anchor_frame.x = math.max(anchor_frame.x, canvas.x)
...
if anchor_frame.x2 > canvas.x2 then
    anchor_frame.x = canvas.x2 - anchor_frame.w
end

When focus returns to a window that was previously parked at left_margin - width, this clamp appears to land as a one-pixel sliver at screen_margin instead of bringing the window fully onto the canvas. Right-direction cycling doesn't hit this path because the new anchor is already on-canvas.

Observations that support the hypothesis

  • With the default filter: hs.window.focusedWindow() returns nil while Atlas is frontmost, even though hs.application.frontmostApplication():allWindows() returns the Atlas windows normally.
  • With the filter override {visible = true, fullscreen = false}: PaperWM.window_filter:isWindowAllowed(atlas_window) returns false despite every rule matching the window's attributes. getWindows() and isWindowAllowed() appear to disagree on the same window.
  • Keystrokes (alt+cmd+j/k) reach Hammerspoon correctly — this is not Chromium intercepting DevTools shortcuts.

Suggested fix direction (hypothesis)

  • Default filter should admit Chromium-style windows — either drop hasTitlebar = true, or whitelist by bundle ID / subrole.
  • tileSpace should recenter (not just clamp) the anchor when the focused window's frame is outside the canvas, so backward cycling scrolls symmetrically with forward cycling.

jvaldiviezo9 avatar Apr 21 '26 00:04 jvaldiviezo9

quick update. i've been sick. i'll look at this issue when i'm feeling better.

mogenson avatar Apr 23 '26 14:04 mogenson

Hi, I'm hesitant to make the default window filter more relaxed. There are a number of applications that use standard windows without titlebars as modal pop up windows (for example IntelliJ).

For this use case, try adding a local window filter config that explicitly includes all windows for the Atlas application:

PaperWM.window_filter = PaperWM.window_filter:allowApp('com.openai.atlas')

Or use setAppFilter() to fine tune which Atlas windows should be allowed, denied.

mogenson avatar Apr 27 '26 13:04 mogenson

Hi @mogenson, Thanks for the follow up, hope you're feeling better!

Quick question: what would be the best way to apply those recommendations? Just at the end of the code once it has started? I agree that we should aim for minimal changes. I want to understand: in cases where there are pop-ups that don't have a title, what's the expected behavior? To keep them as "floating" windows?

Also, I'm wondering: if some apps behave like this and we're not aware of it, they might end up in a bad state. For example, while I was experimenting, Atlas didn't behave as expected and ended up out of focus, and when I tried to fix it, it affected the other apps. So, is there a way to guarantee a "smooth recovery" if that happens? Like a "reset" function we could use to prevent having the other widows out of focus?

Thanks in advance!

jvaldiviezo9 avatar Apr 27 '26 15:04 jvaldiviezo9

PaperWM = hs.loadSpoon("PaperWM")
... you config here ...
PaperWM.window_filter = PaperWM.window_filter:allowApp('com.openai.atlas')
PaperWM:start()

In the Hammerspoon Console you can type:

hs.inspect(PaperWM.window_filter)

I can see all visible windows from Atlas should be allowed in window filter:

    ["com.openai.atlas"] = {
      visible = true
    },

I don't have Chat GPT Atlas installed so please confirm this works.

mogenson avatar Apr 28 '26 14:04 mogenson

Yes, pop up windows without a title should be floating and should not be resized and tiled.

You can use the stop events, start events, or refresh windows actions to force PaperWM to reset.

https://github.com/mogenson/PaperWM.spoon/blob/e9e78a68fce3d88e5ab67dbc636c23c591a7202c/actions.lua#L16-L18

mogenson avatar Apr 28 '26 14:04 mogenson