fix(resource-manager): make popover draggable
Summary
Make the Resource Manager popover draggable from its header so it can be moved off content it covers.
- Drag the panel by the header grip; the offset is applied as a CSS transform on
PopoverContent. - Keep the panel reachable inside the viewport, and re-clamp after window resizes and on reopen.
- Add reset-position and close controls, plus arrow-key movement from the grip.
- Move the panel during a drag via
requestAnimationFrameand CSS custom properties, committing React state only once when the drag ends.
Framing: despite the fix(...) title, this is a UX feature, not a bug fix. Nothing was broken — the popover simply was not movable before. The title is kept for branch/commit continuity, but reviewers should evaluate it as a feature addition.
ELI5
The Resource Manager is a little panel that pops up from the status bar to show what is using your CPU and memory. Until now it was nailed to one spot, so it could sit on top of something you were trying to read. Now you can grab it by the handle at the top and slide it somewhere else, and it will not let you shove it off the edge of the screen where you could never get it back.
Proof of fix
The clamping math lives in a new pure module, resource-manager-drag-bounds.ts. It does not exist on main, so the test suite cannot even resolve the import there:
$ git checkout $(git merge-base origin/main HEAD) -- src/renderer/src/components/status-bar/resource-manager-drag-bounds.ts
error: pathspec 'src/renderer/src/components/status-bar/resource-manager-drag-bounds.ts' did not match any file(s) known to git
$ npx vitest run --config config/vitest.config.ts src/renderer/src/components/status-bar/resource-manager-drag-bounds.test.ts
FAIL src/renderer/src/components/status-bar/resource-manager-drag-bounds.test.ts
Error: Cannot find module './resource-manager-drag-bounds' imported from
/private/tmp/prbash/pr-9062/src/renderer/src/components/status-bar/resource-manager-drag-bounds.test.ts
Test Files 1 failed (1)
Tests no tests
"Module missing" is a weak signal, so I also substituted the naive implementation this feature would have without bounds logic (apply the pointer delta unclamped) and re-ran the same tests. 6 of 7 fail — the panel escapes the viewport exactly as the clamping is meant to prevent:
$ npx vitest run --config config/vitest.config.ts src/renderer/src/components/status-bar/resource-manager-drag-bounds.test.ts
FAIL > pulls a panel parked off a shrunken viewport back into view
AssertionError: expected { x: 1200, y: 700 } to deeply equal { x: 92, y: -8 }
{
- "x": 92,
- "y": -8,
+ "x": 1200,
+ "y": 700,
}
FAIL > prefers the leading edge when the panel cannot fit either axis
AssertionError: expected { x: -5000, y: -5000 } to deeply equal { x: 8, y: 8 }
Test Files 1 failed (1)
Tests 6 failed | 1 passed (7)
With the real implementation restored, all 7 pass:
$ npx vitest run --config config/vitest.config.ts src/renderer/src/components/status-bar/resource-manager-drag-bounds.test.ts
Test Files 1 passed (1)
Tests 7 passed (7)
The suite now covers: a fitting panel clamped to the margin, clamping against the live translated rect on a later drag, an over-tall panel keeping its recovery header on screen, an oversized panel blocked at the bottom/right edge, recovery of a position stranded by a viewport shrink (the small-monitor / resize case), idempotence for an already-valid position, and the unfittable-on-both-axes case resolving to the leading edge rather than NaN.
Proof of no regressions
$ npx vitest run --config config/vitest.config.ts src/renderer/src/components/status-bar/
Test Files 29 passed (29)
Tests 185 passed (185)
$ npx tsc --noEmit -p config/tsconfig.tc.web.json
# (no diagnostics emitted)
exit 0
$ npx oxlint src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx \
src/renderer/src/components/status-bar/resource-manager-drag-bounds.ts
# (no diagnostics emitted)
exit 0
$ npx oxlint --config config/oxlint-react-doctor.json \
src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx
# (no diagnostics emitted)
exit 0
$ node config/scripts/verify-localization-catalog.mjs
Verified 9903 localization key references against en.json.
Verified locale parity for es.json (10666 keys).
Verified locale parity for ja.json (10666 keys).
Verified locale parity for ko.json (10666 keys).
Verified locale parity for zh.json (10666 keys).
$ node config/scripts/audit-localization-coverage.mjs --check
Localization coverage check passed with 0 allowlisted candidates.
User-visible behavior that does change (all intended):
- The Resource Manager header gains a grip, a close (X) button, and — once moved — a reset-position button. The header is slightly denser as a result.
- The panel can be repositioned and stays where you put it for the lifetime of the component. Position is not persisted to disk, so it resets on app restart. That is deliberate: it also means a position saved on a large monitor can never strand the panel on a smaller one.
- Everything else is unchanged. Escape still closes the popover (no
onEscapeKeyDownoverride onPopoverContent; the handlers at the bottom of the file belong to the kill-confirmDialog), outside-click still closes it, and the resource polling cadence is untouched.
Compatibility
- Platforms: macOS / Linux / Windows. Renderer-only. Uses Pointer Events,
getBoundingClientRect,window.inner{Width,Height}, and CSS transforms — no platform branches, nometaKey/ctrlKeyhandling, no path or shell code. Verified by inspection of the diff; the automated evidence above (tests, typecheck, lint) ran on macOS. - SSH / remote: N/A. No main-process, IPC, git, or shell surface is touched. Panel geometry is computed entirely in the renderer from the local window, so it behaves identically against SSH hosts and relay connections.
- Performance: No hot-path regression, and this is the risk worth scrutinising since the panel renders live CPU/memory on a timer.
pointermovedoes not callsetState: moves write into a ref, coalesce through a singlerequestAnimationFrame, and update two CSS custom properties directly on the panel node. React state is committed once, on drag end. Every handler isuseCallback-wrapped with stable dependencies, so theResourceTreechildren do not re-render while dragging. The pending frame is cancelled on drag end and on unmount. Polling frequency is unchanged.config/oxlint-react-doctor.json— the config that exists to catch render storms — exits 0 with no diagnostics.
Screenshots
No screenshot or recording attached, and I want to be explicit rather than imply a visual check I did not perform. A drag is motion, so a still frame proves little, and the cheap renderer harness (pnpm dev:web) cannot render this component: ResourceUsageStatusSegment calls window.api.pty.listSessions(), an Electron preload surface the web config does not stub, so the popover body fails to populate outside a full Electron build. The behavioral evidence is the unit-test suite above, which exercises the clamping math directly, including the off-screen-recovery cases.
Testing
- [x]
pnpm lint— ran the underlyingoxlint(default +oxlint-react-doctorconfigs) and both localization scripts thatpnpm lintinvokes, on the changed files. Output above. - [x]
pnpm typecheck— ran the renderer project,config/tsconfig.tc.web.json, which covers every changed file. Exit 0. - [ ]
pnpm test— not run in full (30+ min). Ran all 29 test files insrc/renderer/src/components/status-bar/instead: 185 passed. - [ ]
pnpm build— not run; this worktree shares a symlinkednode_modulesand must not write to it. - [x] Added or updated high-quality tests that would catch regressions — extended
resource-manager-drag-bounds.test.tsfrom 4 to 7 cases.
AI Review Report
Reviewed as a hostile maintainer against the perf, bounds, i18n, a11y, and scope risks this change carries. Three real defects were found and fixed in this PR:
- Untranslated locale strings (shipped-broken i18n).
es.json,ja.json,ko.json, andzh.jsonall carried the literal English strings"Move Resource Manager","Reset Resource Manager position", and"Close Resource Manager". Both catalog scripts passed anyway because they verify key parity, not that a value was actually translated — so CI would not have caught this. Replaced with real translations, consistent with each locale's existing rendering of "Resource Manager" (Administrador de recursos,リソースマネージャー,리소스 관리자,资源管理器). - Drag grip was invisible to assistive tech and keyboard users. It was a
<span role="presentation">with only pointer handlers — flagged in review on this PR and left unaddressed. Promoted to a real<button>with anaria-label, a focus ring, and arrow-key movement (Shiftfor coarse steps) that reuses the same clamping path as pointer dragging. - Diff was ~3x larger than the change warranted. An earlier revision wrapped the popover body in a
<div>to host the transform. The transform was later moved toPopoverContent(correctly —PopoverContentsetsoverflow-hidden, which would have clipped a translated child), but the now-inert wrapper stayed and reindented ~340 lines of untouched JSX. Removing it cut the component diff from +538/−282 to +291/−5;git diff -wconfirmed the removed lines were pure reindentation.
Also checked and found correct: pointermove does not setState per event; handlers are stable across renders; polling cadence is unchanged; the pending rAF is cancelled on unmount; the drag threshold prevents a click from being swallowed; pointer capture is released on end and cancel; a non-primary button does not start a drag; the transform sits outside the overflow-hidden clip; Escape and outside-click dismissal are intact. Cross-platform compatibility was checked explicitly for macOS, Linux, and Windows — there are no shortcuts, labels, paths, shell invocations, or Electron platform branches in this diff; the only keyboard handling added is arrow keys, which carry no modifier-key platform split.
Security Audit
Renderer-only UI behavior. No command execution, file or path handling, auth, secrets, new dependencies, network access, preload APIs, or IPC surfaces are added. Pointer and keyboard deltas are numeric and are clamped against viewport geometry before being written as CSS custom properties — they are never interpolated into markup, selectors, or any string that reaches a shell. Locale additions are static display strings. No follow-up needed.
Notes
- Panel position is intentionally session-scoped, not persisted. Persisting it would need re-clamping at load against the current display, otherwise an offset saved on a large monitor would place the panel off-screen on a smaller one; the clamp logic for that already exists and is tested (
pulls a panel parked off a shrunken viewport back into view), so persistence is a safe follow-up if it is wanted. - Multi-monitor and DPI-change handling relies on the
resizelistener, which fires on scale changes and on window moves between displays. A monitor being disconnected while the panel sits on it resolves through the same path once the window is relocated by the OS. - Intentionally split from #9022; this covers only the draggable Resource Manager behavior.
Original patch by @davefano.
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
📝 Walkthrough
Walkthrough
The Resource Manager popover now supports mouse-driven dragging with threshold activation, movement clamping, and position reset. Its body applies the stored offset, while the header includes a draggable grip and conditional reset control using new icons. English, Spanish, Japanese, Korean, and Chinese locales add labels for moving, resetting, and closing the Resource Manager.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Title check | ✅ Passed | The title clearly and concisely describes the main change: making the Resource Manager popover draggable. |
| Description check | ✅ Passed | The description thoroughly covers the change, rationale, visual proof, testing, compatibility, performance, and security, despite omitting some template headings. |
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Consider decoupling the drag-move visuals from React state to avoid re-rendering the popover on every pointermove.
Addressed in 148eb05b2. Pointer moves now coalesce through requestAnimationFrame and update CSS custom properties directly on the popover; React state is committed once when the drag ends. Focused tests, full typecheck, lint, and build pass.
Heads-up: this branch now conflicts with main and needs a rebase before it can merge.
git merge origin/main auto-merges all five locale files cleanly, but leaves 6 conflict regions in src/renderer/src/components/status-bar/ResourceUsageStatusSegment.tsx (around lines 76, 107, 837, 931, 1735, …). main has moved under that file since this branch was cut.
Not resolving it here — the conflicts are in the drag/render logic this PR rewrites, so they need the author's intent rather than a mechanical resolution. Everything else verified green on the current head:
$ npx vitest run --config config/vitest.config.ts src/renderer/src/components/status-bar/
Test Files 29 passed (29)
Tests 185 passed (185)
$ node config/scripts/verify-localization-catalog.mjs
Verified locale parity for es/ja/ko/zh.json (10666 keys each)
$ node config/scripts/audit-localization-coverage.mjs --check
Localization coverage check passed with 0 allowlisted candidates.
Conflict analysis — locale files are trivial, the component is not
This is CONFLICTING against main in six files. I analyzed each so the rebase isn't a blind exercise.
Five are mechanical and safe — en/es/ja/ko/zh.json. Your change is purely additive (three new keys: 0f41c4e8d1 "Move Resource Manager", b2f6b4c0b4 "Reset Resource Manager position", 17a6a2c4f3 "Close Resource Manager"), and the conflict is only the trailing-comma line where main appended its own keys next to yours. I confirmed none of your three key hashes exist on main, so there's no semantic collision — take both sides and fix the comma.
One needs real attention — ResourceUsageStatusSegment.tsx. Since the merge base, main changed it by +63/−141 while this branch changes it by +291/−5. Main didn't edit around your change; it refactored the component and deleted a large portion of what you built on. A textual conflict resolution here risks reintroducing code main deliberately removed, so this one wants a look at main's current structure and a re-application of the drag behavior on top of it, rather than a merge-tool pass.
I'm not resolving it myself — which parts of main's refactor should survive is an authoring decision, not a mechanical one. Flagging it with the specifics so whoever picks it up knows the component is the only genuinely substantive piece.
Everything else on this PR is in order: the body carries all ten required sections.
this branch now conflicts with
mainand needs a rebase before it can merge.
Addressed in 4136be4b7. I rebuilt the branch directly on current upstream/main and force-updated the PR head using a guarded lease. The targeted status-bar suite passes: 34 files and 233 tests; full typecheck and the production desktop build also pass.
A textual conflict resolution here risks reintroducing code main deliberately removed, so this one wants a look at main's current structure and a re-application of the drag behavior on top of it.
Addressed that way in 4136be4b7: ResourceUsageStatusSegment.tsx now preserves current main's refactored session-inventory and render structure, with the final pointer-capture drag behavior reapplied additively. The bounds helper/tests, keyboard-operable grip, reset/close controls, and five translated catalogs are retained.
Okay, I tried it by hand 2 things:
- I think instead of drag icon, just make the top row draggable. Show the little drag icon for mouse cursor
- There is a bug:
- If I drag to a position.
- Then I close.
- Then I re-open. So far all good (position is reset)
- I try to drag again and it flies out to old position <-- this is the bug
So if these are fixed we can merge in!
Updated after manual testing on Ultra Magnus: closing a moved Resource Manager no longer snaps it back to the anchor before disappearing. The close path now cancels transient drag work immediately but preserves the rendered translation through Radix’s exit animation, then clears the position when the closed animation completes. Added regression coverage for the ordering. Verified 235 status-bar tests, full typecheck, focused lint/format, max-lines, and production Electron/web builds.
Readiness verdict — MERGE-READY
Rebased contributor head c48e87be089cb1f0570925f0c405445f05124dd2 onto current base 3d74f5fe0315d8125b969704a8830a9a6f2ee9ba and pushed with an exact guarded lease. No merge was performed.
P0 / P1 / P2
- P0: none.
- P1: none.
- P2: none open.
- Fixed proven P2: the dragged offset previously shared the CSS
transformproperty with the Radix close zoom, allowing the panel to interpolate back toward its anchor. The panel now uses composable CSStranslate(ResourceUsageStatusSegment.tsx:1499-1509). - Fixed proven P2: exit cancellation and rapid close/reopen could preserve stale drag state. Open now resets synchronously, completed/cancelled
exitanimations reset with event-name/state guards, and the native listener is removed with the ref lifecycle (ResourceUsageStatusSegment.tsx:1028-1088).
Tests — macOS local
vitestfocused drag/bounds suite: 2 files, 9 tests passed on the pushed SHA.- Real headful Orca Electron/Playwright CDP scenario: passed pointer drag,
ArrowRight,Shift+ArrowUp, close-frame geometry/translation stability, normal close/reopen reset, rapid close/reopen cancellation, and reduced-motion emulation. The run built the E2E Electron bundle first and exited cleanly: 1 passed. tsc --noEmit -p config/tsconfig.tc.web.json: passed.- E2E typecheck: no diagnostics for
resource-manager-dragging.spec.ts; the project still has unrelated baseline diagnostics elsewhere. - Focused oxlint, React Doctor oxlint, and oxfmt: passed.
- Production
pnpm run build:electron-vite: passed. - Localization catalog + coverage and max-lines ratchet: passed.
- Broader serialized status-bar run was not usable as a gate on this host: load average reached 670 with 380 users and an unrelated provider-segment test hit its 30s timeout. The changed 9-test surface and real Electron scenario were rerun independently and passed.
Readiness scan / compatibility
Renderer-only change: no dependency, lockfile, command execution, auth, secret, IPC, RPC/wire, persistence, process-lifecycle, or provider-specific surface. SSH/network-loss, mixed-version remote wire, mobile/data-loss, folder-workspace, and GitHub/GitLab behavior are therefore unchanged. Pointer Events, viewport geometry, CSS custom properties/translate, and Arrow keys are platform-neutral across macOS/Linux/Windows; no modifier, path, shell, or host assumptions were added. Drag updates remain rAF-coalesced and commit React state only at drag end; frames/listeners are cancelled or removed, so no unbounded-growth or hot-render path was found.
Visual proof
Fresh uncropped macOS Electron/CDP recording (800×600):
https://github.com/user-attachments/assets/34fe188c-1021-4e89-a6d4-e9e950073d1e
The only later base input before the pushed SHA touched unrelated HTML preview inventory files; feature code was unchanged and focused tests were rerun on the pushed SHA.
Residual risk / merge blockers
- Residual risk: Linux and Windows were assessed from renderer-only APIs and cross-platform code paths, not launched locally; the serialized broad suite was host-load-limited as noted above.
- GitHub:
MERGEABLE; head/base SHAs match the pushed/rebased branch. No check runs or commit statuses are reported.mergeStateStatus=UNSTABLEreflects GitHub combined statuspendingwith zero contexts;mainhas no branch protection or matching ruleset, so there is no required-check blocker. - Exact merge blockers: none proven.
Closing #9062 as stale after ResourceUsageStatusSegment.tsx was split into multi-tab controller, Resources, PTYs, and Space modules on main. Thank you @davefano for the effort on this!