Skip to content

Commit cddc7d7

Browse files
Merge ca61d20 into 793b65b
2 parents 793b65b + ca61d20 commit cddc7d7

33 files changed

Lines changed: 9186 additions & 511 deletions

‎packages/types/src/__tests__/global-settings.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,33 @@ describe("alwaysDenyUnapprovedCommands global setting", () => {
3737
it("rejects non-boolean setting values", () => {
3838
expect(() => globalSettingsSchema.parse({ alwaysDenyUnapprovedCommands: "true" })).toThrow()
3939
})
40+
41+
describe("viewStates global setting", () => {
42+
it("parses a valid per-view record", () => {
43+
const parsed = globalSettingsSchema.parse({
44+
viewStates: {
45+
"stable-view-1": { mode: "code", currentApiConfigName: "profile-a", updatedAt: 1730000000000 },
46+
"stable-view-2": {},
47+
},
48+
})
49+
expect(parsed.viewStates?.["stable-view-1"]).toEqual({
50+
mode: "code",
51+
currentApiConfigName: "profile-a",
52+
updatedAt: 1730000000000,
53+
})
54+
expect(parsed.viewStates?.["stable-view-2"]).toEqual({})
55+
expect(GLOBAL_SETTINGS_KEYS).toContain("viewStates")
56+
})
57+
58+
it("rejects invalid field values inside a view entry", () => {
59+
expect(() => globalSettingsSchema.parse({ viewStates: { v: { mode: 42 } } })).toThrow()
60+
expect(() => globalSettingsSchema.parse({ viewStates: { v: { currentApiConfigName: 42 } } })).toThrow()
61+
expect(() => globalSettingsSchema.parse({ viewStates: { v: { updatedAt: "soon" } } })).toThrow()
62+
})
63+
64+
it("rejects non-object viewStates values", () => {
65+
expect(() => globalSettingsSchema.parse({ viewStates: "not-a-record" })).toThrow()
66+
expect(() => globalSettingsSchema.parse({ viewStates: { v: "not-an-entry" } })).toThrow()
67+
})
68+
})
4069
})

‎packages/types/src/__tests__/index.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import { GLOBAL_STATE_KEYS } from "../index.js"
44

55
describe("GLOBAL_STATE_KEYS", () => {
6+
it("should contain registered durable per-view state", () => {
7+
expect(GLOBAL_STATE_KEYS).toContain("viewStates")
8+
})
9+
610
it("should contain provider settings keys", () => {
711
expect(GLOBAL_STATE_KEYS).toContain("autoApprovalEnabled")
812
})
@@ -13,6 +17,7 @@ describe("GLOBAL_STATE_KEYS", () => {
1317

1418
it("should not contain secret state keys", () => {
1519
expect(GLOBAL_STATE_KEYS).not.toContain("openRouterApiKey")
20+
expect(GLOBAL_STATE_KEYS).not.toContain("apiKey")
1621
})
1722

1823
it("should contain OpenAI Compatible base URL setting", () => {

‎packages/types/src/global-settings.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ export const MAX_CHECKPOINT_TIMEOUT_SECONDS = 60
111111
*/
112112
export const DEFAULT_CHECKPOINT_TIMEOUT_SECONDS = 15
113113

114+
/**
115+
* Persisted non-secret selections for a stable webview instance.
116+
*/
117+
export const viewStateSchema = z.object({
118+
mode: z.string().optional(),
119+
currentApiConfigName: z.string().optional(),
120+
updatedAt: z.number().optional(),
121+
})
122+
114123
/**
115124
* GlobalSettings
116125
*/
@@ -119,6 +128,7 @@ export const globalSettingsSchema = z.object({
119128
currentApiConfigName: z.string().optional(),
120129
listApiConfigMeta: z.array(providerSettingsEntrySchema).optional(),
121130
pinnedApiConfigs: z.record(z.string(), z.boolean()).optional(),
131+
viewStates: z.record(z.string(), viewStateSchema).optional(),
122132

123133
lastShownAnnouncementId: z.string().optional(),
124134
customInstructions: z.string().optional(),

‎packages/types/src/vscode-extension-host.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ export interface WebviewMessage {
653653
| "openRulesDirectory"
654654
| "themeFixtureProbeResponse"
655655
text?: string
656+
viewStateId?: string
656657
taskId?: string
657658
editedMessageContent?: string
658659
tab?: "settings" | "history" | "mcp" | "modes" | "chat" | "marketplace" | "cloud"

‎packages/types/src/vscode.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ export const commandIds = [
3535
"popoutButtonClicked",
3636
"settingsButtonClicked",
3737

38+
// Editor-tab (popped-out) surface variants of the title-bar buttons. The
39+
// shared ids above target the sidebar click origin, so the tab surface
40+
// needs its own ids (see registerCommands.ts getTabProvider).
41+
"plusButtonClickedInTab",
42+
"settingsButtonClickedInTab",
43+
"marketplaceButtonClickedInTab",
44+
"historyButtonClickedInTab",
45+
3846
"openInNewTab",
3947

4048
"newTask",

0 commit comments

Comments
 (0)