Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
389f1b4
feat(webview): per-view view-state identity and host-minted claim tok…
easonLiangWorldedtech Nov 5, 2026
6c9a0f3
chore: strip BOM and fix lint imports
easonLiangWorldedtech Oct 29, 2026
29a09c5
fix(webview): address review findings on view-state durability
easonLiangWorldedtech Oct 29, 2026
aaa5962
chore: tighten the view-identity comments
easonLiangWorldedtech Oct 30, 2026
a4293ad
fix(webview): load persisted selections when a view id is registered
easonLiangWorldedtech Oct 30, 2026
8917173
chore: tighten the shared view-state docs
easonLiangWorldedtech Oct 30, 2026
5acc1d5
fix(webview): track buffer writes so a same-value save survives the load
easonLiangWorldedtech Oct 30, 2026
f17c21b
chore: tighten the N1 test comments
easonLiangWorldedtech Oct 30, 2026
1341c56
fix(lint): drop the now-unused load snapshot and log spy
easonLiangWorldedtech Oct 30, 2026
68c47f1
fix(webview): harden viewStates reads and retry an unrestored view state
easonLiangWorldedtech Nov 3, 2026
123398d
fix(config): drop viewStates from settings imports
easonLiangWorldedtech Nov 4, 2026
dcc03e6
fix(webview): await view-state claim delivery and report an undeliver…
easonLiangWorldedtech Nov 4, 2026
876710b
test(webview): cover malformed view id rejections in setViewStateId
easonLiangWorldedtech Nov 4, 2026
3fdef00
fix(webview): cancel queued view-state work with a disposal generation
easonLiangWorldedtech Nov 4, 2026
3ed1cee
fix(webview): report claim delivery and retry an undelivered claim on…
easonLiangWorldedtech Nov 4, 2026
be37f89
fix(webview): refuse non-portable settings keys posted by the webview
easonLiangWorldedtech Nov 4, 2026
f807e34
fix(webview): hold view-state claims until the renderer launches and …
easonLiangWorldedtech Nov 4, 2026
01da20f
fix(webview): reset isViewLaunched when the renderer is replaced
easonLiangWorldedtech Nov 5, 2026
e5b7ef5
fix(webview): close the claim-boundary and persistence gaps from review
easonLiangWorldedtech Nov 5, 2026
c7f40a2
fix(webview): detach rejected writes and restore view-local fields
easonLiangWorldedtech Nov 5, 2026
73efca9
style(webview): fold guard blocks that add no behaviour
easonLiangWorldedtech Nov 5, 2026
02b53d4
fix(extension): keep host-owned view states out of API.getConfigurati…
easonLiangWorldedtech Nov 5, 2026
a84f002
test(core): cover the export omission, the webview post result, and i…
easonLiangWorldedtech Nov 5, 2026
bfc9462
refactor(core): fold three copies of the view-state queue call into o…
easonLiangWorldedtech Nov 5, 2026
7a076e8
test(extension): cover secret filtering and export retention, type th…
easonLiangWorldedtech Nov 5, 2026
616c804
fix(webview): undo a re-key whose view died before the entry reached …
easonLiangWorldedtech Nov 5, 2026
f6b04ed
fix(webview): keep memory and storage agreeing when a re-key recovery…
easonLiangWorldedtech Nov 5, 2026
b5a2429
refactor(config): trim the branch to the portable-keys and typed-prof…
easonLiangWorldedtech Nov 10, 2026
0a89680
refactor(webview): port the message-handler and API-surface unit
easonLiangWorldedtech Nov 10, 2026
e6ba310
fix(webview): heal the conflict-union scars in the handler pair
easonLiangWorldedtech Nov 28, 2026
3ce462c
fix(types,webview): realign the retirement surface and handler pair w…
easonLiangWorldedtech Nov 28, 2026
46f30de
fix(test): drop the GlobalState type import left dead by landing drift
easonLiangWorldedtech Nov 28, 2026
fe77eea
fix(config,test): honor the own-profile contract and assert the filte…
easonLiangWorldedtech Nov 28, 2026
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
43 changes: 43 additions & 0 deletions packages/types/src/__tests__/global-settings.test.ts

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

5 changes: 5 additions & 0 deletions packages/types/src/__tests__/index.test.ts

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

12 changes: 12 additions & 0 deletions packages/types/src/global-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ 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(),
/** Host-minted token binding this entry to the webview that wrote it. */
claimToken: z.string().optional(),
})

