Skip to content

Commit 6e3cfda

Browse files
u1: move the two profile-record declarations to the units that carry their readers
sharedStoreCarriesProfileRecord is called only from the hunk unit 3 carries (1921 head ClineProvider.ts:3840); ProfileActivationInconsistentError is used only from the hunks unit 2 carries (1921 head :3350 and :4465). Carrying a declaration whose readers live in another unit leaves it unreachable in the unit that owns it, which is what made eslint report 2 no-unused-vars problems on this unit, and it is the carrier rule broken in the opposite direction from the guard test: the guard travelled with its readers, these two did not. Both declarations move out of this unit and no call site moves to keep a declaration in place. Until unit 3's head exists on a remote, sharedStoreCarriesProfileRecord exists in no pushed ref, which the unit body and the plan of record say rather than smooth over. Hooks: state this plainly. This commit is being made in the campaign scratch worktree where pnpm 10.8.1 is on PATH and where this round ran check-types and eslint, so husky's pre-commit is able to run; the hook result for this commit is recorded in the campaign ledger for this round from the commit's own output, not asserted here. Carrier repairs at unit 1, per the round 58 ruling. The empty broadcastResetToAllInstances header is closed on one line so prettier --check, which the compile context runs, reports the file formatted; the cut that created the two-line form happened here. The module src/core/webview/profileDeletionError.ts no longer travels in unit 1: unit 1 contains no reader of it, and the only reader in #1921 is the import at head 89, which unit 3 carries, so at unit 1's head the file is a new file with no reader, which is what knip --treat-config-hints-as-errors reports as Unused files (1). Its delta moves to unit 3, with the import and the re-export. No behaviour moved, no reading statement changed, no suppression touched. Review dispositions (CodeRabbit row 5849395565 at 836e204-then-71cfcf331411), batched into this one push rather than four, because dismiss_stale_reviews_on_push is true and every push after a review row buys another review of the same PR. - packages/types/src/__tests__/global-settings.test.ts: two describe blocks shared the name "viewStates global setting" and three of their cases said the same thing. One block now, with the duplicated reject cases dropped, the key-list assertion and the optional-field case moved into it, and a null-entry case added so the non-object test covers null as well as a string. Both blocks were campaign-added by this unit, so no donor line moves. - src/core/config/ContextProxy.ts:72 and src/core/config/importExport.ts:105: the review comments and the mutation-diff advisories assert the same thing about the same lines - a surviving BooleanLiteral mutant at the export omit list, and two surviving mutants at the import skip - so they are answered here once: a test that export() omits viewStates while keeping a sibling, and a pair of tests covering the import skip in both directions. Neither setting had any test in either spec file before this commit. - src/core/webview/ClineProvider.ts:803: not changed. The compensating restore writes the comment asks to delete are #1921's own lines at 892, 933, 989 and 1083, and the comment's own analysis concedes that removing them does not guarantee rollback of the value the extension host may retain. A split unit does not delete donor production to answer a minor finding; the reasoning belongs in the thread, not in the diff. All legs ran under node v25.9.0 with pnpm 10.8.1; the src check-types legs print Unsupported engine: wanted {"node":"22.23.4"} beside the direct legs, so those legs are node-25 readings and not the CI interpreter's.
1 parent 836e2e0 commit 6e3cfda

5 files changed

Lines changed: 100 additions & 51 deletions

