Repository navigation
fix(pet): stop the desktop pet from clipping on the left - #3642
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Out-of-order resize IPC (
fix(pet): keep desktop pet window resize requests in order)Each
resize_agent_companion_desktop_petinvoke 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.Inner vs outer size (
fix(desktop): size the pet window by its inner bounds)set_sizeapplies 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.
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
petdexMaxSizebox that scales the native cell down while keeping its aspect ratio.Reviewed, no change needed
Menucaps itself at the window width, so it cannot overflow left.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 hygieneRemote scenarios: the pet is a controller-local desktop window; no remote workspace, remote control, peer device or dispatch path is affected.