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
5 changes: 4 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"preLaunchTask": "${defaultBuildTask}",
"env": {
"NODE_ENV": "development",
"VSCODE_DEBUG_MODE": "true"
"VSCODE_DEBUG_MODE": "true",
// Dev-only: registers the `zoo-code.openInBrowser` command (socket.io
// browser bridge for render debugging). See src/activate/registerCommands.ts.
"ROO_BROWSER_BRIDGE": "1"
},
"resolveSourceMapLocations": ["${workspaceFolder}/**", "!**/node_modules/**"],
"presentation": {
Expand Down
137 changes: 137 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions src/activate/__tests__/registerCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Mock } from "vitest"
import * as vscode from "vscode"
import { ClineProvider } from "../../core/webview/ClineProvider"

import { BrowserBridgeServer } from "../../core/webview/browserBridge"
import { getVisibleProviderOrLog, openClineInNewTab, registerCommands, setPanel } from "../registerCommands"

vi.mock("execa", () => ({
Expand Down Expand Up @@ -93,6 +94,13 @@ vi.mock("../../services/ripgrep/diagnostic", () => ({
registerRipgrepDiagnosticCommand: vi.fn().mockReturnValue({ dispose: vi.fn() }),
}))

// The browser bridge command is dev-only tooling; registerCommands must merely
// hand it the activation context (its self-gating is covered in
// core/webview/__tests__/browserBridge.spec.ts).
vi.mock("../../core/webview/browserBridge", () => ({
BrowserBridgeServer: { registerCommand: vi.fn() },
}))

describe("getVisibleProviderOrLog", () => {
let mockOutputChannel: vscode.OutputChannel

Expand Down Expand Up @@ -192,6 +200,17 @@ describe("registerCommands handlers", () => {
expect(mockContext.subscriptions).toContain(disposable)
})

it("delegates the dev-only browser bridge command registration to BrowserBridgeServer", async () => {
const registerCommandSpy = vi.mocked(BrowserBridgeServer.registerCommand)
expect(registerCommandSpy).toHaveBeenCalledTimes(1)
expect(registerCommandSpy).toHaveBeenCalledWith(mockContext, mockOutputChannel, expect.any(Function))

// The third argument is the visible-provider callback the bridge uses
// to find the provider to put into browser mode.
const getVisibleProvider = registerCommandSpy.mock.calls[0][2]
expect(getVisibleProvider()).toBe(mockVisibleProvider)
})

it("settingsButtonClicked posts both settingsButtonClicked and didBecomeVisible actions", () => {
handlers["zoo-code.settingsButtonClicked"]()

Expand Down
5 changes: 4 additions & 1 deletion src/activate/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import delay from "delay"
import type { CommandId } from "@roo-code/types"
import { TelemetryService } from "@roo-code/telemetry"

import { Package } from "../shared/package"
import { getCommand } from "../utils/commands"
import { ClineProvider } from "../core/webview/ClineProvider"
import { ContextProxy } from "../core/config/ContextProxy"
Expand All @@ -15,6 +14,7 @@ import { importSettingsWithFeedback } from "../core/config/importExport"
import { MdmService } from "../services/mdm/MdmService"
import { registerRipgrepDiagnosticCommand } from "../services/ripgrep/diagnostic"
import { t } from "../i18n"
import { BrowserBridgeServer } from "../core/webview/browserBridge"

/**
* Helper to get the visible ClineProvider instance or log if not found.
Expand Down Expand Up @@ -71,6 +71,9 @@ export const registerCommands = (options: RegisterCommandOptions) => {
}

context.subscriptions.push(registerRipgrepDiagnosticCommand())

// Dev-only tooling: self-gating no-op in production (see browserBridge.ts).
BrowserBridgeServer.registerCommand(context, options.outputChannel, () => ClineProvider.getVisibleInstance())
}

// `showRipgrepDiagnostic` is registered separately by
Expand Down
Loading
Loading