Skip to content
Merged
145 changes: 145 additions & 0 deletions packages/app/e2e/snap/right-panel-titlebar.snap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import { expect, type Page } from "@playwright/test"
import type { Todo } from "@opencode-ai/sdk/v2/client"
import { openRightPanel, openSidebar } from "../actions"
import { test } from "../fixtures"
import { sessionItemSelector } from "../selectors"
import { applyDarkModeForTests } from "../utils"
import { composeGrid, snapOutputPath, type Shot } from "./_compose"

// Seed four todos covering every status — completed / in_progress / pending /
// cancelled — so the Status tab shows real content (not the "No todos yet"
// empty state). Same approach as status-summary-todos.snap.ts.
async function updateTodos(input: {
url: string
directory: string
sessionID: string
todos: Array<Pick<Todo, "content" | "status" | "priority">>
}) {
const response = await fetch(
`${input.url}/session/__e2e/update-todos?directory=${encodeURIComponent(input.directory)}`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ sessionID: input.sessionID, todos: input.todos }),
},
)
if (response.status !== 204) {
throw new Error(`updateTodos failed: ${response.status} ${await response.text()}`)
}
}

// Right-panel + titlebar shell composition. This target exists to verify the
// visual contract between the titlebar's right edge and the right panel:
//
// 1) The right-panel tab row (Status / Files / …) lives INSIDE the titlebar,
// portalled from <SessionSidePanel> into <Titlebar>'s `pawwork-titlebar-tabs`
// slot, so the tabs read as window chrome instead of a second toolbar.
// 2) The titlebar's `border-l border-border-weaker` at the tab slot's left
// edge must align pixel-for-pixel with the panel body's `border-l` below it
// — one continuous 1px separator from top of titlebar to bottom of viewport.
//
// We capture full-viewport (fullPage: false) so the seam between chrome and
// body is visible in one frame. Component-level crops would hide exactly the
// alignment we are checking. Both light and dark are captured because the seam
// is most fragile in dark mode where `--border-weaker` is only a hair lighter
// than `--bg-base`.

// reducedMotion: "reduce" trips the layout shell's `motion-reduce:transition-none`,
// which kills the 240ms --right-panel-width transition. Without this, Playwright's
// stability check keeps blocking clicks on tabs/buttons sitting on the moving slot.
test.use({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 2, reducedMotion: "reduce" })

// Open Files and Review in the right-panel tab strip via the "+" dropdown.
// We want the snap to capture the multi-tab layout (active indicator, gap
// between tabs, alignment with the body) rather than just the single Status
// pill. Status is non-closable so always present; the other two cover the
// closable + active-state variants.
async function openExtraTabs(page: Page) {
// Use the registered command keybinds rather than clicking the "+" dropdown.
// The dropdown trigger lives in the portalled titlebar tab slot, where
// Playwright's hit-test mis-attributes pointer-events to the right-panel
// body below (z-stacking false positive). Keybinds bypass the issue entirely
// and are stable across platforms via ControlOrMeta.
// fileTree.toggle → mod+\
// review.toggle → mod+shift+r
// Registered in packages/app/src/pages/session/use-session-commands.tsx.
// Focus the main app region first so the global keybind dispatcher receives
// the events (Playwright otherwise can dispatch from the document root before
// any element is focused).
await page.locator("main").first().click()
await page.keyboard.press("ControlOrMeta+\\")
await page.keyboard.press("ControlOrMeta+Shift+R")
// Wait for the openTabs side-effect to propagate before we click Status —
// otherwise the snap can race the tab list update and capture a single-tab
// strip when we expect three.
await expect.poll(() => page.getByRole("tab").count(), { timeout: 5_000 }).toBe(3)
// Click Status so the snap captures Status-active (the default landing tab)
// rather than whichever extra tab opened last.
await page.getByRole("tab", { name: "Status" }).click()
}

async function captureRightPanelShell(
page: Page,
label: "light" | "dark",
project: { url: string; directory: string },
sessionID: string,
todos: Array<Pick<Todo, "content" | "status" | "priority">>,
): Promise<Shot> {
// Sidebar → click session item: same navigation as status-summary-todos.snap.ts.
// Direct route navigation is fragile because session routes carry directory state
// that the sidebar entry already encodes.
await openSidebar(page)
await page.locator(sessionItemSelector(sessionID)).click()
await openRightPanel(page)
await openExtraTabs(page)
// Re-seed todos every capture. applyDarkModeForTests calls page.reload, which
// wipes the in-memory sync cache; re-posting is cheaper and more deterministic
// than waiting for the session_todo stream to re-hydrate after reload.
await updateTodos({ url: project.url, directory: project.directory, sessionID, todos })
await expect
.poll(() => page.locator('[data-slot="status-summary-todo"]').count(), { timeout: 15_000 })
.toBe(todos.length)
// Move the pointer to a neutral spot so no hover/tooltip is captured on top
// of the tab strip (the openRightPanel button otherwise leaves a tooltip).
await page.mouse.move(0, 0)
// animations: "disabled" freezes the right-panel width transition so width is
// stable when we snapshot, otherwise the tab portal's `right: var(--right-panel-width)`
// can capture mid-tween.
return { name: label, buf: await page.screenshot({ fullPage: false, animations: "disabled" }) }
}

