chore: generate
This commit is contained in:
@@ -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"
|
||||
@@ -333,14 +327,14 @@ export function RunCommandMenuBody(props: {
|
||||
category: item.source === "mcp" ? "MCP Commands" : "Project Commands",
|
||||
name: item.name,
|
||||
display: item.name,
|
||||
footer: `/${item.name}`,
|
||||
keywords:
|
||||
item.source === "mcp"
|
||||
? `/${item.name} ${item.name} mcp ${item.description ?? ""}`
|
||||
: `/${item.name} ${item.name} ${item.description ?? ""}`,
|
||||
}) satisfies CommandEntry,
|
||||
)
|
||||
.sort((a, b) => categoryRank(a.category) - categoryRank(b.category) || a.display.localeCompare(b.display)),
|
||||
footer: `/${item.name}`,
|
||||
keywords:
|
||||
item.source === "mcp"
|
||||
? `/${item.name} ${item.name} mcp ${item.description ?? ""}`
|
||||
: `/${item.name} ${item.name} ${item.description ?? ""}`,
|
||||
}) satisfies CommandEntry,
|
||||
)
|
||||
.sort((a, b) => categoryRank(a.category) - categoryRank(b.category) || a.display.localeCompare(b.display)),
|
||||
{ action: "exit", category: "System", display: "Exit", footer: "/exit", keywords: "/exit exit" },
|
||||
]
|
||||
})
|
||||
|
||||
@@ -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,11 +172,14 @@ export function RunFooterMenu(props: {
|
||||
|
||||
const rows = createMemo<RunFooterMenuRow[]>(() => {
|
||||
if (!props.grouped) {
|
||||
return props.items().slice(props.offset(), props.offset() + limit()).map((item, index) => ({
|
||||
type: "item",
|
||||
item,
|
||||
index: index + props.offset(),
|
||||
}))
|
||||
return props
|
||||
.items()
|
||||
.slice(props.offset(), props.offset() + limit())
|
||||
.map((item, index) => ({
|
||||
type: "item",
|
||||
item,
|
||||
index: index + props.offset(),
|
||||
}))
|
||||
}
|
||||
|
||||
const all = groupedRows()
|
||||
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -567,9 +567,9 @@ export class RunFooter implements FooterApi {
|
||||
? 1 + tabs + MODEL_ROWS
|
||||
: this.promptRoute.type === "variant"
|
||||
? 1 + tabs + VARIANT_ROWS
|
||||
: this.promptRoute.type === "subagent"
|
||||
? this.base + tabs + SUBAGENT_INSPECTOR_ROWS
|
||||
: Math.max(base + TEXTAREA_MIN_ROWS, Math.min(base + PROMPT_MAX_ROWS, base + this.rows))
|
||||
: this.promptRoute.type === "subagent"
|
||||
? this.base + tabs + SUBAGENT_INSPECTOR_ROWS
|
||||
: Math.max(base + TEXTAREA_MIN_ROWS, Math.min(base + PROMPT_MAX_ROWS, base + this.rows))
|
||||
|
||||
if (height !== this.renderer.footerHeight) {
|
||||
this.renderer.footerHeight = height
|
||||
|
||||
@@ -103,15 +103,13 @@ export function withRunSpan<A>(
|
||||
attributes: attributes(input),
|
||||
})
|
||||
|
||||
return context.with(
|
||||
trace.setSpan(context.active(), span),
|
||||
() =>
|
||||
finish(
|
||||
span,
|
||||
new Promise<A>((resolve) => {
|
||||
resolve(fn(span))
|
||||
}),
|
||||
),
|
||||
return context.with(trace.setSpan(context.active(), span), () =>
|
||||
finish(
|
||||
span,
|
||||
new Promise<A>((resolve) => {
|
||||
resolve(fn(span))
|
||||
}),
|
||||
),
|
||||
)
|
||||
},
|
||||
() => fn(noop),
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
@@ -548,9 +545,9 @@ async function runInteractiveRuntime(input: RunRuntimeInput): Promise<void> {
|
||||
state.sessionTitle = created.sessionTitle
|
||||
state.agent = created.agent ?? state.agent
|
||||
state.history = []
|
||||
includeFiles = true
|
||||
state.demo = input.demo
|
||||
? createRunDemo({
|
||||
includeFiles = true
|
||||
state.demo = input.demo
|
||||
? createRunDemo({
|
||||
footer,
|
||||
sessionID: state.sessionID,
|
||||
thinking: input.thinking,
|
||||
|
||||
@@ -118,37 +118,37 @@ export class RunScrollbackStream {
|
||||
const renderable =
|
||||
body.type === "text"
|
||||
? new TextRenderable(surface.renderContext, {
|
||||
id,
|
||||
content: "",
|
||||
width: "100%",
|
||||
wrapMode: "word",
|
||||
fg: style.fg,
|
||||
attributes: style.attrs,
|
||||
})
|
||||
: body.type === "code"
|
||||
? new CodeRenderable(surface.renderContext, {
|
||||
id,
|
||||
content: "",
|
||||
filetype: body.filetype,
|
||||
syntaxStyle: entrySyntax(commit, this.theme),
|
||||
width: "100%",
|
||||
wrapMode: "word",
|
||||
drawUnstyledText: false,
|
||||
streaming: true,
|
||||
fg: entryColor(commit, this.theme),
|
||||
treeSitterClient: this.treeSitterClient,
|
||||
fg: style.fg,
|
||||
attributes: style.attrs,
|
||||
})
|
||||
: body.type === "code"
|
||||
? new CodeRenderable(surface.renderContext, {
|
||||
id,
|
||||
content: "",
|
||||
filetype: body.filetype,
|
||||
syntaxStyle: entrySyntax(commit, this.theme),
|
||||
width: "100%",
|
||||
wrapMode: "word",
|
||||
drawUnstyledText: false,
|
||||
streaming: true,
|
||||
fg: entryColor(commit, this.theme),
|
||||
treeSitterClient: this.treeSitterClient,
|
||||
})
|
||||
: new MarkdownRenderable(surface.renderContext, {
|
||||
id,
|
||||
content: "",
|
||||
syntaxStyle: entrySyntax(commit, this.theme),
|
||||
width: "100%",
|
||||
streaming: true,
|
||||
internalBlockMode: "top-level",
|
||||
tableOptions: { widthMode: "content" },
|
||||
fg: entryColor(commit, this.theme),
|
||||
treeSitterClient: this.treeSitterClient,
|
||||
})
|
||||
id,
|
||||
content: "",
|
||||
syntaxStyle: entrySyntax(commit, this.theme),
|
||||
width: "100%",
|
||||
streaming: true,
|
||||
internalBlockMode: "top-level",
|
||||
tableOptions: { widthMode: "content" },
|
||||
fg: entryColor(commit, this.theme),
|
||||
treeSitterClient: this.treeSitterClient,
|
||||
})
|
||||
|
||||
surface.root.add(renderable)
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
@@ -380,7 +378,7 @@ function createLayer(input: StreamInput) {
|
||||
(events) =>
|
||||
Effect.sync(() => {
|
||||
void events.stream.return(undefined).catch(() => {})
|
||||
}),
|
||||
}),
|
||||
),
|
||||
)
|
||||
closeStream = () => {
|
||||
@@ -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, {
|
||||
...current,
|
||||
variant: next,
|
||||
}).pipe(Effect.orElseSucceed(() => undefined))
|
||||
yield* file
|
||||
.writeJson(MODEL_FILE, {
|
||||
...current,
|
||||
variant: next,
|
||||
})
|
||||
.pipe(Effect.orElseSucceed(() => undefined))
|
||||
})
|
||||
|
||||
return Service.of({
|
||||
|
||||
Reference in New Issue
Block a user