From 25f0dd3e6cd0411fe68fe1f6c13389d06963ffd4 Mon Sep 17 00:00:00 2001 From: Mariano Blua Date: Sat, 17 Oct 2026 18:36:33 -0300 Subject: [PATCH] chore(3052): mirror profile pair identity metadata --- src/shared/ipc.transport.test.ts | 29 +++++++++++++++++++++++++++-- src/shared/types.ts | 4 +++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/shared/ipc.transport.test.ts b/src/shared/ipc.transport.test.ts index 4e49da63f..2289aba9b 100644 --- a/src/shared/ipc.transport.test.ts +++ b/src/shared/ipc.transport.test.ts @@ -1439,9 +1439,14 @@ describe("tolerant configuration readers (#3019)", () => { } finally { restore(); } }); - it.each(["legacy", "canonical"])("projects complete %s backend fixtures through complete APIs", async (shape) => { + it.each(["legacy", "canonical"].flatMap((shape) => + [undefined, "cid1:literal-pair-metadata"].map((idHash) => ({ shape, idHash })), + ))("projects complete $shape backend fixtures with pair hash $idHash through complete APIs", async ({ shape, idHash }) => { const ipc = await import("./ipc"); - const cell: ProfileCellConfig = { command: "--model x", enabled: true, env: { KEY: "value" }, notes: "keep" }; + const cell: ProfileCellConfig = { + command: "--model x", enabled: true, env: { KEY: "value" }, notes: "keep", + ...(idHash === undefined ? {} : { id_hash: idHash }), + }; const agent = { id: "a", label: "Agent", color: "blue", command: "agent --base", envs: [], isolatedHome: false }; const definition: CodingAgentDefinition = { key: "a", label: "Agent", description: "Description", color: "blue", command: "agent --base", @@ -1466,6 +1471,9 @@ describe("tolerant configuration readers (#3019)", () => { fake.resolve("get_settings", response(wire)); fake.resolve("get_coding_agent_catalog", response([wireDefinition])); fake.resolve("get_coding_agent_catalog_report", response({ ...report, catalog: [wireDefinition] })); + fake.resolve("update_settings", undefined); + fake.resolve("save_settings_draft", undefined); + fake.resolve("update_coding_agent_profiles", undefined); const restore = ipc.__setTransportForTests(fake); try { const settings: SettingsSnapshot = await ipc.SettingsAPI.get(); @@ -1474,6 +1482,23 @@ describe("tolerant configuration readers (#3019)", () => { expect(settings).toEqual(expected); expect(catalog).toEqual([definition]); expect(decodedReport).toEqual(report); + expect(settings.codingAgentProfiles.profilesByAgent.a.A.id_hash).toBe(idHash); + await ipc.SettingsAPI.update(settings); + await ipc.SettingsAPI.saveDraft(settings); + await expect(ipc.SettingsAPI.updateCodingAgentProfiles(settings.codingAgentProfiles)).resolves.toBeUndefined(); + const sentProfiles = [ + (fake.lastCall("update_settings")?.args?.newSettings as Record).codingAgentProfiles, + (fake.lastCall("save_settings_draft")?.args?.draft as Record).codingAgentProfiles, + fake.lastCall("update_coding_agent_profiles")?.args?.profiles, + ]; + const { command, ...rest } = cell; + for (const profiles of sentProfiles) { + expect(profiles).toEqual({ + ...expected.codingAgentProfiles, + profilesByAgent: { a: { A: { ...rest, additionalArguments: command } } }, + }); + } + expect(settings.codingAgentProfiles.profilesByAgent.a.A).toEqual(cell); } finally { restore(); } }); diff --git a/src/shared/types.ts b/src/shared/types.ts index f40926b31..5d97d1983 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -430,7 +430,7 @@ export interface AgentBackendConfig { export interface AgentConfig { id: string; - /** Backend-derived from final command/envs; informational, not authority or an alternate lookup. */ + /** Backend-derived legacy base command/env identity; informational, not authority or an alternate lookup. */ id_hash?: string; label: string; command: string; @@ -565,6 +565,8 @@ export interface ProfileSlotConfig { } export interface ProfileCellConfig { + /** Backend-derived identity of this pair's configured baseCommand + additionalArguments/env; not authority or a lookup. */ + id_hash?: string; enabled: boolean; command: string; env: Record;