File tree

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

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -39,36 +39,6 @@ describe("alwaysDenyUnapprovedCommands global setting", () => {
3939
expect(() => globalSettingsSchema.parse({ alwaysDenyUnapprovedCommands: "true" })).toThrow()
4040
})
4141
})
42-
describe("viewStates global setting", () => {
43-
it("accepts a persisted per-view record", () => {
44-
const parsed = globalSettingsSchema.parse({
45-
viewStates: {
46-
"view-1": { mode: "architect", currentApiConfigName: "profile-a", updatedAt: 1_700_000_000_000 },
47-
},
48-
})
49-
50-
expect(GLOBAL_SETTINGS_KEYS).toContain("viewStates")
51-
expect(parsed.viewStates?.["view-1"]).toEqual({
52-
mode: "architect",
53-
currentApiConfigName: "profile-a",
54-
updatedAt: 1_700_000_000_000,
55-
})
56-
})
57-
58-
it("accepts an empty entry because every field is optional", () => {
59-
const parsed = globalSettingsSchema.parse({ viewStates: { "view-1": {} } })
60-
61-
expect(parsed.viewStates?.["view-1"]).toEqual({})
62-
})
63-
64-
it("rejects malformed fields, non-object entries and non-record values", () => {
65-
expect(() => globalSettingsSchema.parse({ viewStates: { "view-1": { mode: 7 } } })).toThrow()
66-
expect(() => globalSettingsSchema.parse({ viewStates: { "view-1": { updatedAt: "now" } } })).toThrow()
67-
expect(() => globalSettingsSchema.parse({ viewStates: { "view-1": "architect" } })).toThrow()
68-
expect(() => globalSettingsSchema.parse({ viewStates: "view-1" })).toThrow()
69-
})
70-
})
71-
7242
describe("collapseCommandOutputByDefault global setting", () => {
7343
it.each([true, false, undefined])("round-trips %s through the export/import schema", (value) => {
7444
const settings = globalSettingsSchema.parse({ collapseCommandOutputByDefault: value })
@@ -96,6 +66,18 @@ describe("viewStates global setting", () => {
9666
"session-1": { mode: "code", currentApiConfigName: "default", updatedAt: 1700000000000 },
9767
"session-2": { mode: "architect" },
9868
})
69+
70+
// The key list is part of the contract: a setting that never reaches
71+
// GLOBAL_SETTINGS_KEYS is not a persisted setting, whatever the schema does.
72+
expect(GLOBAL_SETTINGS_KEYS).toContain("viewStates")
73+
})
74+
75+
it("accepts an empty entry because every field is optional", () => {
76+
expect(() => globalSettingsSchema.parse({ viewStates: { "view-1": {} } })).not.toThrow()
77+
// The control that makes the line above a test: an absent viewStates is omitted
78+
// rather than defaulted, so an empty entry is a record and not the same shape
79+
// as nothing at all.
80+
expect(globalSettingsSchema.parse({}).viewStates).toBeUndefined()
9981
})
10082

10183
it("parses a single view state on its own", () => {
@@ -145,5 +127,9 @@ describe("viewStates global setting", () => {
145127

146128
expect(result.success).toBe(false)
147129
expect(result.error?.issues[0]?.path).toEqual(["viewStates", "a"])
130+
131+
// A null entry fails for a different reason than a string entry: the record
132+
// type tolerates an absent value and rejects a present non-object one.
133+
expect(() => globalSettingsSchema.parse({ viewStates: { "view-1": null } })).toThrow()
148134
})
149135
})

‎src/core/config/__tests__/ContextProxy.spec.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,4 +1170,31 @@ Output only the summary of the conversation so far, without any additional comme
11701170
expect(customSupportPromptsUpdateCalls.length).toBe(0)
11711171
})
11721172
})
1173+
1174+
describe("export", () => {
1175+
it("omits viewStates from the exported global settings", async () => {
1176+
// The sibling setting is the control: if the export returned nothing at all -
1177+
// a schema failure, an empty value set - the first assertion below fails and the
1178+
// absent viewStates cannot be read as a passing test for the wrong reason.
1179+
mockGlobalState.get.mockImplementation((key: string) => {
1180+
if (key === "viewStates") {
1181+
return { "view-1": { mode: "code", currentApiConfigName: "profile-a", updatedAt: 1700000000000 } }
1182+
}
1183+
if (key === "mode") {
1184+
return "code"
1185+
}
1186+
return undefined
1187+
})
1188+
1189+
const exportProxy = new ContextProxy(mockContext)
1190+
await exportProxy.initialize()
1191+
1192+
const exported = await exportProxy.export()
1193+
1194+
expect(exported?.mode).toBe("code")
1195+
expect(Object.keys(exported ?? {})).toContain("mode")
1196+
expect(exported?.viewStates).toBeUndefined()
1197+
expect(Object.keys(exported ?? {})).not.toContain("viewStates")
1198+
})
1199+
})
11731200
})

