Skip to content
Draft
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: 5 additions & 0 deletions packages/types/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import { GLOBAL_STATE_KEYS } from "../index.js"

describe("GLOBAL_STATE_KEYS", () => {
it("should contain registered durable per-view state", () => {
expect(GLOBAL_STATE_KEYS).toContain("viewStates")
})

it("should contain provider settings keys", () => {
expect(GLOBAL_STATE_KEYS).toContain("autoApprovalEnabled")
})
Expand All @@ -13,6 +17,7 @@ describe("GLOBAL_STATE_KEYS", () => {

it("should not contain secret state keys", () => {
expect(GLOBAL_STATE_KEYS).not.toContain("openRouterApiKey")
expect(GLOBAL_STATE_KEYS).not.toContain("apiKey")
})

it("should contain OpenAI Compatible base URL setting", () => {
Expand Down
17 changes: 16 additions & 1 deletion packages/types/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { EventEmitter } from "events"
import type { Socket } from "net"

import type { RooCodeEvents } from "./events.js"
import type { RooCodeSettings } from "./global-settings.js"
import type { GlobalState, RooCodeSettings } from "./global-settings.js"
import type { HistoryItem } from "./history.js"
import type { ProviderSettingsEntry, ProviderSettings } from "./provider-settings.js"
import type { IpcMessage, IpcServerEvents } from "./ipc.js"
Expand All @@ -21,11 +21,13 @@ export interface RooCodeAPI extends EventEmitter<RooCodeAPIEvents> {
text,
images,
newTab,
preserveOpenTabs,
}: {
configuration?: RooCodeSettings
text?: string
images?: string[]
newTab?: boolean
preserveOpenTabs?: boolean
}): Promise<string>
/**
* Resumes a task with the given ID.
Expand Down Expand Up @@ -92,6 +94,15 @@ export interface RooCodeAPI extends EventEmitter<RooCodeAPIEvents> {
* confirming a completion result. No-ops if no task is active.
*/
approveCurrentAsk(): Promise<void>
/**
* Programmatically approves the pending ask for a task by ID. Intended for use in tests only.
*/
approveTaskAsk(taskId: string): Promise<boolean>
/**
* Simulates selecting a follow-up suggestion for a task by ID, including its optional mode switch.
* Intended for use in tests only.
*/
selectTaskFollowupSuggestion(options: { taskId: string; answer: string; mode?: string }): Promise<boolean>
/**
* Returns true if the API is ready to use.
*/
Expand All @@ -106,6 +117,10 @@ export interface RooCodeAPI extends EventEmitter<RooCodeAPIEvents> {
* @param values An object containing key-value pairs to set.
*/
setConfiguration(values: RooCodeSettings): Promise<void>
/**
* Returns a value from VS Code globalState. Intended for use in tests only.
*/
getGlobalState<K extends keyof GlobalState>(key: K): GlobalState[K]
/**
* Returns a list of all configured profile names
* @returns Array of profile names
Expand Down
10 changes: 10 additions & 0 deletions packages/types/src/global-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ export const MAX_CHECKPOINT_TIMEOUT_SECONDS = 60
*/
export const DEFAULT_CHECKPOINT_TIMEOUT_SECONDS = 15

/**
* Persisted non-secret selections for a stable webview instance.
*/
export const viewStateSchema = z.object({
mode: z.string().optional(),
currentApiConfigName: z.string().optional(),
updatedAt: z.number().optional(),
})

/**
* GlobalSettings
*/
Expand All @@ -107,6 +116,7 @@ export const globalSettingsSchema = z.object({
currentApiConfigName: z.string().optional(),
listApiConfigMeta: z.array(providerSettingsEntrySchema).optional(),
pinnedApiConfigs: z.record(z.string(), z.boolean()).optional(),
viewStates: z.record(z.string(), viewStateSchema).optional(),

lastShownAnnouncementId: z.string().optional(),
customInstructions: z.string().optional(),
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/vscode-extension-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ export interface WebviewMessage {
| "deleteRule"
| "openRuleFile"
| "openRulesDirectory"
viewStateId?: string
text?: string
taskId?: string
editedMessageContent?: string
Expand Down
Loading
Loading