Skip to content

feat(workspaces): support smooth horizontal wheel switching in sidebar#12448

Open
Andresshamis wants to merge 22 commits intozen-browser:devfrom
Andresshamis:codex/horizontal-wheel-workspace-switch
Open

feat(workspaces): support smooth horizontal wheel switching in sidebar#12448
Andresshamis wants to merge 22 commits intozen-browser:devfrom
Andresshamis:codex/horizontal-wheel-workspace-switch

Conversation

@Andresshamis
Copy link
Copy Markdown

@Andresshamis Andresshamis commented Feb 21, 2026

Summary

  • add horizontal wheel support for workspace switching when hovering the sidebar
  • implement gesture-style preview movement with normalized wheel deltas for smoother motion
  • switch based on horizontal position threshold so snapping feels spring-like instead of waiting for wheel release
  • prevent duplicate opposite-direction behavior by suppressing AppCommand shortly after horizontal wheel events
  • align preview and final snap direction so they are consistent

Related

Testing

  • npx eslint src/zen/workspaces/ZenWorkspaces.mjs
  • npx prettier --check src/zen/workspaces/ZenWorkspaces.mjs
  • manual validation on macOS with a horizontal mouse wheel over sidebar:
    • live preview follows wheel direction
    • crossing threshold snaps to the adjacent workspace
    • no opposite-direction snap at gesture end
IMG_6964.compressed.mp4

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Feature labels Feb 21, 2026
@Andresshamis Andresshamis force-pushed the codex/horizontal-wheel-workspace-switch branch from cf4a940 to a36c1f8 Compare February 21, 2026 07:54
Copy link
Copy Markdown
Member

@mr-cheffy mr-cheffy left a comment

Choose a reason for hiding this comment

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

Could you please run npm run lint:fix?

@mr-cheffy mr-cheffy marked this pull request as draft February 22, 2026 01:11
@Andresshamis Andresshamis marked this pull request as ready for review February 22, 2026 08:29
@Andresshamis
Copy link
Copy Markdown
Author

Dear Mr Cheffy, anything you would like to improve or adjust? I believe this is finished but Id be happy to work on it if you have anything in mind, let me know!

@Davis8483
Copy link
Copy Markdown

as an MX Master haver, this would be very nice :D

Copy link
Copy Markdown
Member

@mr-cheffy mr-cheffy left a comment

Choose a reason for hiding this comment

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

I think, instead of re-doing existing swipe behavior with the trackpad, we should rather migrate listeners from MozSwipeGesture to start using wheel events? Let me know what you think. It should fix both problems

@Andresshamis
Copy link
Copy Markdown
Author

Added targeted inline comments in /src/zen/workspaces/ZenWorkspaces.mjs explaining the non-obvious wheel behavior decisions: direction-flip accumulator reset, explicit wheel accumulator for smoother low-amplitude input, and why forceSwitch commits immediately once visual snap threshold is crossed. This keeps the wheel-only architecture while documenting why these choices are intentional for UX consistency.

@mr-cheffy
Copy link
Copy Markdown
Member

It's acting a bit weird. Trackpad move is inverted, swiping fast overshoots, swiping slow makes a sudden space change, etc:

CleanShot.2026-02-25.at.00.44.58.mp4

@Andresshamis Andresshamis force-pushed the codex/horizontal-wheel-workspace-switch branch from ff341e2 to 5b31d0b Compare February 25, 2026 00:01
@mr-cheffy
Copy link
Copy Markdown
Member

mr-cheffy commented Feb 25, 2026

Why are you force pushing? Its making it really difficult to keep cloning the PR 😅

@Andresshamis
Copy link
Copy Markdown
Author

Thanks for the detailed feedback. I tested a full migration from MozSwipeGesture to wheel, but on macOS it regressed trackpad behavior (inversion/overshoot/sudden transitions), likely due to overlap between trackpad momentum wheel events and gesture/AppCommand paths.

I’ve now restored native trackpad gesture handling to match pre-PR behavior, and scoped the new behavior to horizontal mouse-wheel input.

