chore: generate

This commit is contained in:
opencode-agent[bot] 2026-06-07 05:25:52 +00:00
commit 21a644fef5
12 changed files with 40 additions and 50 deletions

View file

@ -3,12 +3,7 @@ import { mkdir, symlink } from "node:fs/promises"
import os from "node:os" import os from "node:os"
import path from "node:path" import path from "node:path"
import { afterEach, expect, spyOn, test } from "bun:test" import { afterEach, expect, spyOn, test } from "bun:test"
import { import { isZedTerminal, offsetToPosition, resolveZedDbPath, resolveZedSelection } from "@opencode-ai/tui/editor-zed"
isZedTerminal,
offsetToPosition,
resolveZedDbPath,
resolveZedSelection,
} from "@opencode-ai/tui/editor-zed"
import { tmpdir } from "../../fixture/fixture" import { tmpdir } from "../../fixture/fixture"
const originalZedTerm = process.env.ZED_TERM const originalZedTerm = process.env.ZED_TERM

View file

@ -35,13 +35,10 @@ function mountEditorContext(WebSocketImpl?: typeof WebSocket) {
const value = process.env.CLAUDE_CODE_SSE_PORT || process.env.OPENCODE_EDITOR_SSE_PORT const value = process.env.CLAUDE_CODE_SSE_PORT || process.env.OPENCODE_EDITOR_SSE_PORT
return ( return (
<TestTuiContexts <TestTuiContexts cwd={process.cwd()} paths={{ home: os.homedir() }}>
cwd={process.cwd()} <EditorContextProvider integration={editorService} WebSocketImpl={WebSocketImpl}>
paths={{ home: os.homedir() }} <Consumer />
> </EditorContextProvider>
<EditorContextProvider integration={editorService} WebSocketImpl={WebSocketImpl}>
<Consumer />
</EditorContextProvider>
</TestTuiContexts> </TestTuiContexts>
) )
}) })

View file

