Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 59 additions & 1 deletion src/activate/__tests__/registerCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Mock } from "vitest"
import * as vscode from "vscode"
import { ClineProvider } from "../../core/webview/ClineProvider"

import { getVisibleProviderOrLog, registerCommands, setPanel } from "../registerCommands"
import { getVisibleProviderOrLog, openClineInNewTab, registerCommands, setPanel } from "../registerCommands"

vi.mock("execa", () => ({
execa: vi.fn(),
Expand All @@ -13,8 +13,16 @@ vi.mock("vscode", () => ({
QuickFix: { value: "quickfix" },
RefactorRewrite: { value: "refactor.rewrite" },
},
Uri: {
joinPath: vi.fn((_base: unknown, ..._pathSegments: string[]) => ({ path: _pathSegments.join("/") })),
},
ViewColumn: {
Two: 2,
},
window: {
createTextEditorDecorationType: vi.fn().mockReturnValue({ dispose: vi.fn() }),
createWebviewPanel: vi.fn(),
visibleTextEditors: [],
},
workspace: {
workspaceFolders: [
Expand Down Expand Up @@ -367,3 +375,53 @@ describe("registerCommands handlers", () => {
await handlers["zoo-code.plusButtonClicked"]()
})
})

describe("openClineInNewTab", () => {
let mockOutputChannel: vscode.OutputChannel
let mockContext: vscode.ExtensionContext

beforeEach(() => {
vi.clearAllMocks()

mockOutputChannel = {
appendLine: vi.fn(),
append: vi.fn(),
clear: vi.fn(),
hide: vi.fn(),
name: "mock",
replace: vi.fn(),
show: vi.fn(),
dispose: vi.fn(),
}

mockContext = {
subscriptions: [],
extensionUri: { path: "/mock/ext" },
} as unknown as vscode.ExtensionContext

const mockPanel = {
webview: { postMessage: vi.fn() },
onDidChangeViewState: vi.fn(),
onDidDispose: vi.fn(),
}
;(vscode.window.createWebviewPanel as Mock).mockReturnValue(mockPanel)

// Reset module-level panel state.
setPanel(undefined, "sidebar")
setPanel(undefined, "tab")
})

it("creates a webview panel with title 'Zoo Code'", async () => {
await openClineInNewTab({ context: mockContext, outputChannel: mockOutputChannel })

expect(vscode.window.createWebviewPanel).toHaveBeenCalledWith(
"zoo-code.TabPanelProvider",
"Zoo Code",
expect.any(Number),
expect.objectContaining({
enableScripts: true,
retainContextWhenHidden: true,
}),
)
})
})
2 changes: 1 addition & 1 deletion src/activate/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export const openClineInNewTab = async ({ context, outputChannel }: Omit<Registe

const targetCol = hasVisibleEditors ? Math.max(lastCol + 1, 1) : vscode.ViewColumn.Two

const newPanel = vscode.window.createWebviewPanel(ClineProvider.tabPanelId, "Roo Code", targetCol, {
const newPanel = vscode.window.createWebviewPanel(ClineProvider.tabPanelId, "Zoo Code", targetCol, {
enableScripts: true,
retainContextWhenHidden: true,
localResourceRoots: [context.extensionUri],
Expand Down
6 changes: 4 additions & 2 deletions src/api/providers/__tests__/lmstudio.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ describe("LmStudioHandler", () => {
for await (const _chunk of stream) {
// Should not reach here
}
}).rejects.toThrow("Please check the LM Studio developer logs to debug what went wrong")
}).rejects.toThrow(
"Please check the LM Studio developer logs to debug what went wrong. You may need to load the model with a larger context length to work with Zoo Code's prompts.",
)
})
})

Expand All @@ -144,7 +146,7 @@ describe("LmStudioHandler", () => {
it("should handle API errors", async () => {
mockCreate.mockRejectedValueOnce(new Error("API Error"))
await expect(handler.completePrompt("Test prompt")).rejects.toThrow(
"Please check the LM Studio developer logs to debug what went wrong",
"Please check the LM Studio developer logs to debug what went wrong. You may need to load the model with a larger context length to work with Zoo Code's prompts.",
)
})

Expand Down
Loading
Loading