From d799c5211247eb67c3f31ff64c95caccba434068 Mon Sep 17 00:00:00 2001 From: poli0981 <127664709+poli0981@users.noreply.github.com> Date: Fri, 6 Nov 2026 22:17:44 +0700 Subject: [PATCH] feat(rig): add a LUT field under the video editor A new My Rig field for the LUT graded in the video editor. The description and the social captions print it on its own line right under the editor ("LUT: Arri Alexa LogC to Rec709"); left empty, there is no line. - Typing offers the LUTs that come with DaVinci Resolve, named the way its LUT menu shows them (from Resolve 21's own LUT folder); any other name is printed as typed. - cleanLutName tidies a pasted file name or path: Explorer's "Copy as path" or a macOS path keeps only the file name, and a .cube / .dat / .3dl / .csp / .ilut / .olut / .look extension goes. Dots inside a name ("SLog3SGamut3.CineToLC-709") stay. - RigField gets `clean` (CPU and LUT) and `wide`. The cleaner runs when the field loses focus and again in formatRigValue, so Ctrl/Cmd+Shift+C or Ctrl/Cmd+S pressed with the cursor still in the field prints the tidy name too; the LUT field spans both columns, under the editor row. - `rig.lut` and `description.rigLabels.lut` ("LUT") in all eight locales and _schema.json; a test now holds both label sets to RIG_FIELDS. No store migration: the rig is a flat string map in the channel profile. Co-Authored-By: Claude Opus 5.5 --- docs/FEATURES.md | 9 +- docs/TECH-SPEC.md | 2 +- src/components/editor/RigEditor.tsx | 25 +++-- src/config/rig-fields.ts | 86 ++++++++++++++++- src/i18n/locales/_schema.json | 6 +- src/i18n/locales/en/templates.json | 3 +- src/i18n/locales/en/ui.json | 3 +- src/i18n/locales/es/templates.json | 3 +- src/i18n/locales/es/ui.json | 3 +- src/i18n/locales/id/templates.json | 3 +- src/i18n/locales/id/ui.json | 3 +- src/i18n/locales/ja/templates.json | 3 +- src/i18n/locales/ja/ui.json | 3 +- src/i18n/locales/ko/templates.json | 3 +- src/i18n/locales/ko/ui.json | 3 +- src/i18n/locales/pt-BR/templates.json | 3 +- src/i18n/locales/pt-BR/ui.json | 3 +- src/i18n/locales/vi/templates.json | 3 +- src/i18n/locales/vi/ui.json | 3 +- src/i18n/locales/zh/templates.json | 3 +- src/i18n/locales/zh/ui.json | 3 +- tests/engine/description-builder.test.ts | 29 ++++++ tests/engine/rig-fields.test.ts | 113 ++++++++++++++++++++++- 23 files changed, 285 insertions(+), 33 deletions(-) diff --git a/docs/FEATURES.md b/docs/FEATURES.md index 4407d7d..542733c 100644 --- a/docs/FEATURES.md +++ b/docs/FEATURES.md @@ -142,7 +142,7 @@ is now "X (Twitter)" (same `twitter` id, so saved links still load). Bank, Cake by VPBank and Timo; a profile saved with OceanBank, CBBank or DongA Bank is offered the new name in one click. -## 💻 Rig Fields (10 fields) +## 💻 Rig Fields (11 fields) Printed in this order, with labels in the output language. @@ -158,6 +158,13 @@ Printed in this order, with labels in the output language. | `capture` | Capture Software | Text | OBS Studio 31 | | `controller` | Controller | Text | DualSense / Xbox Wireless Controller | | `video_editor` | Video Editor | Dropdown + version | DaVinci Resolve Studio 19.1 | +| `lut` | LUT | Text with suggestions (DaVinci Resolve's own LUTs) — v1.4.0 | Arri Alexa LogC to Rec709 | + +**LUT (v1.4.0)** — the LUT you grade with, on its own line right under the +video editor. The suggestions are LUTs that come with DaVinci Resolve, named +the way its LUT menu shows them; any other name is printed as typed. A pasted +file name or path (Explorer's _Copy as path_) is cut down to the LUT's name: +`"C:\…\Arri\Arri Alexa LogC to Rec709.dat"` → `Arri Alexa LogC to Rec709`. **GPU catalog (v1.0.0)** — 198 models in 29 groups: NVIDIA GeForce (desktop and laptop), AMD Radeon (including integrated), Intel Arc and integrated, diff --git a/docs/TECH-SPEC.md b/docs/TECH-SPEC.md index 85b3122..fc218db 100644 --- a/docs/TECH-SPEC.md +++ b/docs/TECH-SPEC.md @@ -419,7 +419,7 @@ export interface TitleFormatConfig { **Empty channel name** (`channel-phrase.ts`, used by the description, pinned comment and playlist builders): templates render with `CHANNEL_SLOT` (`@@CHANNEL@@`) in place of an empty channel name. `withoutEmptyChannel(text, language)` then removes the words that go with the channel name in that language ("trên kênh", "による", "en", "no", "di", …) and the English "on" (for English, and for locales that still carry English sentences for newer video types), replaces any slot left over with a neutral fallback ("this channel", "kênh", …) and tidies the spacing before punctuation. "…of Hades on ." no longer happens in any of the eight languages. -**Rig block** (`rig-block.ts`): `buildRigLines(rig, t)` returns `Label: value` lines, shared by the description and the social captions. Labels come from `description.rigLabels.` in the output language, the order is `RIG_FIELDS` (CPU, GPU, RAM, motherboard, storage, OS, monitor, capture, controller, video editor), and values go through `formatRigValue` (`gpu:nvidia-rtx-5080` → "NVIDIA GeForce RTX 5080"). Keys that are no longer rig fields are still printed, after the known ones. +**Rig block** (`rig-block.ts`): `buildRigLines(rig, t)` returns `Label: value` lines, shared by the description and the social captions. Labels come from `description.rigLabels.` in the output language, the order is `RIG_FIELDS` (CPU, GPU, RAM, motherboard, storage, OS, monitor, capture, controller, video editor, LUT), and values go through `formatRigValue` (`gpu:nvidia-rtx-5080` → "NVIDIA GeForce RTX 5080"; a text field's `clean` — `cleanCpuName`, and since v1.4.0 `cleanLutName`, which cuts a pasted path or `.cube` / `.dat` file name down to the LUT's name — runs there as well as when the editor field loses focus). Keys that are no longer rig fields are still printed, after the known ones. **Chapters** (`timeline-parser.ts`): diff --git a/src/components/editor/RigEditor.tsx b/src/components/editor/RigEditor.tsx index 726ab2b..ccea5ad 100644 --- a/src/components/editor/RigEditor.tsx +++ b/src/components/editor/RigEditor.tsx @@ -9,7 +9,6 @@ import { PopoverContent, PopoverRoot, PopoverTrigger } from "@components/ui/Popo import { Spinner } from "@components/icons/animated"; import { RIG_FIELDS, - cleanCpuName, parseCompositeValue, resolveCompositeOptions, resolveCompositeLabelKey, @@ -117,7 +116,7 @@ function GpuPicker({ ); } -/** CPU (and any other suggested text field): type freely or pick a suggestion. */ +/** CPU, LUT (any suggested text field): type freely or pick a suggestion. */ function SuggestedTextField({ field, value, @@ -139,10 +138,11 @@ function SuggestedTextField({ list={listId} autoComplete="off" onChange={(e) => onChange(e.target.value)} - // "Intel(R) Core(TM) i7-12700K CPU @ 3.60GHz", as Windows shows it, - // becomes "Intel Core i7-12700K" once the user leaves the field. + // The field's own tidy-up once the user leaves it: Windows' "Intel(R) + // Core(TM) i7-12700K CPU @ 3.60GHz" becomes "Intel Core i7-12700K", + // a pasted "Rec709 Kodak 2383 D65.cube" loses its extension. onBlur={(e) => { - const cleaned = field.id === "cpu" ? cleanCpuName(e.target.value) : e.target.value.trim(); + const cleaned = field.clean ? field.clean(e.target.value) : e.target.value.trim(); if (cleaned !== e.target.value) onChange(cleaned); }} /> @@ -293,12 +293,10 @@ export function RigEditor() { } if (field.type === "composite_dropdown") return renderComposite(field); if (field.type === "dropdown_with_version") return renderDropdownWithVersion(field); - if (field.suggestions) { - return ; - } - return ( + const input = field.suggestions ? ( + + ) : ( set(e.target.value)} /> ); + // A wide field (the LUT) takes the whole row, right under the + // Video Editor row it belongs to. + return ( +
+ {input} +
+ ); })} diff --git a/src/config/rig-fields.ts b/src/config/rig-fields.ts index e5f2918..e01eaaf 100644 --- a/src/config/rig-fields.ts +++ b/src/config/rig-fields.ts @@ -102,6 +102,15 @@ export interface RigField { readonly composite?: CompositeFieldSpec; /** `text` fields: values offered while typing (the user may type anything). */ readonly suggestions?: readonly string[]; + /** + * `text` fields: tidies the typed or pasted text. Runs when the user + * leaves the field and again in {@link formatRigValue}, so a shortcut + * pressed while the cursor is still in the field prints the tidy form + * too. Must be idempotent. + */ + readonly clean?: (raw: string) => string; + /** Takes both columns of the editor's grid (long values, such as a LUT name). */ + readonly wide?: boolean; } /** @@ -477,6 +486,66 @@ export function cleanCpuName(raw: string): string { ); } +/** + * LUTs that come with DaVinci Resolve, named the way its LUT menu shows + * them (from Resolve 21's own LUT folder), offered while typing in the + * LUT field. Any other LUT's name is accepted as typed. + */ +export const LUT_SUGGESTIONS: readonly string[] = [ + "Arri Alexa LogC to Rec709", + "Rec709 Kodak 2383 D65", + "Rec709 Kodak 2383 D60", + "Rec709 Kodak 2383 D55", + "Rec709 Fujifilm 3513DI D65", + "Rec709 Fujifilm 3513DI D60", + "Rec709 Fujifilm 3513DI D55", + "HDR 1000 nits to Gamma 2.4", + "Blackmagic Gen 6 DaVinci to Rec709 BT1886 Film Look", + "SLog3SGamut3.CineToLC-709", + "SLog3SGamut3.CineToLC-709TypeA", + "V-Log to V-709", + "Leica Pure L-Log to Rec.709 Gamma 2.4", + "Samsung Log to Rec709", +]; + +/** The file extensions LUTs come in. Anchored at the end: linear. */ +const LUT_FILE_EXTENSION = /\.(?:cube|3dl|dat|csp|ilut|olut|look)$/i; + +/** One pass of {@link cleanLutName}. */ +function tidyLutNameOnce(text: string): string { + let name = text.trim(); + // Explorer's "Copy as path" wraps the path in double quotes. + if (name.length >= 2 && name.startsWith('"') && name.endsWith('"')) { + name = name.slice(1, -1).trim(); + } + // A path (a backslash, a drive letter, or a leading / or ~/) keeps only + // its file name. A slash in an ordinary name ("Teal/Orange") stays. + const isPath = + name.includes("\\") || /^[a-z]:\//i.test(name) || name.startsWith("/") || name.startsWith("~/"); + if (isPath) { + name = name.slice(Math.max(name.lastIndexOf("\\"), name.lastIndexOf("/")) + 1).trim(); + } + return name.replace(LUT_FILE_EXTENSION, "").trim(); +} + +/** + * Tidy a LUT name pasted from a file manager: + * `"Rec709 Kodak 2383 D65.cube"` → `"Rec709 Kodak 2383 D65"`, and + * Explorer's `"C:\…\Arri\Arri Alexa LogC to Rec709.dat"` (or a macOS + * path) → `"Arri Alexa LogC to Rec709"`. Dots inside a name + * ("SLog3SGamut3.CineToLC-709", "Rec.709 Gamma 2.4") stay. Idempotent: + * passes repeat until nothing changes. + */ +export function cleanLutName(raw: string): string { + let name = raw; + let previous: string; + do { + previous = name; + name = tidyLutNameOnce(name); + } while (name !== previous); + return name; +} + /** * The rig fields, in the order both the editor and the description show * them: the parts a viewer compares first (CPU, GPU, RAM), then the rest. @@ -488,6 +557,7 @@ export const RIG_FIELDS: readonly RigField[] = [ type: "text", placeholder: "AMD Ryzen 7 9800X3D", suggestions: CPU_SUGGESTIONS, + clean: cleanCpuName, }, { id: "gpu", labelKey: "rig.gpu", type: "gpu" }, { id: "ram", labelKey: "rig.ram", type: "composite_dropdown", composite: RAM_COMPOSITE }, @@ -514,6 +584,16 @@ export const RIG_FIELDS: readonly RigField[] = [ options: VIDEO_EDITOR_OPTIONS, versionPlaceholder: "20 / 2026 / v25", }, + // The LUT graded in that editor — its own line, right under it. + { + id: "lut", + labelKey: "rig.lut", + type: "text", + placeholder: "Arri Alexa LogC to Rec709", + suggestions: LUT_SUGGESTIONS, + clean: cleanLutName, + wide: true, + }, ]; /** @@ -567,7 +647,9 @@ function withSuffix(text: string, suffix: string): string { * - `composite_dropdown` ("32|DDR5|6000", "custom:48|DDR5|") → * "32 GB DDR5-6000" / "48 GB DDR5" via the field's * {@link CompositeFieldSpec.format}. - * - All other field types pass the raw value through. + * - `text` fields with a {@link RigField.clean} go through it (a pasted + * "Rec709 Kodak 2383 D65.cube" → "Rec709 Kodak 2383 D65"); other text + * passes through as typed. */ export function formatRigValue(fieldId: string, raw: string): string { const field = RIG_FIELDS.find((f) => f.id === fieldId); @@ -619,5 +701,5 @@ export function formatRigValue(fieldId: string, raw: string): string { return field.composite.format(resolved); } - return raw; + return field.clean ? field.clean(raw) : raw; } diff --git a/src/i18n/locales/_schema.json b/src/i18n/locales/_schema.json index f80657c..af5848b 100644 --- a/src/i18n/locales/_schema.json +++ b/src/i18n/locales/_schema.json @@ -826,7 +826,8 @@ "capture", "motherboard", "controller", - "video_editor" + "video_editor", + "lut" ], "social": [ "kofi", @@ -1717,7 +1718,8 @@ "monitor", "capture", "controller", - "video_editor" + "video_editor", + "lut" ] } } diff --git a/src/i18n/locales/en/templates.json b/src/i18n/locales/en/templates.json index 54821ac..286228c 100644 --- a/src/i18n/locales/en/templates.json +++ b/src/i18n/locales/en/templates.json @@ -592,7 +592,8 @@ "monitor": "Monitor", "capture": "Capture Software", "controller": "Controller", - "video_editor": "Video Editor" + "video_editor": "Video Editor", + "lut": "LUT" } }, "pinnedComment": { diff --git a/src/i18n/locales/en/ui.json b/src/i18n/locales/en/ui.json index 46b2cba..cdfda1b 100644 --- a/src/i18n/locales/en/ui.json +++ b/src/i18n/locales/en/ui.json @@ -1001,7 +1001,8 @@ "capture": "Capture Software", "motherboard": "Motherboard", "controller": "Controller", - "video_editor": "Video Editor" + "video_editor": "Video Editor", + "lut": "LUT" }, "social": { "kofi": "Ko-fi", diff --git a/src/i18n/locales/es/templates.json b/src/i18n/locales/es/templates.json index 1a7704f..bb6511e 100644 --- a/src/i18n/locales/es/templates.json +++ b/src/i18n/locales/es/templates.json @@ -592,7 +592,8 @@ "monitor": "Monitor", "capture": "Software de Captura", "controller": "Mando", - "video_editor": "Editor de Video" + "video_editor": "Editor de Video", + "lut": "LUT" } }, "pinnedComment": { diff --git a/src/i18n/locales/es/ui.json b/src/i18n/locales/es/ui.json index ded5a43..eb17cf4 100644 --- a/src/i18n/locales/es/ui.json +++ b/src/i18n/locales/es/ui.json @@ -1001,7 +1001,8 @@ "capture": "Software de Captura", "motherboard": "Placa Base", "controller": "Mando", - "video_editor": "Editor de Video" + "video_editor": "Editor de Video", + "lut": "LUT" }, "social": { "kofi": "Ko-fi", diff --git a/src/i18n/locales/id/templates.json b/src/i18n/locales/id/templates.json index a605318..30f74dc 100644 --- a/src/i18n/locales/id/templates.json +++ b/src/i18n/locales/id/templates.json @@ -592,7 +592,8 @@ "monitor": "Monitor", "capture": "Software Perekam", "controller": "Kontroler", - "video_editor": "Editor Video" + "video_editor": "Editor Video", + "lut": "LUT" } }, "pinnedComment": { diff --git a/src/i18n/locales/id/ui.json b/src/i18n/locales/id/ui.json index 9a7e64f..e37ba93 100644 --- a/src/i18n/locales/id/ui.json +++ b/src/i18n/locales/id/ui.json @@ -1001,7 +1001,8 @@ "capture": "Software Perekam", "motherboard": "Motherboard", "controller": "Kontroler", - "video_editor": "Editor Video" + "video_editor": "Editor Video", + "lut": "LUT" }, "social": { "kofi": "Ko-fi", diff --git a/src/i18n/locales/ja/templates.json b/src/i18n/locales/ja/templates.json index 62f3b86..7101466 100644 --- a/src/i18n/locales/ja/templates.json +++ b/src/i18n/locales/ja/templates.json @@ -592,7 +592,8 @@ "monitor": "モニター", "capture": "キャプチャソフト", "controller": "コントローラー", - "video_editor": "動画編集ソフト" + "video_editor": "動画編集ソフト", + "lut": "LUT" } }, "pinnedComment": { diff --git a/src/i18n/locales/ja/ui.json b/src/i18n/locales/ja/ui.json index a0a5486..b0c7e16 100644 --- a/src/i18n/locales/ja/ui.json +++ b/src/i18n/locales/ja/ui.json @@ -1001,7 +1001,8 @@ "capture": "キャプチャソフト", "motherboard": "マザーボード", "controller": "コントローラー", - "video_editor": "動画編集ソフト" + "video_editor": "動画編集ソフト", + "lut": "LUT" }, "social": { "kofi": "Ko-fi", diff --git a/src/i18n/locales/ko/templates.json b/src/i18n/locales/ko/templates.json index 366429e..cd4d149 100644 --- a/src/i18n/locales/ko/templates.json +++ b/src/i18n/locales/ko/templates.json @@ -592,7 +592,8 @@ "monitor": "모니터", "capture": "캡처 소프트웨어", "controller": "컨트롤러", - "video_editor": "영상 편집 프로그램" + "video_editor": "영상 편집 프로그램", + "lut": "LUT" } }, "pinnedComment": { diff --git a/src/i18n/locales/ko/ui.json b/src/i18n/locales/ko/ui.json index 2542cbc..436b103 100644 --- a/src/i18n/locales/ko/ui.json +++ b/src/i18n/locales/ko/ui.json @@ -1001,7 +1001,8 @@ "capture": "캡처 소프트웨어", "motherboard": "메인보드", "controller": "컨트롤러", - "video_editor": "영상 편집 프로그램" + "video_editor": "영상 편집 프로그램", + "lut": "LUT" }, "social": { "kofi": "Ko-fi", diff --git a/src/i18n/locales/pt-BR/templates.json b/src/i18n/locales/pt-BR/templates.json index bbf13c3..ab732c0 100644 --- a/src/i18n/locales/pt-BR/templates.json +++ b/src/i18n/locales/pt-BR/templates.json @@ -592,7 +592,8 @@ "monitor": "Monitor", "capture": "Software de captura", "controller": "Controle", - "video_editor": "Editor de vídeo" + "video_editor": "Editor de vídeo", + "lut": "LUT" } }, "pinnedComment": { diff --git a/src/i18n/locales/pt-BR/ui.json b/src/i18n/locales/pt-BR/ui.json index cb11ccd..12c4d5a 100644 --- a/src/i18n/locales/pt-BR/ui.json +++ b/src/i18n/locales/pt-BR/ui.json @@ -1001,7 +1001,8 @@ "capture": "Software de captura", "motherboard": "Placa-mãe", "controller": "Controle", - "video_editor": "Editor de vídeo" + "video_editor": "Editor de vídeo", + "lut": "LUT" }, "social": { "kofi": "Ko-fi", diff --git a/src/i18n/locales/vi/templates.json b/src/i18n/locales/vi/templates.json index 1d8d51b..ac1a409 100644 --- a/src/i18n/locales/vi/templates.json +++ b/src/i18n/locales/vi/templates.json @@ -592,7 +592,8 @@ "monitor": "Màn hình", "capture": "Phần mềm quay", "controller": "Tay cầm", - "video_editor": "Phần mềm dựng video" + "video_editor": "Phần mềm dựng video", + "lut": "LUT" } }, "pinnedComment": { diff --git a/src/i18n/locales/vi/ui.json b/src/i18n/locales/vi/ui.json index 6bb4aa3..0050d8d 100644 --- a/src/i18n/locales/vi/ui.json +++ b/src/i18n/locales/vi/ui.json @@ -1001,7 +1001,8 @@ "capture": "Phần mềm quay", "motherboard": "Bo mạch chủ", "controller": "Tay cầm", - "video_editor": "Phần mềm dựng video" + "video_editor": "Phần mềm dựng video", + "lut": "LUT" }, "social": { "kofi": "Ko-fi", diff --git a/src/i18n/locales/zh/templates.json b/src/i18n/locales/zh/templates.json index 4be8f90..80254b2 100644 --- a/src/i18n/locales/zh/templates.json +++ b/src/i18n/locales/zh/templates.json @@ -592,7 +592,8 @@ "monitor": "显示器", "capture": "录制软件", "controller": "手柄", - "video_editor": "视频编辑软件" + "video_editor": "视频编辑软件", + "lut": "LUT" } }, "pinnedComment": { diff --git a/src/i18n/locales/zh/ui.json b/src/i18n/locales/zh/ui.json index cce9f4d..121e6a1 100644 --- a/src/i18n/locales/zh/ui.json +++ b/src/i18n/locales/zh/ui.json @@ -1001,7 +1001,8 @@ "capture": "录制软件", "motherboard": "主板", "controller": "手柄", - "video_editor": "视频编辑软件" + "video_editor": "视频编辑软件", + "lut": "LUT" }, "social": { "kofi": "Ko-fi", diff --git a/tests/engine/description-builder.test.ts b/tests/engine/description-builder.test.ts index 400fd0e..d3ed31e 100644 --- a/tests/engine/description-builder.test.ts +++ b/tests/engine/description-builder.test.ts @@ -722,6 +722,35 @@ describe("buildDescription", () => { expect(vi).toContain("Ổ cứng: 2TB NVMe"); }); + it("prints the LUT on its own line right under the video editor (v1.4.0)", () => { + const rig = { + lut: "Arri Alexa LogC to Rec709.dat", + capture: "OBS Studio 31", + video_editor: "davinci_resolve_studio|21.2", + }; + const lineAfter = (text: string, line: string) => { + const lines = text.split("\n"); + const at = lines.indexOf(line); + return at >= 0 ? lines[at + 1] : undefined; + }; + const en = buildDescription(makeInput({ rig }), createMockT("en")); + expect(lineAfter(en, "Video Editor: DaVinci Resolve Studio 21.2")).toBe( + "LUT: Arri Alexa LogC to Rec709", + ); + + const vi = buildDescription(makeInput({ language: "vi", rig }), createMockT("vi")); + expect(lineAfter(vi, "Phần mềm dựng video: DaVinci Resolve Studio 21.2")).toBe( + "LUT: Arri Alexa LogC to Rec709", + ); + + const noLut = buildDescription( + makeInput({ rig: { video_editor: "capcut|", lut: " " } }), + createMockT("en"), + ); + expect(noLut).toContain("Video Editor: CapCut"); + expect(noLut).not.toContain("LUT:"); + }); + it("prints rig lines in a fixed order, whatever order they were filled in", () => { const t = createMockT("en"); const result = buildDescription( diff --git a/tests/engine/rig-fields.test.ts b/tests/engine/rig-fields.test.ts index 9be44cc..0318fab 100644 --- a/tests/engine/rig-fields.test.ts +++ b/tests/engine/rig-fields.test.ts @@ -1,5 +1,15 @@ import { describe, it, expect } from "vitest"; -import { cleanCpuName, formatRigValue, migrateRig, RIG_FIELDS } from "@config/rig-fields"; +import { + cleanCpuName, + cleanLutName, + CPU_SUGGESTIONS, + formatRigValue, + LUT_SUGGESTIONS, + migrateRig, + RIG_FIELDS, +} from "@config/rig-fields"; +import { compareCodeUnits } from "@utils/sort"; +import { schemaKeys } from "../helpers/locale-schema"; describe("formatRigValue", () => { it("passes text fields through unchanged", () => { @@ -176,6 +186,107 @@ describe("formatRigValue", () => { }); }); +describe("LUT (v1.4.0)", () => { + it("sits right after the video editor, across both columns", () => { + const ids = RIG_FIELDS.map((f) => f.id); + expect(ids.indexOf("lut")).toBe(ids.indexOf("video_editor") + 1); + const field = RIG_FIELDS.find((f) => f.id === "lut"); + expect(field).toMatchObject({ type: "text", wide: true, labelKey: "rig.lut" }); + expect(field?.suggestions).toBe(LUT_SUGGESTIONS); + }); + + it("prints the name as typed", () => { + expect(formatRigValue("lut", "Arri Alexa LogC to Rec709")).toBe("Arri Alexa LogC to Rec709"); + expect(formatRigValue("lut", "")).toBe(""); + }); + + it("drops a pasted file extension even before the field is left", () => { + // Ctrl/⌘+Shift+C or Ctrl/⌘+S can run while the cursor is still in the + // field, before the on-blur tidy-up. + expect(formatRigValue("lut", "Arri Alexa LogC to Rec709.dat")).toBe( + "Arri Alexa LogC to Rec709", + ); + }); +}); + +describe("cleanLutName", () => { + it("drops the LUT's file extension, whatever its case", () => { + expect(cleanLutName("Rec709 Kodak 2383 D65.cube")).toBe("Rec709 Kodak 2383 D65"); + expect(cleanLutName("Rec709 Kodak 2383 D65.CUBE")).toBe("Rec709 Kodak 2383 D65"); + expect(cleanLutName("Arri Alexa LogC to Rec709.dat")).toBe("Arri Alexa LogC to Rec709"); + expect(cleanLutName("Horror Look.3dl")).toBe("Horror Look"); + }); + + it("keeps only the file name of a pasted path", () => { + // Explorer's "Copy as path", quotes included. + expect( + cleanLutName( + '"C:\\ProgramData\\Blackmagic Design\\DaVinci Resolve\\Support\\LUT\\Arri\\Arri Alexa LogC to Rec709.dat"', + ), + ).toBe("Arri Alexa LogC to Rec709"); + expect( + cleanLutName( + "/Library/Application Support/Blackmagic Design/DaVinci Resolve/LUT/Film Looks/Rec709 Kodak 2383 D65.cube", + ), + ).toBe("Rec709 Kodak 2383 D65"); + expect(cleanLutName("C:/LUTs/Teal Orange.cube")).toBe("Teal Orange"); + }); + + it("keeps dots and slashes that belong to the name", () => { + expect(cleanLutName("SLog3SGamut3.CineToLC-709")).toBe("SLog3SGamut3.CineToLC-709"); + expect(cleanLutName("SLog3SGamut3.CineToLC-709.cube")).toBe("SLog3SGamut3.CineToLC-709"); + expect(cleanLutName("Leica Pure L-Log to Rec.709 Gamma 2.4")).toBe( + "Leica Pure L-Log to Rec.709 Gamma 2.4", + ); + expect(cleanLutName("Teal/Orange")).toBe("Teal/Orange"); + }); + + it("trims, and a second pass changes nothing", () => { + expect(cleanLutName(" Horror Look ")).toBe("Horror Look"); + for (const raw of ['""Look.cube""', "Look.cube.dat", '" x.CUBE "', "/", '"', ""]) { + const once = cleanLutName(raw); + expect(cleanLutName(once)).toBe(once); + } + expect(cleanLutName("Look.cube.dat")).toBe("Look"); + }); +}); + +describe("suggestions", () => { + it("offers each CPU and LUT once, already in the form its cleaner gives", () => { + const lists = [ + [CPU_SUGGESTIONS, cleanCpuName], + [LUT_SUGGESTIONS, cleanLutName], + ] as const; + for (const [list, clean] of lists) { + expect(new Set(list).size).toBe(list.length); + for (const suggestion of list) expect(clean(suggestion)).toBe(suggestion); + } + }); + + it("tidies a CPU name pasted from Windows in the output too", () => { + expect(formatRigValue("cpu", "Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz")).toBe( + "Intel Core i9-9900K", + ); + }); +}); + +/** + * The mock `t` returns a missing key as-is, so a rig field without labels + * would print "description.rigLabels.x: …" in tests without failing. + * `_schema.json` covers all eight locales (`validate:locales`). + */ +describe("rig field labels", () => { + const ids = RIG_FIELDS.map((f) => f.id).sort(compareCodeUnits); + + it("has an editor label for every rig field, and none for unknown ids", () => { + expect(schemaKeys("ui", "rig")).toEqual(ids); + }); + + it("has a description label for every rig field, and none for unknown ids", () => { + expect(schemaKeys("templates", "description.rigLabels")).toEqual(ids); + }); +}); + describe("cleanCpuName", () => { it("strips Windows' trademark marks and clock suffix", () => { expect(cleanCpuName("Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz")).toBe("Intel Core i9-9900K");