test("right-panel-titlebar", async ({ page, project }) => {
test.setTimeout(180_000)

let sessionID: string | undefined
await project.open({
beforeGoto: async ({ sdk }) => {
const session = await sdk.session.create({ title: "snap right panel titlebar" }).then((res) => res.data)
sessionID = session?.id
},
})
if (!sessionID) throw new Error("Session create did not return an id")
project.trackSession(sessionID)

// Realistic Progress content — five todos across every marker variant. Picked
// from a believable PR cleanup session so the snap reads as a real moment of
// work, not lorem-ipsum placeholders.
const todos: Array<Pick<Todo, "content" | "status" | "priority">> = [
{ content: "Audit session-status-summary tokens against DESIGN.md", status: "completed", priority: "high" },
{ content: "Wire portal slot in titlebar for right-panel tabs", status: "completed", priority: "high" },
{ content: "Verify hairline alignment across mac & windows chrome", status: "in_progress", priority: "high" },
{ content: "Sweep stale 'No connections' empty-state copy", status: "pending", priority: "medium" },
{ content: "Drop the brand underline on active tab", status: "cancelled", priority: "low" },
]

const shots: Shot[] = []

shots.push(await captureRightPanelShell(page, "light", project, sessionID, todos))

await applyDarkModeForTests(page)
shots.push(await captureRightPanelShell(page, "dark", project, sessionID, todos))

const out = snapOutputPath("right-panel-titlebar")
await composeGrid(shots, out)
process.stdout.write(`\n[snap] right-panel-titlebar grid -> ${out}\n\n`)
})
14 changes: 9 additions & 5 deletions packages/app/src/components/session/session-context-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ import { getSessionContextMetrics } from "./session-context-metrics"
import { estimateSessionContextBreakdown, type SessionContextBreakdownKey } from "./session-context-breakdown"
import { createSessionContextFormatter } from "./session-context-format"

// brand-primary alpha ladder: user gets the full brand color (focus), assistant/tool/system/other
// recede via decreasing alpha. Hardcoded rgba (not color-mix(..., transparent)) per PawWork pierre
// convention — Safari's non-premultiplied interpolation can shift the apparent hue.
// Previous syntax-* tokens violated DESIGN.md (those are reserved for code highlighting).
const BREAKDOWN_COLOR: Record<SessionContextBreakdownKey, string> = {
system: "var(--syntax-info)",
user: "var(--syntax-success)",
assistant: "var(--syntax-property)",
tool: "var(--syntax-warning)",
other: "var(--syntax-comment)",
system: "rgba(255, 89, 16, 0.30)",
user: "var(--brand-primary)",
assistant: "rgba(255, 89, 16, 0.70)",
tool: "rgba(255, 89, 16, 0.45)",
other: "rgba(255, 89, 16, 0.18)",
Comment thread
Astro-Han marked this conversation as resolved.
Resolved
}

