chore: generate

This commit is contained in:
opencode-agent[bot]
2026-05-08 10:18:22 +00:00
parent 7f2b5ee8c2
commit ac7a885ae9
23 changed files with 283 additions and 282 deletions
+1 -8
View File
@@ -18,14 +18,7 @@ import path from "path"
import type { Event, ToolPart } from "@opencode-ai/sdk/v2"
import { createSessionData, reduceSessionData, type SessionData } from "./session-data"
import { writeSessionOutput } from "./stream"
import type {
FooterApi,
PermissionReply,
QuestionReject,
QuestionReply,
RunPrompt,
StreamCommit,
} from "./types"
import type { FooterApi, PermissionReply, QuestionReject, QuestionReply, RunPrompt, StreamCommit } from "./types"
const KINDS = [
"markdown",
@@ -180,13 +180,7 @@ function PanelShell(props: {
children: JSX.Element
}) {
return (
<box
id={props.id}
width="100%"
flexDirection="column"
backgroundColor="transparent"
flexShrink={0}
>
<box id={props.id} width="100%" flexDirection="column" backgroundColor="transparent" flexShrink={0}>
<box
width="100%"
flexDirection="column"
@@ -161,10 +161,7 @@ export function RunFooterMenu(props: {
return
}
const dir =
props.selected() === previous + 1 ? 1
: props.selected() === previous - 1 ? -1
: undefined
const dir = props.selected() === previous + 1 ? 1 : props.selected() === previous - 1 ? -1 : undefined
setGroupOffset((value) =>
dir
? moveOffset(value, { count: all.length, limit: limit(), selected, dir })
@@ -175,7 +172,10 @@ export function RunFooterMenu(props: {
const rows = createMemo<RunFooterMenuRow[]>(() => {
if (!props.grouped) {
return props.items().slice(props.offset(), props.offset() + limit()).map((item, index) => ({
return props
.items()
.slice(props.offset(), props.offset() + limit())
.map((item, index) => ({
type: "item",
item,
index: index + props.offset(),
@@ -187,7 +187,13 @@ export function RunFooterMenu(props: {
return all.slice(start, start + limit())
})
const descriptionColumn = createMemo(() => {
const width = Math.max(0, ...props.items().filter((item) => item.description).map((item) => Bun.stringWidth(item.display)))
const width = Math.max(
0,
...props
.items()
.filter((item) => item.description)
.map((item) => Bun.stringWidth(item.display)),
)
return width === 0 ? 0 : width + 2
})
const descriptionPad = (item: RunFooterMenuItem) => {
@@ -264,7 +270,12 @@ export function RunFooterMenu(props: {
backgroundColor={active() ? props.theme().highlight : props.theme().surface}
>
<box width="100%" flexDirection="row" justifyContent="space-between" gap={1}>
<text fg={active() ? props.theme().surface : props.theme().text} wrapMode="none" truncate flexGrow={1}>
<text
fg={active() ? props.theme().surface : props.theme().text}
wrapMode="none"
truncate
flexGrow={1}
>
{row.item.display}
{row.item.description ? (
<span style={{ fg: active() ? props.theme().surface : props.theme().muted }}>
@@ -274,7 +285,12 @@ export function RunFooterMenu(props: {
) : undefined}
</text>
{row.item.footer ? (
<text fg={active() ? props.theme().surface : props.theme().muted} wrapMode="none" truncate flexShrink={0}>
<text
fg={active() ? props.theme().surface : props.theme().muted}
wrapMode="none"
truncate
flexShrink={0}
>
{row.item.footer}
</text>
) : undefined}
@@ -36,10 +36,7 @@ function statusIcon(status: FooterSubagentTab["status"]) {
}
function tabText(tab: FooterSubagentTab, slot: string, count: number, width: number) {
const perTab = Math.max(
1,
Math.floor((width - 4 - Math.max(0, count - 1) * 3) / Math.max(1, count)),
)
const perTab = Math.max(1, Math.floor((width - 4 - Math.max(0, count - 1) * 3) / Math.max(1, count)))
if (count >= 8 || perTab < 12) {
return `[${slot}]`
}
@@ -96,7 +93,9 @@ export function RunFooterSubagentTabs(props: {
flexDirection="row"
flexShrink={0}
>
<box flexDirection="row" gap={3} flexShrink={1} flexGrow={1}>{items()}</box>
<box flexDirection="row" gap={3} flexShrink={1} flexGrow={1}>
{items()}
</box>
</box>
)
}
+1 -3
View File
@@ -103,9 +103,7 @@ export function withRunSpan<A>(
attributes: attributes(input),
})
return context.with(
trace.setSpan(context.active(), span),
() =>
return context.with(trace.setSpan(context.active(), span), () =>
finish(
span,
new Promise<A>((resolve) => {
@@ -23,13 +23,7 @@ export type PromptHistoryState = {
draft: string
}
export function promptInfo(event: {
name: string
ctrl?: boolean
meta?: boolean
shift?: boolean
super?: boolean
}) {
export function promptInfo(event: { name: string; ctrl?: boolean; meta?: boolean; shift?: boolean; super?: boolean }) {
return {
name: event.name === " " ? "space" : event.name,
ctrl: !!event.ctrl,
@@ -123,7 +117,11 @@ export function promptBindings(bindings: FooterKeybinds["commandList"], leader:
})
}
function mapInputBindings(bindings: FooterKeybinds["inputSubmit"], leader: string, action: "submit" | "newline"): KeyBinding[] {
function mapInputBindings(
bindings: FooterKeybinds["inputSubmit"],
leader: string,
action: "submit" | "newline",
): KeyBinding[] {
return promptBindings(bindings, leader).flatMap((key) => {
if (key.leader) {
return []
@@ -248,7 +248,12 @@ export async function createRuntimeLifecycle(input: LifecycleInput): Promise<Lif
process.on("SIGINT", sigint)
let closed = false
const close = async (next: { showExit: boolean; sessionTitle?: string; sessionID?: string; history?: RunPrompt[] }) => {
const close = async (next: {
showExit: boolean
sessionTitle?: string
sessionID?: string
history?: RunPrompt[]
}) => {
if (closed) {
return
}
+1 -4
View File
@@ -39,10 +39,7 @@ type CreateSessionInput = {
variant: string | undefined
}
type CreateSession = (
sdk: RunInput["sdk"],
input: CreateSessionInput,
) => Promise<{ id: string; title?: string }>
type CreateSession = (sdk: RunInput["sdk"], input: CreateSessionInput) => Promise<{ id: string; title?: string }>
type RunRuntimeInput = {
boot: () => Promise<BootContext>
@@ -326,8 +326,7 @@ export class RunScrollbackStream {
if (
body.type !== "structured" &&
(entryCanStream(commit, body) ||
(commit.kind === "tool" && commit.phase === "final" && body.type === "markdown"))
(entryCanStream(commit, body) || (commit.kind === "tool" && commit.phase === "final" && body.type === "markdown"))
) {
await this.writeStreaming(commit, body)
if (entryDone(commit)) {
@@ -55,7 +55,12 @@ export function entryLayout(commit: StreamCommit, body: RunEntryBody = entryBody
return "block"
}
if (commit.phase === "progress" && commit.toolState === "completed" && body.type === "text" && body.content.includes("\n")) {
if (
commit.phase === "progress" &&
commit.toolState === "completed" &&
body.type === "text" &&
body.content.includes("\n")
) {
return "block"
}
@@ -205,10 +205,7 @@ function out(data: SessionData, commits: SessionCommit[], footer?: FooterOutput)
}
}
export function pickBlockerView(input: {
permission?: PermissionRequest
question?: QuestionRequest
}): FooterView {
export function pickBlockerView(input: { permission?: PermissionRequest; question?: QuestionRequest }): FooterView {
if (input.permission) {
return { type: "permission", request: input.permission }
}
+9 -1
View File
@@ -259,7 +259,15 @@ function build(input: SplashWriterInput, kind: "entry" | "exit", ctx: Scrollback
}
push(lines, body_left, top + 1, label, left, undefined, TextAttributes.DIM)
push(lines, body_left + label.length, top + 1, `opencode run -i -s ${meta.session_id}`, right, undefined, TextAttributes.BOLD)
push(
lines,
body_left + label.length,
top + 1,
`opencode run -i -s ${meta.session_id}`,
right,
undefined,
TextAttributes.BOLD,
)
height = top + mark.length
}
@@ -189,9 +189,7 @@ function waitTurn(done: Wait["done"], signal: AbortSignal) {
signal.addEventListener("abort", onAbort, { once: true })
return Effect.sync(() => signal.removeEventListener("abort", onAbort))
}).pipe(Effect.exit),
]).pipe(
Effect.flatMap((exit) => (Exit.isFailure(exit) ? Effect.failCause(exit.cause) : Effect.succeed(exit.value))),
)
]).pipe(Effect.flatMap((exit) => (Exit.isFailure(exit) ? Effect.failCause(exit.cause) : Effect.succeed(exit.value))))
}
export function formatUnknownError(error: unknown): string {
@@ -422,10 +420,7 @@ function createLayer(input: StreamInput) {
return
}
if (
event.properties.sessionID !== input.sessionID &&
!state.subagent.tabs.has(event.properties.sessionID)
) {
if (event.properties.sessionID !== input.sessionID && !state.subagent.tabs.has(event.properties.sessionID)) {
return
}
@@ -178,10 +178,12 @@ function createLayer(fs = AppFileSystem.defaultLayer) {
delete next[key]
}
yield* file.writeJson(MODEL_FILE, {
yield* file
.writeJson(MODEL_FILE, {
...current,
variant: next,
}).pipe(Effect.orElseSucceed(() => undefined))
})
.pipe(Effect.orElseSucceed(() => undefined))
})
return Service.of({
@@ -335,26 +335,16 @@ describe("run entry body", () => {
tool: "bash",
phase: "progress",
toolState: "completed",
text: [
"/tmp/demo",
"git status",
"On branch demo",
"nothing to commit, working tree clean",
"",
].join("\n"),
text: ["/tmp/demo", "git status", "On branch demo", "nothing to commit, working tree clean", ""].join("\n"),
state: {
status: "completed",
input: {
command: "git status",
workdir: "/tmp/demo",
},
output: [
"/tmp/demo",
"git status",
"On branch demo",
"nothing to commit, working tree clean",
"",
].join("\n"),
output: ["/tmp/demo", "git status", "On branch demo", "nothing to commit, working tree clean", ""].join(
"\n",
),
title: "git status",
metadata: {
exitCode: 0,
@@ -2,7 +2,12 @@
import { expect, test } from "bun:test"
import { testRender } from "@opentui/solid"
import { createSignal } from "solid-js"
import { RUN_COMMAND_PANEL_ROWS, RunCommandMenuBody, RunModelSelectBody, RunVariantSelectBody } from "@/cli/cmd/run/footer.command"
import {
RUN_COMMAND_PANEL_ROWS,
RunCommandMenuBody,
RunModelSelectBody,
RunVariantSelectBody,
} from "@/cli/cmd/run/footer.command"
import { RunEntryContent } from "@/cli/cmd/run/scrollback.writer"
import { RUN_THEME_FALLBACK } from "@/cli/cmd/run/theme"
import type { FooterKeybinds, RunCommand, RunInput, RunProvider, StreamCommit } from "@/cli/cmd/run/types"
@@ -117,14 +122,17 @@ test("run entry content updates when live commit text changes", async () => {
tool: "bash",
})
const app = await testRender(() => (
const app = await testRender(
() => (
<box width={80} height={4}>
<RunEntryContent commit={commit()} theme={RUN_THEME_FALLBACK} width={80} />
</box>
), {
),
{
width: 80,
height: 4,
})
},
)
try {
await app.renderOnce()
@@ -155,7 +163,8 @@ test("direct command panel renders grouped command palette", async () => {
])
const [variants] = createSignal(["high", "minimal"])
const app = await testRender(() => (
const app = await testRender(
() => (
<box width={100} height={RUN_COMMAND_PANEL_ROWS}>
<RunCommandMenuBody
theme={() => RUN_THEME_FALLBACK.footer}
@@ -171,10 +180,12 @@ test("direct command panel renders grouped command palette", async () => {
onExit={() => {}}
/>
</box>
), {
),
{
width: 100,
height: RUN_COMMAND_PANEL_ROWS,
})
},
)
try {
await app.renderOnce()
@@ -207,7 +218,8 @@ test("direct model panel renders current model selector", async () => {
const [providers] = createSignal<RunProvider[] | undefined>([provider()])
const [current] = createSignal<RunInput["model"]>({ providerID: "opencode", modelID: "gpt-5" })
const app = await testRender(() => (
const app = await testRender(
() => (
<box width={100} height={RUN_COMMAND_PANEL_ROWS}>
<RunModelSelectBody
theme={() => RUN_THEME_FALLBACK.footer}
@@ -217,10 +229,12 @@ test("direct model panel renders current model selector", async () => {
onSelect={() => {}}
/>
</box>
), {
),
{
width: 100,
height: RUN_COMMAND_PANEL_ROWS,
})
},
)
try {
await app.renderOnce()
@@ -243,7 +257,8 @@ test("direct variant panel renders current variant selector", async () => {
const [variants] = createSignal(["high", "minimal"])
const [current] = createSignal<string | undefined>("high")
const app = await testRender(() => (
const app = await testRender(
() => (
<box width={100} height={RUN_COMMAND_PANEL_ROWS}>
<RunVariantSelectBody
theme={() => RUN_THEME_FALLBACK.footer}
@@ -253,10 +268,12 @@ test("direct variant panel renders current variant selector", async () => {
onSelect={() => {}}
/>
</box>
), {
),
{
width: 100,
height: RUN_COMMAND_PANEL_ROWS,
})
},
)
try {
await app.renderOnce()
@@ -7,11 +7,7 @@ import { TuiConfig, type Resolved } from "@/cli/cmd/tui/config/tui"
import { formatBindings } from "@/cli/cmd/run/keymap.shared"
import { KeymapSectionNames, keymapBindingDefaults, type KeymapSection } from "@/cli/cmd/tui/config/tui-schema"
import { ConfigKeybinds } from "@/config/keybinds"
import {
resolveDiffStyle,
resolveFooterKeybinds,
resolveModelInfo,
} from "@/cli/cmd/run/runtime.boot"
import { resolveDiffStyle, resolveFooterKeybinds, resolveModelInfo } from "@/cli/cmd/run/runtime.boot"
type RunBinding = Binding<Renderable, KeyEvent>
@@ -299,5 +295,4 @@ describe("run runtime boot", () => {
},
})
})
})
@@ -58,10 +58,12 @@ function destroy(commits: ClaimedCommit[]) {
}
}
async function setup(input: {
async function setup(
input: {
width?: number
wrote?: boolean
} = {}) {
} = {},
) {
const out = await createTestRenderer({
width: input.width ?? 80,
screenMode: "split-footer",
@@ -150,7 +152,8 @@ function toolCommit(input: {
}
test("finalizes markdown tables for streamed and coalesced input", async () => {
const text = "| Column 1 | Column 2 | Column 3 |\n|---|---|---|\n| Row 1 | Value 1 | Value 2 |\n| Row 2 | Value 3 | Value 4 |"
const text =
"| Column 1 | Column 2 | Column 3 |\n|---|---|---|\n| Row 1 | Value 1 | Value 2 |\n| Row 2 | Value 3 | Value 4 |"
for (const chunks of [[text], [...text]]) {
const out = await setup()
@@ -182,7 +185,9 @@ test("holds markdown code blocks until final commit and keeps newline ownership"
try {
await out.scrollback.append(
assistant('# Markdown Sample\n\n- Item 1\n- Item 2\n\n```js\nconst message = "Hello, markdown"\nconsole.log(message)\n```'),
assistant(
'# Markdown Sample\n\n- Item 1\n- Item 2\n\n```js\nconst message = "Hello, markdown"\nconsole.log(message)\n```',
),
)
const progress = claim(out.renderer)
@@ -543,7 +548,7 @@ test("inserts a spacer before the next tool after completed multiline bash outpu
take()
const output = lines.join("\n")
expect(output).toContain("total 4\n\n✱ Glob \"**/*tool*\" in src/cli/cmd")
expect(output).toContain('total 4\n\n✱ Glob "**/*tool*" in src/cli/cmd')
} finally {
out.scrollback.destroy()
}
@@ -48,12 +48,7 @@ function user(id: string) {
}
}
function text(input: {
id: string
messageID: string
text: string
time?: Record<string, number>
}) {
function text(input: { id: string; messageID: string; text: string; time?: Record<string, number> }) {
return {
type: "message.part.updated",
properties: {
@@ -98,13 +93,7 @@ function delta(messageID: string, partID: string, value: string) {
}
}
function tool(input: {
id: string
messageID: string
tool: string
state: Record<string, unknown>
callID?: string
}) {
function tool(input: { id: string; messageID: string; tool: string; state: Record<string, unknown>; callID?: string }) {
return {
type: "message.part.updated",
properties: {
@@ -144,11 +144,7 @@ function statusMap(busy: boolean): SessionStatusMap {
return {}
}
function assistantMessage(input: {
sessionID: string
id: string
parts: SessionMessage["parts"]
}): SessionMessage {
function assistantMessage(input: { sessionID: string; id: string; parts: SessionMessage["parts"] }): SessionMessage {
return {
info: {
id: input.id,
@@ -334,7 +330,8 @@ function footer(fn?: (commit: StreamCommit) => void) {
return { api, commits, events }
}
function sdk(input: {
function sdk(
input: {
stream?: EventStream
subscribe?: OpencodeClient["event"]["subscribe"]
promptAsync?: OpencodeClient["session"]["promptAsync"]
@@ -343,7 +340,8 @@ function sdk(input: {
children?: OpencodeClient["session"]["children"]
permissions?: OpencodeClient["permission"]["list"]
questions?: OpencodeClient["question"]["list"]
} = {}) {
} = {},
) {
const client = new OpencodeClient()
const subscribe: OpencodeClient["event"]["subscribe"] = input.subscribe ?? (() => sse(input.stream ?? emptyStream()))
@@ -419,7 +417,8 @@ describe("run stream transport", () => {
])
},
children: async () => ok([child("child-1")]),
permissions: async () => ok([
permissions: async () =>
ok([
{
id: "perm-1",
sessionID: "child-1",
@@ -743,7 +742,8 @@ describe("run stream transport", () => {
expect(
ui.events.some(
(event) => event.type === "stream.view" && event.view.type === "question" && event.view.request.id === request.id,
(event) =>
event.type === "stream.view" && event.view.type === "question" && event.view.request.id === request.id,
),
).toBe(false)
@@ -982,11 +982,14 @@ describe("run stream transport", () => {
const transport = await createSessionTransport({
sdk: sdk({
subscribe: () => sse((async function* (): AsyncGenerator<SdkEvent> {
subscribe: () =>
sse(
(async function* (): AsyncGenerator<SdkEvent> {
await ready.promise
yield busy()
throw new Error("boom")
})()),
})(),
),
promptAsync: async () => {
ready.resolve()
return ok(undefined)
+5 -12
View File
@@ -2,16 +2,7 @@ import { expect, test } from "bun:test"
import { RGBA, type CliRenderer, type TerminalColors } from "@opentui/core"
import { RUN_THEME_FALLBACK, generateSystem, resolveRunTheme, resolveTheme } from "@/cli/cmd/run/theme"
const palette = [
"#15161e",
"#f7768e",
"#9ece6a",
"#e0af68",
"#7aa2f7",
"#bb9af7",
"#7dcfff",
"#c0caf5",
] as const
const palette = ["#15161e", "#f7768e", "#9ece6a", "#e0af68", "#7aa2f7", "#bb9af7", "#7dcfff", "#c0caf5"] as const
function terminalColors(input: Partial<TerminalColors> = {}): TerminalColors {
return {
@@ -28,11 +19,13 @@ function terminalColors(input: Partial<TerminalColors> = {}): TerminalColors {
}
}
function renderer(input: {
function renderer(
input: {
themeMode?: "dark" | "light"
colors?: TerminalColors
fail?: boolean
} = {}) {
} = {},
) {
return {
themeMode: input.themeMode,
getPalette: async () => {
@@ -79,7 +79,10 @@ const providers: RunProvider[] = [
},
]
function userMessage(id: string, input: { providerID: string; modelID: string; variant?: string }): SessionMessages[number] {
function userMessage(
id: string,
input: { providerID: string; modelID: string; variant?: string },
): SessionMessages[number] {
return {
info: {
id,