-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(vscode): preserve changes in multi-repo sessions #13088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "kilo-code": patch | ||
| --- | ||
|
|
||
| Keep the Changes chip and Git changes visible across tab switches in multi-repository workspaces. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import * as path from "path" | ||
|
|
||
| const tools = new Set(["apply_patch", "edit", "generate_image", "multiedit", "write"]) | ||
|
|
||
| function record(value: unknown): Record<string, unknown> | undefined { | ||
| if (!value || typeof value !== "object") return | ||
| return value as Record<string, unknown> | ||
| } | ||
|
|
||
| function value(input: unknown): string | undefined { | ||
| return typeof input === "string" && input.length > 0 ? input : undefined | ||
| } | ||
|
|
||
| function files(part: Record<string, unknown>): string[] { | ||
| const state = record(part.state) | ||
| if (part.type !== "tool" || state?.status !== "completed") return [] | ||
| if (typeof part.tool !== "string" || !tools.has(part.tool)) return [] | ||
|
|
||
| const meta = record(state.metadata) | ||
| if (part.tool === "apply_patch" && Array.isArray(meta?.files)) { | ||
| return meta.files.flatMap((item) => { | ||
| const file = record(item) | ||
| return value(file?.movePath) ?? value(file?.filePath) ?? value(file?.relativePath) ?? [] | ||
| }) | ||
| } | ||
|
|
||
| if (part.tool === "multiedit" && Array.isArray(meta?.results)) { | ||
| return meta.results.flatMap((item) => { | ||
| const result = record(item) | ||
| const diff = record(result?.filediff) | ||
| return value(diff?.file) ?? [] | ||
| }) | ||
| } | ||
|
|
||
| const diff = record(meta?.filediff) | ||
| const input = record(state.input) | ||
| return [value(diff?.file) ?? value(meta?.filepath) ?? value(input?.filePath)].filter((file): file is string => !!file) | ||
| } | ||
|
|
||
| /** Absolute paths written by completed file-mutating tool parts. */ | ||
| export function editPaths(parts: unknown[], base: string): string[] { | ||
| return parts.flatMap((part) => { | ||
| const item = record(part) | ||
| if (!item) return [] | ||
| return files(item).map((file) => (path.isAbsolute(file) ? path.normalize(file) : path.resolve(base, file))) | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/kilo-vscode/tests/unit/diff-viewer-provider.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { describe, expect, it } from "bun:test" | ||
| import * as vscode from "vscode" | ||
| import { DiffViewerProvider } from "../../src/diff/DiffViewerProvider" | ||
| import type { PanelContext } from "../../src/diff/types" | ||
|
|
||
| describe("DiffViewerProvider.openFromCommand", () => { | ||
| it("uses the invoking provider directory even when it is explicitly unavailable", () => { | ||
| const provider = new DiffViewerProvider({} as vscode.Uri, {} as never, {} as never, { | ||
| sessionIdProvider: () => "sidebar", | ||
| sessionDirectoryProvider: () => "/sidebar/repo", | ||
| }) | ||
| const contexts: PanelContext[] = [] | ||
| provider.openPanel = (ctx) => contexts.push(ctx) | ||
|
|
||
| provider.openFromCommand({ sessionId: "agent-manager", directory: "/agent/repo" }) | ||
| provider.openFromCommand({ sessionId: "editor-tab", directory: undefined }) | ||
| provider.openFromCommand() | ||
|
|
||
| expect(contexts.map((ctx) => ctx.dir)).toEqual(["/agent/repo", undefined, "/sidebar/repo"]) | ||
| provider.dispose() | ||
| }) | ||
| }) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.