## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The web UI shows a resizable left sidebar, a center column, and a
resizable right side panel
> - On the chat page (and other layouts with a secondary sidebar), the
right side panel can go past the right edge of the window
> - Then the right part of the panel is cut off, and the close control
is not visible
> - Resizing the left sidebar or the panel does not bring it back
> - This pull request makes the panel fit the space that its layout row
actually has
> - The benefit is that the panel always stays inside the window, at all
sidebar and panel widths
## Linked Issues or Issue Description
No public issue exists. I searched open PRs and issues for overflow,
clipped, and right-panel problems and found no match.
**What happened?**
On the chat page, the right side panel went past the right edge of the
window (or crushed the center thread under the 280px conversation list).
At a 1280px window, with the left sidebar at 420px and a saved panel
width of 624px, the right panel overflowed the available space in its
layout row and clipped its right edge and close control. Dragging the
panel or the sidebar did not fix it.
**Expected behavior**
With any sidebar and panel width, the panel stays inside the window with
its close control visible, and the center column keeps a usable width.
**Steps to reproduce**
1. Open the chat page for an agent and open the right side panel.
2. Drag the left sidebar to its maximum width (420px).
3. Drag the right panel to its maximum width.
4. Look at the right edge of the window or shrink the viewport to 900px:
the panel overflows/clips.
**Paperclip version or commit**
Rebased onto `master` at `2d06567795`.
## What Changed
- Cause: `PropertiesPanel` clamped its width to `window.innerWidth -
656`, assuming a fixed 236px left sidebar and no secondary sidebar in
the row. The left sidebar can be up to 420px wide, and Agent Chat adds a
280px conversation list in the same row.
- `ui/src/components/PropertiesPanel.tsx`:
- `measureFittedPaneMax` measures the real space available for the
panel: `row.getBoundingClientRect().right -
main.getBoundingClientRect().left`. It preserves a 420px minimum center
column down to the 260px panel minimum, and when total remaining space
is below 260px, fits to that remaining space so the panel and its close
control never clip past the row's right edge.
- Displays `min(saved width, fitted width)` without overwriting the
saved width in `localStorage`, so when space returns the panel grows
back to the saved width.
- Observes both the layout row and `#main-content` with `ResizeObserver`
(plus window `resize`), so changes to the window, primary sidebar, or
collapsible secondary rails (such as Agent Chat's collapsible
conversation list) apply immediately.
- Uses the fitted display width for drag start, drag clamping, and
maximize restore glides, and keeps `widthRef` in sync during
`pointermove` so fast `pointerup` persists the clamped drag width.
- Falls back to window-based clamping when no `#main-content` exists in
the row (for example, in isolated stories).
- Leaves the classic fixed 320px panel unchanged.
- `ui/src/components/PropertiesPanel.test.tsx`: focused regression suite
covering layout-row fitting, narrow `<260px` desktop clamping,
`#main-content` resize re-measurement when the row width is unchanged,
drag start/clamping/persistence, and fallback without `#main-content`.
## Verification
- RED before fix (on `2d06567795`): `pnpm --filter @paperclipai/ui exec
vitest run src/components/PropertiesPanel.test.tsx` -> 3 failed / 1
passed (`Expected "260px", Received "624px"` and `Expected "372px",
Received "624px"`).
- GREEN after fix (`66adf42c82`):
- `pnpm --filter @paperclipai/ui exec vitest run
src/components/PropertiesPanel.test.tsx` -> 4/4 passed.
- `pnpm --filter @paperclipai/ui typecheck` -> passed.
- `pnpm check:token-gates` -> all 4 gates clean.
- `node scripts/check-test-budget.mjs --files
ui/src/components/PropertiesPanel.test.tsx` -> PASS.
- Affected UI suite (217 files, 3,870 tests): 211 passed on initial
parallel run and the 6 CPU-contention timed-out suites passed 6/6
(103/103 tests) on focused rerun.
- Real-browser Chromium check against the built production UI
(`server/ui-dist`) with left sidebar at 420px and saved panel width
624px:
- Agent Chat 1280×800: `mainWidth=320`, `asideWidth=260`,
`asideRight=1280`, `closeRight=1272`, `scrollWidth=1280`, saved width
still `"624"`.
- Agent Chat 900×800: `asideWidth=200`, `asideRight=900`,
`closeRight=892`, `scrollWidth=900`.
- Agent Chat 1440×900: `mainWidth=420`, `asideWidth=320`,
`asideRight=1440`, `closeRight=1432`, `scrollWidth=1440`.
- Task Detail 1280×800: `mainWidth=420`, `asideWidth=440`,
`asideRight=1280`, `closeRight=1272`, `scrollWidth=1280`.
- Task Detail 900×800: `mainWidth=220`, `asideWidth=260`,
`asideRight=900`, `closeRight=892`, `scrollWidth=900`.
## Risks
- Low risk. The production change is confined to `PropertiesPanel.tsx`.
When the row has space, the panel width matches prior behavior.
- When space is constrained, the panel narrows to fit the layout row
rather than overflowing past the right edge of the window.
- Layout measurement relies on `#main-content` rendered by `Layout`;
when absent, the existing window-based clamp applies.
## Model Used
- Original PR: Claude Opus 5.5 (`claude-opus-5-5`).
- Rebase, `#main-content` ResizeObserver & drag-ref refinement, and
verification: Antigravity (Google DeepMind) with shell, Vitest, and
Playwright Chromium tools.
## Checklist
- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: Dotta <bippadotta@protonmail.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>