Browse Source

feat: add a diff_style option to allow disabling columnar diffs (resolve #4677) (#4756)

Co-authored-by: Dax Raad <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: rekram1-node <[email protected]>
Ariane Emory 3 months ago
parent
commit
57644a4be8

+ 8 - 1
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx

@@ -80,6 +80,7 @@ const context = createContext<{
   conceal: () => boolean
   conceal: () => boolean
   showThinking: () => boolean
   showThinking: () => boolean
   showTimestamps: () => boolean
   showTimestamps: () => boolean
+  sync: ReturnType<typeof useSync>
 }>()
 }>()
 
 
 function use() {
 function use() {
@@ -732,6 +733,7 @@ export function Session() {
         conceal,
         conceal,
         showThinking,
         showThinking,
         showTimestamps,
         showTimestamps,
+        sync,
       }}
       }}
     >
     >
       <box flexDirection="row" paddingBottom={1} paddingTop={1} paddingLeft={2} paddingRight={2} gap={2}>
       <box flexDirection="row" paddingBottom={1} paddingTop={1} paddingLeft={2} paddingRight={2} gap={2}>
@@ -1482,7 +1484,12 @@ ToolRegistry.register<typeof EditTool>({
     const ctx = use()
     const ctx = use()
     const { theme, syntax } = useTheme()
     const { theme, syntax } = useTheme()
 
 
-    const style = createMemo(() => (ctx.width > 120 ? "split" : "stacked"))
+    const style = createMemo(() => {
+      const diffStyle = ctx.sync.data.config.tui?.diff_style
+      if (diffStyle === "stacked") return "stacked"
+      // Default to "auto" behavior
+      return ctx.width > 120 ? "split" : "stacked"
+    })
 
 
     const diff = createMemo(() => {
     const diff = createMemo(() => {
       const diff = props.metadata.diff ?? props.permission["diff"]
       const diff = props.metadata.diff ?? props.permission["diff"]

+ 4 - 0
packages/opencode/src/config/config.ts

@@ -456,6 +456,10 @@ export namespace Config {
       })
       })
       .optional()
       .optional()
       .describe("Scroll acceleration settings"),
       .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 Layout = z.enum(["auto", "stretch"]).meta({
   export const Layout = z.enum(["auto", "stretch"]).meta({

+ 4 - 0
packages/sdk/js/src/gen/types.gen.ts

@@ -1003,6 +1003,10 @@ export type Config = {
        */
        */
       enabled: boolean
       enabled: boolean
     }
     }
+    /**
+     * Control diff rendering style: 'auto' adapts to terminal width, 'stacked' always shows single column
+     */
+    diff_style?: "auto" | "stacked"
   }
   }
   /**
   /**
    * Command configuration, see https://opencode.ai/docs/commands
    * Command configuration, see https://opencode.ai/docs/commands