Skip to content

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

fix(chat): open turn usage popover upward

v_wyxgwangecd9ea9f6c35
diff --git a/apps/desktop/src/features/chat/transcript/TurnUsageCapsule.tsx b/apps/desktop/src/features/chat/transcript/TurnUsageCapsule.tsx
index 3e9041833..b3aca616b 100644
--- a/apps/desktop/src/features/chat/transcript/TurnUsageCapsule.tsx
+++ b/apps/desktop/src/features/chat/transcript/TurnUsageCapsule.tsx
@@ -159,9 +159,6 @@ export function TurnUsageCapsule({
popover: { width: popoverRect.width, height: popoverRect.height },
pane: paneRect ? { left: paneRect.left, right: paneRect.right } : null,
viewport: { width: window.innerWidth, height: window.innerHeight },
- // The approved capsule design opens into the space under the answer;
- // the bottom dock flips it above only when that space is too short.
- prefer: "below",
});
if (!next) {
setOpen(false);
diff --git a/apps/desktop/src/lib/context-inspector-position.ts b/apps/desktop/src/lib/context-inspector-position.ts
index 58647419b..a18e5e81c 100644
--- a/apps/desktop/src/lib/context-inspector-position.ts
+++ b/apps/desktop/src/lib/context-inspector-position.ts
@@ -49,7 +49,6 @@ export function placeContextInspector({
viewport,
margin = CONTEXT_INSPECTOR_MARGIN,
gap = CONTEXT_INSPECTOR_GAP,
- prefer = "above",
}: {
trigger: ContextInspectorTrigger;
popover: { width: number; height: number };
@@ -58,11 +57,6 @@ export function placeContextInspector({
viewport: { width: number; height: number };
margin?: number;
gap?: number;
- /**
- * Which side wins when both fit. The composer inspector opens above its
- * bottom-docked trigger; a turn footer prefers the space below the answer.
- */
- prefer?: "above" | "below";
}): ContextInspectorPlacement | null {
const left = (pane ? pane.left : 0) + margin;
const right = (pane ? pane.right : viewport.width) - margin;
@@ -81,20 +75,12 @@ export function placeContextInspector({
margin,
viewport.height - popover.height - margin,
);
- const fitsAbove = above >= margin && above <= maximumTop;
- const fitsBelow = below >= margin && below <= maximumTop;
const top =
- prefer === "below"
- ? fitsBelow
+ above >= margin && above <= maximumTop
+ ? above
+ : below >= margin && below <= maximumTop
? below
- : fitsAbove
- ? above
- : Math.min(Math.max(margin, below), maximumTop)
- : fitsAbove
- ? above
- : fitsBelow
- ? below
- : Math.min(Math.max(margin, below), maximumTop);
+ : Math.min(Math.max(margin, below), maximumTop);
return { top, left: clampedLeft, maxWidth };
}
diff --git a/apps/desktop/test/context-inspector-position.test.mjs b/apps/desktop/test/context-inspector-position.test.mjs
index c9c785ffd..dda30cb22 100644
--- a/apps/desktop/test/context-inspector-position.test.mjs
+++ b/apps/desktop/test/context-inspector-position.test.mjs
@@ -77,21 +77,6 @@ test("the popover opens above the trigger and falls back below it", () => {
assert.equal(below.top, 128 + 8);
});
-test("a turn footer can prefer the space below while the dock keeps above", () => {
- const trigger = { left: 600, top: 400, bottom: 428 };
- const above = place(trigger);
- const below = placeContextInspector({
- trigger,
- popover: POPOVER,
- pane: PANE,
- viewport: VIEWPORT,
- prefer: "below",
- });
- assert.ok(above && below);
- assert.equal(above.top, 400 - POPOVER.height - 8);
- assert.equal(below.top, 428 + 8);
-});
-
test("a pane with no usable width leaves the popover unplaced", () => {
assert.equal(
place({ left: 10, top: 700, bottom: 728 }, { left: 0, right: 20 }),
diff --git a/apps/desktop/test/turn-usage-capsule.test.mjs b/apps/desktop/test/turn-usage-capsule.test.mjs
index 25603db98..a44e16c4d 100644
--- a/apps/desktop/test/turn-usage-capsule.test.mjs
+++ b/apps/desktop/test/turn-usage-capsule.test.mjs
@@ -62,7 +62,7 @@ test("the popover portals to body and clamps to the conversation pane", () => {
assert.match(capsule, /useId\(\)/);
assert.match(capsule, /portalToBody\(popover\)/);
assert.match(capsule, /placeContextInspector\(\{/);
- assert.match(capsule, /prefer: "below"/);
+ assert.doesNotMatch(capsule, /prefer:/);
assert.match(capsule, /closest\("\.main-pane"\)/);
assert.match(capsule, /new ResizeObserver\(updatePosition\)/);
assert.match(capsule, /addEventListener\("scroll", handleViewportChange, true\)/);