Repository navigation
fix: stabilize tray panel resizing - #36
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Stale run's finally block corrupts concurrent resize measurement
- Moved original style snapshot to a shared ref (only captured when no measurement is in progress) and gated the finally block's style restoration on the run still being the latest, so stale runs no longer corrupt the DOM for active concurrent runs.
Or push these changes by commenting:
@cursor push 6d8296b267
Preview (6d8296b267)
diff --git a/apps/desktop-tauri/src/surfaces/TrayPanel.tsx b/apps/desktop-tauri/src/surfaces/TrayPanel.tsx
--- a/apps/desktop-tauri/src/surfaces/TrayPanel.tsx
+++ b/apps/desktop-tauri/src/surfaces/TrayPanel.tsx
@@ -76,6 +76,16 @@
const [layoutReady, setLayoutReady] = useState(false);
const layoutReadyRef = useRef(false);
const resizeRunRef = useRef(0);
+ const originalStylesRef = useRef<{
+ htmlOverflow: string;
+ bodyOverflow: string;
+ bodyMinHeight: string;
+ surfaceMaxHeight: string;
+ surfaceOverflow: string;
+ bodyInnerOverflow: string | undefined;
+ bodyFlex: string | undefined;
+ stackOverflow: string | undefined;
+ } | null>(null);
// Cards to display based on mode
// Overview: all providers in the grid — non-error first, then errors
@@ -115,16 +125,21 @@
const body = surface.querySelector<HTMLElement>(".menu-surface__body");
const stack = surface.querySelector<HTMLElement>(".menu-stack");
- const previous = {
- htmlOverflow: document.documentElement.style.overflow,
- bodyOverflow: document.body.style.overflow,
- bodyMinHeight: document.body.style.minHeight,
- surfaceMaxHeight: surface.style.maxHeight,
- surfaceOverflow: surface.style.overflow,
- bodyInnerOverflow: body?.style.overflow,
- bodyFlex: body?.style.flex,
- stackOverflow: stack?.style.overflow,
- };
+ // Only capture original styles if no other run already has them saved.
+ // This prevents a later run from snapshotting the measurement styles
+ // applied by an earlier concurrent run.
+ if (!originalStylesRef.current) {
+ originalStylesRef.current = {
+ htmlOverflow: document.documentElement.style.overflow,
+ bodyOverflow: document.body.style.overflow,
+ bodyMinHeight: document.body.style.minHeight,
+ surfaceMaxHeight: surface.style.maxHeight,
+ surfaceOverflow: surface.style.overflow,
+ bodyInnerOverflow: body?.style.overflow,
+ bodyFlex: body?.style.flex,
+ stackOverflow: stack?.style.overflow,
+ };
+ }
let committedHeight = false;
document.documentElement.style.overflow = "visible";
@@ -181,20 +196,27 @@
setLayoutReady(true);
}
} finally {
- if (!committedHeight) {
- surface.style.maxHeight = previous.surfaceMaxHeight;
+ // Only restore styles if this is still the latest run.
+ // A stale run must not touch the DOM — a newer run is still
+ // using the measurement styles and will handle cleanup itself.
+ if (run === resizeRunRef.current) {
+ const previous = originalStylesRef.current!;
+ originalStylesRef.current = null;
+ if (!committedHeight) {
+ surface.style.maxHeight = previous.surfaceMaxHeight;
+ }
+ surface.style.overflow = previous.surfaceOverflow;
+ document.documentElement.style.overflow = previous.htmlOverflow;
+ document.body.style.overflow = previous.bodyOverflow;
+ document.body.style.minHeight = previous.bodyMinHeight;
+ if (body) {
+ body.style.overflow = previous.bodyInnerOverflow ?? "";
+ body.style.flex = previous.bodyFlex ?? "";
+ }
+ if (stack) {
+ stack.style.overflow = previous.stackOverflow ?? "";
+ }
}
- surface.style.overflow = previous.surfaceOverflow;
- document.documentElement.style.overflow = previous.htmlOverflow;
- document.body.style.overflow = previous.bodyOverflow;
- document.body.style.minHeight = previous.bodyMinHeight;
- if (body) {
- body.style.overflow = previous.bodyInnerOverflow ?? "";
- body.style.flex = previous.bodyFlex ?? "";
- }
- if (stack) {
- stack.style.overflow = previous.stackOverflow ?? "";
- }
}
};You can send follow-ups to the cloud agent here.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit acd6682. Configure here.
| } | ||
| if (stack) { | ||
| stack.style.overflow = previous.stackOverflow ?? ""; | ||
| } |
There was a problem hiding this comment.
Stale run's finally block corrupts concurrent resize measurement
Medium Severity
When two resize() calls run concurrently (likely during initial load while providers update), the stale run's finally block restores DOM styles to their original values, undoing the measurement styles that the active run still needs. The active run then measures content with wrong styles (constrained overflow/maxHeight), producing an incorrect panel height. Worse, the active run's previous captured the measurement styles (set by the earlier run), so its own finally permanently leaves the page with overflow: "visible" instead of the original values.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit acd6682. Configure here.
|
Windows VPS validation on Checks passed:
Smoke proof run:
Notes: the settings screenshot was partially overlapped by the active terminal window on the VPS desktop, but the proof process launched, rendered, exited cleanly, and the installed app restarted. The tray screenshot showed the panel at a stable measured height rather than bouncing to max height. |
|
Expanded Windows validation completed on Additional checks passed:
Follow-up commit added during validation:
Release executable smoke at current head:
One attempted deeper scheduled click smoke hung before writing evidence, so I killed/deleted that scheduled task and verified the installed app was restored. The reliable proof-mode release smoke above passed. |
|
One more validation pass completed on Windows VPS at current head Repeat checks passed:
Repeat release smoke passed:
Cleaned scheduled task after the run. Remote worktree only has evidence folders left untracked ( |



Summary
Fixes #35
Tests
Note
Medium Risk
Touches Tauri window sizing/measurement and DOM style mutation logic, which can easily introduce regressions like incorrect tray sizing or flicker across platforms, but does not affect security or data handling.
Overview
Prevents the tray popover from visibly "bouncing" to
MAX_HEIGHTduring subsequent provider refreshes by only doing the expand-to-measure step on the initial hidden layout pass, and by cancelling stale resize runs with a run counter.Hardens the resize measurement path by snapshotting/restoring temporary overflow/flex styles in a
finallyblock, and simplifies the delayed resize scheduling to a single timeout.Updates tray actions so opening Settings/About closes the tray window afterward, and removes the smooth-scroll-to-card behavior when selecting a provider from the grid.
Reviewed by Cursor Bugbot for commit acd6682. Configure here.