asmvik / asmvik/yabai

`--toggle scratchpad` jumps to previous space after moving scratchpad to the current space

Open
#2,807 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C
Stars
29.6k
Forks
750
PR merge metrics
No merged PRs in 30d

Description

When toggling a scratchpad window that currently belongs to another space, `yabai -m window --toggle ` correctly moves/shows the scratchpad on the current space, but then focus can jump back to the scratchpad's previous space.

**Here's the catch: it only happens when the currently focused window belongs to the same app as the scratchpad, but it doesn't have a scratchpad property itself.**

I can reproduce it by running the raw yabai command directly from a terminal.

I first noticed it with a Bear scratchpad, but I was also able to reproduce the same behavior with an Arc scratchpad, so it does not seem unique to Bear.

### Reproduction Steps

1. Create or assign a scratchpad window, for example:

```sh
yabai -m window --scratchpad bearScratchpad
```

2. Hide/toggle the scratchpad so it is no longer visible.

3. Move to a different space.

4. Focus a normal, non-scratchpad window from the same app as the scratchpad.
Example: focus the main Bear window while the hidden `bearScratchpad` window is on another space.

5. Run the raw yabai toggle command with a small delay, so there is time to focus that same app before the command executes:

```sh
sleep 1 && yabai -m window --toggle bearScratchpad
```

6. **During the one-second delay, make sure the focused window is a normal window from the same app, not the scratchpad window.**

### Actual Behavior

The scratchpad appears on the current space as expected, but shortly after that, macOS/yabai focus jumps to the scratchpad's previous space. The scratchpad itself is no longer visible on the space that gets focused.

In other words:

- The scratchpad is moved/shown on the correct current space.
- Focus then jumps to the old space where the scratchpad used to be.

### Expected Behavior

`yabai -m window --toggle ` should keep focus on the current space where the scratchpad was toggled visible.

If the scratchpad is shown on the current space, focus should not jump back to the scratchpad's previous space.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the behavior with the raw `yabai -m window --toggle ` command while a normal window from the same app is focused. Trace the scratchpad toggle, window movement, and subsequent focus or space change; done means the scratchpad appears on the current space without focus returning to its previous space.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, macos
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.