‎src/core/config/__tests__/importExport.spec.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,4 +2806,60 @@ describe("importExport", () => {
28062806
},
28072807
)
28082808
})
2809+
2810+
describe("viewStates import skip", () => {
2811+
const importedWith = async (globalSettings: Record<string, unknown>) => {
2812+
;(fs.readFile as Mock).mockResolvedValue(
2813+
JSON.stringify({
2814+
providerProfiles: {
2815+
currentApiConfigName: "test",
2816+
apiConfigs: { test: { apiProvider: providerIdentifiers.openai, id: "test-id" } },
2817+
},
2818+
globalSettings,
2819+
}),
2820+
)
2821+
mockProviderSettingsManager.export.mockResolvedValue({
2822+
currentApiConfigName: "default",
2823+
apiConfigs: { default: { apiProvider: providerIdentifiers.anthropic, id: "default-id" } },
2824+
})
2825+
mockProviderSettingsManager.listConfig.mockResolvedValue([
2826+
{ name: "test", id: "test-id", apiProvider: providerIdentifiers.openai },
2827+
])
2828+
2829+
const result = await importSettingsFromPath("/mock/path/settings.json", {
2830+
providerSettingsManager: mockProviderSettingsManager,
2831+
contextProxy: mockContextProxy,
2832+
customModesManager: mockCustomModesManager,
2833+
})
2834+
2835+
return {
2836+
warnings: (result as { warnings?: string[] }).warnings,
2837+
written: mockContextProxy.setValues.mock.calls[0]?.[0],
2838+
}
2839+
}
2840+
2841+
it("skips viewStates without a warning and keeps the sibling setting", async () => {
2842+
const { warnings, written } = await importedWith({
2843+
mode: "code",
2844+
viewStates: { "view-1": { mode: "code", updatedAt: 1700000000000 } },
2845+
})
2846+
2847+
// The sibling is the control: if the skip swallowed every key the first line
2848+
// below fails, so an absent viewStates on its own cannot pass for the wrong
2849+
// reason.
2850+
expect(Object.keys(written ?? {})).toContain("mode")
2851+
expect(Object.keys(written ?? {})).not.toContain("viewStates")
2852+
// The skip is deliberate, so it must not arrive dressed as an "Unknown setting"
2853+
// warning: the key is known and deliberately not exported, not junk.
2854+
expect(warnings?.some((warning) => warning.includes("viewStates"))).toBeFalsy()
2855+
})
2856+
2857+
it("keeps the sibling setting when viewStates is absent", async () => {
2858+
const { warnings, written } = await importedWith({ mode: "code" })
2859+
2860+
expect(Object.keys(written ?? {})).toContain("mode")
2861+
expect(Object.keys(written ?? {})).not.toContain("viewStates")
2862+
expect(warnings?.some((warning) => warning.includes("viewStates"))).toBeFalsy()
2863+
})
2864+
})
28092865
})

‎src/core/webview/ClineProvider.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4554,8 +4554,7 @@ export class ClineProvider
45544554
* both in-memory view-local caches and durable per-view selections so stale view state
45554555
* cannot mask imported/reset shared state after reload.
45564556
*/
4557-
async broadcastResetToAllInstances(): Promise<void> {
4558-
}
4557+
async broadcastResetToAllInstances(): Promise<void> {}
45594558

45604559
// dev
45614560

‎src/core/webview/profileDeletionError.ts‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)