mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-17 05:26:47 +03:00
fix(app): make the session details popover match menus (#60494)
This commit is contained in:
committed by
GitHub
Unverified
parent
2339bdacda
commit
a97ed5c3eb
@@ -870,9 +870,10 @@ test("long MCP lists stay in the viewport in a real RTL locale", async ({ page }
|
||||
await summary.getByRole("button", { name: "MCP", exact: true }).click()
|
||||
const menu = page.getByRole("group", { name: "MCP", exact: true })
|
||||
await expect(menu.locator(".session-mcp-row")).toHaveCount(30)
|
||||
await expect.poll(() => menu.evaluate((element) => element.scrollHeight > element.clientHeight)).toBe(true)
|
||||
const list = menu.locator("[data-scrollable]")
|
||||
await expect.poll(() => list.evaluate((element) => element.scrollHeight > element.clientHeight)).toBe(true)
|
||||
// Long names truncate; the list only scrolls vertically.
|
||||
expect(await menu.evaluate((element) => element.scrollWidth - element.clientWidth)).toBe(0)
|
||||
expect(await list.evaluate((element) => element.scrollWidth - element.clientWidth)).toBe(0)
|
||||
// The submenu shows and moves without motion unless its Knobs toggle is on.
|
||||
expect(
|
||||
await page.locator(".session-service-flyout").evaluate((element) => getComputedStyle(element).transitionDuration),
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
.session-summary-popover {
|
||||
transform-origin: var(--kb-popover-content-transform-origin);
|
||||
animation: menu-v2-in 120ms ease-out;
|
||||
/* Only the card scrolls, so neither its shadow nor the Extensions flyout beside it is clipped. */
|
||||
.session-summary-popover .session-summary-card {
|
||||
max-height: calc(100dvh - 96px);
|
||||
overflow-y: auto;
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
box-shadow: var(--v2-elevation-floating);
|
||||
}
|
||||
|
||||
[data-component="session-summary-panel"] {
|
||||
@@ -44,13 +47,13 @@
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
min-height: 32px;
|
||||
min-height: 28px;
|
||||
padding: 4px 12px;
|
||||
border-radius: 4px;
|
||||
color: var(--v2-text-text-base);
|
||||
font-size: 13px;
|
||||
font-weight: 440;
|
||||
line-height: var(--line-height-base);
|
||||
line-height: var(--line-height-compact);
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
@@ -92,12 +95,13 @@ button.session-service-row:focus-visible,
|
||||
}
|
||||
|
||||
.session-summary-row[data-expanded] {
|
||||
background: var(--v2-overlay-simple-overlay-pressed);
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
}
|
||||
|
||||
.session-summary-heading {
|
||||
color: var(--v2-text-text-faint);
|
||||
font-weight: 530;
|
||||
font-weight: 440;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.session-summary-label {
|
||||
@@ -154,9 +158,6 @@ button.session-service-row:focus-visible,
|
||||
}
|
||||
|
||||
.session-service-flyout-body {
|
||||
/* The shadow follows the clipped surface, so it is a filter rather than a box shadow. */
|
||||
filter: drop-shadow(0 8px 8px var(--v2-alpha-dark-4)) drop-shadow(0 4px 4px var(--v2-alpha-dark-8))
|
||||
drop-shadow(0 0 0.5px var(--v2-alpha-dark-12));
|
||||
opacity: 0;
|
||||
scale: 0.96;
|
||||
translate: 4px 0;
|
||||
@@ -174,21 +175,18 @@ button.session-service-row:focus-visible,
|
||||
}
|
||||
}
|
||||
|
||||
[data-color-scheme="dark"] .session-service-flyout-body {
|
||||
filter: drop-shadow(0 8px 8px var(--v2-alpha-dark-30)) drop-shadow(0 4px 4px var(--v2-alpha-dark-30))
|
||||
drop-shadow(0 0 0.5px var(--v2-alpha-light-16));
|
||||
}
|
||||
|
||||
.session-service-flyout-surface {
|
||||
display: grid;
|
||||
padding: 2px;
|
||||
height: var(--flyout-height);
|
||||
overflow: hidden;
|
||||
padding: 2px 0;
|
||||
border-radius: 6px;
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
box-shadow: var(--v2-elevation-floating);
|
||||
color: var(--v2-text-text-base);
|
||||
font-size: 13px;
|
||||
font-weight: 440;
|
||||
line-height: var(--line-height-compact);
|
||||
clip-path: inset(0 0 calc(100% - var(--flyout-height)) 0 round 6px);
|
||||
}
|
||||
|
||||
/* Motion is off unless the "Extensions submenu motion" knob sets data-motion. */
|
||||
@@ -218,20 +216,20 @@ button.session-service-row:focus-visible,
|
||||
}
|
||||
|
||||
.session-service-flyout-surface {
|
||||
transition: clip-path 0.3s var(--spring-snap);
|
||||
transition: height 0.3s var(--spring-snap);
|
||||
}
|
||||
}
|
||||
|
||||
.session-service-pane {
|
||||
grid-area: 1 / 1;
|
||||
align-self: start;
|
||||
/* The list scrolls above its actions, which stay in view. */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: min(480px, calc(100dvh - 36px));
|
||||
/* Only vertical: long names truncate rather than scroll sideways. */
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
/* Long names truncate inside the list instead of widening it. */
|
||||
min-width: 0;
|
||||
outline: none;
|
||||
--session-service-scrollbar: 0px;
|
||||
|
||||
/* Lists swap at once; only the box glides and resizes, so two lists never show together. */
|
||||
&:not([data-active]) {
|
||||
@@ -240,8 +238,25 @@ button.session-service-row:focus-visible,
|
||||
}
|
||||
}
|
||||
|
||||
/* A long list keeps the menu's 2px inset at both ends, and fades only at an edge with rows scrolled past it. The
|
||||
scrollbar's strip stays unmasked, so the thumb never fades. */
|
||||
.session-service-scroll {
|
||||
min-height: 0;
|
||||
/* Only vertical: long names truncate rather than scroll sideways. */
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
overscroll-behavior: contain;
|
||||
}
|
||||
|
||||
/* The list and its actions own the menu's inline inset, so a separator can run edge to edge. */
|
||||
.session-service-pane-content,
|
||||
.session-service-pane > .session-service-footer {
|
||||
padding-inline: 2px;
|
||||
}
|
||||
|
||||
.session-service-pane > .session-service-footer {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* A long list keeps the menu's 2px inset at both ends, and fades only at an edge with rows scrolled past it. */
|
||||
@property --session-service-fade-start {
|
||||
syntax: "<length>";
|
||||
inherits: false;
|
||||
@@ -273,23 +288,14 @@ button.session-service-row:focus-visible,
|
||||
}
|
||||
|
||||
@supports (animation-timeline: scroll()) {
|
||||
.session-service-pane[data-overflow] {
|
||||
mask-image:
|
||||
linear-gradient(#000, #000),
|
||||
linear-gradient(
|
||||
to bottom,
|
||||
transparent,
|
||||
#000 var(--session-service-fade-start),
|
||||
#000 calc(100% - var(--session-service-fade-end)),
|
||||
transparent
|
||||
);
|
||||
mask-size:
|
||||
var(--session-service-scrollbar) 100%,
|
||||
100% 100%;
|
||||
mask-position:
|
||||
right top,
|
||||
left top;
|
||||
mask-repeat: no-repeat;
|
||||
.session-service-pane[data-overflow] .session-service-scroll {
|
||||
mask-image: linear-gradient(
|
||||
to bottom,
|
||||
transparent,
|
||||
#000 var(--session-service-fade-start),
|
||||
#000 calc(100% - var(--session-service-fade-end)),
|
||||
transparent
|
||||
);
|
||||
animation:
|
||||
session-service-fade-start linear both,
|
||||
session-service-fade-end linear both;
|
||||
@@ -297,33 +303,6 @@ button.session-service-row:focus-visible,
|
||||
animation-range:
|
||||
0 16px,
|
||||
calc(100% - 16px) 100%;
|
||||
|
||||
&:dir(rtl) {
|
||||
mask-position:
|
||||
left top,
|
||||
left top;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The thumb sits 6px inside the menu's edge and clear of its corners, rather than against the border. */
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
@supports selector(::-webkit-scrollbar) {
|
||||
.session-service-pane {
|
||||
--session-service-scrollbar: 12px;
|
||||
}
|
||||
|
||||
.session-service-pane::-webkit-scrollbar {
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.session-service-pane::-webkit-scrollbar-track:vertical {
|
||||
margin: 6px 0;
|
||||
}
|
||||
|
||||
.session-service-pane::-webkit-scrollbar-thumb {
|
||||
border-width: 2px 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +360,8 @@ button.session-service-row:focus-visible,
|
||||
|
||||
strong {
|
||||
padding: 8px 12px;
|
||||
font-weight: 530;
|
||||
font-weight: 440;
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +370,7 @@ button.session-service-row:focus-visible,
|
||||
color: var(--v2-text-text-faint);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
:is(.session-service-pane-content, .session-service-drawer) > .session-service-footer {
|
||||
:is(.session-service-pane, .session-service-drawer) > .session-service-footer {
|
||||
padding-block-start: 6px;
|
||||
}
|
||||
.session-service-config-separator {
|
||||
@@ -401,11 +381,6 @@ button.session-service-row:focus-visible,
|
||||
background: var(--v2-border-border-muted);
|
||||
}
|
||||
|
||||
/* Inside a submenu's scroll box, a full-bleed separator would overflow it sideways. */
|
||||
.session-service-pane .session-service-config-separator {
|
||||
width: auto;
|
||||
margin-inline: 0;
|
||||
}
|
||||
.session-service-config {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -492,6 +467,11 @@ button.session-service-dot {
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
/* The 16px switch sits 6px from the row's top, bottom and end. */
|
||||
.session-mcp-row {
|
||||
padding-inline-end: 6px;
|
||||
}
|
||||
|
||||
.session-mcp-trailing {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
@@ -544,7 +524,7 @@ button.session-service-dot {
|
||||
.session-summary-dismiss {
|
||||
position: absolute;
|
||||
inset-inline-end: 8px;
|
||||
bottom: 8px;
|
||||
bottom: 6px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
@@ -569,7 +549,6 @@ button.session-service-dot {
|
||||
}
|
||||
|
||||
:root[data-motion="reduce"] {
|
||||
.session-summary-popover,
|
||||
.session-service-dot::before {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
@@ -100,8 +100,7 @@ function DetailsPopover(
|
||||
/>
|
||||
</Tooltip>
|
||||
<Popover.Portal>
|
||||
{/* Kobalte positions the content relatively, so it places the Extensions flyout. Only the inner box scrolls,
|
||||
so the flyout beside it is not clipped. */}
|
||||
{/* Kobalte positions the content relatively, so it places the Extensions flyout. */}
|
||||
<Popover.Content
|
||||
class="session-summary-popover z-50 border-0 bg-transparent outline-none"
|
||||
aria-label={ctx.t("title")}
|
||||
@@ -117,7 +116,7 @@ function DetailsPopover(
|
||||
if (content instanceof HTMLElement) setTimeout(() => content.focus({ preventScroll: true }))
|
||||
}}
|
||||
>
|
||||
<div class="max-h-[calc(100dvh-96px)] overflow-y-auto p-1">{props.children}</div>
|
||||
{props.children}
|
||||
</Popover.Content>
|
||||
</Popover.Portal>
|
||||
</Popover>
|
||||
|
||||
@@ -55,6 +55,8 @@ type ServiceSource = {
|
||||
readonly failed: boolean
|
||||
retry: () => void
|
||||
Body: Component
|
||||
/** The actions under the list, outside its scroll box so they stay in view. */
|
||||
Footer: Component
|
||||
}
|
||||
|
||||
// How long a pointer may rest inside the safe triangle before the row under it takes over.
|
||||
@@ -143,6 +145,7 @@ function ServiceMenu(props: ServiceProps & { mobile?: boolean; name: string }) {
|
||||
|
||||
const rows: Partial<Record<Service, HTMLButtonElement>> = {}
|
||||
const panes: Partial<Record<Service, HTMLElement>> = {}
|
||||
const scrollers: Partial<Record<Service, HTMLElement>> = {}
|
||||
let flyout: HTMLDivElement | undefined
|
||||
let surface: HTMLDivElement | undefined
|
||||
// The flyout's containing block in the viewport, measured when a list opens and on scroll or resize, so pointer
|
||||
@@ -341,10 +344,11 @@ function ServiceMenu(props: ServiceProps & { mobile?: boolean; name: string }) {
|
||||
entries.forEach((entry) => {
|
||||
const service = services.find((item) => panes[item.type]?.contains(entry.target))?.type
|
||||
const pane = service ? panes[service] : undefined
|
||||
const scroller = service ? scrollers[service] : undefined
|
||||
|
||||
if (!service || !pane) return
|
||||
if (!service || !pane || !scroller) return
|
||||
setMenu("heights", service, pane.offsetHeight)
|
||||
setMenu("overflow", service, pane.scrollHeight > pane.clientHeight + 1)
|
||||
setMenu("overflow", service, scroller.scrollHeight > scroller.clientHeight + 1)
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -365,6 +369,7 @@ function ServiceMenu(props: ServiceProps & { mobile?: boolean; name: string }) {
|
||||
<ServiceBody source={source}>
|
||||
<source.Body />
|
||||
</ServiceBody>
|
||||
<ServiceFooter source={source} />
|
||||
</div>
|
||||
))
|
||||
|
||||
@@ -466,11 +471,18 @@ function ServiceMenu(props: ServiceProps & { mobile?: boolean; name: string }) {
|
||||
data-overflow={menu.overflow[service.type] || undefined}
|
||||
inert={menu.pane !== service.type || undefined}
|
||||
>
|
||||
<div ref={(element) => observer.observe(element)} class="session-service-pane-content">
|
||||
<ServiceBody source={source}>
|
||||
<source.Body />
|
||||
</ServiceBody>
|
||||
<div
|
||||
ref={(element) => (scrollers[service.type] = element)}
|
||||
class="session-service-scroll"
|
||||
data-scrollable
|
||||
>
|
||||
<div ref={(element) => observer.observe(element)} class="session-service-pane-content">
|
||||
<ServiceBody source={source}>
|
||||
<source.Body />
|
||||
</ServiceBody>
|
||||
</div>
|
||||
</div>
|
||||
<ServiceFooter source={source} />
|
||||
</div>
|
||||
)
|
||||
}}
|
||||
@@ -524,7 +536,7 @@ function useLsp(props: ServiceProps): ServiceSource {
|
||||
failed: false,
|
||||
retry: () => void refetch(),
|
||||
Body: () => (
|
||||
<Show when={names().length} fallback={<ServiceEmpty owner={props} title={ctx.t("lsp.empty")} service="lsp" />}>
|
||||
<Show when={names().length} fallback={<ServiceEmpty title={ctx.t("lsp.empty")} />}>
|
||||
<For each={names()}>
|
||||
{(name) => (
|
||||
<div class="session-service-row">
|
||||
@@ -532,6 +544,10 @@ function useLsp(props: ServiceProps): ServiceSource {
|
||||
</div>
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
),
|
||||
Footer: () => (
|
||||
<Show when={names().length} fallback={<ServiceEmptyFooter owner={props} service="lsp" />}>
|
||||
<div class="session-service-footer">
|
||||
<span class="session-service-config-separator" role="separator" />
|
||||
<ServiceConfigLink owner={props} service="lsp" />
|
||||
@@ -586,7 +602,7 @@ function useMcp(props: ServiceProps, close: () => void): ServiceSource {
|
||||
},
|
||||
retry: () => void refetch(),
|
||||
Body: () => (
|
||||
<Show when={servers().length} fallback={<ServiceEmpty owner={props} title={ctx.t("mcp.empty")} service="mcp" />}>
|
||||
<Show when={servers().length} fallback={<ServiceEmpty title={ctx.t("mcp.empty")} />}>
|
||||
<Index each={servers()}>
|
||||
{(server) => {
|
||||
const enabled = () => server().status.status !== "disabled"
|
||||
@@ -674,6 +690,10 @@ function useMcp(props: ServiceProps, close: () => void): ServiceSource {
|
||||
)
|
||||
}}
|
||||
</Index>
|
||||
</Show>
|
||||
),
|
||||
Footer: () => (
|
||||
<Show when={servers().length} fallback={<ServiceEmptyFooter owner={props} service="mcp" />}>
|
||||
<div class="session-service-footer">
|
||||
<span class="session-service-config-separator" role="separator" />
|
||||
<ServiceConfigLink owner={props} service="mcp" />
|
||||
@@ -771,11 +791,7 @@ function useCatalog(props: ServiceProps, service: "plugins" | "skills"): Service
|
||||
<Show
|
||||
when={list().length}
|
||||
fallback={
|
||||
<ServiceEmpty
|
||||
owner={props}
|
||||
title={ctx.t(service === "plugins" ? "plugins.empty" : "skills.empty")}
|
||||
service={service}
|
||||
/>
|
||||
<ServiceEmpty title={ctx.t(service === "plugins" ? "plugins.empty" : "skills.empty")} />
|
||||
}
|
||||
>
|
||||
<For each={list()}>
|
||||
@@ -814,6 +830,10 @@ function useCatalog(props: ServiceProps, service: "plugins" | "skills"): Service
|
||||
</Show>
|
||||
)}
|
||||
</For>
|
||||
</Show>
|
||||
),
|
||||
Footer: () => (
|
||||
<Show when={list().length} fallback={<ServiceEmptyFooter owner={props} service={service} />}>
|
||||
<div class="session-service-footer">
|
||||
<span class="session-service-config-separator" role="separator" />
|
||||
<Show when={service === "skills"}>
|
||||
@@ -890,6 +910,15 @@ function ServiceBody(props: { source: ServiceSource; children: JSX.Element }) {
|
||||
)
|
||||
}
|
||||
|
||||
// Shown once the list is, as ServiceBody shows it.
|
||||
function ServiceFooter(props: { source: ServiceSource }) {
|
||||
return (
|
||||
<Show when={(props.source.ready || !props.source.loading) && !props.source.error}>
|
||||
<props.source.Footer />
|
||||
</Show>
|
||||
)
|
||||
}
|
||||
|
||||
function ServiceConfigLink(props: { owner: ServiceProps; service: Service }) {
|
||||
const ctx = usePlugin()
|
||||
const system = ctx.system
|
||||
@@ -1000,15 +1029,20 @@ function ServiceSetup(props: { owner: ServiceProps; service: Service }) {
|
||||
)
|
||||
}
|
||||
|
||||
function ServiceEmpty(props: { owner: ServiceProps; title: string; service: Service }) {
|
||||
function ServiceEmpty(props: { title: string }) {
|
||||
return (
|
||||
<div class="session-service-empty">
|
||||
<strong>{props.title}</strong>
|
||||
<div class="session-service-footer">
|
||||
<ServiceSetup owner={props.owner} service={props.service} />
|
||||
<span class="session-service-config-separator" role="separator" />
|
||||
<ServiceConfigLink owner={props.owner} service={props.service} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ServiceEmptyFooter(props: { owner: ServiceProps; service: Service }) {
|
||||
return (
|
||||
<div class="session-service-footer">
|
||||
<span class="session-service-config-separator" role="separator" />
|
||||
<ServiceSetup owner={props.owner} service={props.service} />
|
||||
<ServiceConfigLink owner={props.owner} service={props.service} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ const replacements: Partial<Record<IconName, { name: NewIconName; rotate?: numbe
|
||||
"select-element": { name: "annotate" },
|
||||
download: { name: "download" },
|
||||
"post-skill": { name: "skill" },
|
||||
"graduation-cap": { name: "skill" },
|
||||
eye: { name: "eye-open" },
|
||||
"outline-eye": { name: "eye-open" },
|
||||
"outline-eye-slash": { name: "eye-closed" },
|
||||
@@ -131,7 +132,7 @@ const replacements: Partial<Record<IconName, { name: NewIconName; rotate?: numbe
|
||||
// Status: circle-xmark (10) / circle-x (1), outline-hexagonal-warning (7) / warning (6), status / status-active (4),
|
||||
// help (3), info (2)
|
||||
// Features: terminal (6), mcp (5), branch (5, held back), console / outline-console (2), stop, models,
|
||||
// link, share, brain / outline-brain, shield, graduation-cap
|
||||
// link, share, brain / outline-brain, shield
|
||||
// Arrows: arrow-up-right (5) / outline-arrow-up-right (3), arrow-down-to-line (2), arrow-undo-down
|
||||
// Layout: layout-left / layout-left-full (4), layout-right / layout-right-full (2), chevron-grabber-vertical (4),
|
||||
// fill-triangle-down (3), menu (2), expand / collapse, split / unified, dot-grid
|
||||
|
||||
Reference in New Issue
Block a user