Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(sidebar): prevent viewport clipping of session row actions

Totopo27a6d0135fe16b
diff --git a/apps/desktop/src/components/Sidebar.tsx b/apps/desktop/src/components/Sidebar.tsx
index 52743d5c2..0ae84dde3 100644
--- a/apps/desktop/src/components/Sidebar.tsx
+++ b/apps/desktop/src/components/Sidebar.tsx
@@ -103,6 +103,7 @@ type ProjectEntry = {
};
const VIEWPORT_PADDING = 8;
+const SIDEBAR_FLOATING_MENU_MAX_HEIGHT = 360;
/** Private MIME so a sidebar session drag is never mistaken for an OS file drop. */
const SESSION_DRAG_MIME = "application/x-pi-desktop-session";
@@ -499,7 +500,10 @@ export function Sidebar({
setMenuPosition({
top: Math.max(
VIEWPORT_PADDING,
- Math.min(rect.bottom + 4, window.innerHeight - 220),
+ Math.min(
+ rect.bottom + 4,
+ window.innerHeight - SIDEBAR_FLOATING_MENU_MAX_HEIGHT - VIEWPORT_PADDING,
+ ),
),
left: Math.max(VIEWPORT_PADDING, rect.right + 4),
});
@@ -511,7 +515,10 @@ export function Sidebar({
setMenuPosition({
top: Math.max(
VIEWPORT_PADDING,
- Math.min(y + 4, window.innerHeight - 220),
+ Math.min(
+ y + 4,
+ window.innerHeight - SIDEBAR_FLOATING_MENU_MAX_HEIGHT - VIEWPORT_PADDING,
+ ),
),
left: Math.max(VIEWPORT_PADDING, x + 4),
});
diff --git a/apps/desktop/src/styles/sessions.css b/apps/desktop/src/styles/sessions.css
index c6ed9b3f8..f9b359e55 100644
--- a/apps/desktop/src/styles/sessions.css
+++ b/apps/desktop/src/styles/sessions.css
@@ -479,6 +479,8 @@
bottom: auto;
z-index: 60;
min-width: 172px;
+ max-height: calc(100vh - 16px);
+ overflow-y: auto;
padding: 5px;
border: 1px solid var(--ds-border-subtle);
border-radius: var(--radius-md-plus);
diff --git a/apps/desktop/test/sidebar-navigation.test.mjs b/apps/desktop/test/sidebar-navigation.test.mjs
index e8c987cf0..a790c2eba 100644
--- a/apps/desktop/test/sidebar-navigation.test.mjs
+++ b/apps/desktop/test/sidebar-navigation.test.mjs
@@ -204,6 +204,8 @@ test("portaled sort menu does not stretch to the viewport edge", () => {
assert.match(basePopoverRule, /position:\s*fixed;/);
assert.doesNotMatch(basePopoverRule, /position:\s*absolute;/);
+ assert.match(basePopoverRule, /max-height:\s*calc\(100vh - 16px\);/);
+ assert.match(basePopoverRule, /overflow-y:\s*auto;/);
assert.match(floatingPopoverRule, /top:\s*auto;/);
assert.match(floatingPopoverRule, /right:\s*auto;/);
assert.match(globalStyles, /\.sidebar-floating-menu\s*\{[^}]*width:\s*max-content;/s);