mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-29 03:44:06 +08:00
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:
committed by
Johnny Eric Amancio
parent
87a8cdd071
commit
11f2e2afbe
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user