diff --git a/packages/session-ui/component-tests/session-tool-projection.spec.ts b/packages/session-ui/component-tests/session-tool-projection.spec.ts index 297453a837e..498886c42fa 100644 --- a/packages/session-ui/component-tests/session-tool-projection.spec.ts +++ b/packages/session-ui/component-tests/session-tool-projection.spec.ts @@ -172,7 +172,6 @@ story("opens an execution's code and output from its View code action", async ({ const dialog = timeline.page().getByRole("dialog") await expect(dialog.getByRole("heading", { name: "Execute" })).toBeVisible() await expect(dialog).toContainText("Completed") - await expect(dialog).toContainText("2 calls") await expect(dialog).toContainText('const tab = await tools.browser.tabs.open({ url: "http://localhost:4399" })') await expect(dialog).toContainText('"tab": "tab_4f1c"') await expect(dialog.getByRole("button", { name: "Copy code" })).toBeVisible() diff --git a/packages/session-ui/src/components/message-part.css b/packages/session-ui/src/components/message-part.css index dcd8ac40cab..c57968395d2 100644 --- a/packages/session-ui/src/components/message-part.css +++ b/packages/session-ui/src/components/message-part.css @@ -1152,24 +1152,6 @@ align-items: center; gap: 8px; min-width: 0; - - [data-slot="execute-details-status"] { - padding: 0 6px; - border-radius: 4px; - font-size: 12px; - line-height: var(--line-height-base); - color: var(--v2-text-text-muted); - background: var(--v2-background-bg-layer-02); - } - - [data-slot="execute-details-status"][data-status="error"] { - color: var(--v2-state-fg-danger); - } - - [data-slot="execute-details-meta"] { - font-size: 12px; - color: var(--v2-text-text-faint); - } } [data-component="execute-details"] { @@ -1207,11 +1189,6 @@ color: var(--v2-text-text-muted); } - [data-slot="execute-details-section-meta"] { - font-size: 12px; - color: var(--v2-text-text-faint); - } - [data-slot="execute-details-source"] { max-height: 360px; overflow: auto; @@ -1228,16 +1205,8 @@ } } - [data-slot="execute-details-error"] { - margin: 0; - padding: 12px 14px; - font-family: var(--v2-font-family-code); - font-size: 13px; - line-height: var(--line-height-base); - white-space: pre-wrap; - overflow-wrap: anywhere; - color: var(--v2-state-fg-danger); - background: var(--v2-background-bg-layer-01); + [data-tone="danger"] { + --opencode-diffs-fg: var(--v2-state-fg-danger); } } diff --git a/packages/session-ui/src/pierre/index.ts b/packages/session-ui/src/pierre/index.ts index ba11a819f1c..c6367e50441 100644 --- a/packages/session-ui/src/pierre/index.ts +++ b/packages/session-ui/src/pierre/index.ts @@ -31,6 +31,7 @@ export type DiffProps = FileDiffOptions & { const unsafeCSS = ` :host { --diffs-bg: var(--opencode-diffs-bg, var(--color-background-stronger)); + --diffs-fg: var(--opencode-diffs-fg, light-dark(var(--diffs-light, #000), var(--diffs-dark, #fff))); /* Pierre mixes 15% in dark mode, which makes collapsed rows read as highlighted. */ --diffs-bg-separator-override: light-dark( color-mix(in lab, var(--diffs-bg) 98%, var(--diffs-mixer)), @@ -151,6 +152,11 @@ const unsafeCSS = ` --mix-dark: 0%; } +/* A host can set --opencode-diffs-fg to tint plain text lines (such as error output) across all browsers. */ +[data-file] [data-line] span { + color: var(--opencode-diffs-fg, light-dark(var(--diffs-token-light, var(--diffs-light)), var(--diffs-token-dark, var(--diffs-dark)))); +} + /* Syntax colors are inline styles on token spans, so emphasized text needs !important to stay legible on its highlight. */ [data-line-type='change-addition'] [data-diff-span], [data-line-type='change-addition'] [data-diff-span] * { diff --git a/packages/session-ui/src/tools/tool-renderer.tsx b/packages/session-ui/src/tools/tool-renderer.tsx index b2ff482193c..85f6515e4ec 100644 --- a/packages/session-ui/src/tools/tool-renderer.tsx +++ b/packages/session-ui/src/tools/tool-renderer.tsx @@ -40,6 +40,7 @@ import { useMarkdown } from "../context/markdown" import { getDirectory, getFilename } from "@opencode/util/path" import { checksum } from "@opencode/util/encode" import { formatExecuteOutput } from "@opencode/util/execute-output" +import { Badge } from "@opencode/ui/badge" import { Tooltip } from "@opencode/ui/tooltip" import { useDialog } from "@opencode/ui/context/dialog" import { Dialog, DialogBody, DialogHeader, DialogTitle } from "@opencode/ui/dialog" @@ -2090,9 +2091,7 @@ ToolRegistry.register({ const viewable = () => props.status !== "streaming" && !!code() const openDetails = () => - dialog.show(() => ( - - )) + dialog.show(() => ) return ( text.split("\n").length - const lines = (text: string) => i18n.plural("ui.tool.execute.lines", lineCount(text)) // Code Mode returns structured results as compact JSON; show those indented, and highlight a bare JSON result. const output = createMemo(() => formatExecuteOutput(props.output)) - // Code and output share one number gutter, sized to the longer block, so their content starts on the same column. + // Code and output/error share one number gutter, sized to the longer block, so their content starts on the same column. const numberDigits = () => - String(Math.max(lineCount(props.code), props.output && !props.error ? lineCount(output().text) : 0)).length + String( + Math.max( + lineCount(props.code), + props.error ? lineCount(props.error) : props.output ? lineCount(output().text) : 0, + ), + ).length + + const statusLabel = () => + props.error + ? i18n.t("ui.toolErrorCard.failed") + : props.status === "running" + ? i18n.t("ui.tool.execute.running") + : i18n.t("ui.tool.execute.completed") return (
{i18n.t("ui.tool.execute")} - - {props.error - ? i18n.t("ui.toolErrorCard.failed") - : props.status === "running" - ? i18n.t("ui.tool.execute.running") - : i18n.t("ui.tool.execute.completed")} - - {i18n.plural("ui.tool.execute.calls", props.calls)} + {statusLabel()}
@@ -2196,6 +2198,7 @@ function ExecuteDetails(props: { code: string; output: string; error?: string; c mode="text" file={{ name: "execute.js", contents: props.code, cacheKey: checksum(props.code) }} overflow="wrap" + lineHoverHighlight="disabled" /> @@ -2217,6 +2219,7 @@ function ExecuteDetails(props: { code: string; output: string; error?: string; c cacheKey: checksum(output().text), }} overflow="wrap" + lineHoverHighlight="disabled" /> @@ -2228,7 +2231,15 @@ function ExecuteDetails(props: { code: string; output: string; error?: string; c copy={error()} copyLabel={i18n.t("ui.toolErrorCard.copyError")} > -
{error()}
+
+ +
)} @@ -2240,7 +2251,6 @@ function ExecuteDetails(props: { code: string; output: string; error?: string; c function ExecuteDetailsSection(props: { label: string - meta?: string copy: string copyLabel: string children: JSX.Element @@ -2252,7 +2262,6 @@ function ExecuteDetailsSection(props: {
{props.label} - {(meta) => {meta()}}