fix: default edit-tool diff to side-by-side (split) view

Add an explicit initialDiffStyle field to the openDiffVirtual message flow so each caller declares the desired diff style up front while having `unified` diff as default to prevent regressions.
This commit is contained in:
Johnny Amancio
2026-04-27 18:55:54 +02:00
committed by Johnny Eric Amancio
parent 87a8cdd071
commit 11f2e2afbe
8 changed files with 20 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---
Open edit-tool diffs in side-by-side (split) mode by default; permission-dock expand stays unified.
@@ -8,6 +8,7 @@ export interface DiffVirtualFile {
after: string
additions: number
deletions: number
initialDiffStyle: "unified" | "split"
}
/**
@@ -83,7 +84,7 @@ export class DiffVirtualProvider implements vscode.Disposable {
private pushData(): void {
if (!this.pending) return
this.post({ type: "diffVirtual.data", diff: this.pending })
this.post({ type: "diffVirtual.data", diff: this.pending, initialDiffStyle: this.pending.initialDiffStyle })
}
private post(message: Record<string, unknown>): void {
+5 -3
View File
@@ -729,7 +729,7 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper
vscode.commands.executeCommand("kilo-code.new.marketplaceButtonClicked", this.projectDirectory)
break
case "openDiffVirtual":
this.openDiffVirtual(message.diff)
this.openDiffVirtual(message.diff, message.initialDiffStyle)
break
case "forkSession":
handleForkSession(this.forkCtx, message.sessionId, message.messageId).catch((e) =>
@@ -1073,9 +1073,11 @@ export class KiloProvider implements vscode.WebviewViewProvider, TelemetryProper
void vscode.env.openExternal(vscode.Uri.parse(url))
}
private openDiffVirtual(diff: unknown): void {
private openDiffVirtual(diff: unknown, initialDiffStyle?: unknown): void {
if (!this.diffVirtualProvider || !diff) return
this.diffVirtualProvider.open(diff as import("./DiffVirtualProvider").DiffVirtualFile)
const d = diff as import("./DiffVirtualProvider").DiffVirtualFile
d.initialDiffStyle = initialDiffStyle === "split" ? "split" : "unified"
this.diffVirtualProvider.open(d)
}
/**
@@ -68,7 +68,9 @@ describe("DataBridge openDiff wiring (regression guard)", () => {
}
it("wires openDiff to the openDiffVirtual webview message", () => {
expect(openDiffBlock()).toMatch(/postMessage\(\{\s*type:\s*["']openDiffVirtual["']\s*,\s*diff\s*\}\)/)
expect(openDiffBlock()).toMatch(
/postMessage\(\{\s*type:\s*["']openDiffVirtual["']\s*,\s*diff\s*,\s*initialDiffStyle:\s*["']split["']\s*\}\)/,
)
expect(src).toContain("onOpenDiff={openDiff}")
})
})
@@ -32,9 +32,10 @@ const DiffVirtualContent: Component = () => {
const [style, setStyle] = createSignal<DiffStyle>("unified")
const handler = (event: MessageEvent) => {
const msg = event.data as { type: string; diff?: DiffVirtualFile }
const msg = event.data as { type: string; diff?: DiffVirtualFile; initialDiffStyle?: DiffStyle }
if (msg?.type === "diffVirtual.data" && msg.diff) {
setDiff(msg.diff)
setStyle(msg.initialDiffStyle ?? "unified")
}
}
+1 -1
View File
@@ -134,7 +134,7 @@ export const DataBridge: Component<{ children: any }> = (props) => {
}
const openDiff = (diff: { file: string; before: string; after: string; additions: number; deletions: number }) => {
vscode.postMessage({ type: "openDiffVirtual", diff })
vscode.postMessage({ type: "openDiffVirtual", diff, initialDiffStyle: "split" })
}
const openUrl = (url: string) => {
@@ -39,6 +39,7 @@ export const PermissionDiff: Component<PermissionDiffProps> = (props) => {
vscode.postMessage({
type: "openDiffVirtual",
diff: { ...props.filediff, before, after },
initialDiffStyle: "unified",
})
}
@@ -731,6 +731,7 @@ export interface OpenChangesRequest {
export interface OpenDiffVirtualRequest {
type: "openDiffVirtual"
diff: PermissionFileDiff
initialDiffStyle: "unified" | "split"
}
export interface RetryConnectionRequest {