mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 13:05:14 +03:00
feat(app): redesign the todo pill and share the composer pill styling (#59979)
This commit is contained in:
committed by
GitHub
Unverified
parent
3829291126
commit
6007274795
@@ -62,7 +62,7 @@ story("treats the reachable end as the end under page zoom", async ({ page }) =>
|
||||
await page.evaluate(async (fixture) => {
|
||||
document.documentElement.style.zoom = "1.1"
|
||||
const { mountTimelineVirtualizer } = await import(fixture)
|
||||
mountTimelineVirtualizer({ count: 4, rowHeight: 60.3, immediate: true, viewportHeight: 200.5 })
|
||||
mountTimelineVirtualizer({ count: 4, rowHeight: 59.3, immediate: true, viewportHeight: 200.5 })
|
||||
}, fixture)
|
||||
const root = page.getByTestId("timeline-virtualizer-fixture")
|
||||
const content = root.locator("[data-timeline-virtual-content]")
|
||||
@@ -108,8 +108,8 @@ for (const input of [
|
||||
await expect(content.locator("[data-timeline-key]")).toHaveCount(1)
|
||||
|
||||
if (input.name === "offset-only") {
|
||||
// Pinned to the end: the 600px row and the virtualizer's 82px tail, less the 180px viewport.
|
||||
await expect(root).toHaveAttribute("data-last-scroll-top", "502")
|
||||
// Pinned to the end: the 600px row and the virtualizer's 86px tail, less the 180px viewport.
|
||||
await expect(root).toHaveAttribute("data-last-scroll-top", "506")
|
||||
await root.locator("[data-scrollable]").dispatchEvent("wheel", { deltaY: -1 })
|
||||
await expect(root.getByTestId("timeline-controls")).toHaveAttribute("data-pinned", "false")
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ for (const width of [1440, 390]) {
|
||||
// The gap above the composer is part of the tail: the status lane, then the activity pill and its gap.
|
||||
const spacer = page.locator('[data-timeline-row="bottom-spacer"]')
|
||||
await expect(spacer).toBeVisible()
|
||||
expect(await spacer.evaluate((element) => element.getBoundingClientRect().height)).toBe(82)
|
||||
expect(await spacer.evaluate((element) => element.getBoundingClientRect().height)).toBe(86)
|
||||
} finally {
|
||||
release.resolve()
|
||||
}
|
||||
|
||||
@@ -614,8 +614,7 @@ export const dict = {
|
||||
"session.queue.reverted": "Redo the revert before you reorder or edit queued prompts",
|
||||
"session.queue.attachments.one": "{{count}} attachment",
|
||||
"session.queue.attachments.other": "{{count}} attachments",
|
||||
"session.todo.title": "Todos",
|
||||
"session.todo.progress": "{{done}}/{{total}}",
|
||||
"session.todo.moreInProgress": "+{{count}}",
|
||||
"session.todo.label.one": "{{done}} of {{count}} todo done",
|
||||
"session.todo.label.other": "{{done}} of {{count}} todos done",
|
||||
"session.timeline.working": "Working",
|
||||
|
||||
@@ -1,28 +1,3 @@
|
||||
[data-color-scheme="dark"] [data-slot="session-activity-chip"] {
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
}
|
||||
|
||||
/* The composer buttons' overlays and focus ring, with overlays layered over the capsule's own surface. */
|
||||
[data-slot="session-activity-chip"] {
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--v2-border-border-focus);
|
||||
outline-offset: 2.5px;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
&:hover:not(:active, [data-expanded]) {
|
||||
background-image: linear-gradient(var(--v2-overlay-simple-overlay-hover), var(--v2-overlay-simple-overlay-hover));
|
||||
}
|
||||
}
|
||||
|
||||
&:is(:active, [data-expanded]) {
|
||||
background-image: linear-gradient(
|
||||
var(--v2-overlay-simple-overlay-pressed),
|
||||
var(--v2-overlay-simple-overlay-pressed)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="session-activity-summary"] {
|
||||
color: var(--v2-text-text-faint);
|
||||
|
||||
@@ -251,9 +226,3 @@
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (hover: none) {
|
||||
[data-slot="session-activity-chip"] {
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { stripAnsi } from "@opencode/session-ui/tools/ansi"
|
||||
import { createEffect, createMemo, createSignal, For, on, onCleanup, Show } from "solid-js"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
import { useSettings } from "@/settings/model"
|
||||
import { useComposerLaneAlignment } from "./composer-lane"
|
||||
import { composerLanePlacement, useComposerLaneAlignment } from "./composer-lane"
|
||||
import { createShellPanel, createShellTail, type ShellEnd } from "./shell-panel"
|
||||
import "./activity-chips.css"
|
||||
|
||||
@@ -80,7 +80,6 @@ export function SessionActivityChips(props: {
|
||||
|
||||
const alignment = useComposerLaneAlignment()
|
||||
|
||||
const placement = () => (({ center: "top", start: "top-start", end: "top-end" }) as const)[alignment()]
|
||||
|
||||
// A subagent can only be interrupted once its child session exists.
|
||||
const stoppable = (item: SessionActivityItem) => item.type === "shell" || !!item.sessionID
|
||||
@@ -229,13 +228,14 @@ export function SessionActivityChips(props: {
|
||||
return (
|
||||
<Show when={active()}>
|
||||
<div data-component="session-activity-chips" class="flex min-w-0 shrink items-center">
|
||||
<Menu gutter={8} placement={placement()} open={open()} onOpenChange={changeOpen}>
|
||||
<Menu gutter={8} placement={composerLanePlacement(alignment())} open={open()} onOpenChange={changeOpen}>
|
||||
<Menu.Trigger
|
||||
as="button"
|
||||
type="button"
|
||||
data-slot="session-activity-chip"
|
||||
aria-label={label()}
|
||||
class="pointer-events-auto flex h-7 min-w-0 max-w-full items-center gap-2 rounded-[12px] border-[0.5px] border-v2-border-border-muted bg-v2-background-bg-base ps-2.5 pe-2.5 text-[13px] font-[440] leading-text-compact tracking-[-0.04px] whitespace-nowrap tabular-nums text-v2-text-text-base shadow-[var(--v2-elevation-raised)] outline-none duration-150 ease-out motion-reduce:animate-none"
|
||||
data-composer-pill
|
||||
class="tabular-nums duration-150 ease-out motion-reduce:animate-none"
|
||||
classList={{ "animate-in fade-in": enter() }}
|
||||
>
|
||||
<SessionProgressIndicatorV2 class="shrink-0" />
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
/* Every pill in the composer lane shares one capsule: its surface, overlays, focus ring and touch size. */
|
||||
[data-composer-pill] {
|
||||
pointer-events: auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
height: 32px;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
padding-inline: 10px;
|
||||
/* The elevation draws the hairline; a second border would double it. */
|
||||
border: 0.5px solid transparent;
|
||||
border-radius: 8px;
|
||||
background: var(--v2-background-bg-base);
|
||||
box-shadow: var(--v2-elevation-raised);
|
||||
font-size: 13px;
|
||||
font-weight: 440;
|
||||
line-height: var(--line-height-compact);
|
||||
letter-spacing: -0.04px;
|
||||
white-space: nowrap;
|
||||
color: var(--v2-text-text-base);
|
||||
outline: none;
|
||||
|
||||
[data-color-scheme="dark"] & {
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--v2-border-border-focus);
|
||||
outline-offset: 2.5px;
|
||||
}
|
||||
|
||||
/* Overlays layer over the capsule's own surface. */
|
||||
@media (hover: hover) {
|
||||
&:hover:not(:active, [data-expanded]) {
|
||||
background-image: linear-gradient(var(--v2-overlay-simple-overlay-hover), var(--v2-overlay-simple-overlay-hover));
|
||||
}
|
||||
}
|
||||
|
||||
&:active:not([data-expanded]) {
|
||||
background-image: linear-gradient(
|
||||
var(--v2-overlay-simple-overlay-pressed),
|
||||
var(--v2-overlay-simple-overlay-pressed)
|
||||
);
|
||||
}
|
||||
|
||||
/* While its popover is open, the pill steps onto the popover's layer. */
|
||||
&[data-expanded] {
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
|
||||
[data-color-scheme="dark"] & {
|
||||
background: var(--v2-background-bg-layer-02);
|
||||
}
|
||||
}
|
||||
|
||||
@media (hover: none) {
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
/* The popover a pill opens, just above it. */
|
||||
[data-composer-pill-panel] {
|
||||
max-width: calc(100vw - 56px);
|
||||
border: 0.5px solid transparent;
|
||||
border-radius: 10px;
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
box-shadow: var(--v2-elevation-floating);
|
||||
outline: none;
|
||||
transform-origin: var(--kb-popover-content-transform-origin);
|
||||
animation: composer-pill-panel-in 150ms ease-out;
|
||||
|
||||
:root[data-motion="reduce"] & {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes composer-pill-panel-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(4px) scale(0.98);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createMemo, type ParentProps } from "solid-js"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
import { useSettings } from "@/settings/model"
|
||||
import "./composer-lane.css"
|
||||
|
||||
/** Where the floating pills above the composer sit, in logical terms, following the background activity setting. */
|
||||
export function useComposerLaneAlignment() {
|
||||
@@ -17,6 +18,11 @@ export function useComposerLaneAlignment() {
|
||||
})
|
||||
}
|
||||
|
||||
/** Where a pill's popover opens: above it, from the lane's aligned edge. */
|
||||
export function composerLanePlacement(alignment: "center" | "start" | "end") {
|
||||
return ({ center: "top", start: "top-start", end: "top-end" } as const)[alignment]
|
||||
}
|
||||
|
||||
// The pills float out of flow in a lane the timeline reserves at its tail, so coming and going never resizes the
|
||||
// composer region or moves the timeline. Every pill shares the lane's one row.
|
||||
export function SessionComposerLane(props: ParentProps) {
|
||||
|
||||
@@ -14,10 +14,8 @@ import {
|
||||
} from "@opencode/plugin/gui"
|
||||
import { usePluginHost } from "@/runtime/plugin/host"
|
||||
import { Contribution } from "@/runtime/plugin/render"
|
||||
import type { useComposerLaneAlignment } from "./composer-lane"
|
||||
import { composerLanePlacement, type useComposerLaneAlignment } from "./composer-lane"
|
||||
|
||||
const capsule =
|
||||
"pointer-events-auto flex h-7 min-w-0 max-w-full items-center gap-2 rounded-[12px] border-[0.5px] border-v2-border-border-muted bg-v2-background-bg-base ps-2.5 pe-2.5 text-[13px] font-[440] leading-text-compact tracking-[-0.04px] whitespace-nowrap text-v2-text-text-base shadow-[var(--v2-elevation-raised)] outline-none"
|
||||
|
||||
type Alignment = ReturnType<ReturnType<typeof useComposerLaneAlignment>>
|
||||
|
||||
@@ -73,7 +71,6 @@ export function SessionPluginPills(props: {
|
||||
function PluginPill(props: { pill: ComposerPill; input: ComposerPillProps; alignment: Accessor<Alignment> }) {
|
||||
const alignment = props.alignment
|
||||
const view = createMemo(() => props.pill.show(props.input))
|
||||
const placement = () => (({ center: "top", start: "top-start", end: "top-end" }) as const)[alignment()]
|
||||
const [state, setState] = createStore({ open: false })
|
||||
|
||||
return (
|
||||
@@ -85,7 +82,7 @@ function PluginPill(props: { pill: ComposerPill; input: ComposerPillProps; align
|
||||
type="button"
|
||||
data-slot="session-plugin-pill"
|
||||
aria-label={current().title}
|
||||
class={capsule}
|
||||
data-composer-pill
|
||||
onClick={() => current().run?.()}
|
||||
>
|
||||
<Content view={current()} />
|
||||
@@ -97,7 +94,7 @@ function PluginPill(props: { pill: ComposerPill; input: ComposerPillProps; align
|
||||
<Popover
|
||||
open={state.open}
|
||||
onOpenChange={(open) => setState("open", open)}
|
||||
placement={placement()}
|
||||
placement={composerLanePlacement(alignment())}
|
||||
gutter={8}
|
||||
>
|
||||
<Popover.Trigger
|
||||
@@ -105,7 +102,7 @@ function PluginPill(props: { pill: ComposerPill; input: ComposerPillProps; align
|
||||
type="button"
|
||||
data-slot="session-plugin-pill"
|
||||
aria-label={current().title}
|
||||
class={capsule}
|
||||
data-composer-pill
|
||||
>
|
||||
<Content view={current()} />
|
||||
</Popover.Trigger>
|
||||
@@ -113,7 +110,8 @@ function PluginPill(props: { pill: ComposerPill; input: ComposerPillProps; align
|
||||
<Popover.Content
|
||||
data-slot="session-plugin-pill-popover"
|
||||
aria-label={current().title ?? current().label}
|
||||
class="w-80 max-w-[calc(100vw-56px)] rounded-[10px] border-[0.5px] border-v2-border-border-muted bg-v2-background-bg-layer-01 p-1 shadow-[var(--v2-elevation-floating)] outline-none"
|
||||
data-composer-pill-panel
|
||||
class="w-80 p-1"
|
||||
>
|
||||
<div class="px-2 pt-1 pb-1.5 text-[11px] font-[530] tracking-[0.05px] leading-[var(--line-height-tight)] text-v2-text-text-faint">
|
||||
<span dir="auto" class="line-clamp-3 break-words">
|
||||
@@ -139,13 +137,13 @@ function PluginPill(props: { pill: ComposerPill; input: ComposerPillProps; align
|
||||
</Match>
|
||||
<Match when={current().rows}>
|
||||
{(rows) => (
|
||||
<Menu gutter={8} placement={placement()}>
|
||||
<Menu gutter={8} placement={composerLanePlacement(alignment())}>
|
||||
<Menu.Trigger
|
||||
as="button"
|
||||
type="button"
|
||||
data-slot="session-plugin-pill"
|
||||
aria-label={current().title}
|
||||
class={capsule}
|
||||
data-composer-pill
|
||||
>
|
||||
<Content view={current()} />
|
||||
</Menu.Trigger>
|
||||
|
||||
@@ -1,52 +1,19 @@
|
||||
[data-color-scheme="dark"] [data-slot="session-todo-pill"] {
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
[data-composer-pill][data-slot="session-todo-pill"] {
|
||||
gap: 6px;
|
||||
padding-inline-start: 8px;
|
||||
}
|
||||
|
||||
/* The activity capsule's overlays and focus ring. */
|
||||
[data-slot="session-todo-pill"] {
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--v2-border-border-focus);
|
||||
outline-offset: 2.5px;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
&:hover:not(:active, [data-expanded]) {
|
||||
background-image: linear-gradient(var(--v2-overlay-simple-overlay-hover), var(--v2-overlay-simple-overlay-hover));
|
||||
}
|
||||
}
|
||||
|
||||
&:is(:active, [data-expanded]) {
|
||||
background-image: linear-gradient(
|
||||
var(--v2-overlay-simple-overlay-pressed),
|
||||
var(--v2-overlay-simple-overlay-pressed)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="session-todo-panel"] {
|
||||
width: 320px;
|
||||
max-width: calc(100vw - 56px);
|
||||
padding-top: 6px;
|
||||
border: 0.5px solid var(--v2-border-border-muted);
|
||||
border-radius: 10px;
|
||||
background: var(--v2-background-bg-layer-01);
|
||||
box-shadow: var(--v2-elevation-floating);
|
||||
transform-origin: var(--kb-popover-content-transform-origin);
|
||||
animation: session-todo-panel-in 150ms ease-out;
|
||||
}
|
||||
|
||||
@keyframes session-todo-panel-in {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(4px) scale(0.98);
|
||||
}
|
||||
[data-composer-pill-panel][data-slot="session-todo-panel"] {
|
||||
width: max-content;
|
||||
min-width: max(var(--kb-popper-anchor-width, 0px), 240px);
|
||||
max-width: min(400px, calc(100vw - 56px));
|
||||
}
|
||||
|
||||
[data-slot="session-todo-glyph"] {
|
||||
color: var(--v2-icon-icon-faint);
|
||||
|
||||
&[data-status="in_progress"] {
|
||||
color: var(--v2-icon-icon-accent);
|
||||
color: var(--v2-state-fg-warning);
|
||||
}
|
||||
|
||||
&[data-status="completed"] {
|
||||
@@ -54,50 +21,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="session-todo-pulse"] {
|
||||
transform-box: fill-box;
|
||||
transform-origin: center;
|
||||
animation: session-todo-pulse 1.6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes session-todo-pulse {
|
||||
50% {
|
||||
transform: scale(0.6);
|
||||
opacity: 0.55;
|
||||
}
|
||||
}
|
||||
|
||||
[data-slot="session-todo-row"] {
|
||||
&[data-status="in_progress"] {
|
||||
background: var(--v2-overlay-simple-overlay-hover);
|
||||
[data-slot="session-todo-text"] {
|
||||
color: var(--v2-text-text-muted);
|
||||
}
|
||||
|
||||
[data-slot="session-todo-text"] {
|
||||
font-weight: 530;
|
||||
}
|
||||
&[data-status="in_progress"] [data-slot="session-todo-text"] {
|
||||
color: var(--v2-text-text-base);
|
||||
}
|
||||
|
||||
&:is([data-status="completed"], [data-status="cancelled"]) [data-slot="session-todo-text"] {
|
||||
color: var(--v2-text-text-faint);
|
||||
}
|
||||
|
||||
&[data-status="cancelled"] [data-slot="session-todo-text"] {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
}
|
||||
|
||||
:root[data-motion="reduce"] :is([data-slot="session-todo-pulse"], [data-slot="session-todo-panel"]) {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
[data-slot="session-todo-pulse"],
|
||||
[data-slot="session-todo-panel"] {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (hover: none) {
|
||||
[data-slot="session-todo-pill"] {
|
||||
min-height: 44px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,24 @@ const plan = [
|
||||
"Run the app typecheck",
|
||||
]
|
||||
|
||||
// `progress` todos are done, the next one is in progress and the rest are pending.
|
||||
const todosAt = (progress: number): Todo[] =>
|
||||
type Scenario = "plan" | "cancelled" | "parallel"
|
||||
|
||||
// `progress` todos are done, the next one is in progress and the rest are pending. `cancelled` drops the last todo,
|
||||
// and `parallel` runs the two after `progress` at once.
|
||||
const todosAt = (progress: number, scenario: Scenario): Todo[] =>
|
||||
plan.map((content, index) => ({
|
||||
content,
|
||||
status: index < progress ? "completed" : index === progress ? "in_progress" : "pending",
|
||||
status:
|
||||
index < progress
|
||||
? "completed"
|
||||
: index === progress || (scenario === "parallel" && index === progress + 1)
|
||||
? "in_progress"
|
||||
: scenario === "cancelled" && index === plan.length - 1
|
||||
? "cancelled"
|
||||
: "pending",
|
||||
}))
|
||||
|
||||
const activity: { subagents: SessionActivityItem[]; shells: SessionActivityItem[] } = {
|
||||
const activity = {
|
||||
subagents: [
|
||||
{
|
||||
key: "ses_child_audit",
|
||||
@@ -47,7 +57,7 @@ const activity: { subagents: SessionActivityItem[]; shells: SessionActivityItem[
|
||||
started: Date.now() - 341_000,
|
||||
},
|
||||
],
|
||||
}
|
||||
} satisfies { subagents: SessionActivityItem[]; shells: SessionActivityItem[] }
|
||||
|
||||
function document(todos: Todo[]): SessionDocument {
|
||||
const messages: SessionMessageInfo[] = [
|
||||
@@ -86,10 +96,10 @@ function document(todos: Todo[]): SessionDocument {
|
||||
return { sessionID: CURRENT_SESSION_ID, messages, status: { type: "busy" }, diffs: [] }
|
||||
}
|
||||
|
||||
type PreviewArgs = { progress: number; open: boolean; activity: boolean }
|
||||
type PreviewArgs = { progress: number; scenario: Scenario; open: boolean; activity: boolean }
|
||||
|
||||
function Preview(props: PreviewArgs) {
|
||||
const value = createMemo(() => document(todosAt(props.progress)))
|
||||
const value = createMemo(() => document(todosAt(props.progress, props.scenario)))
|
||||
|
||||
onMount(() =>
|
||||
setTimeout(() => {
|
||||
@@ -114,9 +124,10 @@ export default {
|
||||
title: "OpenCode/Session/Todo pill",
|
||||
id: "session-todo-pill",
|
||||
render: (args: PreviewArgs) => <Preview {...args} />,
|
||||
args: { progress: 3, open: false, activity: true },
|
||||
args: { progress: 3, scenario: "plan", open: false, activity: true },
|
||||
argTypes: {
|
||||
progress: { control: { type: "range", min: 0, max: 7, step: 1 } },
|
||||
scenario: { control: { type: "select" }, options: ["plan", "cancelled", "parallel"] },
|
||||
open: { control: { type: "boolean" } },
|
||||
activity: { control: { type: "boolean" } },
|
||||
},
|
||||
@@ -136,3 +147,7 @@ export const Collapsed = {}
|
||||
export const Open = { args: { open: true } }
|
||||
|
||||
export const WithoutActivity = { args: { activity: false } }
|
||||
|
||||
export const Cancelled = { args: { scenario: "cancelled", open: true } }
|
||||
|
||||
export const SeveralInProgress = { args: { scenario: "parallel", open: true } }
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
import { Popover } from "@kobalte/core/popover"
|
||||
import { AnimatedNumber } from "@opencode/ui/animated-number"
|
||||
import { ProgressCircle } from "@opencode/ui/progress-circle"
|
||||
import { createEffect, createMemo, For, on, Show } from "solid-js"
|
||||
import { Badge } from "@opencode/ui/badge"
|
||||
import { createEffect, createMemo, For, Match, on, Show, Switch } from "solid-js"
|
||||
import { createStore } from "solid-js/store"
|
||||
import { useLanguage } from "@/runtime/i18n/language"
|
||||
import { useComposerLaneAlignment } from "./composer-lane"
|
||||
import { currentTodo, todoFinished, type Todo, type TodoStatus } from "./todos"
|
||||
import { composerLanePlacement, useComposerLaneAlignment } from "./composer-lane"
|
||||
import { currentTodo, type Todo, type TodoStatus } from "./todos"
|
||||
import "./todo-pill.css"
|
||||
|
||||
// The agent's plan as one capsule in the composer lane, beside the background activity capsule: progress and the todo
|
||||
// in hand, opening a popover with the whole list.
|
||||
// The agent's plan as one capsule in the composer lane, beside the background activity capsule: the todo in hand,
|
||||
// opening a popover with the whole list.
|
||||
export function SessionTodoPill(props: { todos: readonly Todo[]; defaultOpen?: boolean }) {
|
||||
const language = useLanguage()
|
||||
const alignment = useComposerLaneAlignment()
|
||||
const [state, setState] = createStore({ open: props.defaultOpen ?? false })
|
||||
|
||||
const done = createMemo(() => props.todos.filter((todo) => todo.status === "completed").length)
|
||||
const finished = createMemo(() => props.todos.filter(todoFinished).length)
|
||||
const current = createMemo(() => currentTodo(props.todos))
|
||||
// The pill names the first todo in progress and counts the others running beside it.
|
||||
const more = createMemo(() => Math.max(0, props.todos.filter((todo) => todo.status === "in_progress").length - 1))
|
||||
const label = () => language.plural("session.todo.label", props.todos.length, { done: String(done()) })
|
||||
const placement = () => (({ center: "top", start: "top-start", end: "top-end" }) as const)[alignment()]
|
||||
|
||||
return (
|
||||
// Sits beside the activity capsule, on the side away from the lane's aligned edge.
|
||||
@@ -28,44 +27,37 @@ export function SessionTodoPill(props: { todos: readonly Todo[]; defaultOpen?: b
|
||||
class="flex min-w-0 shrink"
|
||||
classList={{ "-order-1": alignment() === "end", "order-1": alignment() !== "end" }}
|
||||
>
|
||||
<Popover open={state.open} onOpenChange={(open) => setState("open", open)} placement={placement()} gutter={8}>
|
||||
<Popover
|
||||
open={state.open}
|
||||
onOpenChange={(open) => setState("open", open)}
|
||||
placement={composerLanePlacement(alignment())}
|
||||
gutter={8}
|
||||
>
|
||||
<Popover.Trigger
|
||||
as="button"
|
||||
type="button"
|
||||
data-slot="session-todo-pill"
|
||||
data-composer-pill
|
||||
aria-label={label()}
|
||||
class="pointer-events-auto flex h-7 min-w-0 max-w-full items-center gap-2 rounded-[12px] border-[0.5px] border-v2-border-border-muted bg-v2-background-bg-base ps-2.5 pe-2.5 text-[13px] font-[440] leading-text-compact tracking-[-0.04px] whitespace-nowrap text-v2-text-text-base shadow-[var(--v2-elevation-raised)] outline-none"
|
||||
>
|
||||
<ProgressCircle
|
||||
percentage={props.todos.length ? (finished() / props.todos.length) * 100 : 0}
|
||||
size={14}
|
||||
strokeWidth={2}
|
||||
class="shrink-0"
|
||||
/>
|
||||
<span data-slot="session-todo-count" class="shrink-0 tabular-nums text-v2-text-text-muted">
|
||||
{language
|
||||
.t("session.todo.progress", { done: "\u0000", total: String(props.todos.length) })
|
||||
.split("\u0000")
|
||||
.flatMap((part, index) => (index === 0 ? [part] : [<AnimatedNumber value={done()} />, part]))}
|
||||
</span>
|
||||
<Show when={current()}>
|
||||
{(todo) => (
|
||||
<span dir="auto" class="min-w-0 max-w-[260px] truncate">
|
||||
{todo().content}
|
||||
</span>
|
||||
<>
|
||||
<TodoGlyph status={todo().status} />
|
||||
<span dir="auto" class="min-w-0 max-w-[260px] truncate">
|
||||
{todo().content}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</Show>
|
||||
<Show when={more() > 0}>
|
||||
<Badge data-slot="session-todo-more" dir="ltr" class="shrink-0">
|
||||
{language.t("session.todo.moreInProgress", { count: String(more()) })}
|
||||
</Badge>
|
||||
</Show>
|
||||
</Popover.Trigger>
|
||||
<Popover.Portal>
|
||||
<Popover.Content data-slot="session-todo-panel" aria-label={label()} class="outline-none">
|
||||
<div class="flex items-center gap-2 px-2 pt-1 pb-1.5">
|
||||
<span class="flex-1 text-[11px] font-[530] uppercase leading-[var(--line-height-tight)] tracking-[0.05px] text-v2-text-text-muted">
|
||||
{language.t("session.todo.title")}
|
||||
</span>
|
||||
<span class="text-[11px] tabular-nums leading-[var(--line-height-tight)] text-v2-text-text-faint">
|
||||
{language.t("session.todo.progress", { done: String(done()), total: String(props.todos.length) })}
|
||||
</span>
|
||||
</div>
|
||||
<Popover.Content data-slot="session-todo-panel" data-composer-pill-panel aria-label={label()}>
|
||||
<TodoList todos={props.todos} />
|
||||
</Popover.Content>
|
||||
</Popover.Portal>
|
||||
@@ -93,20 +85,22 @@ function TodoList(props: { todos: readonly Todo[] }) {
|
||||
ref={list}
|
||||
data-slot="session-todo-list"
|
||||
data-scrollable
|
||||
class="flex max-h-[232px] flex-col overflow-y-auto px-1 pb-1"
|
||||
class="flex max-h-[232px] flex-col overflow-y-auto p-1"
|
||||
>
|
||||
<For each={props.todos}>
|
||||
{(todo) => (
|
||||
<div
|
||||
data-slot="session-todo-row"
|
||||
data-status={todo.status}
|
||||
class="flex min-h-7 shrink-0 items-start gap-2 rounded-[4px] px-1.5 py-1.5"
|
||||
class="flex shrink-0 items-start gap-2 rounded-[4px] px-1.5 py-1"
|
||||
>
|
||||
<TodoGlyph status={todo.status} />
|
||||
<span class="flex h-5 shrink-0 items-center">
|
||||
<TodoGlyph status={todo.status} />
|
||||
</span>
|
||||
<span
|
||||
dir="auto"
|
||||
data-slot="session-todo-text"
|
||||
class="min-w-0 flex-1 text-[13px] leading-[var(--line-height-compact)]"
|
||||
class="min-w-0 flex-1 text-[13px] leading-[var(--line-height-base)] tracking-[-0.04px]"
|
||||
>
|
||||
{todo.content}
|
||||
</span>
|
||||
@@ -129,31 +123,18 @@ function TodoGlyph(props: { status: TodoStatus }) {
|
||||
aria-hidden="true"
|
||||
class="shrink-0"
|
||||
>
|
||||
<Show when={props.status === "completed"}>
|
||||
<circle cx="8" cy="8" r="6" fill="currentColor" />
|
||||
<path
|
||||
d="M5.4 8.2 7.2 9.9 10.6 6.2"
|
||||
stroke="var(--v2-background-bg-base)"
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</Show>
|
||||
<Show when={props.status !== "completed"}>
|
||||
<circle
|
||||
cx="8"
|
||||
cy="8"
|
||||
r="5.5"
|
||||
stroke="currentColor"
|
||||
stroke-dasharray={props.status === "pending" ? "2.2 1.9" : undefined}
|
||||
/>
|
||||
</Show>
|
||||
<Show when={props.status === "in_progress"}>
|
||||
<circle data-slot="session-todo-pulse" cx="8" cy="8" r="2.75" fill="currentColor" />
|
||||
</Show>
|
||||
<Show when={props.status === "cancelled"}>
|
||||
<path d="M5.5 8h5" stroke="currentColor" stroke-linecap="round" />
|
||||
</Show>
|
||||
<circle cx="8" cy="8" r="6.5" stroke="currentColor" />
|
||||
<Switch>
|
||||
<Match when={props.status === "in_progress"}>
|
||||
<path d="M8 4a4 4 0 0 0 0 8V4Z" fill="currentColor" />
|
||||
</Match>
|
||||
<Match when={props.status === "completed"}>
|
||||
<path d="M5 8 7.5 11 11 5.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</Match>
|
||||
<Match when={props.status === "cancelled"}>
|
||||
<path d="M3.5 12.5 12.5 3.5" stroke="currentColor" />
|
||||
</Match>
|
||||
</Switch>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ import { holdLandingWidth } from "@/shell/panel-motion"
|
||||
|
||||
const fallbackItemSize = 60
|
||||
|
||||
// Reserved below the last row: a 36px lane for the live status row and its background hint, an 8px gap, then a 28px
|
||||
// Reserved below the last row: a 36px lane for the live status row and its background hint, an 8px gap, then a 32px
|
||||
// activity pill and its 10px composer gap. Both come and go inside it, so neither moves the rows above.
|
||||
const tailSize = 82
|
||||
const tailSize = 86
|
||||
|
||||
const pendingMarkdown = '[data-component="markdown"]:not([data-markdown-ready])'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user