Skip to content

feat(desktop): Alt+wheel to scale the pet, never cropped - #52877

Merged
OutThisLife merged 3 commits into
mainfrom
bb/pet-scale-gesture
Jun 26, 2026
Merged

feat(desktop): Alt+wheel to scale the pet, never cropped#52877
OutThisLife merged 3 commits into
mainfrom
bb/pet-scale-gesture

Conversation

@OutThisLife

@OutThisLife OutThisLife commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Alt/Option + scroll over the pet to scale it — same on Mac and Windows. The modifier is required so a plain scroll still scrolls the page underneath (we only preventDefault while Alt is held). Drives the same display.pet.scale path as the settings slider, so the two stay in agreement and it persists.
  • Zooms toward the cursor — the pixel under the pointer stays put as the pet grows/shrinks, so it scales in place instead of running off (see Math below).
  • Never cropped. The popped-out overlay grows its OS window to fit the pet at any scale, and the new bounds are persisted so it reopens at the right size. The in-window pet re-clamps against its actual size, so growing near an edge can't push it out of view.
  • Per-pixel click-through on the overlay. Only solid sprite pixels (plus the bubble / mail button / open composer) are interactive — clicks on the transparent rectangle around the art pass through to whatever's behind, instead of the old bounding-box test.

How it's wired

  • usePetZoomGesture — small hook, native non-passive wheel listener, reads live scale from $petInfo, no-ops unless altKey. Emits the new scale plus a { clientX, clientY, ratio } anchor. Used by both the in-window pet and the overlay.
  • nextScaleFromWheel (pet-gallery) — pure multiplicative step clamped to the slider range.
  • overlayWindowSize (pet-overlay) — single source of truth for overlay window dims at a given scale; used by both pop-out and the live resize.
  • electron/main.cjsset-bounds briefly flips resizable on when the size actually changes (Electron 40 ignores programmatic resize on non-resizable windows on Win/Linux); pure drags untouched.
  • Overlay → main scale control message persists through the main window's gateway (the overlay has none).
  • pet-sprite canvas opts into willReadFrequently for the per-pixel alpha sampling.

Math — zoom toward the cursor

Standard "zoom about a point": as the sprite scales by ratio = newScale / oldScale, every pixel's offset from the anchor scales by the same ratio. To keep the anchor pixel fixed on screen, move the origin by the growth of that offset. ratio is clamp-aware (it's next / base after clamping to the slider range), so at the min/max bound ratio = 1 and nothing drifts.

In-window pet (origin = the element's top-left pos, anchor = cursor in viewport coords):

posNew = cursor − (cursor − pos) · ratio      // per axis

The (cursor − pos) is the cursor's offset inside the pet; scaling it by ratio and subtracting from cursor gives the new top-left. Result is clamped to the viewport so the whole sprite stays visible.

Overlay (the OS window moves; the sprite is laid out bottom-centered at window-local B = (W/2, H − padBottom) and scales about B):

Let a be the anchor in window-local coords (the wheel cursor; for a slider change with no cursor we fall back to a = B, which makes the term below vanish). The window-local anchor maps to screen screen + a. After scaling, the sprite's bottom-center must land where the anchor's scaled offset still resolves to that same screen point, so the new window origin is:

originNew = screen + a − (a − B) · ratio − Bnew

where Bnew = (Wnew/2, Hnew − padBottom). With a = B this collapses to originNew = screen + B − Bnew, i.e. pin the feet. One formula covers both wheel and slider.

Caveat: the overlay resize is an async IPC round-trip, so the live window.outerWidth/screenX read can lag a frame during a very fast continuous scroll, causing slight drift. Exact at notch-by-notch speed.

Test plan

  • In-window pet: Alt+scroll up/down resizes about the cursor; plain scroll still scrolls the chat; slider still works and agrees.
  • Pop the pet out: Alt+scroll resizes toward the cursor, window grows/shrinks to fit (no clipping at any scale).
  • Overlay: clicking transparent area around the sprite passes through; clicking the sprite/bubble/mail still works; drag still works.
  • Restart with a large popped-out pet → reopens at the right size/spot.

Hold Alt/Option and scroll over the mascot to resize it (same on Mac and
Windows); the modifier keeps a plain scroll passing through to the page. The
gesture drives the same `display.pet.scale` path as the settings slider.

The popped-out overlay grows its OS window to fit the pet at any scale (anchored
bottom-center) so the sprite is never clipped by the window edge, and the
in-window pet re-clamps against its actual size so growing near an edge can't
crop it. Also makes the overlay click-through per-pixel: only solid sprite
pixels (plus bubble / mail button) are interactive, transparent margins pass
clicks through.
Alt+wheel now scales about the pixel under the pointer instead of growing from a
corner, so the pet stays put under the cursor instead of running away. In-window
shifts its top-left; the overlay repositions its OS window (cursor-anchored on
wheel, bottom-center for slider-driven changes).
@OutThisLife
OutThisLife merged commit 2b86e9d into main Jun 26, 2026
21 checks passed
@OutThisLife
OutThisLife deleted the bb/pet-scale-gesture branch June 26, 2026 05:45
@alt-glitch alt-glitch added type/feature New feature or request comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have labels Jun 26, 2026
T02200059 pushed a commit to T02200059/hermes-agent that referenced this pull request Jun 29, 2026
…ch#52888 from kshitijk4poor/chore 2b86e9d Merge pull request NousResearch#52877 from NousResearch/bb/pet  [analysis]
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…gesture

feat(desktop): Alt+wheel to scale the pet, never cropped
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
…gesture

feat(desktop): Alt+wheel to scale the pet, never cropped
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…gesture

feat(desktop): Alt+wheel to scale the pet, never cropped
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…gesture

feat(desktop): Alt+wheel to scale the pet, never cropped
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…gesture

feat(desktop): Alt+wheel to scale the pet, never cropped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants