Skip to content

fix(pet): stop the desktop pet from clipping on the left - #3642

Merged
bobleer merged 3 commits into
openBitFun:mainfrom
bobleer:bob/fix-desktop-pet-clipping
Oct 31, 2026
Merged

bobleer merged 3 commits into
openBitFun:mainfrom
bobleer:bob/fix-desktop-pet-clipping

Conversation

@bobleer

@bobleer bobleer commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Problem

On Windows the desktop pet sometimes renders with its left side cut off (reported at 2560x1440, 100% scaling; other resolutions and scales are not ruled out).

The pet dock is anchored to the bottom-right of its window (right: 0; bottom: 0), so whenever the native window is narrower than the dock, the overflow is clipped on the left, usually through the bubble.

Root causes and fixes

  1. Out-of-order resize IPC (fix(pet): keep desktop pet window resize requests in order)
    Each resize_agent_companion_desktop_pet invoke runs as its own async task, so a stale "shrink to 96px" could land after a newer "grow to 288px". The window then stayed too narrow until the layout changed again. Now there is one request in flight at a time, coalesced to the latest size. The size is re-requested when the viewport comes out shorter than the dock needs (display or DPI changes), and the height is rounded up so physical-pixel conversion cannot shave a row. The command contract is unchanged.

  2. Inner vs outer size (fix(desktop): size the pet window by its inner bounds)
    set_size applies the inner size, but the no-op check and the bottom-right anchoring compared against the outer size. Where the native frame adds pixels, a request could be skipped. The window now compares and anchors on the inner size and includes the frame when clamping to the work area.
    The same commit re-clamps the pet into the work area after a display scale change: the platform keeps the physical origin while the physical size follows the new scale, which could push the pet past a screen edge. The re-clamp is deferred past the platform's own DPI bounds update. The clamp math is now a pure function with unit tests.

  3. Oversized custom pets (fix(pet): fit oversized custom pets beside the bubble)
    A bubble (180) plus the gap, the pet and the edge buffer must fit in the 360px window. A spritesheet with large cells exceeded that, the host clamped the window, and the bubble was clipped every time. The pet renderer gains a petdexMaxSize box that scales the native cell down while keeping its aspect ratio.

Reviewed, no change needed

  • Context menu: the design-system Menu caps itself at the window width, so it cannot overflow left.
  • Windows controlled drag: uses physical coordinates end to end.
  • Desktop card windows: no rapid frontend-driven resizes; remembered positions are already validated against all displays.

Verification

  • pnpm --dir src/web-ui run test:run src/app/components/AgentCompanionDesktopPet src/flow_chat/components/AgentCompanionPet: 36 passed (new: resize ordering and coalescing, short-viewport re-request, oversized-cell fit)
  • cargo test -p openbitfun-desktop --lib appearance::: 8 passed (4 new geometry tests)
  • tsc --noEmit, eslint on the touched files, repository hygiene
  • Not yet exercised on a physical Windows machine; the scale-change re-clamp especially needs a manual check there.

Remote scenarios: the pet is a controller-local desktop window; no remote workspace, remote control, peer device or dispatch path is affected.

The pet dock is anchored bottom-right, so a host window narrower than the
dock clips the bubbles on the left. Each resize invoke runs as its own
async task, so a stale smaller size could land after a newer larger one
and leave the window too narrow until the layout changed again.

Keep a single resize request in flight and coalesce the rest to the
latest size, re-request the size when the viewport comes out shorter
than the dock needs (display or DPI changes), and round the height up so
physical-pixel conversion cannot shave a row.
set_size applies the inner size, but the no-op check and the
bottom-right anchoring compared against the outer size. Where the native
frame adds pixels the request was skipped, leaving the viewport narrower
than the dock. Compare and anchor on the inner size and include the frame
when keeping the window inside the work area.

Also re-clamp the pet into the work area after a display scale change:
the platform keeps the physical origin while the physical size follows
the new scale, which could push the pet past a screen edge until the next
bubble-driven resize. The clamp math is now a pure function with tests.
A bubble, gap, pet and edge buffer must fit in the 360px pet window; a
custom spritesheet with large cells exceeded it, the host clamped the
window and the bubble was clipped on the left every time. Add a
petdexMaxSize box to the pet renderer that scales the native cell down
while keeping its aspect ratio, and size the desktop pet within it.
@bobleer
bobleer merged commit 732e54f into openBitFun:main Oct 31, 2026
13 checks passed
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.

1 participant