Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pkg/ui/scripts/composer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,36 @@ for (const [width, height, ratio] of [
await tab.screenshot({ path: join(OUT, `${name}.png`) })
await tab.locator('[data-slot="composer-shell"]').screenshot({ path: join(OUT, `${name}-rest.png`) })

// Effort and Mode open their list where it can be seen: drawn, on screen, beside the word that opened it.
for (const slotName of kind === 'dev' ? ['effort', 'mode'] : ['effort']) {
const trigger = tab.locator(`[data-slot="composer-foot"] [data-slot="${slotName}"]`)
check((await trigger.count()) === 1, `${name}: ${slotName} is drawn under the frame`)
if (!(await trigger.count())) continue
await trigger.click()
await tab.locator('[data-slot="choices"]').last().waitFor({ state: 'visible', timeout: 5_000 }).catch(() => {})
const panel = await tab.evaluate((s) => {
const list = [...document.querySelectorAll('[data-slot="choices"]')].at(-1)
if (!list) return null
const b = list.getBoundingClientRect()
const t = document.querySelector(`[data-slot="composer-foot"] [data-slot="${s}"]`).getBoundingClientRect()
let seen = true
for (let n = list; n; n = n.parentElement) {
const st = getComputedStyle(n)
if (st.opacity === '0' || st.visibility === 'hidden' || st.display === 'none') seen = false
}
return { seen, x: b.x, y: b.y, r: b.right, bottom: b.bottom, w: b.width, vw: innerWidth, vh: innerHeight, gap: Math.min(Math.abs(t.top - b.bottom), Math.abs(b.top - t.bottom)) }
}, slotName)
check(
panel && panel.seen && panel.w > 0 && panel.x >= 0 && panel.y >= 0 && panel.r <= panel.vw + 1 && panel.bottom <= panel.vh + 1,
`${name}: ${slotName} opens a list that is seen on screen (${JSON.stringify(panel)})`,
)
if (!phone) check(panel && panel.gap <= 24, `${name}: ${slotName}'s list opens beside its word (${panel?.gap})`)
await tab.keyboard.press('Escape')
const shut = await tab.locator('[data-slot="choices"]').last().waitFor({ state: 'hidden', timeout: 5_000 }).then(() => true, () => false)
check(shut, `${name}: Escape puts ${slotName}'s list away`)
await settle(tab)
}

// Focused, with three lines: the edge brightens, send has the last place, the field three lines tall.
const field = tab.locator('[data-slot="composer-field"]')
await field.focus()
Expand Down
66 changes: 34 additions & 32 deletions pkg/ui/src/chat/Tune.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,13 @@ function Opens({
)
}

// The Popover sits inside the TooltipTrigger, as the Model picker's does. A Tooltip between a Popover and its
// trigger takes the trigger as its own anchor, and the panel then opens unplaced and unseen.
return (
<Popover open={open} onOpenChange={(o) => (o ? !disabled && setOpen(true) : close(false))} allowFlip stayInFrame placement="top-end">
<Tooltip placement="top" offset={6} open={open ? false : undefined}>
<TooltipTrigger asChild>
<XStack items="center" minW={0} shrink={1} maxW="100%">
<Tooltip placement="top" offset={6} open={open ? false : undefined}>
<TooltipTrigger asChild>
<XStack items="center" minW={0} shrink={1} maxW="100%">
<Popover open={open} onOpenChange={(o) => (o ? !disabled && setOpen(true) : close(false))} allowFlip stayInFrame placement="top-end">
<PopoverTrigger asChild disablePressTrigger>
<Word
ref={triggerRef}
Expand All @@ -325,34 +327,34 @@ function Opens({
{word}
</Word>
</PopoverTrigger>
</XStack>
</TooltipTrigger>
<TooltipContent bg="var(--popover)" borderWidth={1} borderColor={STRONG}>
<Text fontFamily="$body" fontSize="$1" lineHeight={16} color="$ink">
{hint}
</Text>
</TooltipContent>
</Tooltip>
<PopoverContent
solid
bg="var(--popover)"
borderWidth={1}
borderColor={STRONG}
boxShadow="var(--shadow-floating)"
rounded="$4"
p={6}
width={288}
maxW="calc(100vw - 24px)"
maxH="75dvh"
overflowY="auto"
onCloseAutoFocus={(e: Event) => {
e.preventDefault()
triggerRef.current?.focus?.()
}}
>
{children(() => close(true), false)}
</PopoverContent>
</Popover>
<PopoverContent
solid
bg="var(--popover)"
borderWidth={1}
borderColor={STRONG}
boxShadow="var(--shadow-floating)"
rounded="$4"
p={6}
width={288}
maxW="calc(100vw - 24px)"
maxH="75dvh"
overflowY="auto"
onCloseAutoFocus={(e: Event) => {
e.preventDefault()
triggerRef.current?.focus?.()
}}
>
{children(() => close(true), false)}
</PopoverContent>
</Popover>
</XStack>
</TooltipTrigger>
<TooltipContent bg="var(--popover)" borderWidth={1} borderColor={STRONG}>
<Text fontFamily="$body" fontSize="$1" lineHeight={16} color="$ink">
{hint}
</Text>
</TooltipContent>
</Tooltip>
)
}

Expand Down
Loading