Skip to content
Draft
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
10 changes: 10 additions & 0 deletions packages/opencode/src/cli/cmd/tui/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,16 @@ function App() {
dialog.clear()
},
},
{
title: kv.get("diff_style", "auto") === "auto" ? "Use unified diff style" : "Use automatic diff style",
value: "tui.diff_style.toggle",
category: "System",
onSelect: (dialog) => {
const current = kv.get("diff_style", "auto")
kv.set("diff_style", current === "auto" ? "unified" : "auto")
dialog.clear()
},
},
])

createEffect(() => {
Expand Down
10 changes: 6 additions & 4 deletions packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1819,11 +1819,12 @@ function Task(props: ToolProps<typeof TaskTool>) {

function Edit(props: ToolProps<typeof EditTool>) {
const ctx = use()
const kv = useKV()
const { theme, syntax } = useTheme()

const view = createMemo(() => {
const diffStyle = ctx.sync.data.config.tui?.diff_style
if (diffStyle === "stacked") return "unified"
const diffStyle = kv.get("diff_style", "auto")
if (diffStyle === "unified") return "unified"
// Default to "auto" behavior
return ctx.width > 120 ? "split" : "unified"
})
Expand Down Expand Up @@ -1888,13 +1889,14 @@ function Edit(props: ToolProps<typeof EditTool>) {

function ApplyPatch(props: ToolProps<typeof ApplyPatchTool>) {
const ctx = use()
const kv = useKV()
const { theme, syntax } = useTheme()

const files = createMemo(() => props.metadata.files ?? [])

const view = createMemo(() => {
const diffStyle = ctx.sync.data.config.tui?.diff_style
if (diffStyle === "stacked") return "unified"
const diffStyle = kv.get("diff_style", "auto")
if (diffStyle === "unified") return "unified"
return ctx.width > 120 ? "split" : "unified"
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { PermissionRequest } from "@opencode-ai/sdk/v2"
import { useSDK } from "../../context/sdk"
import { SplitBorder } from "../../component/border"
import { useSync } from "../../context/sync"
import { useKV } from "../../context/kv"
import { useTextareaKeybindings } from "../../component/textarea-keybindings"
import path from "path"
import { LANGUAGE_EXTENSIONS } from "@/lsp/language"
Expand Down Expand Up @@ -48,15 +49,15 @@ function EditBody(props: { request: PermissionRequest }) {
const themeState = useTheme()
const theme = themeState.theme
const syntax = themeState.syntax
const sync = useSync()
const kv = useKV()
const dimensions = useTerminalDimensions()

const filepath = createMemo(() => (props.request.metadata?.filepath as string) ?? "")
const diff = createMemo(() => (props.request.metadata?.diff as string) ?? "")

const view = createMemo(() => {
const diffStyle = sync.data.config.tui?.diff_style
if (diffStyle === "stacked") return "unified"
const diffStyle = kv.get("diff_style", "auto")
if (diffStyle === "unified") return "unified"
return dimensions().width > 120 ? "split" : "unified"
})

Expand Down
4 changes: 0 additions & 4 deletions packages/opencode/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,10 +806,6 @@ export namespace Config {
})
.optional()
.describe("Scroll acceleration settings"),
diff_style: z
.enum(["auto", "stacked"])
.optional()
.describe("Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column"),
})

export const Server = z
Expand Down