diff --git a/packages/opencode/test/cli/tui/editor-context-zed.test.ts b/packages/opencode/test/cli/tui/editor-context-zed.test.ts index bd0ddba57..3cd6adb18 100644 --- a/packages/opencode/test/cli/tui/editor-context-zed.test.ts +++ b/packages/opencode/test/cli/tui/editor-context-zed.test.ts @@ -3,12 +3,7 @@ import { mkdir, symlink } from "node:fs/promises" import os from "node:os" import path from "node:path" import { afterEach, expect, spyOn, test } from "bun:test" -import { - isZedTerminal, - offsetToPosition, - resolveZedDbPath, - resolveZedSelection, -} from "@opencode-ai/tui/editor-zed" +import { isZedTerminal, offsetToPosition, resolveZedDbPath, resolveZedSelection } from "@opencode-ai/tui/editor-zed" import { tmpdir } from "../../fixture/fixture" const originalZedTerm = process.env.ZED_TERM diff --git a/packages/opencode/test/cli/tui/editor-context.test.tsx b/packages/opencode/test/cli/tui/editor-context.test.tsx index 52cceb298..2b114b5ce 100644 --- a/packages/opencode/test/cli/tui/editor-context.test.tsx +++ b/packages/opencode/test/cli/tui/editor-context.test.tsx @@ -35,13 +35,10 @@ function mountEditorContext(WebSocketImpl?: typeof WebSocket) { const value = process.env.CLAUDE_CODE_SSE_PORT || process.env.OPENCODE_EDITOR_SSE_PORT return ( - - - - + + + + ) }) diff --git a/packages/tui/src/clipboard.ts b/packages/tui/src/clipboard.ts index 3bd84df64..08f86f9f7 100644 --- a/packages/tui/src/clipboard.ts +++ b/packages/tui/src/clipboard.ts @@ -73,7 +73,11 @@ export async function read() { 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 === "linux" && wayland && has("wl-copy")) return ["wl-copy"] if (os === "linux" && has("xclip")) return ["xclip", "-selection", "clipboard"] diff --git a/packages/tui/src/component/error-component.tsx b/packages/tui/src/component/error-component.tsx index 113e7da8e..d42f5d18f 100644 --- a/packages/tui/src/component/error-component.tsx +++ b/packages/tui/src/component/error-component.tsx @@ -6,11 +6,7 @@ import { useClipboard } from "../context/clipboard" import { InstallationVersion } from "@opencode-ai/core/installation/version" import { destroyRenderer } from "../util/renderer" -export function ErrorComponent(props: { - error: Error - reset: () => void - mode?: "dark" | "light" -}) { +export function ErrorComponent(props: { error: Error; reset: () => void; mode?: "dark" | "light" }) { const term = useTerminalDimensions() const renderer = useRenderer() const clipboard = useClipboard() diff --git a/packages/tui/src/context/editor.ts b/packages/tui/src/context/editor.ts index b1c871850..cf2fbbf9e 100644 --- a/packages/tui/src/context/editor.ts +++ b/packages/tui/src/context/editor.ts @@ -116,7 +116,8 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create const editor = props.integration ?? editorIntegration const value = process.env.CLAUDE_CODE_SSE_PORT || process.env.OPENCODE_EDITOR_SSE_PORT 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 mentionListeners = new Set<(mention: EditorMention) => void>() const WebSocketImpl = props.WebSocketImpl ?? WebSocket @@ -319,9 +320,7 @@ export const { use: useEditorContext, provider: EditorContextProvider } = create return { enabled() { - return Boolean( - resolveEditorConnection(directory, port, editor.connection) || (zedTerminal && editor.selection), - ) + return Boolean(resolveEditorConnection(directory, port, editor.connection) || (zedTerminal && editor.selection)) }, connected() { return store.status === "connected" diff --git a/packages/tui/src/context/kv.tsx b/packages/tui/src/context/kv.tsx index f64c9e2bb..7b90c95f5 100644 --- a/packages/tui/src/context/kv.tsx +++ b/packages/tui/src/context/kv.tsx @@ -19,7 +19,7 @@ export const { use: useKV, provider: KVProvider } = createSimpleContext({ // Queue same-process writes so rapid updates persist in order. let write = Promise.resolve() - ;Flock.withLock(lock, () => readJson>(file)) + Flock.withLock(lock, () => readJson>(file)) .then((x) => { setStore(x) }) @@ -55,9 +55,7 @@ export const { use: useKV, provider: KVProvider } = createSimpleContext({ setStore(key, value) const snapshot = structuredClone(unwrap(store)) write = write - .then(() => - Flock.withLock(lock, () => writeJsonAtomic(file, snapshot)), - ) + .then(() => Flock.withLock(lock, () => writeJsonAtomic(file, snapshot))) .catch((error) => { console.error("Failed to write KV state", { error }) }) diff --git a/packages/tui/src/context/sync.tsx b/packages/tui/src/context/sync.tsx index 9b05e2350..54e08219e 100644 --- a/packages/tui/src/context/sync.tsx +++ b/packages/tui/src/context/sync.tsx @@ -52,7 +52,11 @@ function search(items: T[], target: string, key: (item: T) => string) { 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", init: () => { const startup = useTuiStartup() diff --git a/packages/tui/src/context/theme.tsx b/packages/tui/src/context/theme.tsx index 65d4816a9..909dd69ac 100644 --- a/packages/tui/src/context/theme.tsx +++ b/packages/tui/src/context/theme.tsx @@ -52,10 +52,10 @@ const themeSource: ThemeSource = { export async function discoverThemes(directories: string[]) { const result: Record = {} for (const directory of directories) { - const files = await Glob.scan("themes/*.json", { cwd: directory, absolute: true, dot: true, symlink: true }) - for (const file of files) { - result[path.basename(file, ".json")] = JSON.parse(await readFile(file, "utf8")) as unknown - } + const files = await Glob.scan("themes/*.json", { cwd: directory, absolute: true, dot: true, symlink: true }) + for (const file of files) { + result[path.basename(file, ".json")] = JSON.parse(await readFile(file, "utf8")) as unknown + } } return result } diff --git a/packages/tui/src/feature-plugins/home/footer.tsx b/packages/tui/src/feature-plugins/home/footer.tsx index a417ea195..41bee5da5 100644 --- a/packages/tui/src/feature-plugins/home/footer.tsx +++ b/packages/tui/src/feature-plugins/home/footer.tsx @@ -16,9 +16,7 @@ function Directory(props: { api: TuiPluginApi }) { if (!selected || selected.type === "new") return const out = abbreviateHome(selected.directory, paths.home) const branch = - selected.directory === (props.api.state.path.directory || paths.cwd) - ? props.api.state.vcs?.branch - : undefined + selected.directory === (props.api.state.path.directory || paths.cwd) ? props.api.state.vcs?.branch : undefined if (branch) return out + ":" + branch return out }) diff --git a/packages/tui/src/routes/session/index.tsx b/packages/tui/src/routes/session/index.tsx index 6159d6624..7736eb75b 100644 --- a/packages/tui/src/routes/session/index.tsx +++ b/packages/tui/src/routes/session/index.tsx @@ -467,7 +467,8 @@ export function Session() { }, run: async () => { const copy = (url: string) => - clipboard.write?.(url) + clipboard + .write?.(url) .then(() => toast.show({ message: "Share URL copied to clipboard!", variant: "success" })) .catch(() => toast.show({ message: "Failed to copy URL to clipboard", variant: "error" })) const url = session()?.share?.url @@ -902,7 +903,8 @@ export function Session() { return } - clipboard.write?.(text) + clipboard + .write?.(text) .then(() => toast.show({ message: "Message copied to clipboard!", variant: "success" })) .catch(() => toast.show({ message: "Failed to copy to clipboard", variant: "error" })) dialog.clear() diff --git a/packages/tui/test/cli/cmd/tui/sync-fixture.tsx b/packages/tui/test/cli/cmd/tui/sync-fixture.tsx index 96b95bcc6..a212f5be1 100644 --- a/packages/tui/test/cli/cmd/tui/sync-fixture.tsx +++ b/packages/tui/test/cli/cmd/tui/sync-fixture.tsx @@ -45,15 +45,15 @@ export async function mount(override?: FetchHandler, state?: string) { const app = await testRender(() => ( - - - - - - - - - + + + + + + + + + )) diff --git a/packages/tui/test/runtime.test.tsx b/packages/tui/test/runtime.test.tsx index b9e60d0b3..3ee9817df 100644 --- a/packages/tui/test/runtime.test.tsx +++ b/packages/tui/test/runtime.test.tsx @@ -1,10 +1,7 @@ import { expect, test } from "bun:test" import { testRender } from "@opentui/solid" import { abbreviateHome } from "../src/runtime" -import { - TuiPathsProvider, - useTuiPaths, -} from "../src/context/runtime" +import { TuiPathsProvider, useTuiPaths } from "../src/context/runtime" test("abbreviates paths within home boundaries", () => { expect(abbreviateHome("/home/test", "/home/test")).toBe("~")