import { Button } from "@opencode/ui/button" import { createSignal, For, Show } from "solid-js" import { usePlugin } from "@opencode/plugin/gui" import { browserPaneFixture, type BrowserScenario } from "./panel.fixture" import barStyles from "./bar.css?inline" import commentStyles from "./comment.css?inline" type Delivery = "Send" | "Steer" | "Queue" | "Unavailable" type BrowserArgs = { scenario: BrowserScenario; delivery: Delivery } function composerDelivery(value: Delivery) { if (value === "Send") return "send" if (value === "Steer") return "steer" if (value === "Queue") return "queue" } function BrowserStory(props: BrowserArgs) { const language = usePlugin() return ( {() => { const Fixture = browserPaneFixture({ scenario: props.scenario, delivery: composerDelivery(props.delivery), useLanguage: () => language, Page: (page) => { const [saved, setSaved] = createSignal(false) let surface!: HTMLDivElement return (

{page.url}

Project preview

{page.picking ? "Select Save changes to annotate this element." : "Save the sample page or add a note to the session."}

Changes saved to fixture.

) }, Frame: (frame) => (
{/* The in-app web host only installs browser styles on desktop. */}
{frame.children}
Fixture page ยท Addresses and actions stay in this preview.
System browser request: {frame.external} {(note) => (

{frame.sent.includes(note.commentID) ? "Sent" : "Attached"}: {note.label} {note.comment}

)}
), }) return }}
) } export default { title: "App/Plugins/Browser", id: "plugins-browser", args: { scenario: "Page", delivery: "Steer" }, argTypes: { delivery: { control: "select", options: ["Send", "Steer", "Queue", "Unavailable"] satisfies Delivery[] }, scenario: { control: "select", options: ["Page", "Empty", "Recent", "History", "Loading", "Failed", "Suspended"] satisfies BrowserScenario[], }, }, render: (props: BrowserArgs) => , } export const Page = { args: { scenario: "Page" } } export const Empty = { args: { scenario: "Empty" } } export const RecentPages = { args: { scenario: "Recent" } } // A history as an import from another browser leaves it: type in the address field, for example "rune" or "gith". export const ImportedHistory = { args: { scenario: "History" } } export const Loading = { args: { scenario: "Loading" } } export const LoadFailed = { args: { scenario: "Failed" } } export const Suspended = { args: { scenario: "Suspended" } } // Comments: press Comment on part of the page in the bar, pick Save changes, type, then hover the check button. Enter // attaches the comment; Mod+Enter attaches and sends it, labelled by how the session takes it now. "Add page to // session" under Browser options opens the page note editor, with the same two actions. /** The session is idle: Mod+Enter reads "Send comment". */ export const CommentSend = { args: { scenario: "Page", delivery: "Send" } } /** The session works and the follow-up behavior steers: "Steer comment". */ export const CommentSteer = { args: { scenario: "Page", delivery: "Steer" } } /** The session works and the follow-up behavior queues: "Queue comment". */ export const CommentQueue = { args: { scenario: "Page", delivery: "Queue" } } /** Nothing can be sent now, e.g. in a subagent's session or while another send is in flight: the action is disabled. */ export const CommentSendUnavailable = { args: { scenario: "Page", delivery: "Unavailable" } }