mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-29 03:24:54 +00:00
feat(app): project icons stay put; status spins on the right (#57469)
This commit is contained in:
parent
c040d9953f
commit
f930ff3fc7
10 changed files with 186 additions and 99 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { expect, test, type Locator, type Page } from "@playwright/test"
|
||||
import type { OpenCodeEvent, WorktreeDirectory } from "@opencode/client/promise"
|
||||
import { draftHref, expectPath, NO_PROVIDER, project, provider, seed, sessionHref, T0 } from "../utils/app"
|
||||
import { mockOpenCodeServer, type MockAnswer } from "../utils/mock-server"
|
||||
import { mockOpenCodeServer } from "../utils/mock-server"
|
||||
import { newSessionLocation, openDraft, openSession, openWorktreeDraft, type WorkspaceInput } from "../utils/workspace"
|
||||
|
||||
const directory = "C:/OpenCode/WorkspacePending"
|
||||
|
|
@ -37,7 +37,7 @@ const pendingDraft = {
|
|||
createdSessionTitle: "Created workspace session",
|
||||
} satisfies WorkspaceInput & { draftID: string }
|
||||
|
||||
const failFirstCreate = (_: unknown, attempt: number): MockAnswer | undefined =>
|
||||
const failFirstCreate: NonNullable<WorkspaceInput["onSessionCreate"]> = (_body, attempt) =>
|
||||
attempt === 1 ? { status: 500, body: { message: "Session creation failed in the fixture" } } : undefined
|
||||
|
||||
test.use({
|
||||
|
|
@ -179,7 +179,11 @@ test("a pending worktree session shows immediately, keeps its draft, and hands o
|
|||
const label = page.locator('[data-titlebar-tab-slot][data-active="true"] [data-titlebar-tab-title]')
|
||||
await expect(label).toHaveText("Session")
|
||||
const pending = await submitPending(page, mock)
|
||||
const spinner = tabLink(page, pending.sessionID).locator('[data-component="session-progress-indicator-v2"]')
|
||||
|
||||
const spinner = page.locator(
|
||||
`[data-titlebar-tab-slot]:has(a[href="${sessionHref(pending.sessionID)}"]) [data-component="activity-ring"]`,
|
||||
)
|
||||
|
||||
await expect(spinner).toBeVisible()
|
||||
await expect(label).toHaveText("Session")
|
||||
|
||||
|
|
@ -276,9 +280,7 @@ test("the title and message stay stable through worktree creation", async ({ pag
|
|||
title: visible(title) ? title!.textContent : null,
|
||||
message: visible(document.querySelector('[data-component="user-message"]')),
|
||||
spinner: visible(
|
||||
document.querySelector(
|
||||
'[data-titlebar-tab-slot][data-active="true"] [data-component="session-progress-indicator-v2"]',
|
||||
),
|
||||
document.querySelector('[data-titlebar-tab-slot][data-active="true"] [data-component="activity-ring"]'),
|
||||
),
|
||||
draft: visible(editor) ? editor!.textContent : null,
|
||||
})
|
||||
|
|
@ -469,6 +471,7 @@ test("executes a selected slash command after creating its worktree", async ({ p
|
|||
},
|
||||
])
|
||||
// The server owns command expansion; the client receives the expanded inbox item.
|
||||
// SAFETY: the fixture event matches the generated OpenCodeEvent shape for its type.
|
||||
await mock.push([
|
||||
{
|
||||
id: "evt_workspace_review",
|
||||
|
|
@ -494,8 +497,10 @@ test("the location dialog lists every ready server's projects in one list and ta
|
|||
page,
|
||||
}) => {
|
||||
const apollo = "http://apollo.test:4096"
|
||||
|
||||
const entry = (id: string, directory: string, active: number) =>
|
||||
project({ id, directory, time: { created: T0, updated: T0, active: T0 + active } })
|
||||
|
||||
const remote = entry("proj_apollo_opencode", "/home/dax/opencode", 4)
|
||||
const files: string[] = []
|
||||
page.on("request", (request) => {
|
||||
|
|
@ -645,6 +650,7 @@ for (const row of [
|
|||
(response) => new URL(response.url()).pathname === "/api/worktree" && response.request().method() === "GET",
|
||||
)
|
||||
|
||||
// SAFETY: the fixture event matches the generated OpenCodeEvent shape for its type.
|
||||
await view.push([
|
||||
{
|
||||
id: "evt_accent_inventory",
|
||||
|
|
@ -657,6 +663,7 @@ for (const row of [
|
|||
await expect(page).toHaveURL(url)
|
||||
await expect(view.editor).toHaveText("Inspect this fixture workspace.")
|
||||
await expectBackground(send, "icon-button-contrast")
|
||||
// SAFETY: the fixture event matches the generated OpenCodeEvent shape for its type.
|
||||
await view.push([
|
||||
{
|
||||
id: "evt_accent_running",
|
||||
|
|
@ -674,6 +681,7 @@ for (const row of [
|
|||
}
|
||||
|
||||
function renamed(sessionID: string) {
|
||||
// SAFETY: the fixture event matches the generated OpenCodeEvent shape for its type.
|
||||
return {
|
||||
id: "evt_generated_title",
|
||||
type: "session.renamed",
|
||||
|
|
|
|||
|
|
@ -75,7 +75,8 @@ test("inactive session attention dots share the close control without marking th
|
|||
await page.goto(sessionHref(a.id))
|
||||
const tabA = page.locator(`[data-titlebar-tab-slot]:has(a[href="${sessionHref(a.id)}"])`)
|
||||
const tabB = page.locator(`[data-titlebar-tab-slot]:has(a[href="${sessionHref(b.id)}"])`)
|
||||
const dot = tabB.locator('[data-slot="tab-unread-dot"]')
|
||||
const dot = tabB.locator('[data-mark="attention"]')
|
||||
const status = tabB.locator('[data-slot="tab-status"]')
|
||||
const close = tabB.getByRole("button", { name: "Close tab", exact: true })
|
||||
await expect(tabA.locator('[data-slot="tab-title"]')).toHaveText(a.title)
|
||||
await expect(tabB.locator('[data-slot="tab-title"]')).toHaveText(b.title)
|
||||
|
|
@ -99,21 +100,21 @@ test("inactive session attention dots share the close control without marking th
|
|||
.toBeLessThan(1)
|
||||
|
||||
await tabB.hover()
|
||||
await expect(dot).toBeHidden()
|
||||
await expect(status).toHaveCSS("opacity", "0")
|
||||
await expect(close).toHaveCSS("opacity", "1")
|
||||
await page.mouse.move(0, 0)
|
||||
await tabB.locator("[data-titlebar-tab-link]").focus()
|
||||
await page.keyboard.press("Tab")
|
||||
await expect(close).toBeFocused()
|
||||
await expect(dot).toBeHidden()
|
||||
await expect(status).toHaveCSS("opacity", "0")
|
||||
await expect(close).toHaveCSS("opacity", "1")
|
||||
await close.blur()
|
||||
await expect(dot).toBeVisible()
|
||||
await expect(status).toHaveCSS("opacity", "1")
|
||||
|
||||
await tabB.locator("[data-titlebar-tab-link]").click()
|
||||
await expectPath(page, sessionHref(b.id))
|
||||
await expect(tabB).toHaveAttribute("data-active", "true")
|
||||
await expect(dot).toHaveCount(0)
|
||||
await expect(dot).toBeHidden()
|
||||
await tabA.locator("[data-titlebar-tab-link]").click()
|
||||
await expectPath(page, sessionHref(a.id))
|
||||
await page.mouse.move(0, 0)
|
||||
|
|
@ -218,7 +219,7 @@ test("option arrows move to the previous or next tab, and with shift to the next
|
|||
await page.goto(sessionHref(a.id))
|
||||
await page.mouse.move(0, 0)
|
||||
await expect(
|
||||
page.locator(`[data-titlebar-tab-slot]:has(a[href="${sessionHref(c.id)}"]) [data-slot="tab-unread-dot"]`),
|
||||
page.locator(`[data-titlebar-tab-slot]:has(a[href="${sessionHref(c.id)}"]) [data-mark="attention"]`),
|
||||
).toBeVisible()
|
||||
|
||||
await page.keyboard.press("Alt+ArrowDown")
|
||||
|
|
@ -310,13 +311,13 @@ for (const row of [
|
|||
await expect(tabA).toHaveAttribute("data-active", "true")
|
||||
await expect(tabA.locator('[data-slot="tab-close"]')).toBeVisible()
|
||||
await expect(tabB.locator('[data-slot="tab-close"]')).toBeVisible()
|
||||
await expect(tabB.locator('[data-slot="tab-unread-dot"]')).toBeVisible()
|
||||
await expect(tabB.locator('[data-slot="tab-unread-slot"]')).toHaveCSS("width", "20px")
|
||||
await expect(tabB.locator('[data-slot="tab-unread-slot"]')).toHaveCSS("height", "20px")
|
||||
await expect(tabB.locator('[data-mark="attention"]')).toBeVisible()
|
||||
await expect(tabB.locator('[data-slot="tab-status"]')).toHaveCSS("width", "20px")
|
||||
await expect(tabB.locator('[data-slot="tab-status"]')).toHaveCSS("height", "20px")
|
||||
await expect
|
||||
.poll(() =>
|
||||
tabB.evaluate((element) => {
|
||||
const dot = element.querySelector('[data-slot="tab-unread-slot"]')!.getBoundingClientRect()
|
||||
const dot = element.querySelector('[data-slot="tab-status"]')!.getBoundingClientRect()
|
||||
const close = element.querySelector('[data-slot="tab-close"]')!.getBoundingClientRect()
|
||||
|
||||
return dot.right <= close.left || dot.left >= close.right
|
||||
|
|
@ -670,9 +671,9 @@ test("a remote tab stays busy while a child session runs", async ({ page }) => {
|
|||
|
||||
const tabB = page.locator(`[data-titlebar-tab-slot]:has(a[href="${sessionHref(sessionB.id, REMOTE_SERVER)}"])`)
|
||||
const tabA = page.locator(`[data-titlebar-tab-slot]:has(a[href="${sessionHref(sessionA.id)}"])`)
|
||||
await expect(tabB.locator('[data-component="session-progress-indicator-v2"]')).toBeVisible()
|
||||
await expect(tabB.locator('[data-component="activity-ring"]')).toBeVisible()
|
||||
await expect(tabA.locator("[data-titlebar-tab-title]")).toHaveText(sessionA.title)
|
||||
await expect(tabA.locator('[data-component="session-progress-indicator-v2"]')).toHaveCount(0)
|
||||
await expect(tabA.locator('[data-component="activity-ring"]')).toBeHidden()
|
||||
})
|
||||
|
||||
test("inactive tabs stay busy while work waits in their inbox, and pulse on a new prompt, as in the TUI", async ({
|
||||
|
|
@ -703,11 +704,11 @@ test("inactive tabs stay busy while work waits in their inbox, and pulse on a ne
|
|||
})
|
||||
|
||||
const tab = (id: string) => page.locator(`[data-titlebar-tab-slot]:has(a[href="${sessionHref(id)}"])`)
|
||||
const progress = '[data-component="session-progress-indicator-v2"]'
|
||||
const progress = '[data-component="activity-ring"]'
|
||||
|
||||
await expect(tab(b.id).locator(progress)).toBeVisible()
|
||||
await expect(tab(c.id).locator("[data-titlebar-tab-title]")).toHaveText(c.title)
|
||||
await expect(tab(c.id).locator(progress)).toHaveCount(0)
|
||||
await expect(tab(c.id).locator(progress)).toBeHidden()
|
||||
await expect(tab(c.id).locator('[data-slot="tab-prompt-pulse"]')).toHaveCount(0)
|
||||
// The pulse lasts one animation, so record that it appeared rather than racing its removal.
|
||||
await tab(c.id).evaluate((element) => {
|
||||
|
|
@ -756,7 +757,7 @@ test("switching between busy sessions keeps the busy indicators and the activity
|
|||
await expectSessionTitle(page, a.title)
|
||||
|
||||
const sidebar = page.locator('[data-slot="vertical-tabs-sidebar"]')
|
||||
const indicators = sidebar.locator('[data-component="session-progress-indicator-v2"]')
|
||||
const indicators = sidebar.locator('[data-component="activity-ring"]')
|
||||
const capsule = page.locator('[data-slot="session-activity-chip"]')
|
||||
await expect(indicators).toHaveCount(2)
|
||||
await expect(capsule).toHaveText("1 subagent")
|
||||
|
|
@ -774,7 +775,7 @@ test("switching between busy sessions keeps the busy indicators and the activity
|
|||
record.setAttribute("data-test-capsule-missing", "")
|
||||
}).observe(document.body, { childList: true, subtree: true })
|
||||
document
|
||||
.querySelectorAll('[data-slot="vertical-tabs-sidebar"] [data-component="session-progress-indicator-v2"]')
|
||||
.querySelectorAll('[data-slot="vertical-tabs-sidebar"] [data-component="activity-ring"]')
|
||||
.forEach((element) => element.setAttribute("data-test-before-switch", ""))
|
||||
})
|
||||
|
||||
|
|
@ -813,7 +814,7 @@ test("selecting a tab with waiting work waits for its transcript instead of show
|
|||
})
|
||||
const tabB = page.locator(`[data-titlebar-tab-slot]:has(a[href="${sessionHref(b.id)}"])`)
|
||||
// The inactive tab read its inbox, which materializes the pending steer as a transcript row.
|
||||
await expect(tabB.locator('[data-component="session-progress-indicator-v2"]')).toBeVisible()
|
||||
await expect(tabB.locator('[data-component="activity-ring"]')).toBeVisible()
|
||||
|
||||
const transcript = await holdRoute(page, (url) => url.pathname === `/api/session/${b.id}/message`)
|
||||
await page.locator(`[data-titlebar-tab-link][href="${sessionHref(b.id)}"]`).click()
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ export function useSessionTabAvatarState(
|
|||
return sessionBusy(data, sessionId())
|
||||
})
|
||||
|
||||
return { unread, loading }
|
||||
return { unread, loading, attention: needsAttention }
|
||||
}
|
||||
|
||||
// Pending permission and form requests anywhere in the session (or its family, for roots).
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@
|
|||
justify-content: center;
|
||||
}
|
||||
|
||||
[data-titlebar-tab] :is([data-slot="tab-unread-dot"], [data-slot="tab-avatar-unread-dot"]) {
|
||||
position: absolute;
|
||||
[data-titlebar-tab] :is([data-slot="tab-status-dot"], [data-slot="tab-avatar-unread-dot"]) {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 9999px;
|
||||
|
|
@ -22,29 +21,54 @@
|
|||
position: relative;
|
||||
}
|
||||
|
||||
[data-titlebar-tab] :is([data-mark="attention"], [data-status="attention"] [data-slot="tab-avatar-unread-dot"]) {
|
||||
background: var(--v2-state-fg-warning);
|
||||
}
|
||||
|
||||
[data-titlebar-tab] [data-slot="tab-avatar-unread-dot"] {
|
||||
position: absolute;
|
||||
display: none;
|
||||
inset-inline-end: -3px;
|
||||
top: -3px;
|
||||
}
|
||||
|
||||
[data-titlebar-tab] [data-slot="tab-unread-slot"] {
|
||||
/* Status sits where the close button appears; marks and the hover swap change instantly. */
|
||||
[data-titlebar-tab] [data-slot="tab-status"] {
|
||||
position: absolute;
|
||||
inset-block: 0;
|
||||
inset-inline-end: 0;
|
||||
display: flex;
|
||||
display: grid;
|
||||
margin-block: auto;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
place-items: center;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
[data-titlebar-tab] [data-slot="tab-status"] > [data-mark] {
|
||||
grid-area: 1 / 1;
|
||||
display: none;
|
||||
}
|
||||
|
||||
[data-titlebar-tab][data-status="busy"] [data-mark="busy"],
|
||||
[data-titlebar-tab][data-status="attention"] [data-mark="attention"],
|
||||
[data-titlebar-tab][data-status="unread"] [data-mark="unread"] {
|
||||
display: block;
|
||||
}
|
||||
|
||||
[data-titlebar-tab] [data-slot="tab-close"] > button {
|
||||
transition: none;
|
||||
}
|
||||
|
||||
/* Every row, the active one included, shows the close button only on hover or keyboard focus. */
|
||||
[data-titlebar-tab]:is(:hover, :has(:focus-visible), [data-editing="true"]) [data-slot="tab-close"] > button {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
[data-titlebar-tab]:not(:where([data-slot="mobile-tabs-drawer"] *)):is(:hover, :has(:focus-visible))
|
||||
[data-slot="tab-unread-slot"] {
|
||||
display: none;
|
||||
[data-slot="tab-status"] {
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -116,8 +140,7 @@
|
|||
--tab-overlay: var(--v2-overlay-simple-overlay-pressed);
|
||||
}
|
||||
|
||||
[data-titlebar-tab]:is(:hover, :has(:focus-visible), [data-state="pressed"], [data-unread="true"])
|
||||
[data-slot="tab-close"] {
|
||||
[data-titlebar-tab]:is(:hover, :has(:focus-visible), [data-state="pressed"], [data-status]) [data-slot="tab-close"] {
|
||||
background: linear-gradient(var(--tab-overlay), var(--tab-overlay)), var(--tab-base);
|
||||
}
|
||||
|
||||
|
|
@ -197,9 +220,7 @@
|
|||
}
|
||||
|
||||
[data-titlebar-tab][data-title-overflow="true"]:not([data-editing="true"]) [data-slot="tab-link"],
|
||||
[data-titlebar-tab]:is(:hover, :has(:focus-visible), [data-active="true"], [data-unread="true"]):not(
|
||||
[data-editing="true"]
|
||||
)
|
||||
[data-titlebar-tab]:is(:hover, :has(:focus-visible), [data-active="true"], [data-status]):not([data-editing="true"])
|
||||
[data-slot="tab-link"] {
|
||||
--tab-title-fade-offset: calc(4px + var(--tab-link-inset, 0px));
|
||||
-webkit-mask-image: linear-gradient(
|
||||
|
|
@ -219,7 +240,7 @@
|
|||
}
|
||||
|
||||
[data-titlebar-tab][data-title-overflow="true"]:not([data-editing="true"]):dir(rtl) [data-slot="tab-link"],
|
||||
[data-titlebar-tab]:is(:hover, :has(:focus-visible), [data-active="true"], [data-unread="true"]):not(
|
||||
[data-titlebar-tab]:is(:hover, :has(:focus-visible), [data-active="true"], [data-status]):not(
|
||||
[data-editing="true"]
|
||||
):dir(rtl)
|
||||
[data-slot="tab-link"] {
|
||||
|
|
@ -239,9 +260,7 @@
|
|||
);
|
||||
}
|
||||
|
||||
[data-titlebar-tab]:is(:hover, :has(:focus-visible), [data-active="true"], [data-unread="true"]):not(
|
||||
[data-editing="true"]
|
||||
)
|
||||
[data-titlebar-tab]:is(:hover, :has(:focus-visible), [data-active="true"], [data-status]):not([data-editing="true"])
|
||||
[data-slot="tab-link"] {
|
||||
--tab-title-fade-offset: calc(24px + var(--tab-link-inset, 0px));
|
||||
}
|
||||
|
|
@ -270,7 +289,7 @@
|
|||
}
|
||||
|
||||
@media (hover: none) {
|
||||
[data-titlebar-tab] [data-slot="tab-unread-slot"] {
|
||||
[data-titlebar-tab] [data-slot="tab-status"] {
|
||||
inset-inline-end: 20px;
|
||||
}
|
||||
|
||||
|
|
@ -302,7 +321,7 @@
|
|||
--tab-title-fade-direction: to left;
|
||||
}
|
||||
|
||||
[data-titlebar-tab][data-unread="true"]:not([data-editing="true"]) [data-slot="tab-link"] {
|
||||
[data-titlebar-tab][data-status]:not([data-editing="true"]) [data-slot="tab-link"] {
|
||||
--tab-title-fade-offset: calc(44px + var(--tab-link-inset, 0px));
|
||||
}
|
||||
}
|
||||
|
|
@ -312,7 +331,7 @@
|
|||
:hover,
|
||||
:has(:focus-visible),
|
||||
[data-active="true"],
|
||||
[data-unread="true"]
|
||||
[data-status]
|
||||
)
|
||||
[data-slot="tab-link"] {
|
||||
-webkit-mask-image: none;
|
||||
|
|
@ -323,7 +342,7 @@
|
|||
:hover,
|
||||
:has(:focus-visible),
|
||||
[data-active="true"],
|
||||
[data-unread="true"]
|
||||
[data-status]
|
||||
)
|
||||
[data-titlebar-tab-title] {
|
||||
visibility: hidden;
|
||||
|
|
@ -337,12 +356,13 @@
|
|||
height: 6px;
|
||||
}
|
||||
|
||||
[data-titlebar-tab][data-unread="true"]:not([data-orientation="vertical"]) [data-slot="project-avatar-surface"] {
|
||||
[data-titlebar-tab]:is([data-status="attention"], [data-status="unread"]):not([data-orientation="vertical"])
|
||||
[data-slot="project-avatar-surface"] {
|
||||
-webkit-mask-image: radial-gradient(circle 4.5px at 100% 0, transparent 4px, black 5px);
|
||||
mask-image: radial-gradient(circle 4.5px at 100% 0, transparent 4px, black 5px);
|
||||
}
|
||||
|
||||
[data-titlebar-tab][data-unread="true"]:not([data-orientation="vertical"]):dir(rtl)
|
||||
[data-titlebar-tab]:is([data-status="attention"], [data-status="unread"]):not([data-orientation="vertical"]):dir(rtl)
|
||||
[data-slot="project-avatar-surface"] {
|
||||
-webkit-mask-image: radial-gradient(circle 4.5px at 0 0, transparent 4px, black 5px);
|
||||
mask-image: radial-gradient(circle 4.5px at 0 0, transparent 4px, black 5px);
|
||||
|
|
@ -364,12 +384,15 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
[data-titlebar-tab]:not([data-orientation="vertical"]):not([data-active="true"]) [data-slot="tab-close"] {
|
||||
[data-titlebar-tab]:not([data-orientation="vertical"]):not([data-active="true"]):not([data-status="busy"])
|
||||
[data-slot="tab-close"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (hover: hover) {
|
||||
[data-titlebar-tab]:not([data-orientation="vertical"]):not(:hover):not(:has(:focus-visible))
|
||||
[data-titlebar-tab]:not([data-orientation="vertical"]):not([data-status="busy"]):not(:hover):not(
|
||||
:has(:focus-visible)
|
||||
)
|
||||
[data-slot="tab-close"] {
|
||||
display: none;
|
||||
}
|
||||
|
|
@ -380,6 +403,22 @@
|
|||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
/* Icon-only tabs have no room on the right, so a busy one spins over its icon. */
|
||||
[data-titlebar-tab][data-status="busy"]:not([data-orientation="vertical"]):not([data-active="true"])
|
||||
[data-slot="tab-close"]
|
||||
> button {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
[data-titlebar-tab][data-status="busy"]:not([data-orientation="vertical"]):not([data-active="true"])
|
||||
[data-slot="tab-status"] {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
[data-titlebar-tab][data-status="busy"]:not([data-orientation="vertical"]) [data-slot="project-avatar-slot"] {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
/* A prompt that arrives in a background tab rings it once, like the TUI's prompt pulse. */
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { createStore } from "solid-js/store"
|
|||
import { Predicate } from "effect"
|
||||
import { makeEventListener } from "@solid-primitives/event-listener"
|
||||
import { createResizeObserver } from "@solid-primitives/resize-observer"
|
||||
import { ActivityRing } from "@opencode/ui/activity-ring"
|
||||
import { IconButton } from "@opencode/ui/icon-button"
|
||||
import { Icon } from "@opencode/ui/icon"
|
||||
import { Menu } from "@opencode/ui/menu"
|
||||
|
|
@ -11,7 +12,6 @@ import { useLanguage } from "@/runtime/i18n/language"
|
|||
import { ServerConnection, useServers } from "@/runtime/server/registry"
|
||||
import { displayName } from "@opencode/ui/project-avatar"
|
||||
import { SessionTabAvatarView } from "@/shell/layout/session-tab-avatar"
|
||||
import { SessionProgressIndicatorV2 } from "@opencode/session-ui/v2/session-progress-indicator-v2"
|
||||
import type { SessionInfo } from "@opencode/client/promise"
|
||||
import { sessionTabTitle } from "./tab-title"
|
||||
import { TabPreviewPopover } from "./tab-popover"
|
||||
|
|
@ -27,6 +27,7 @@ export function TabNavItem(props: {
|
|||
session: SessionInfo | undefined
|
||||
preparing: boolean
|
||||
unread: boolean
|
||||
attention: boolean
|
||||
loading: boolean
|
||||
fallbackTitle?: string
|
||||
fallbackDirectory?: string
|
||||
|
|
@ -58,7 +59,18 @@ export function TabNavItem(props: {
|
|||
const servers = useServers()
|
||||
const serverCtx = useServerCtx(() => servers.list.find((item) => ServerConnection.key(item) === props.server))
|
||||
|
||||
const unread = () => !!props.session && !props.active && props.unread
|
||||
// The project icon stays put; status shows where the close button appears on hover.
|
||||
const status = () => {
|
||||
if (props.preparing || props.loading) return "busy"
|
||||
|
||||
if (!props.session || props.active) return
|
||||
|
||||
if (props.attention) return "attention"
|
||||
|
||||
if (props.unread) return "unread"
|
||||
}
|
||||
|
||||
const dotted = () => status() === "attention" || status() === "unread"
|
||||
|
||||
const project = createMemo(() => {
|
||||
const session = props.session
|
||||
|
|
@ -238,7 +250,7 @@ export function TabNavItem(props: {
|
|||
class="group relative flex h-7 w-full min-w-0 select-none flex-row items-center gap-1.5 overflow-hidden whitespace-nowrap rounded-[6px] px-1.5 [container-type:inline-size]"
|
||||
classList={{ invisible: props.hidden }}
|
||||
data-active={props.active}
|
||||
data-unread={unread()}
|
||||
data-status={status()}
|
||||
data-dragging={props.dragging}
|
||||
data-state={props.active || props.pressed ? "pressed" : undefined}
|
||||
onMouseDown={(event) => {
|
||||
|
|
@ -291,47 +303,14 @@ export function TabNavItem(props: {
|
|||
>
|
||||
<span data-slot="project-avatar-slot" class="flex size-4 shrink-0 items-center justify-center">
|
||||
<Show
|
||||
when={props.session}
|
||||
keyed
|
||||
when={props.session?.location.directory ?? props.fallbackDirectory}
|
||||
fallback={
|
||||
<Show
|
||||
when={props.preparing}
|
||||
fallback={
|
||||
// The remembered directory keeps the project avatar while the server is unreachable.
|
||||
<Show
|
||||
when={props.fallbackDirectory}
|
||||
fallback={
|
||||
<span
|
||||
class="block size-4 rounded-[3px] border border-v2-border-border-muted"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
}
|
||||
>
|
||||
{(directory) => (
|
||||
<SessionTabAvatarView
|
||||
project={project()}
|
||||
directory={directory()}
|
||||
unread={false}
|
||||
loading={false}
|
||||
/>
|
||||
)}
|
||||
</Show>
|
||||
}
|
||||
>
|
||||
<SessionProgressIndicatorV2 />
|
||||
</Show>
|
||||
<span class="block size-4 rounded-[3px] border border-v2-border-border-muted" aria-hidden="true" />
|
||||
}
|
||||
>
|
||||
{(session) => (
|
||||
<SessionTabAvatarView
|
||||
project={project()}
|
||||
directory={session.location.directory}
|
||||
unread={false}
|
||||
loading={props.loading}
|
||||
/>
|
||||
)}
|
||||
{(directory) => <SessionTabAvatarView project={project()} directory={directory()} unread={false} />}
|
||||
</Show>
|
||||
<Show when={unread()}>
|
||||
<Show when={dotted()}>
|
||||
<span data-slot="tab-avatar-unread-dot" aria-hidden="true" />
|
||||
</Show>
|
||||
</span>
|
||||
|
|
@ -378,15 +357,15 @@ export function TabNavItem(props: {
|
|||
</Menu.Context.Trigger>
|
||||
|
||||
<div data-slot="tab-close">
|
||||
<Show when={unread()}>
|
||||
<span data-slot="tab-unread-slot" aria-hidden="true">
|
||||
<span data-slot="tab-unread-dot" />
|
||||
</span>
|
||||
</Show>
|
||||
<span data-slot="tab-status" aria-hidden="true">
|
||||
<ActivityRing data-mark="busy" />
|
||||
<span data-mark="attention" data-slot="tab-status-dot" />
|
||||
<span data-mark="unread" data-slot="tab-status-dot" />
|
||||
</span>
|
||||
<IconButton
|
||||
size="small"
|
||||
variant="ghost-muted"
|
||||
class="hover-reveal relative z-10 group-hover:opacity-100 group-has-[:focus-visible]:opacity-100 group-data-[active=true]:opacity-100 group-data-[editing=true]:opacity-100"
|
||||
class="hover-reveal relative z-10"
|
||||
onPointerDown={(event) => {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
|
|
@ -552,7 +531,7 @@ export function DraftTabItem(props: {
|
|||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
}}
|
||||
class="hover-reveal relative z-10 group-hover:opacity-100 group-data-[active=true]:opacity-100 group-data-[editing=true]:opacity-100"
|
||||
class="hover-reveal relative z-10"
|
||||
onClick={closeTab}
|
||||
icon={<Icon name="xmark-small" />}
|
||||
aria-label={language.t("common.closeTab")}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ function SessionTabSlot(props: {
|
|||
session: SessionInfo | undefined
|
||||
preparing: boolean
|
||||
unread: boolean
|
||||
attention: boolean
|
||||
loading: boolean
|
||||
fallbackTitle?: string
|
||||
fallbackDirectory?: string
|
||||
|
|
@ -80,6 +81,7 @@ function SessionTabSlot(props: {
|
|||
session={props.session}
|
||||
preparing={props.preparing}
|
||||
unread={props.unread}
|
||||
attention={props.attention}
|
||||
loading={props.loading}
|
||||
fallbackTitle={props.fallbackTitle}
|
||||
fallbackDirectory={props.fallbackDirectory}
|
||||
|
|
@ -277,13 +279,14 @@ function SessionTabEntry(props: {
|
|||
session={session()}
|
||||
preparing={!!pending()}
|
||||
unread={unread()}
|
||||
attention={status.attention()}
|
||||
loading={status.loading()}
|
||||
fallbackTitle={
|
||||
pending()
|
||||
? language.t("session.tab.session")
|
||||
: (persisted()?.title ?? (missingSession() ? language.t("session.tab.unknown") : undefined))
|
||||
}
|
||||
fallbackDirectory={persisted()?.directory}
|
||||
fallbackDirectory={pending()?.draft.directory ?? persisted()?.directory}
|
||||
onRename={rename}
|
||||
onDelete={() => dialog.show(() => <DeleteDialog />)}
|
||||
onNavigate={props.onNavigate}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@
|
|||
opacity: 1;
|
||||
}
|
||||
|
||||
[data-slot="mobile-tabs-drawer"] [data-titlebar-tab] [data-slot="tab-unread-slot"] {
|
||||
[data-slot="mobile-tabs-drawer"] [data-titlebar-tab] [data-slot="tab-status"] {
|
||||
inset-inline-end: 44px;
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@
|
|||
mask-image: none;
|
||||
}
|
||||
|
||||
[data-slot="mobile-tabs-drawer"] [data-titlebar-tab][data-unread="true"] [data-slot="tab-link"] {
|
||||
[data-slot="mobile-tabs-drawer"] [data-titlebar-tab][data-status] [data-slot="tab-link"] {
|
||||
padding-inline-end: 58px;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@
|
|||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
"./accordion": "./src/data-display/accordion/accordion.tsx",
|
||||
"./activity-ring": "./src/feedback/activity-ring/activity-ring.tsx",
|
||||
"./avatar": "./src/data-display/avatar/avatar.tsx",
|
||||
"./badge": "./src/data-display/badge/badge.tsx",
|
||||
"./button": "./src/actions/button/button.tsx",
|
||||
|
|
|
|||
32
packages/ui/src/feedback/activity-ring/activity-ring.css
Normal file
32
packages/ui/src/feedback/activity-ring/activity-ring.css
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
[data-component="activity-ring"] {
|
||||
display: block;
|
||||
flex-shrink: 0;
|
||||
color: var(--v2-icon-icon-muted);
|
||||
/* The tail fades in to a solid head; the head's round cap still gets full colour just past the arc. */
|
||||
mask-image: conic-gradient(from 90deg, transparent 0turn, black 0.72turn, black 0.78turn, transparent 0.9turn);
|
||||
animation: activity-ring-spin 800ms linear infinite;
|
||||
}
|
||||
|
||||
[data-component="activity-ring"] circle {
|
||||
stroke: currentColor;
|
||||
stroke-width: 1.8;
|
||||
stroke-linecap: round;
|
||||
}
|
||||
|
||||
@keyframes activity-ring-spin {
|
||||
to {
|
||||
transform: rotate(1turn);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-contrast: more) {
|
||||
[data-component="activity-ring"] {
|
||||
mask-image: none;
|
||||
}
|
||||
}
|
||||
|
||||
:root[data-motion="reduce"] {
|
||||
[data-component="activity-ring"] {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
24
packages/ui/src/feedback/activity-ring/activity-ring.tsx
Normal file
24
packages/ui/src/feedback/activity-ring/activity-ring.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { splitProps, type ComponentProps } from "solid-js"
|
||||
import "./activity-ring.css"
|
||||
|
||||
// An open arc in constant rotation, matching the iOS drawer's busy ring.
|
||||
export function ActivityRing(props: ComponentProps<"svg">) {
|
||||
const [local, rest] = splitProps(props, ["class", "classList", "width", "height"])
|
||||
|
||||
return (
|
||||
<svg
|
||||
{...rest}
|
||||
class={local.class}
|
||||
classList={local.classList}
|
||||
width={local.width ?? 14}
|
||||
height={local.height ?? 14}
|
||||
viewBox="0 0 14 14"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
data-component="activity-ring"
|
||||
aria-hidden={rest["aria-hidden"] ?? "true"}
|
||||
>
|
||||
<circle cx="7" cy="7" r="6.1" pathLength="100" stroke-dasharray="72 28" />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue