Repository navigation
fix(agent-manager): propagate base branch override to active diff source #12696
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 1 commit
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 | ||
| --- | ||
|
|
||
| Apply the Agent Manager base branch picker selection to the active diff immediately. Changing the base branch now refreshes the diff against the new base instead of keeping the previous comparison until the scope or session changed. |
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
89 changes: 89 additions & 0 deletions
89
packages/kilo-vscode/tests/unit/worktree-diff-controller.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,89 @@ | ||
| import { describe, it, expect } from "bun:test" | ||
| import { WorktreeDiffController } from "../../src/agent-manager/worktree-diff-controller" | ||
| import type { DiffSourceCatalog } from "../../src/diff/sources/catalog" | ||
| import type { DiffSource } from "../../src/diff/sources/types" | ||
| import type { PanelContext } from "../../src/diff/types" | ||
| import type { GitOps } from "../../src/agent-manager/GitOps" | ||
| import type { WorktreeStateManager } from "../../src/agent-manager/WorktreeStateManager" | ||
|
|
||
| // Records every PanelContext handed to catalog.build so tests can assert which | ||
| // base branch the active source was (re)built with. The controller, scope | ||
| // resolution, and SourceController lifecycle under test are all real. | ||
| function make() { | ||
| const builds: { id: string; ctx: PanelContext }[] = [] | ||
| const catalog = { | ||
| build: (id: string, ctx: PanelContext): DiffSource => { | ||
| builds.push({ id, ctx }) | ||
| return { | ||
| descriptor: { id, type: "workspace", group: "Git", capabilities: { revert: true, comments: true } }, | ||
| async fetch() { | ||
| return { diffs: [] } | ||
| }, | ||
| } | ||
| }, | ||
| } as unknown as DiffSourceCatalog | ||
|
|
||
| const state = { | ||
| getSession: (id: string) => (id === "s1" ? { id: "s1", worktreeId: "w1", createdAt: "" } : undefined), | ||
| getWorktree: (id: string) => | ||
| id === "w1" ? { id: "w1", path: "/wt", parentBranch: "main", remote: "origin" } : undefined, | ||
| } as unknown as WorktreeStateManager | ||
|
|
||
| const controller = new WorktreeDiffController({ | ||
| getState: () => state, | ||
| getRoot: () => "/repo", | ||
| getStateReady: () => undefined, | ||
| catalog, | ||
| git: {} as GitOps, | ||
| localDiffFile: async () => null, | ||
| post: () => {}, | ||
| log: () => {}, | ||
| }) | ||
| return { controller, builds } | ||
| } | ||
|
|
||
| const tick = () => new Promise((resolve) => setTimeout(resolve, 0)) | ||
|
|
||
| async function waitFor(cond: () => boolean): Promise<void> { | ||
| for (let i = 0; i < 50; i++) { | ||
| if (cond()) return | ||
| await tick() | ||
| } | ||
| throw new Error("waitFor timed out") | ||
| } | ||
|
|
||
| describe("WorktreeDiffController.setBase", () => { | ||
| it("rebuilds the active source against the overridden base branch", async () => { | ||
| const { controller, builds } = make() | ||
| controller.start("s1#branch") | ||
| await waitFor(() => builds.length === 1) | ||
| expect(builds[0]!.ctx.dir).toBe("/wt") | ||
| expect(builds[0]!.ctx.baseBranch).toBe("origin/main") | ||
|
|
||
| await controller.setBase("s1#branch", "feature-x") | ||
| expect(builds.length).toBe(2) | ||
| expect(builds[1]!.ctx.dir).toBe("/wt") | ||
| expect(builds[1]!.ctx.baseBranch).toBe("feature-x") | ||
|
|
||
| // Clearing the override falls back to the recorded parent ref. | ||
| await controller.setBase("s1#branch", undefined) | ||
| expect(builds.length).toBe(3) | ||
| expect(builds[2]!.ctx.baseBranch).toBe("origin/main") | ||
|
|
||
| controller.stop() | ||
| }) | ||
|
|
||
| it("stores the override without rebuilding when the context isn't active", async () => { | ||
| const { controller, builds } = make() | ||
|
|
||
| await controller.setBase("s1#branch", "feature-x") | ||
| expect(builds.length).toBe(0) | ||
|
|
||
| // The next activation of that context resolves the stored override. | ||
| controller.start("s1#branch") | ||
| await waitFor(() => builds.length === 1) | ||
| expect(builds[0]!.ctx.baseBranch).toBe("feature-x") | ||
|
|
||
| controller.stop() | ||
| }) | ||
| }) |
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.