feat(dsh-plugin-browserskill): reskin the overlay with BrowserSkill's own UI system

The previous pass aligned the observation overlay with the dsh shell; the
product call is the opposite direction — the floating card should read as a
BrowserSkill surface, not a shell-native widget.

- Reuse @browser-skill/ui directly (Button, cn); status dots spec'd after the
  extension popup's ConnectionStatusIndicator; Remix icons for
  interrupt/pin/warn/pop-out.
- Compile the BSK tailwind utility sheet scoped under the .bsk-obs root class
  (scripts/build-client-css.mjs + postcss-prefix-selector) and ship the oklch
  design tokens on the same scope, so nothing leaks into the host shell and
  the shell theme cannot bleed back. tsdown injects .nomodule.css verbatim
  (minified, unhashed) alongside the hashed CSS modules.
- BSK ships no shared tooltip, so the one-time interrupt semantics hint is a
  card-spec bubble (bg-card/border/12px radius), retired after first use.
- Tests: pin react/react-dom to this package's 18.x copies in vitest — the ui
  package sources peer on react ^19 and would otherwise emit react-19
  (transitional) elements that the react-18 renderer rejects. Production is
  unaffected (react stays external, provided by the shell).
- stylelint: ignore the generated bsk-ui.nomodule.css.
This commit is contained in:
BB-fat
2026-08-14 10:00:37 +00:00
parent eb71ddc1da
commit d1001e14b2
13 changed files with 682 additions and 157 deletions
@@ -1,8 +1,10 @@
/* Observation overlay: floating card + collapsed capsule. Every color,
surface, shadow, and label style rides the dsh --dsw-alias-* semantic
tokens (dsh 0.1 ships no spacing/radius scales — those stay px, same as
dsh's own components). The shell overlay layer is click-through, so the
card and capsule opt back into pointer events themselves. */
/* Observation overlay skin, BrowserSkill family: colors/radius ride the BSK
design tokens (--card/--border/--primary/--destructive/--ring/--radius,
defined on the .bsk-obs scope root by bsk-tokens.nomodule.css — values
mirrored from packages/ui/src/styles/tailwind.css). Layout-only here;
component chrome (buttons etc.) comes from @browser-skill/ui plus the
scope-prefixed utility sheet. The shell overlay layer is click-through, so
the card and capsule opt back into pointer events themselves. */
.card {
position: fixed;
@@ -10,11 +12,12 @@
display: flex;
flex-direction: column;
pointer-events: auto;
background: var(--dsw-alias-bg-overlay);
border: 1px solid var(--dsw-alias-border-l2);
border-radius: 10px;
box-shadow: var(--dsw-shadow-lv2);
background: var(--card);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: 0 8px 28px rgb(0 0 0 / 18%);
overflow: hidden;
color: var(--card-foreground);
}
.body {
@@ -22,9 +25,9 @@
flex-direction: column;
height: 100%;
min-height: 0;
font: var(--dsw-font-base-16, inherit);
font-size: 12px;
color: var(--dsw-alias-label-primary);
background: var(--card);
color: var(--card-foreground);
}
.header {
@@ -35,34 +38,7 @@
cursor: move;
user-select: none;
touch-action: none;
border-bottom: 1px solid var(--dsw-alias-border-l2);
}
.dot {
flex: none;
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--dsw-alias-label-tertiary);
}
.dot[data-state="active"] {
background: var(--dsw-alias-state-success-primary);
animation: bsk-obs-pulse 1.6s ease-in-out infinite;
}
.dot[data-state="error"] {
background: var(--dsw-alias-state-error-primary);
}
@keyframes bsk-obs-pulse {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.35;
}
border-bottom: 1px solid var(--border);
}
.status-text {
@@ -81,15 +57,15 @@
border: none;
background: none;
padding: 2px;
border-radius: 4px;
border-radius: calc(var(--radius) - 6px);
font: inherit;
color: var(--dsw-alias-label-tertiary);
color: var(--muted-foreground);
cursor: pointer;
}
.icon-button:hover {
color: var(--dsw-alias-label-secondary);
background: var(--dsw-alias-interactive-bg-hover);
color: var(--foreground);
background: var(--accent);
}
.stage {
@@ -99,7 +75,7 @@
display: flex;
align-items: center;
justify-content: center;
background: var(--dsw-alias-bg-base);
background: var(--background);
overflow: hidden;
}
@@ -120,7 +96,7 @@
}
.placeholder {
color: var(--dsw-alias-label-tertiary);
color: var(--muted-foreground);
font-size: 12px;
}
@@ -134,9 +110,9 @@
display: inline-flex;
align-items: center;
justify-content: center;
color: var(--dsw-alias-state-warn-primary);
border: 1px solid var(--dsw-alias-state-warn-primary);
background: var(--dsw-alias-bg-overlay);
color: oklch(0.7 0.19 60);
border: 1px solid oklch(0.7 0.19 60);
background: var(--card);
}
.actions {
@@ -145,17 +121,27 @@
justify-content: space-between;
gap: 8px;
padding: 6px 8px;
border-top: 1px solid var(--dsw-alias-border-l2);
border-top: 1px solid var(--border);
}
/* Destructive action, styled like the shell's own danger affordances. */
.interrupt {
color: var(--dsw-alias-state-error-primary);
border-color: var(--dsw-alias-state-error-primary);
.interrupt-wrap {
position: relative;
display: inline-flex;
}
.interrupt:not(:disabled):hover {
background: var(--dsw-alias-interactive-bg-hover-danger);
.hint {
position: absolute;
bottom: calc(100% + 6px);
left: 0;
width: 220px;
padding: 6px 8px;
border-radius: calc(var(--radius) - 4px);
background: var(--card);
border: 1px solid var(--border);
color: var(--muted-foreground);
font-size: 11px;
box-shadow: 0 4px 14px rgb(0 0 0 / 16%);
z-index: 41;
}
.resize-handle {
@@ -175,8 +161,8 @@
bottom: 3px;
width: 7px;
height: 7px;
border-right: 2px solid var(--dsw-alias-label-tertiary);
border-bottom: 2px solid var(--dsw-alias-label-tertiary);
border-right: 2px solid var(--muted-foreground);
border-bottom: 2px solid var(--muted-foreground);
}
.capsule {
@@ -190,16 +176,16 @@
padding: 6px 12px;
pointer-events: auto;
border-radius: 999px;
border: 1px solid var(--dsw-alias-border-l2);
background: var(--dsw-alias-bg-overlay);
box-shadow: var(--dsw-shadow-lv1);
border: 1px solid var(--border);
background: var(--card);
box-shadow: 0 4px 14px rgb(0 0 0 / 16%);
font-size: 12px;
color: var(--dsw-alias-label-secondary);
color: var(--muted-foreground);
cursor: pointer;
}
.capsule:hover {
background: var(--dsw-alias-interactive-bg-hover);
background: var(--accent);
}
.strip {
@@ -207,22 +193,22 @@
gap: 6px;
padding: 4px 8px;
overflow-x: auto;
border-top: 1px solid var(--dsw-alias-border-l2);
border-top: 1px solid var(--border);
}
.strip-item {
position: relative;
flex: none;
border-radius: 6px;
border: 1px solid var(--dsw-alias-border-l2);
border-radius: calc(var(--radius) - 6px);
border: 1px solid var(--border);
}
.strip-item[data-focused] {
border-color: var(--dsw-alias-brand-primary);
border-color: var(--primary);
}
.strip-item[data-state="error"] {
border-color: var(--dsw-alias-state-error-primary);
border-color: var(--destructive);
}
.strip-item[data-state="dead"] {
@@ -235,16 +221,16 @@
gap: 4px;
padding: 3px 6px;
border: none;
border-radius: 6px;
border-radius: calc(var(--radius) - 6px);
background: none;
font: inherit;
font-size: 11px;
color: var(--dsw-alias-label-secondary);
color: var(--muted-foreground);
cursor: pointer;
}
.strip-main:hover {
background: var(--dsw-alias-interactive-bg-hover);
background: var(--accent);
}
.strip-thumb {
@@ -252,7 +238,7 @@
height: 20px;
overflow: hidden;
border-radius: 3px;
background: var(--dsw-alias-bg-base);
background: var(--background);
display: inline-flex;
}
@@ -274,7 +260,7 @@
}
.pin-badge {
color: var(--dsw-alias-brand-primary);
color: var(--primary);
}
.strip-interrupt {
@@ -287,9 +273,9 @@
display: inline-flex;
align-items: center;
justify-content: center;
border: 1px solid var(--dsw-alias-state-error-primary);
background: var(--dsw-alias-bg-overlay);
color: var(--dsw-alias-state-error-primary);
border: 1px solid var(--destructive);
background: var(--card);
color: var(--destructive);
padding: 0;
cursor: pointer;
}
@@ -303,14 +289,10 @@
.capsule:focus-visible,
.strip-main:focus-visible,
.strip-interrupt:focus-visible {
outline: 2px solid var(--dsw-alias-brand-primary);
outline: 2px solid var(--ring);
outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
.dot[data-state="active"] {
animation: none;
}
.thumb {
animation: none;
}
@@ -3,19 +3,31 @@
// composer's way); collapsed = a status capsule; "pop out" upgrades the same
// content to a native Document PiP window (user gesture required by the
// browser). Multi-session renders a meeting-style strip under the focus view.
// Visuals ride dsh's shared primitives and --dsw-alias-* tokens throughout,
// so the card reads as a native part of the shell, not a foreign widget.
// Visuals follow the BrowserSkill product family: @browser-skill/ui components
// and oklch tokens on a .bsk-obs scope root, so the card reads as BSK's own
// surface without leaking styles into (or inheriting themes from) the shell.
import { Button, cn } from "@browser-skill/ui";
import {
RiArrowDownSLine,
RiErrorWarningLine,
RiPictureInPicture2Line,
RiPushpinFill,
RiStopMiniFill,
} from "@remixicon/react";
// remixicon's component types target @types/react 19 while the dsh shell
// runs react 18 — a compile-time-only recast keeps the 18 typecheck happy.
type IconComponent = (props: { size?: number | string; className?: string }) => ReactNode;
const asIcon = (component: unknown): IconComponent => component as IconComponent;
const IconStop = asIcon(RiStopMiniFill);
const IconPip = asIcon(RiPictureInPicture2Line);
const IconDown = asIcon(RiArrowDownSLine);
const IconWarn = asIcon(RiErrorWarningLine);
const IconPin = asIcon(RiPushpinFill);
import {
Button,
IconChevronDownOutline14,
IconRightUpOutline16,
IconStopFill16,
IconWarningOutline16,
StateDot,
Tooltip,
} from "@deepseek-ai/dsh-client-ui-primitives";
import {
type ReactNode,
type PointerEvent as ReactPointerEvent,
useCallback,
useEffect,
@@ -94,19 +106,23 @@ export function statusOf(obs: SessionObservation): "active" | "idle" | "error" {
return obs.action === "idle" ? "idle" : "active";
}
function dotStateOf(
state: "active" | "idle" | "error" | "dead",
): "done" | "ongoing" | "error" | "warning" {
switch (state) {
case "active":
return "ongoing";
case "error":
return "error";
case "dead":
return "warning";
default:
return "done";
}
/** Flat status dot, specced after the BSK popup's ConnectionStatusIndicator. */
function StatusDot({ state }: { state: "active" | "idle" | "error" | "dead" }) {
const color =
state === "active"
? "bg-emerald-500"
: state === "error"
? "bg-red-500"
: state === "dead"
? "bg-amber-500"
: "bg-muted-foreground/40";
return (
<span
className={cn("size-2 shrink-0 rounded-full ring-2 ring-background", color)}
data-state={state}
aria-hidden
/>
);
}
/** One strip item: mini frame, id, status dot, hover interrupt, pin toggle. */
@@ -149,21 +165,8 @@ function StripItem(props: {
)}
</span>
<span className={css["strip-id"]}>{obs.sessionId}</span>
<StateDot state={dotStateOf(state)} />
{pinned ? (
<svg
className={css["pin-badge"]}
width="9"
height="9"
viewBox="0 0 10 10"
aria-label="pinned"
>
<path
d="M6.5 0.8 9.2 3.5 8.3 4.4 7.9 4 6.2 6.9 6.6 8.7 6 9.4 3.4 5.4 1 7.9 0.6 7.3 2.5 6 3.1 6.6 5.9 2.1 5.5 1.7Z"
fill="currentColor"
/>
</svg>
) : null}
<StatusDot state={state} />
{pinned ? <IconPin size={9} className={css["pin-badge"]} aria-label="pinned" /> : null}
</button>
{hover && !pinned && obs.dead !== true ? (
<button
@@ -176,7 +179,7 @@ function StripItem(props: {
void store.interrupt(obs.sessionId);
}}
>
<IconStopFill16 size={8} />
<IconStop size={9} />
</button>
) : null}
</div>
@@ -211,7 +214,8 @@ function OverlayBody(props: {
onHeaderPointerDown,
} = props;
const [interrupting, setInterrupting] = useState(false);
// One-time semantics hint: a shared Tooltip that retires after first use.
// One-time semantics hint bubble, retired after the first interrupt.
const [hintOpen, setHintOpen] = useState(false);
const [hintSeen, setHintSeen] = useState(false);
const thumbId = focus?.thumbnailAttachmentId;
@@ -241,14 +245,14 @@ function OverlayBody(props: {
const state = !available ? "error" : focus !== undefined ? statusOf(focus) : "idle";
return (
<div className={css.body} data-state={state} data-in-pip={inPip || undefined}>
<div className={cn(css.body, "bsk-obs")} data-state={state} data-in-pip={inPip || undefined}>
<div
className={css.header}
data-testid="obs-header"
onPointerDown={onHeaderPointerDown}
role="presentation"
>
<StateDot state={state === "error" ? "error" : state === "active" ? "ongoing" : "done"} />
<StatusDot state={state === "error" ? "error" : state === "active" ? "active" : "idle"} />
<span className={css["status-text"]}>{statusText}</span>
{onCollapse !== undefined ? (
<button
@@ -257,7 +261,7 @@ function OverlayBody(props: {
aria-label="Collapse"
onClick={onCollapse}
>
<IconChevronDownOutline14 />
<IconDown size={14} />
</button>
) : null}
</div>
@@ -280,7 +284,7 @@ function OverlayBody(props: {
)}
{thumb?.status === "error" ? (
<span className={css.badge} aria-label="thumbnail failed">
<IconWarningOutline16 size={12} />
<IconWarn size={12} />
</span>
) : null}
</div>
@@ -299,34 +303,41 @@ function OverlayBody(props: {
</div>
) : null}
<div className={css.actions}>
<Tooltip
label="Interrupt stops only the current browser action — the agent run continues (use the chat Stop button to halt the run)."
side="top"
maxWidth={240}
disabled={hintSeen}
<span
className={css["interrupt-wrap"]}
onPointerEnter={() => {
if (!hintSeen) setHintOpen(true);
}}
onPointerLeave={() => setHintOpen(false)}
>
<span className={css["interrupt-wrap"]}>
<Button
variant="outline"
size="sm"
className={css.interrupt}
icon={<IconStopFill16 />}
disabled={!canInterrupt}
aria-label="Interrupt the current browser action"
onClick={onInterrupt}
>
{interrupting ? "Interrupting…" : "Interrupt"}
</Button>
</span>
</Tooltip>
<Button
variant="outline"
size="sm"
className="text-destructive border-destructive/60 hover:bg-destructive/10"
disabled={!canInterrupt}
aria-label="Interrupt the current browser action"
onClick={onInterrupt}
>
<IconStop size={14} />
{interrupting ? "Interrupting…" : "Interrupt"}
</Button>
{/* BSK ships no shared tooltip component; this bubble follows the BSK
card spec (bg-card, border, 12px radius, caption text). */}
{hintOpen && !hintSeen ? (
<span className={css.hint} role="tooltip">
Interrupt stops only the current browser action — the agent run continues (use the
chat Stop button to halt the run).
</span>
) : null}
</span>
{onPopOut !== undefined ? (
<Button
variant="ghost"
size="sm"
icon={<IconRightUpOutline16 />}
aria-label="Pop out into a mini window"
onClick={onPopOut}
>
<IconPip size={14} />
Pop out
</Button>
) : null}
@@ -457,12 +468,12 @@ export function ObservationOverlay({ store }: { store: ObservationClientStore })
return (
<button
type="button"
className={css.capsule}
className={cn(css.capsule, "bsk-obs")}
data-state={state}
aria-label="Expand browser observation overlay"
onClick={() => setCollapsed(false)}
>
<StateDot state={dotStateOf(state)} />
<StatusDot state={state} />
<span className={css["capsule-text"]}>
{snapshot.sessions.length} session{snapshot.sessions.length === 1 ? "" : "s"}
{focus !== undefined && focus.action !== "idle"
@@ -478,7 +489,7 @@ export function ObservationOverlay({ store }: { store: ObservationClientStore })
? { left: pos.x, top: pos.y, width: size.w, height: size.h }
: { right: EDGE_MARGIN, top: TOP_OFFSET, width: size.w, height: size.h };
return (
<div className={css.card} style={style} data-obs-card data-testid="obs-card">
<div className={cn(css.card, "bsk-obs")} style={style} data-obs-card data-testid="obs-card">
{body}
<div
className={css["resize-handle"]}
@@ -0,0 +1,49 @@
/*
* BrowserSkill UI design tokens, scoped to the observation overlay root.
* VALUES MIRROR packages/ui/src/styles/tailwind.css (:root and .dark) — keep
* in sync with that file; it is the canonical source. Scoped here (instead of
* :root) so the dsh host theme can neither leak in nor be polluted by us.
* Dark follows prefers-color-scheme, same as the extension popup.
*/
.bsk-obs {
color-scheme: light dark;
--background: oklch(0.99 0.005 50);
--foreground: oklch(0.14 0.03 50);
--card: oklch(0.995 0.003 50 / 0.82);
--card-foreground: oklch(0.14 0.03 50);
--primary: oklch(0.62 0.22 45);
--primary-foreground: oklch(0.99 0.01 50);
--secondary: oklch(0.96 0.04 65);
--secondary-foreground: oklch(0.25 0.08 65);
--muted: oklch(0.96 0.01 50);
--muted-foreground: oklch(0.55 0.04 50);
--accent: oklch(0.96 0.04 65);
--accent-foreground: oklch(0.25 0.08 65);
--destructive: oklch(0.6 0.25 25);
--destructive-foreground: oklch(0.99 0.01 50);
--border: oklch(0.9 0.025 60);
--input: oklch(0.9 0.025 60);
--ring: oklch(0.62 0.22 45);
--radius: 0.75rem;
}
@media (prefers-color-scheme: dark) {
.bsk-obs {
--background: oklch(0.2 0.02 50);
--foreground: oklch(0.98 0.01 50);
--card: oklch(0.24 0.02 50 / 0.82);
--card-foreground: oklch(0.98 0.01 50);
--primary: oklch(0.7 0.18 45);
--primary-foreground: oklch(0.14 0.03 50);
--secondary: oklch(0.32 0.03 60);
--secondary-foreground: oklch(0.98 0.01 50);
--muted: oklch(0.3 0.02 50);
--muted-foreground: oklch(0.75 0.03 50);
--accent: oklch(0.32 0.03 60);
--accent-foreground: oklch(0.98 0.01 50);
--destructive: oklch(0.45 0.2 25);
--destructive-foreground: oklch(0.98 0.01 50);
--border: oklch(0.35 0.02 60);
--input: oklch(0.35 0.02 60);
--ring: oklch(0.7 0.18 45);
}
}
@@ -10,6 +10,10 @@ import type { ClientContext, ISessions, SessionId } from "@deepseek-ai/dsh-clien
import type {} from "@deepseek-ai/dsh-client-ui-layout/client";
import type { ToolCallViewProps } from "@deepseek-ai/dsh-client-ui-tool/client";
import { createElement } from "react";
// Scope-prefixed BSK design tokens and utility sheet (injected verbatim as
// <style> tags; selectors stay unhashed so `cn(..., "bsk-obs")` roots match).
import "./bsk-tokens.nomodule.css";
import "./bsk-ui.nomodule.css";
import { ObservationOverlay } from "./ObservationOverlay";
import { type EventSourceLike, ObservationClientStore } from "./observation-store";
import { ScreenshotToolView } from "./ScreenshotToolView";