Skip to content
Open
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
3 changes: 2 additions & 1 deletion packages/opencode/src/cli/cmd/tui/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { PromptStashProvider } from "./component/prompt/stash"
import { DialogAlert } from "./ui/dialog-alert"
import { ToastProvider, useToast } from "./ui/toast"
import { ExitProvider, useExit } from "./context/exit"
import { Log } from "@/util/log"
import { Session as SessionApi } from "@/session"
import { TuiEvent } from "./event"
import { KVProvider, useKV } from "./context/kv"
Expand Down Expand Up @@ -199,7 +200,7 @@ function App() {
const [terminalTitleEnabled, setTerminalTitleEnabled] = createSignal(kv.get("terminal_title_enabled", true))

createEffect(() => {
console.log(JSON.stringify(route.data))
Log.Default.debug("route.data", route.data)
})

// Update terminal window title based on current route and session
Expand Down
3 changes: 2 additions & 1 deletion packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useCommandDialog } from "../dialog-command"
import { useRenderer } from "@opentui/solid"
import { Editor } from "@tui/util/editor"
import { useExit } from "../../context/exit"
import { Log } from "@/util/log"
import { Clipboard } from "../../util/clipboard"
import type { FilePart } from "@opencode-ai/sdk/v2"
import { TuiEvent } from "../../event"
Expand Down Expand Up @@ -546,7 +547,7 @@ export function Prompt(props: PromptProps) {
inputText.startsWith("/") &&
iife(() => {
const command = inputText.split(" ")[0].slice(1)
console.log(command)
Log.Default.debug("command", { command })
return sync.data.command.some((x) => x.name === command)
})
) {
Expand Down
3 changes: 2 additions & 1 deletion packages/opencode/src/cli/cmd/tui/context/route.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createStore } from "solid-js/store"
import { createSimpleContext } from "./helper"
import { Log } from "@/util/log"
import type { PromptInfo } from "../component/prompt/history"

export type HomeRoute = {
Expand Down Expand Up @@ -31,7 +32,7 @@ export const { use: useRoute, provider: RouteProvider } = createSimpleContext({
return store
},
navigate(route: Route) {
console.log("navigate", route)
Log.Default.debug("navigate", route)
setStore(route)
},
}
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/cli/cmd/tui/context/sync.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export const { use: useSync, provider: SyncProvider } = createSimpleContext({
const args = useArgs()

async function bootstrap() {
console.log("bootstrapping")
Log.Default.debug("bootstrapping sync context")
const start = Date.now() - 30 * 24 * 60 * 60 * 1000
const sessionListPromise = sdk.client.session
.list({ start: start })
Expand Down
5 changes: 3 additions & 2 deletions packages/opencode/src/cli/cmd/tui/context/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { SyntaxStyle, RGBA, type TerminalColors } from "@opentui/core"
import path from "path"
import { createEffect, createMemo, onMount } from "solid-js"
import { useSync } from "@tui/context/sync"
import { Log } from "@/util/log"
import { createSimpleContext } from "./helper"
import aura from "./theme/aura.json" with { type: "json" }
import ayu from "./theme/ayu.json" with { type: "json" }
Expand Down Expand Up @@ -315,13 +316,13 @@ export const { use: useTheme, provider: ThemeProvider } = createSimpleContext({
onMount(init)

function resolveSystemTheme() {
console.log("resolveSystemTheme")
Log.Default.debug("resolveSystemTheme")
renderer
.getPalette({
size: 16,
})
.then((colors) => {
console.log(colors.palette)
Log.Default.debug("theme.palette", colors)
if (!colors.palette[0]) {
if (store.active === "system") {
setStore(
Expand Down
15 changes: 8 additions & 7 deletions packages/opencode/src/cli/cmd/tui/util/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import clipboardy from "clipboardy"
import { lazy } from "../../../../util/lazy.js"
import { tmpdir } from "os"
import path from "path"
import { Log } from "@/util/log"

export namespace Clipboard {
export interface Content {
Expand Down Expand Up @@ -62,7 +63,7 @@ export namespace Clipboard {
const os = platform()

if (os === "darwin" && Bun.which("osascript")) {
console.log("clipboard: using osascript")
Log.Default.debug("clipboard: using osascript")
return async (text: string) => {
const escaped = text.replace(/\\/g, "\\\\").replace(/"/g, '\\"')
await $`osascript -e 'set the clipboard to "${escaped}"'`.nothrow().quiet()
Expand All @@ -71,17 +72,17 @@ export namespace Clipboard {

if (os === "linux") {
if (process.env["WAYLAND_DISPLAY"] && Bun.which("wl-copy")) {
console.log("clipboard: using wl-copy")
return async (text: string) => {
Log.Default.debug("clipboard: using wl-copy")
return async (text: string) => {
const proc = Bun.spawn(["wl-copy"], { stdin: "pipe", stdout: "ignore", stderr: "ignore" })
proc.stdin.write(text)
proc.stdin.end()
await proc.exited.catch(() => {})
}
}
if (Bun.which("xclip")) {
console.log("clipboard: using xclip")
return async (text: string) => {
Log.Default.debug("clipboard: using xclip")
return async (text: string) => {
const proc = Bun.spawn(["xclip", "-selection", "clipboard"], {
stdin: "pipe",
stdout: "ignore",
Expand All @@ -108,15 +109,15 @@ export namespace Clipboard {
}

if (os === "win32") {
console.log("clipboard: using powershell")
Log.Default.debug("clipboard: using powershell")
return async (text: string) => {
// need to escape backticks because powershell uses them as escape code
const escaped = text.replace(/"/g, '""').replace(/`/g, "``")
await $`powershell -NonInteractive -NoProfile -Command "Set-Clipboard -Value \"${escaped}\""`.nothrow().quiet()
}
}

console.log("clipboard: no native support")
Log.Default.debug("clipboard: no native support")
return async (text: string) => {
await clipboardy.write(text).catch(() => {})
}
Expand Down