@ -73,7 +73,11 @@ export async function read() {
if (text) return { data: text, mime: "text/plain" } if (text) return { data: text, mime: "text/plain" }
} }
export function copyCommand(os: NodeJS.Platform, wayland: boolean, has: (name: string) => boolean): string[] | undefined { export function copyCommand(
os: NodeJS.Platform,
wayland: boolean,
has: (name: string) => boolean,
): string[] | undefined {
if (os === "darwin" && has("osascript")) return ["osascript"] if (os === "darwin" && has("osascript")) return ["osascript"]
if (os === "linux" && wayland && has("wl-copy")) return ["wl-copy"] if (os === "linux" && wayland && has("wl-copy")) return ["wl-copy"]
if (os === "linux" && has("xclip")) return ["xclip", "-selection", "clipboard"] if (os === "linux" && has("xclip")) return ["xclip", "-selection", "clipboard"]

View file

@ -6,11 +6,7 @@ import { useClipboard } from "../context/clipboard"
import { InstallationVersion } from "@opencode-ai/core/installation/version" import { InstallationVersion } from "@opencode-ai/core/installation/version"
import { destroyRenderer } from "../util/renderer" import { destroyRenderer } from "../util/renderer"
export function ErrorComponent(props: { export function ErrorComponent(props: { error: Error; reset: () => void; mode?: "dark" | "light" }) {
error: Error
reset: () => void
mode?: "dark" | "light"
}) {
const term = useTerminalDimensions() const term = useTerminalDimensions()
const renderer = useRenderer() const renderer = useRenderer()
const clipboard = useClipboard() const clipboard = useClipboard()

View file

@ -116,7 +116,8 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create
const editor = props.integration ?? editorIntegration const editor = props.integration ?? editorIntegration
const value = process.env.CLAUDE_CODE_SSE_PORT || process.env.OPENCODE_EDITOR_SSE_PORT const value = process.env.CLAUDE_CODE_SSE_PORT || process.env.OPENCODE_EDITOR_SSE_PORT
const parsedPort = value ? Number.parseInt(value, 10) : undefined const parsedPort = value ? Number.parseInt(value, 10) : undefined
const port = parsedPort && Number.isInteger(parsedPort) && parsedPort > 0 && parsedPort <= 65535 ? parsedPort : undefined const port =
parsedPort && Number.isInteger(parsedPort) && parsedPort > 0 && parsedPort <= 65535 ? parsedPort : undefined
const zedTerminal = process.env.ZED_TERM === "true" || process.env.TERM_PROGRAM?.toLowerCase() === "zed" const zedTerminal = process.env.ZED_TERM === "true" || process.env.TERM_PROGRAM?.toLowerCase() === "zed"
const mentionListeners = new Set<(mention: EditorMention) => void>() const mentionListeners = new Set<(mention: EditorMention) => void>()
const WebSocketImpl = props.WebSocketImpl ?? WebSocket const WebSocketImpl = props.WebSocketImpl ?? WebSocket
@ -319,9 +320,7 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create
return { return {
enabled() { enabled() {
return Boolean( return Boolean(resolveEditorConnection(directory, port, editor.connection) || (zedTerminal && editor.selection))
resolveEditorConnection(directory, port, editor.connection) || (zedTerminal && editor.selection),
)
}, },
connected() { connected() {
return store.status === "connected" return store.status === "connected"

View file

@ -19,7 +19,7 @@ export const { use: useKV, provider: KVProvider } = createSimpleContext({
// Queue same-process writes so rapid updates persist in order. // Queue same-process writes so rapid updates persist in order.
let write = Promise.resolve() let write = Promise.resolve()
;Flock.withLock(lock, () => readJson<Record<string, unknown>>(file)) Flock.withLock(lock, () => readJson<Record<string, unknown>>(file))
.then((x) => { .then((x) => {
setStore(x) setStore(x)
}) })
@ -55,9 +55,7 @@ export const { use: useKV, provider: KVProvider } = createSimpleContext({
setStore(key, value) setStore(key, value)
const snapshot = structuredClone(unwrap(store)) const snapshot = structuredClone(unwrap(store))
write = write write = write
.then(() => .then(() => Flock.withLock(lock, () => writeJsonAtomic(file, snapshot)))
Flock.withLock(lock, () => writeJsonAtomic(file, snapshot)),
)
.catch((error) => { .catch((error) => {
console.error("Failed to write KV state", { error }) console.error("Failed to write KV state", { error })
}) })

View file

@ -52,7 +52,11 @@ function search<T>(items: T[], target: string, key: (item: T) => string) {
return { found: false, index: left } return { found: false, index: left }
} }
export const { context: SyncContext, use: useSync, provider: SyncProvider } = createSimpleContext({ export const {
context: SyncContext,
use: useSync,
provider: SyncProvider,
} = createSimpleContext({
name: "Sync", name: "Sync",
init: () => { init: () => {
const startup = useTuiStartup() const startup = useTuiStartup()

View file

@ -52,10 +52,10 @@ const themeSource: ThemeSource = {
export async function discoverThemes(directories: string[]) { export async function discoverThemes(directories: string[]) {
const result: Record<string, unknown> = {} const result: Record<string, unknown> = {}
for (const directory of directories) { for (const directory of directories) {
const files = await Glob.scan("themes/*.json", { cwd: directory, absolute: true, dot: true, symlink: true }) const files = await Glob.scan("themes/*.json", { cwd: directory, absolute: true, dot: true, symlink: true })
for (const file of files) { for (const file of files) {
result[path.basename(file, ".json")] = JSON.parse(await readFile(file, "utf8")) as unknown result[path.basename(file, ".json")] = JSON.parse(await readFile(file, "utf8")) as unknown
} }
} }
return result return result
} }

View file

@ -16,9 +16,7 @@ function Directory(props: { api: TuiPluginApi }) {
if (!selected || selected.type === "new") return if (!selected || selected.type === "new") return
const out = abbreviateHome(selected.directory, paths.home) const out = abbreviateHome(selected.directory, paths.home)
const branch = const branch =
selected.directory === (props.api.state.path.directory || paths.cwd) selected.directory === (props.api.state.path.directory || paths.cwd) ? props.api.state.vcs?.branch : undefined
? props.api.state.vcs?.branch
: undefined
if (branch) return out + ":" + branch if (branch) return out + ":" + branch
return out return out
}) })

View file

@ -467,7 +467,8 @@ export function Session() {
}, },
run: async () => { run: async () => {
const copy = (url: string) => const copy = (url: string) =>
clipboard.write?.(url) clipboard
.write?.(url)
.then(() => toast.show({ message: "Share URL copied to clipboard!", variant: "success" })) .then(() => toast.show({ message: "Share URL copied to clipboard!", variant: "success" }))
.catch(() => toast.show({ message: "Failed to copy URL to clipboard", variant: "error" })) .catch(() => toast.show({ message: "Failed to copy URL to clipboard", variant: "error" }))
const url = session()?.share?.url const url = session()?.share?.url
@ -902,7 +903,8 @@ export function Session() {
return return
} }
clipboard.write?.(text) clipboard
.write?.(text)
.then(() => toast.show({ message: "Message copied to clipboard!", variant: "success" })) .then(() => toast.show({ message: "Message copied to clipboard!", variant: "success" }))
.catch(() => toast.show({ message: "Failed to copy to clipboard", variant: "error" })) .catch(() => toast.show({ message: "Failed to copy to clipboard", variant: "error" }))
dialog.clear() dialog.clear()

View file

@ -45,15 +45,15 @@ export async function mount(override?: FetchHandler, state?: string) {
const app = await testRender(() => ( const app = await testRender(() => (
<TestTuiContexts paths={state ? { state } : undefined}> <TestTuiContexts paths={state ? { state } : undefined}>
<ArgsProvider> <ArgsProvider>
<KVProvider> <KVProvider>
<SDKProvider url="http://test" directory={directory} fetch={calls.fetch} events={events.source}> <SDKProvider url="http://test" directory={directory} fetch={calls.fetch} events={events.source}>
<ProjectProvider> <ProjectProvider>
<SyncProvider> <SyncProvider>
<Probe /> <Probe />
</SyncProvider> </SyncProvider>
</ProjectProvider> </ProjectProvider>
</SDKProvider> </SDKProvider>
</KVProvider> </KVProvider>
</ArgsProvider> </ArgsProvider>
</TestTuiContexts> </TestTuiContexts>
)) ))

View file

@ -1,10 +1,7 @@
import { expect, test } from "bun:test" import { expect, test } from "bun:test"
import { testRender } from "@opentui/solid" import { testRender } from "@opentui/solid"
import { abbreviateHome } from "../src/runtime" import { abbreviateHome } from "../src/runtime"
import { import { TuiPathsProvider, useTuiPaths } from "../src/context/runtime"
TuiPathsProvider,
useTuiPaths,
} from "../src/context/runtime"
test("abbreviates paths within home boundaries", () => { test("abbreviates paths within home boundaries", () => {
expect(abbreviateHome("/home/test", "/home/test")).toBe("~") expect(abbreviateHome("/home/test", "/home/test")).toBe("~")