Concretely, I added a short post-trackpad suppression window so trackpad tail events don’t enter the wheel/AppCommand path (src/zen/workspaces/ZenWorkspaces.mjs). This keeps trackpad UX unchanged while preserving smooth horizontal-wheel switching for mouse users.

I also ran npm run lint:fix and re-tested manually on both trackpad and horizontal-wheel mouse.

Latest adjustment in this push: mouse horizontal direction now matches macOS natural scroll expectation.

@Andresshamis
Copy link
Copy Markdown
Author

@mr-cheffy pushed a final refinement pass focused on swipe consistency and maintainability notes.

What changed in this pass:

  • kept mouse horizontal wheel behavior intact
  • stabilized trackpad slow/reverse behavior by handling cumulative swipe deltas with an explicit baseline and direction tracking
  • documented the non-obvious swipe decisions inline (src/zen/workspaces/ZenWorkspaces.mjs)

Validation:

  • npm run lint:fix
  • manual testing on both trackpad and horizontal-wheel mouse (sidebar workspace switching)

If there’s any remaining behavior you want adjusted before merge, I can iterate immediately.

@Andresshamis
Copy link
Copy Markdown
Author

@mr-cheffy final refinement pushed in 7fdf26e5 with a narrow scope:

  • Kept native trackpad MozSwipeGesture flow intact (no listener migration for trackpad), since earlier wheel-only migration regressed trackpad behavior (inversion/overshoot/abrupt commits).
  • Kept horizontal mouse-wheel handling in the wheel path, with macOS-natural direction parity and smoothing behavior preserved.
  • Improved slow trackpad reversal stability by making direction detection more responsive at low velocity and avoiding rebase-to-center jumps during mid-gesture reversal.
  • Kept explicit recenter on no-op swipe end to avoid the strip being left mid-offset when no workspace change commits.

Code comments were updated inline in src/zen/workspaces/ZenWorkspaces.mjs to document these non-obvious decisions and why they exist.

Validation run on this branch:

  • npm run lint:fix
  • manual sidebar workspace switching tests on both trackpad and horizontal-wheel mouse (including direction reversals and fast/slow swipes)

If you want, I can split these into separate follow-up commits for easier review granularity.

@Andresshamis
Copy link
Copy Markdown
Author

I am sorry for force pushing @mr-cheffy , Wont happen again, I am now aware this makes it more work on your end. If you'd need me to do anything to fix my mistake of the force push Ill do it straight away. I'm always learning, so wont do it again.

@mr-cheffy
Copy link
Copy Markdown
Member

mr-cheffy commented Feb 25, 2026

CleanShot.2026-02-25.at.21.03.38.mp4

Looks good, but when swiping and suddenly changing direction, it kind of goes back half the sidebar's width? Also, there should be some sort of "force" when reaching to the end of the space, instead of just stopping instantly, it should start to get more "difficult" to reach the end. Not sure if im explaining correctly

CleanShot.2026-02-25.at.21.05.01.mp4

Andres added 2 commits February 25, 2026 23:51
@Andresshamis
Copy link
Copy Markdown
Author

In both of your latest videos, I also used to have these bugs, however I fixed and no longer happening on my device Macbook Pro 14 M4, I think you might have been looking at an earlier commit since I also remember these bugs but no longer happen on my device, might have been a partial commit. can you verify? Cant seem to be able to replicate this again, I am pretty sure its fixed in latest version.

@mr-cheffy mr-cheffy linked an issue Feb 28, 2026 that may be closed by this pull request
5 tasks
@mr-cheffy
Copy link
Copy Markdown
Member

mr-cheffy commented Mar 1, 2026

I wonder if moving this into its own ZenSpaceScrollManager (and file) would be worth it as this implementation starts to grow bigger and bigger.

can you verify? Cant seem to be able to replicate this again, I am pretty sure its fixed in latest version.

Yes, but im using a trackpad, so that might be it

@shubhsherl
Copy link
Copy Markdown

@mr-cheffy @Andresshamis Requesting you to please help in shipping this change, tired of clicking on the icons to navigate to workspaces 😭

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

Labels

Feature size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Magic Mouse swipe does not change workspaces on macOS

4 participants