From 2c3d1e07fe63d4a2d67d63a3e29d4ad73e291d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Wed, 28 Oct 2026 20:29:47 +0000 Subject: [PATCH] fix(cli): media-treatment finds an area by the name its overview prints (#6675) * fix(cli): media-treatment finds an area by the name its overview prints * fix(cli): drop the comment lines the ratchet counts --- packages/cli/src/commands/media-treatment.test.ts | 13 ++++++++++++- packages/cli/src/commands/media-treatment.ts | 12 ++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/commands/media-treatment.test.ts b/packages/cli/src/commands/media-treatment.test.ts index a335416e17..efe4f7ad3e 100644 --- a/packages/cli/src/commands/media-treatment.test.ts +++ b/packages/cli/src/commands/media-treatment.test.ts @@ -165,10 +165,21 @@ describe("applyMediaTreatmentToHtml", () => { ); }); + it("resolves every name the overview prints for an area to that area", () => { + const correction = getMediaTreatmentCapabilityDetail("correction"); + expect(correction).toMatchObject({ id: "correction" }); + expect(getMediaTreatmentCapabilityDetail("Adjust")).toEqual(correction); + expect(getMediaTreatmentCapabilityDetail("adjust")).toEqual(correction); + expect(getMediaTreatmentCapabilityDetail("Color Grading")).toMatchObject({ id: "grading" }); + expect(() => getMediaTreatmentCapabilityDetail("adjustments")).toThrow( + /Unknown media-treatment capability/, + ); + }); + it("lists the area ids the lookup accepts when a capability is unknown", () => { let message = ""; try { - getMediaTreatmentCapabilityDetail("adjust"); + getMediaTreatmentCapabilityDetail("adjustments"); } catch (error) { message = error instanceof Error ? error.message : String(error); } diff --git a/packages/cli/src/commands/media-treatment.ts b/packages/cli/src/commands/media-treatment.ts index 42d29627b9..989308093a 100644 --- a/packages/cli/src/commands/media-treatment.ts +++ b/packages/cli/src/commands/media-treatment.ts @@ -90,6 +90,16 @@ export function getMediaTreatmentCapabilityOverview() { }; } +const FAMILY_PAYLOAD_KEY: Record = { correction: "adjust" }; + +function familyIdFor(name: string): string | undefined { + const wanted = name.toLowerCase(); + return getMediaTreatmentCapabilityOverview().families.find( + ({ id, label }) => + id === wanted || label.toLowerCase() === wanted || FAMILY_PAYLOAD_KEY[id] === wanted, + )?.id; +} + export function getMediaTreatmentCapabilityDetail(id: string): unknown { const capabilities = getHfColorGradingCapabilities(); const animation = (path: string) => { @@ -306,6 +316,8 @@ export function getMediaTreatmentCapabilityDetail(id: string): unknown { const detail = Object.hasOwn(details, id) ? Reflect.get(details, id) : undefined; if (detail) return detail; + const family = familyIdFor(id); + if (family && family !== id) return getMediaTreatmentCapabilityDetail(family); const families = [...Object.keys(details), ...capabilities.effectFamilies.map((f) => f.id)]; throw new Error( `Unknown media-treatment capability: ${id}. Available areas: ${families.join(", ")}.`,