function Stat(props: { label: string; value: JSX.Element }) {
Expand Down
77 changes: 57 additions & 20 deletions packages/app/src/components/session/session-sortable-shell-tab.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,88 @@
import type { JSX } from "solid-js"
import { Show, type JSX } from "solid-js"
import { createSortable } from "@thisbeyond/solid-dnd"
import { IconButton } from "@opencode-ai/ui/icon-button"
import { Icon } from "@opencode-ai/ui/icon"
import { Tabs } from "@opencode-ai/ui/tabs"
import { Tooltip } from "@opencode-ai/ui/tooltip"
import { useLanguage } from "@/context/language"
import type { RightPanelTab } from "@/pages/session/right-panel-tabs"

/**
* Right-panel shell tab. Renders as `icon + label`; on a closable tab, hovering
* the leading icon swaps it in place for a close-small × — same 14×14 slot, no
* layout shift, so closable and non-closable tabs share an identical resting
* width. The active tab is marked by a 2px brand underline (handled in
* packages/ui/src/components/tabs.css for `data-variant="sidepanel"`) — chip
* backgrounds are intentionally absent so the strip reads as titlebar chrome
* rather than a competing toolbar.
*
* Click target rules:
* - Click on the icon area:
* • closable + hovered → close (stopPropagation, so Tabs.Trigger doesn't
* also fire the value-change).
* • otherwise → falls through to Tabs.Trigger, selecting the tab.
* - Click anywhere else on the tab → Tabs.Trigger handles the selection.
* - Middle-click anywhere → close (existing onMiddleClick contract).
*/
export function ShellTab(props: {
value: RightPanelTab
label: string
closable: boolean
onClose: (tab: RightPanelTab) => void
children: JSX.Element
icon: JSX.Element
}): JSX.Element {
const language = useLanguage()
const close = () => {
if (!props.closable) return
props.onClose(props.value)
}

const swap = (
<span
data-slot="tab-icon-swap"
data-closable={props.closable || undefined}
class="relative inline-flex items-center justify-center size-3.5"
onClick={(event) => {
if (!props.closable) return
event.stopPropagation()
event.preventDefault()
close()
}}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
>
<span
data-slot="tab-icon-default"
class="absolute inset-0 inline-flex items-center justify-center transition-opacity duration-100"
>
{props.icon}
</span>
<Show when={props.closable}>
<span
data-slot="tab-icon-close"
class="absolute inset-0 inline-flex items-center justify-center opacity-0 transition-opacity duration-100"
>
<Icon name="close-small" class="text-fg-weak" />
</span>
</Show>
</span>
)
Comment thread
Astro-Han marked this conversation as resolved.
Resolved

return (
<div class="h-full flex items-center">
<Tabs.Trigger
value={props.value}
class="shrink-0 h-7"
class="shrink-0 h-full"
classes={{
button:
"h-7 min-h-7 inline-flex items-center whitespace-nowrap rounded-md text-h3 text-fg-weak gap-1.5 px-2.5",
}}
closeButton={
props.closable ? (
<Tooltip value={language.t("common.closeTab")} placement="bottom" gutter={10}>
<IconButton
icon="close-small"
variant="ghost"
class="h-5 w-5"
onClick={close}
aria-label={language.t("common.closeTab")}
/>
</Tooltip>
) : undefined
}
hideCloseButton
onMiddleClick={close}
aria-label={props.label}
>
{props.children}
<Show when={props.closable} fallback={swap}>
<Tooltip value={language.t("common.closeTab")} placement="bottom" gutter={10} openDelay={400}>
{swap}
</Tooltip>
</Show>
<span>{props.label}</span>
</Tabs.Trigger>
</div>
)
Expand All @@ -56,7 +93,7 @@ export function SortableShellTab(props: {
label: string
closable: boolean
onClose: (tab: RightPanelTab) => void
children: JSX.Element
icon: JSX.Element
}): JSX.Element {
const sortable = createSortable(props.value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function SectionRow(props: {
return "bg-border-weak"
}
return (
<div class="border-b border-border-weaker last:border-b-0">
<div>
<button
type="button"
class="flex items-center gap-2 w-full px-4 py-2.5 hover:bg-surface-raised text-left"
Expand Down Expand Up @@ -172,9 +172,12 @@ export function SessionStatusConnections(props: { shown: Accessor<boolean> }) {
}),
)

// Matches the breathing-room rhythm of Section in session-status-summary:
// 24px top padding pulls this block away from Sources above; no hairline
// separator (sections distinguish themselves by space alone).
return (
<div class="flex flex-col">
<div class="text-h3 uppercase tracking-wide text-fg-weaker px-4 py-3 pb-1">
<div class="flex flex-col pt-6">
<div class="text-caption text-fg-weak px-4 pb-2">
{language.t("status.connections.title")}
</div>

Expand Down Expand Up @@ -297,7 +300,7 @@ export function SessionStatusConnections(props: { shown: Accessor<boolean> }) {
</Show>
</SectionRow>

<div class="px-4 py-3">
<div class="px-4 pt-2 pb-6">
<Button variant="secondary" class="px-3 py-1.5" onClick={openServerPicker}>
{language.t("status.popover.action.manageServers")}
</Button>
Expand Down
16 changes: 12 additions & 4 deletions packages/app/src/components/session/session-status-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import { selectSessionTodos } from "@/pages/session/session-todos"
import type { SessionTodoItem } from "@/pages/session/todos/todo-model"

function Section(props: { title: string; children: JSX.Element }) {
// No divider — sections are separated by 24px of breathing room only.
// Hairlines felt too "boxed in" against the warm-neutral surface; the
// generous py-6 (24px top + 24px bottom = 48px between sections) reads
// as a calm pause without enclosing each section in chrome.
return (
<div class="flex flex-col gap-2 px-4 py-3">
<div class="text-h3 uppercase tracking-wide text-fg-weaker">{props.title}</div>
<div class="flex flex-col gap-2 px-4 py-6">
<div class="text-caption text-fg-weak">{props.title}</div>
{props.children}
</div>
)
Expand Down Expand Up @@ -65,8 +69,12 @@ export function SessionStatusSummary(props: {
)
const sources = createMemo(() => extractSources(props.parts()))

// No outer wrapper — Section components attach directly to SessionStatusPanel's
// scroll container, so the first:border-t-0 selector correctly drops the leading
// hairline regardless of whether SessionStatusSummary's siblings (e.g.
// SessionStatusConnections below) come first or last in the DOM.
return (
<div class="flex flex-col">
<>
<Section title={language.t("status.summary.progress")}>
<Show when={todos().length > 0} fallback={<Empty text={language.t("status.summary.progress.empty")} />}>
<div class="flex flex-col">
Expand All @@ -82,6 +90,6 @@ export function SessionStatusSummary(props: {
</div>
</Show>
</Section>
</div>
</>
)
}
Loading
Loading