/**
* GlobalSettings
*/
Expand All @@ -125,6 +136,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
11 changes: 11 additions & 0 deletions packages/types/src/vscode-extension-host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export interface ExtensionMessage {
| "rooHistoryImportProgress"
| "themeFixtureProbeRequest"
| "diagnosticsRequest"
| "viewStateClaim"
text?: string
/** For fileContent: { path, content, error? } */
fileContent?: { path: string; content: string | null; error?: string }
Expand Down Expand Up @@ -203,6 +204,13 @@ export interface ExtensionMessage {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
values?: Record<string, any>
requestId?: string
/**
* For `viewStateClaim`: the durable `viewStates` key the delivered claim governs. The
* message is only ever sent to the webview that key belongs to.
*/
viewStateId?: string
/** For `viewStateClaim`: the host-minted token the webview stores and echoes on launch. */
viewStateClaim?: string
themeFixture?: WebviewThemeFixture
diagnostics?: WebviewDiagnosticsSnapshot
promptText?: string
Expand Down Expand Up @@ -759,6 +767,9 @@ export interface WebviewMessage {
| "themeFixtureProbeResponse"
| "diagnosticsResponse"
text?: string
viewStateId?: string
/** For `webviewDidLaunch`: the claim delivered for `viewStateId`, enforced by setViewStateId. */
viewStateClaim?: string
taskId?: string
editedMessageContent?: string
tab?: "settings" | "history" | "mcp" | "modes" | "chat" | "marketplace" | "cloud"
Expand Down
22 changes: 21 additions & 1 deletion src/core/config/ContextProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,21 @@
taskHistory: true,
listApiConfigMeta: true,
currentApiConfigName: true,
// Host-minted claim tokens and per-view selections are not user-settings: exporting
// them would let a settings file be replayed as another view's identity.
viewStates: true,
})

/**
* Global settings a settings file may not carry in either direction. Per-view selections and the
* claim token that binds them are minted and held by the extension host, so a file that could
* set them would be replayable as another view's identity. The export side omits the key above;
* the import side consults this list in `sanitizeGlobalSettings`.
*/
const NON_PORTABLE_SETTINGS_KEYS: readonly string[] = ["viewStates"]

export const isNonPortableSettingsKey = (key: string): boolean => NON_PORTABLE_SETTINGS_KEYS.includes(key)

export class ContextProxy {
private readonly originalContext: vscode.ExtensionContext

Expand Down Expand Up @@ -666,7 +679,14 @@
* rollback, must provide it themselves.
*/
public async setValues(values: RooCodeSettings) {
const entries = Object.entries(values) as [RooCodeSettingsKey, unknown][]
// viewStates is host-owned: per-view selections and the claim token that binds them are
// minted by the extension host, so no configuration path may carry them. Every caller of
// this setter takes input that did not originate inside the host - a posted updateSettings,
// a newTask taskConfiguration, the external API, an imported settings file - so the filter
// lives here rather than at whichever caller a reviewer happened to point at. The host's
// own view-state methods write through setValue("viewStates", ...), which stays open.
const portableEntries = Object.entries(values).filter(([key]) => !isNonPortableSettingsKey(key))

Check warning on line 688 in src/core/config/ContextProxy.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

src/core/config/ContextProxy.ts:688: Survived MethodExpression mutant (replacement: Object.entries(values)). See the job summary for the complete list and resolution guidance.

Check warning on line 688 in src/core/config/ContextProxy.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

src/core/config/ContextProxy.ts:688: Survived MethodExpression mutant (replacement: Object.entries(values)). See the job summary for the complete list and resolution guidance.
const entries = portableEntries as [RooCodeSettingsKey, unknown][]
const results = await Promise.allSettled(entries.map(([key, value]) => this.setValue(key, value)))

const committed: string[] = []
Expand Down
18 changes: 16 additions & 2 deletions src/core/config/ProviderSettingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@

export type ProviderProfiles = z.infer<typeof providerProfilesSchema>

/** Already-deleted profile: callers branch on this type instead of matching message text. */
export class ProviderSettingsNotFoundError extends Error {
constructor(message: string) {
super(message)
this.name = "ProviderSettingsNotFoundError"

Check warning on line 62 in src/core/config/ProviderSettingsManager.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

src/core/config/ProviderSettingsManager.ts:62: Survived StringLiteral mutant (replacement: ""). See the job summary for the complete list and resolution guidance.

Check warning on line 62 in src/core/config/ProviderSettingsManager.ts

View workflow job for this annotation

GitHub Actions / mutation-diff

Mutation test advisory

src/core/config/ProviderSettingsManager.ts:62: Survived StringLiteral mutant (replacement: ""). See the job summary for the complete list and resolution guidance.
}
}

export class ProviderSettingsManager {
private static readonly SCOPE_PREFIX = "roo_cline_config_"
private readonly defaultConfigId = this.generateId()
Expand Down Expand Up @@ -513,8 +521,9 @@
return await this.lock(async () => {
const providerProfiles = await this.load()

if (!providerProfiles.apiConfigs[name]) {
throw new Error(`Config '${name}' not found`)
// Inherited members such as toString must not pass as a stored profile.
if (!Object.hasOwn(providerProfiles.apiConfigs, name)) {
throw new ProviderSettingsNotFoundError(`Config '${name}' not found`)
}

if (Object.keys(providerProfiles.apiConfigs).length === 1) {
Expand All @@ -525,6 +534,11 @@
await this.store(providerProfiles)
})
} catch (error) {
// A missing config is a caller-meaningful signal, not a failure: rethrow it
// unwrapped so callers can branch on the type instead of message text.
if (error instanceof ProviderSettingsNotFoundError) {
throw error
}
throw new Error(`Failed to delete config: ${error}`)
}
}
Expand Down
19 changes: 19 additions & 0 deletions src/core/config/__tests__/ContextProxy.spec.ts

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

7 changes: 6 additions & 1 deletion src/core/config/__tests__/ProviderSettingsManager.spec.ts

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

49 changes: 49 additions & 0 deletions src/core/config/__tests__/importExport.spec.ts

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

7 changes: 6 additions & 1 deletion src/core/config/importExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { TelemetryService } from "@roo-code/telemetry"

import { ProviderSettingsManager, providerProfilesSchema } from "./ProviderSettingsManager"
import { ContextProxy } from "./ContextProxy"
import { ContextProxy, isNonPortableSettingsKey } from "./ContextProxy"
import { CustomModesManager } from "./CustomModesManager"
import { downgradeLegacyRooConfig, ROUTER_REMOVAL_IMPORT_WARNING } from "./routerRemoval"
import { resolveDefaultSaveUri, saveLastExportPath } from "../../utils/export"
Expand Down Expand Up @@ -105,6 +105,11 @@ function sanitizeGlobalSettings(rawGlobalSettings: unknown): {
continue
}

if (isNonPortableSettingsKey(key)) {
warnings.push(`Setting "${path}" was skipped: host-owned view state is not portable.`)
continue
}

let valueToValidate = rawValue

if (key === "imageGenerationProvider" && rawValue === retiredProviderIdentifiers.roo) {
Expand Down
28 changes: 28 additions & 0 deletions src/core/webview/__tests__/webviewMessageHandler.spec.ts

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

12 changes: 12 additions & 0 deletions src/core/webview/webviewMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import { fileExistsAtPath } from "../../utils/fs"
import { playTts, setTtsEnabled, setTtsSpeed, stopTts } from "../../utils/tts"
import { searchCommits } from "../../utils/git"
import { exportSettings, importSettingsWithFeedback } from "../config/importExport"
import { isNonPortableSettingsKey } from "../config/ContextProxy"
import { getOpenAiModels } from "../../api/providers/openai"
import { getVsCodeLmModels } from "../../api/providers/vscode-lm"
import { getGitHubCopilotViewState } from "../../services/language-models/copilotViewState"
Expand Down Expand Up @@ -794,6 +795,17 @@ export const webviewMessageHandler = async (
}

for (const [key, value] of Object.entries(message.updatedSettings)) {
if (isNonPortableSettingsKey(key)) {
// Per-view selections and the claim token that binds them are minted and held by the host,
// and the settings-file path already refuses them. A posted updateSettings is the same
// untrusted input, so writing them here would let a webview choose which persisted view
// entry - and with which identity - it owns, bypassing the claim check in setViewStateId.
provider.log(
`[updateSettings] Ignoring non-portable settings key ${key} posted by the webview.`,
)

continue
}
// An invalid display value is ignored, before anything is done for it.
if (isInvalidDisplayValue(key, value)) {
provider.log(`[updateSettings] Ignored an invalid value for ${key}`)
Expand Down
Loading
Loading