Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"@octokit/rest": "22.0.0",
"@hono/standard-validator": "0.2.0",
"@hono/zod-validator": "0.4.2",
"@opentui/core": "0.4.5",
"@opentui/keymap": "0.4.5",
"@opentui/solid": "0.4.5",
"@opentui/core": "0.6.6",
"@opentui/keymap": "0.6.6",
"@opentui/solid": "0.6.6",
"@tanstack/solid-virtual": "3.13.32",
"@shikijs/stream": "4.2.0",
"ulid": "3.0.1",
Expand Down Expand Up @@ -146,6 +146,7 @@
"@ai-sdk/[email protected]": "patches/@ai-sdk%[email protected]",
"[email protected]": "patches/[email protected]",
"@tanstack/[email protected]": "patches/@tanstack%[email protected]",
"@modelcontextprotocol/[email protected]": "patches/@modelcontextprotocol%[email protected]"
"@modelcontextprotocol/[email protected]": "patches/@modelcontextprotocol%[email protected]",
"[email protected]": "patches/[email protected]"
}
}
2 changes: 1 addition & 1 deletion packages/opencode/src/cli/cmd/run/footer.prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export function RunPromptBody(props: {
}

// Paste can leave the textarea layout stale until the next edit.
area.getLayoutNode().markDirty()
area.invalidateIntrinsicSize()
renderer.requestRender()
void renderer
.idle()
Expand Down
12 changes: 6 additions & 6 deletions packages/opencode/src/cli/cmd/run/scrollback.shared.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { SyntaxStyle, TextAttributes, type ColorInput } from "@opentui/core"
import { SyntaxStyle, TextAttributes, type ColorInput, type NativeResourceOwner } from "@opentui/core"
import { type RunEntryTheme, type RunTheme } from "./theme"
import type { StreamCommit } from "./types"

function syntax(style?: SyntaxStyle): SyntaxStyle {
return style ?? SyntaxStyle.fromTheme([])
function syntax(style: SyntaxStyle | undefined, owner: NativeResourceOwner): SyntaxStyle {
return style ?? SyntaxStyle.fromTheme([], owner)
}

export function entrySyntax(commit: StreamCommit, theme: RunTheme): SyntaxStyle {
export function entrySyntax(commit: StreamCommit, theme: RunTheme, owner: NativeResourceOwner): SyntaxStyle {
if (commit.kind === "reasoning") {
return syntax(theme.block.subtleSyntax ?? theme.block.syntax)
return syntax(theme.block.subtleSyntax ?? theme.block.syntax, owner)
}

return syntax(theme.block.syntax)
return syntax(theme.block.syntax, owner)
}

export function entryCancelled(commit: StreamCommit): boolean {
Expand Down
6 changes: 3 additions & 3 deletions packages/opencode/src/cli/cmd/run/scrollback.surface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class RunScrollbackStream {
}

active.renderable.fg = entryColor(active.commit, theme)
active.renderable.syntaxStyle = entrySyntax(active.commit, theme)
active.renderable.syntaxStyle = entrySyntax(active.commit, theme, this.renderer.nativeScene)
}

private createEntry(commit: StreamCommit, body: ActiveBody): ActiveEntry {
Expand All @@ -164,7 +164,7 @@ export class RunScrollbackStream {
? new CodeRenderable(surface.renderContext, {
content: "",
filetype: body.filetype,
syntaxStyle: entrySyntax(commit, this.theme),
syntaxStyle: entrySyntax(commit, this.theme, this.renderer.nativeScene),
width: "100%",
wrapMode: "word",
drawUnstyledText: false,
Expand All @@ -174,7 +174,7 @@ export class RunScrollbackStream {
})
: new MarkdownRenderable(surface.renderContext, {
content: "",
syntaxStyle: entrySyntax(commit, this.theme),
syntaxStyle: entrySyntax(commit, this.theme, this.renderer.nativeScene),
width: "100%",
streaming: true,
internalBlockMode: "top-level",
Expand Down
5 changes: 3 additions & 2 deletions packages/opencode/src/cli/cmd/run/scrollback.writer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createScrollbackWriter } from "@opentui/solid"
import { createScrollbackWriter, useRenderer } from "@opentui/solid"
import { TextRenderable, type ColorInput, type ScrollbackRenderContext, type ScrollbackWriter } from "@opentui/core"
import { Match, Switch, createMemo } from "solid-js"
import { entryBody, entryFlags } from "./entry.body"
Expand Down Expand Up @@ -101,10 +101,11 @@ export function RunEntryContent(props: {
opts?: ScrollbackOptions
width?: number
}) {
const renderer = useRenderer()
const theme = createMemo(() => props.theme ?? RUN_THEME_FALLBACK)
const body = createMemo(() => props.body ?? entryBody(props.commit))
const style = createMemo(() => entryLook(props.commit, theme().entry))
const syntax = createMemo(() => entrySyntax(props.commit, theme()))
const syntax = createMemo(() => entrySyntax(props.commit, theme(), renderer.nativeScene))
const color = createMemo(() => entryColor(props.commit, theme()))
const suppressBackgrounds = createMemo(() => props.opts?.suppressBackgrounds === true)
const diffBg = (color: ColorInput) => (suppressBackgrounds() ? transparent : color)
Expand Down
25 changes: 20 additions & 5 deletions packages/opencode/src/cli/cmd/run/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
// detects dark/light mode, builds a small system theme locally, and maps it to
// the run footer + scrollback color model. Falls back to a hardcoded dark-mode
// palette if detection fails.
import { RGBA, SyntaxStyle, type CliRenderer, type ColorInput, type TerminalColors } from "@opentui/core"
import {
RGBA,
SyntaxStyle,
type CliRenderer,
type ColorInput,
type NativeResourceOwner,
type TerminalColors,
} from "@opentui/core"
import type { TuiThemeCurrent } from "@opencode-ai/plugin/tui"
import type { EntryKind } from "./types"

Expand Down Expand Up @@ -189,7 +196,11 @@ function chroma(color: RGBA) {
return Math.max(color.r, color.g, color.b) - Math.min(color.r, color.g, color.b)
}

function opaqueSyntaxStyle(style: SyntaxStyle | undefined, bg: RGBA): SyntaxStyle | undefined {
function opaqueSyntaxStyle(
style: SyntaxStyle | undefined,
bg: RGBA,
owner: NativeResourceOwner,
): SyntaxStyle | undefined {
if (!style) {
return undefined
}
Expand All @@ -205,6 +216,7 @@ function opaqueSyntaxStyle(style: SyntaxStyle | undefined, bg: RGBA): SyntaxStyl
},
]),
),
owner,
)
}

Expand Down Expand Up @@ -501,10 +513,11 @@ function map(
footerTheme: TuiThemeCurrent,
scrollbackTheme: TuiThemeCurrent,
splash: RunSplashTheme,
owner: NativeResourceOwner,
syntax?: SyntaxStyle,
subtleSyntax?: SyntaxStyle,
): RunTheme {
const opaqueSubtleSyntax = opaqueSyntaxStyle(subtleSyntax, scrollbackTheme.background)
const opaqueSubtleSyntax = opaqueSyntaxStyle(subtleSyntax, scrollbackTheme.background, owner)
subtleSyntax?.destroy()
const footerBackground = alpha(footerTheme.background, 1)
const footerMode = mode(footerBackground)
Expand Down Expand Up @@ -676,13 +689,15 @@ export async function resolveRunTheme(renderer: CliRenderer): Promise<RunTheme>
...scrollbackTheme,
_hasSelectedListItemText: true,
}
const syntax = shared.generateSyntax(syntaxTheme)
const owner = renderer.nativeScene
const syntax = shared.generateSyntax(syntaxTheme, owner)
return map(
footerTheme,
scrollbackTheme,
splashTheme(scrollbackTheme, indexed),
owner,
syntax,
shared.generateSubtleSyntax(syntaxTheme),
shared.generateSubtleSyntax(syntaxTheme, owner),
)
} catch {
return RUN_THEME_FALLBACK
Expand Down
Loading
Loading