Skip to content

Commit 1c25ed7

Browse files
flambohmaria-rcks
authored andcommitted
fix(web): the workspace hint sits at the same height on every pane (#30578)
1 parent 9b90a2c commit 1c25ed7

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

‎apps/web/src/layout/LayoutHint.tsx‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ const ARROWS: Record<string, string> = { Left: "←", Right: "→", Up: "↑", D
2121
/** How long a hint stays before its one-shot fade. */
2222
const HINT_VISIBLE_MS = 2400;
2323
const HINT_FADE_MS = 200;
24-
/** Room between the hint and the composer (or the pane's bottom) under it. */
24+
/** Room between the hint and the composer under it. */
2525
const HINT_GAP_PX = 12;
2626
const HINT_EDGE_PX = 16;
27+
const HINT_BOTTOM_PX = 108;
2728

2829
/** Fades the hint after a beat, then clears it. */
2930
function useHintLifetime(id: number): boolean {
@@ -44,9 +45,9 @@ function useHintLifetime(id: number): boolean {
4445
}
4546

4647
/**
47-
* Centers a hint on the focused pane, a gap above its composer stack (banners,
48-
* request cards and tray included), or above the pane's bottom when it has no
49-
* composer. Follows the strip while it scrolls to the landed pane.
48+
* Centers a hint on the focused pane at the same height on every pane, lifted
49+
* a gap above its composer stack (banners, request cards and tray included)
50+
* when that grows taller. Follows the strip while it scrolls to the landed pane.
5051
*/
5152
function useHintPlacement() {
5253
const [hint, setHint] = useState<HTMLDivElement | null>(null);
@@ -61,9 +62,10 @@ function useHintPlacement() {
6162
const hostRect = host.getBoundingClientRect();
6263
const paneRect = pane.getBoundingClientRect();
6364
const composer = pane.querySelector('[data-chat-composer-stack="true"]');
65+
const rest = paneRect.bottom - HINT_BOTTOM_PX;
6466
const floor = composer
65-
? composer.getBoundingClientRect().top - HINT_GAP_PX
66-
: paneRect.bottom - HINT_EDGE_PX;
67+
? Math.min(rest, composer.getBoundingClientRect().top - HINT_GAP_PX)
68+
: rest;
6769
const next = {
6870
left: paneRect.left + paneRect.width / 2 - hostRect.left,
6971
bottom: hostRect.bottom - floor,
@@ -151,7 +153,7 @@ function TerminalHintPill({ hint }: { hint: Extract<LayoutHintState, { kind: "te
151153
aria-live="polite"
152154
data-layout-hint="terminal"
153155
className={cn(
154-
"pointer-events-none absolute bottom-30 left-1/2 z-40 flex h-8.5 max-w-[calc(100%-2rem)] -translate-x-1/2 items-center gap-2.5 rounded-lg px-3 surface-tooltip transition-opacity duration-200 motion-reduce:transition-none",
156+
"pointer-events-none absolute bottom-27 left-1/2 z-40 flex h-8.5 max-w-[calc(100%-2rem)] -translate-x-1/2 items-center gap-2.5 rounded-lg px-3 surface-tooltip transition-opacity duration-200 motion-reduce:transition-none",
155157
leaving && "opacity-0",
156158
)}
157159
>
@@ -212,7 +214,7 @@ function WorkspaceHintPill({
212214
aria-live="polite"
213215
data-layout-hint={hint.kind}
214216
className={cn(
215-
"pointer-events-none absolute bottom-30 left-1/2 z-40 flex max-w-[calc(100%-2rem)] -translate-x-1/2 items-center gap-2 rounded-lg px-3 surface-tooltip transition-opacity duration-200 motion-reduce:transition-none",
217+
"pointer-events-none absolute bottom-27 left-1/2 z-40 flex max-w-[calc(100%-2rem)] -translate-x-1/2 items-center gap-2 rounded-lg px-3 surface-tooltip transition-opacity duration-200 motion-reduce:transition-none",
216218
small ? "h-7.5" : "h-8.5 gap-2.5",
217219
leaving && "opacity-0",
218220
)}
@@ -254,7 +256,7 @@ function ColumnHintPill({ hint }: { hint: Extract<LayoutHintState, { kind: "colu
254256
aria-live="polite"
255257
data-layout-hint="column"
256258
className={cn(
257-
"pointer-events-none absolute bottom-30 left-1/2 z-40 flex h-8.5 max-w-[calc(100%-2rem)] -translate-x-1/2 items-center gap-2.5 rounded-lg px-3 surface-tooltip transition-opacity duration-200 motion-reduce:transition-none",
259+
"pointer-events-none absolute bottom-27 left-1/2 z-40 flex h-8.5 max-w-[calc(100%-2rem)] -translate-x-1/2 items-center gap-2.5 rounded-lg px-3 surface-tooltip transition-opacity duration-200 motion-reduce:transition-none",
258260
leaving && "opacity-0",
259261
)}
260262
>

0 commit comments

Comments
 (0)