mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-09 03:17:58 +00:00
re add default source when all sources are deleted
This commit is contained in:
parent
c92be6aadb
commit
ad91533205
2 changed files with 51 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { PackageManagerItem, PackageManagerSource } from "../../../../src/services/package-manager/types"
|
||||
import { vscode } from "../../utils/vscode"
|
||||
import { WebviewMessage } from "../../../../src/shared/WebviewMessage"
|
||||
import { DEFAULT_PACKAGE_MANAGER_SOURCE } from "../../../../src/services/package-manager/constants"
|
||||
|
||||
export interface ViewState {
|
||||
allItems: PackageManagerItem[]
|
||||
|
|
@ -275,12 +276,14 @@ export class PackageManagerViewStateManager {
|
|||
|
||||
case "UPDATE_SOURCES": {
|
||||
const { sources } = transition.payload as TransitionPayloads["UPDATE_SOURCES"]
|
||||
this.state.sources = sources
|
||||
// If all sources are removed, add the default source
|
||||
const updatedSources = sources.length === 0 ? [DEFAULT_PACKAGE_MANAGER_SOURCE] : sources
|
||||
this.state.sources = updatedSources
|
||||
this.notifyStateChange()
|
||||
|
||||
vscode.postMessage({
|
||||
type: "packageManagerSources",
|
||||
sources,
|
||||
sources: updatedSources,
|
||||
} as WebviewMessage)
|
||||
|
||||
if (this.state.activeTab === "browse") {
|
||||
|
|
|
|||
|
|
@ -231,12 +231,24 @@ describe("PackageManagerViewStateManager", () => {
|
|||
jest.runAllTimers()
|
||||
|
||||
const state = manager.getState()
|
||||
expect(state.sources).toEqual([])
|
||||
expect(state.sources).toEqual([
|
||||
{
|
||||
url: "https://github.com/RooVetGit/Roo-Code-Packages",
|
||||
name: "Roo Code Package Manager Template",
|
||||
enabled: true,
|
||||
},
|
||||
])
|
||||
|
||||
// Should send the final sources state to webview
|
||||
// Should send the final sources state to webview with default source
|
||||
expect(vscode.postMessage).toHaveBeenLastCalledWith({
|
||||
type: "packageManagerSources",
|
||||
sources: [],
|
||||
sources: [
|
||||
{
|
||||
url: "https://github.com/RooVetGit/Roo-Code-Packages",
|
||||
name: "Roo Code Package Manager Template",
|
||||
enabled: true,
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -494,6 +506,37 @@ describe("PackageManagerViewStateManager", () => {
|
|||
// Filter behavior tests are already covered in the previous describe block
|
||||
|
||||
describe("Source Management", () => {
|
||||
it("should re-add default source when all sources are removed", async () => {
|
||||
// Add some test sources
|
||||
const sources = [
|
||||
{ url: "https://github.com/test/repo1", enabled: true },
|
||||
{ url: "https://github.com/test/repo2", enabled: true },
|
||||
]
|
||||
|
||||
await manager.transition({
|
||||
type: "UPDATE_SOURCES",
|
||||
payload: { sources },
|
||||
})
|
||||
|
||||
// Remove all sources
|
||||
await manager.transition({
|
||||
type: "UPDATE_SOURCES",
|
||||
payload: { sources: [] },
|
||||
})
|
||||
|
||||
// Verify that the default source was automatically re-added
|
||||
expect(vscode.postMessage).toHaveBeenLastCalledWith({
|
||||
type: "packageManagerSources",
|
||||
sources: [
|
||||
{
|
||||
url: "https://github.com/RooVetGit/Roo-Code-Packages",
|
||||
name: "Roo Code Package Manager Template",
|
||||
enabled: true,
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
it("should handle UPDATE_SOURCES transition", async () => {
|
||||
const sources = [
|
||||
{ url: "https://github.com/test/repo", enabled: true },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue