Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 8c0ce1a05167ac63ab2d56509d300f511d16494d
parent 59a2dcf32c8535821ec2506d5e556c50814432d7
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Sat, 14 Nov 2026 16:33:13 -0500

site-nav review fixes: nothing moves under a press, a filtered group acts on its matches, present refuses a broken file

- The channel finder's empty field no longer folds to the magnifier on the
  blur a press elsewhere in the row causes: it waits for the release and the
  click it makes, so All / Reset channels / Reset all filters / Reset
  everything land where they were pressed. A keyboard blur folds at once.
- While a query is on, a listed group's box, count and All/None act on the
  channels it lists (the matches; the whole group when its name matched).
- The live region is mounted with the field, so the first count is announced.
- More filters: no second "N selected" line inside (the summary says it, with
  ", any of them" from two); its content is set in like Advanced options'.
- `tags` op `present` refuses a site tags file that does not parse, naming it
  and writing nothing, and refuses a site-only tag without advising `define`.
  Its revalidate is guarded; a route unit test covers the write path and every
  refusal.
- e2e: 13-channel boundary, a click on All and Reset channels from an open
  empty field, None on a filtered group, the live region, the sheet's second
  Esc, a saved profile with a secondary tag.
- plans/FACTS.md: the site layer's fields include `secondary`; OPERATING.md's
  Tag recipe shows `present`.

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
MOPERATING.md | 5+++++
Mcommon/components/FiltersPanel.tsx | 126++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Mcommon/lib/channelFind.test.ts | 4++--
Mcommon/lib/channelFind.ts | 13+++++--------
Aeditor/app/api/ops/tags/route.test.ts | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Meditor/app/tags/actions.ts | 42++++++++++++++++++++++++++++++++++--------
Mexport/e2e/channel-find.spec.ts | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mexport/e2e/tag-chips.spec.ts | 40++++++++++++++++++++++++++++++++++++++--
Mplans/FACTS.md | 11++++++++---
9 files changed, 399 insertions(+), 56 deletions(-)

diff --git a/OPERATING.md b/OPERATING.md @@ -771,6 +771,7 @@ pnpm ops fetch-chat --json '{"slug":"example","id":"<videoId>"}' --wait ```sh pnpm ops get tags pnpm ops tags --json '{"op":"define","tag":{"id":"example-collab","label":"Collab"}}' +pnpm ops tags --json '{"op":"present","site":"example-site","tag":{"id":"example-collab","secondary":true}}' pnpm ops tag-videos --json '{"tag":"example-collab","op":"add","videos":[{"slug":"example","id":"<videoId>"}]}' pnpm ops tag-videos --file ids.json ``` @@ -778,6 +779,10 @@ pnpm ops tag-videos --file ids.json - `transcripts/tags.json` has one writer, and `tags` and `tag-videos` go through it, recording who asked (`ARCHILYZER_AGENT`). `remove` unpins; `suppress` rejects a rule's hit. - A tag's `sites` limits the sites it exists on. +- `present` sets how ONE site shows a corpus tag — one row of `sites/<site>/tags.json`: `label`, `groupLabel`, + `color`, `order`, `hidden`, `secondary` (offered under the site's **More filters** rather than its main Tags + row); other fields are kept, `null` clears one. The site's Tags tab (**Placement**) is the same. Rebuild and + deploy the site to publish it. - Read side: the MCP's `list_tags`, and `tags` on `search_transcripts` / `enumerate_matches`. ## Prepare and export reports diff --git a/common/components/FiltersPanel.tsx b/common/components/FiltersPanel.tsx @@ -153,13 +153,53 @@ export default function FiltersPanel({ // Offered only on a site with many channels. While it holds a query the // listed groups are the matching ones, shown open WITHOUT touching the // persisted `collapsedGroups`: clearing the query gives back exactly the - // panel the reader had. + // panel the reader had. A listed group's box, count and All/None act on + // the channels it lists — the matches — so nothing hidden changes. const { channels: channelModel } = useSearchData(); const showFind = channelOptions.length > CHANNEL_FIND_MIN_CHANNELS; const [findOpen, setFindOpen] = useState(false); const [findQuery, setFindQuery] = useState(""); const findButtonRef = useRef<HTMLButtonElement>(null); const findReturnFocus = useRef(false); + // For the deferred fold on blur (below): read from listeners that outlive + // the render that registered them. + const findQueryRef = useRef(""); + const findFocused = useRef(false); + const pointerHeld = useRef(false); + useEffect(() => { + if (!findOpen) return; + const down = () => { + pointerHeld.current = true; + }; + const up = () => { + pointerHeld.current = false; + }; + document.addEventListener("pointerdown", down, true); + document.addEventListener("pointerup", up, true); + document.addEventListener("pointercancel", up, true); + return () => { + pointerHeld.current = false; + document.removeEventListener("pointerdown", down, true); + document.removeEventListener("pointerup", up, true); + document.removeEventListener("pointercancel", up, true); + }; + }, [findOpen]); + // An EMPTY field folds back to the magnifier when it loses focus — but + // never under a pressed pointer. The field is wider than the magnifier, so + // folding on the blur that a press elsewhere in the row causes slides the + // row left before the press is released, and the click (on All, a Reset + // link) lands on whatever slid under it, or on nothing. So a blur by + // pointer waits for the release, and the fold runs after the click that + // release makes; a blur by keyboard folds at once (nothing is under a + // pointer). Either way it only folds if the field is still empty and has + // not taken focus back meanwhile. + const foldFindIfIdle = useCallback(() => { + window.setTimeout(() => { + if (!findFocused.current && findQueryRef.current.trim() === "") { + setFindOpen(false); + } + }, 0); + }, []); const slugByKey = useMemo( () => new Map(channelModel.map((c) => [c.key, c.slug])), [channelModel], @@ -176,6 +216,7 @@ export default function FiltersPanel({ ); const closeFind = useCallback(() => { findReturnFocus.current = true; + findQueryRef.current = ""; setFindQuery(""); setFindOpen(false); }, []); @@ -186,16 +227,7 @@ export default function FiltersPanel({ findButtonRef.current?.focus(); } }, [findOpen]); - const listedGroupings: FoundGrouping<ChannelGroup>[] = useMemo( - () => - found ?? - channelGroupings.map(({ group, channels }) => ({ - group, - channels, - all: channels, - })), - [found, channelGroupings], - ); + const listedGroupings: FoundGrouping<ChannelGroup>[] = found ?? channelGroupings; const foundCount = found?.reduce((n, g) => n + g.channels.length, 0) ?? 0; @@ -280,7 +312,13 @@ export default function FiltersPanel({ aria-label="Find a channel" placeholder="Find channel" value={findQuery} - onChange={(e) => setFindQuery(e.target.value)} + onChange={(e) => { + findQueryRef.current = e.target.value; + setFindQuery(e.target.value); + }} + onFocus={() => { + findFocused.current = true; + }} onKeyDown={(e) => { if (e.key === "Escape") { e.preventDefault(); @@ -289,7 +327,19 @@ export default function FiltersPanel({ } }} onBlur={() => { - if (findQuery.trim() === "") setFindOpen(false); + findFocused.current = false; + if (findQueryRef.current.trim() !== "") return; + if (!pointerHeld.current) { + foldFindIfIdle(); + return; + } + const release = () => { + document.removeEventListener("pointerup", release, true); + document.removeEventListener("pointercancel", release, true); + foldFindIfIdle(); + }; + document.addEventListener("pointerup", release, true); + document.addEventListener("pointercancel", release, true); }} className="h-7 w-40 rounded-md border border-border bg-card pl-7 pr-2 text-xs text-foreground placeholder:text-muted-foreground" /> @@ -307,11 +357,22 @@ export default function FiltersPanel({ <SearchIcon aria-hidden="true" className="size-3.5" /> </button> ))} - {found && ( - <span className="sr-only" aria-live="polite"> - {foundCount === 1 - ? "1 channel matches" - : `${foundCount} channels match`} + {/* Mounted with the field, before the first query, so the + first count is announced too: a live region only speaks + about changes it was already there to see. */} + {showFind && findOpen && ( + <span + className="sr-only" + aria-live="polite" + data-testid="channel-find-live" + > + {found === null + ? "" + : foundCount === 0 + ? "No channel matches" + : foundCount === 1 + ? "1 channel matches" + : `${foundCount} channels match`} </span> )} <ChannelAllToggle @@ -357,17 +418,18 @@ export default function FiltersPanel({ </p> )} <div className="flex flex-wrap items-start gap-1.5"> - {listedGroupings.map(({ group, channels: shown, all }) => { - // The group's whole membership: what its box, its count and - // All/None act on, whatever the finder lists. - const channels = all; + {listedGroupings.map(({ group, channels }) => { + // While the finder holds a query, `channels` is what it + // lists — the matches, or the whole group when the group's + // name matched — and the box, the count and All/None act on + // exactly that. if (group.inline) { // Inline group: no collapsible box — each member channel // renders as its own loose chip flowing among the group // chips, styled like a collapsed group chip. return ( <Fragment key={group.id}> - {shown.map((key) => { + {channels.map((key) => { const label = channelLabelByKey.get(key) ?? key; return ( <label @@ -512,7 +574,7 @@ export default function FiltersPanel({ </div> )} <div className="flex flex-wrap items-center gap-x-3 gap-y-1 px-3 pt-1 pb-2"> - {shown.map((key) => { + {channels.map((key) => { const checked = !draftExcludedChannels.has(key); return ( <label @@ -978,8 +1040,7 @@ function useTagPlaces() { secondaryGroups, secondary, unpublished, - // Whether the main row renders at all: the disclosure carries the "ANY" - // line itself when it is the only place tags are offered. + // Whether the main row renders at all. hasMainRow: primaryGroups.length > 0 || unpublished.length > 0, }; } @@ -1202,7 +1263,7 @@ function TagChipRow() { // or closes it, their choice holds. (No effect: the open state is derived, so // there is nothing to get out of step with hydration.) function MoreTagFilters() { - const { draftTags, toggleDraftTag, secondaryGroups, secondary, hasMainRow } = + const { draftTags, toggleDraftTag, secondaryGroups, secondary } = useTagPlaces(); const [chosenOpen, setChosenOpen] = useState<boolean | null>(null); const selectedCount = secondary.reduce( @@ -1264,15 +1325,14 @@ function MoreTagFilters() { > {" "} · {selectedCount} selected + {/* Two or more: say how they combine, once, here. */} + {selectedCount > 1 && ", any of them"} </span> )} </summary> - <div className="mt-2 flex flex-col gap-2"> - {!hasMainRow && ( - <span className="text-xs text-muted-foreground"> - Tags: {tagSelectionLine(draftTags.size)} - </span> - )} + {/* Set in like Advanced options' content, so the chips read as inside + the disclosure and not as one more row of the panel. */} + <div className="mt-3 flex flex-col gap-2 rounded-md border border-border bg-card/60 p-4"> {secondaryGroups.map(renderGroup)} </div> </details> diff --git a/common/lib/channelFind.test.ts b/common/lib/channelFind.test.ts @@ -41,7 +41,7 @@ test("an empty or punctuation-only query filters nothing", () => { test("a channel name narrows its group to the matching channels", () => { assert.deepEqual(findChannels(GROUPINGS, "alp", textsOf), [ - { group: GROUPINGS[0].group, channels: ["Alpha"], all: ["Alpha", "Beta"] }, + { group: GROUPINGS[0].group, channels: ["Alpha"] }, ]); }); @@ -55,7 +55,7 @@ test("a slug matches, separators read as spaces", () => { test("a group name lists the whole group", () => { const found = findChannels(GROUPINGS, "review", textsOf); assert.deepEqual(found, [ - { group: GROUPINGS[1].group, channels: ["Gamma", "Delta"], all: ["Gamma", "Delta"] }, + { group: GROUPINGS[1].group, channels: ["Gamma", "Delta"] }, ]); }); diff --git a/common/lib/channelFind.ts b/common/lib/channelFind.ts @@ -24,11 +24,9 @@ export function foldForFind(s: string): string { export type FoundGrouping<G> = { group: G; // The channels to SHOW: every one when the group's name matched, else only - // the matching ones. + // the matching ones. While a query is on these are also what the group's + // box, its count and All/None act on — what you see is what you change. channels: string[]; - // The group's whole membership, for the group's tri-state box, its count - // and All/None — a filter narrows what is listed, not what a group is. - all: string[]; }; // null when there is nothing to filter by (an empty or punctuation-only @@ -45,11 +43,10 @@ export function findChannels<G extends { name: string }>( text !== undefined && foldForFind(text).includes(q); const out: FoundGrouping<G>[] = []; for (const { group, channels } of groupings) { - const all = channels.slice(); const shown = hit(group.name) - ? all - : all.filter((key) => textsOf(key).some(hit)); - if (shown.length > 0) out.push({ group, channels: shown, all }); + ? channels.slice() + : channels.filter((key) => textsOf(key).some(hit)); + if (shown.length > 0) out.push({ group, channels: shown }); } return out; } diff --git a/editor/app/api/ops/tags/route.test.ts b/editor/app/api/ops/tags/route.test.ts @@ -0,0 +1,123 @@ +import test from "node:test"; +import assert from "node:assert/strict"; +import { mkdir, readFile, rm, writeFile } from "node:fs/promises"; +import path from "node:path"; +import { setupOpsCorpus, callPost } from "../_testCorpus"; + +// Run with: +// pnpm -C editor exec tsx --test "app/api/ops/tags/route.test.ts" +// +// `tags` op `present` (presentSiteTagAction): ONE row of a site's +// sites/<site>/tags.json, merged field by field. Every refusal is answered +// before anything is written. The write ends in safeRevalidate, which a bare +// tsx process (no request store) skips, so the write path runs here too. + +const corpus = await setupOpsCorpus(null); +await corpus.writeSite("demo-site"); +const globalTags = { + version: 1, + tags: [ + { id: "case-collab", label: "Collab", group: "case", groupLabel: "Case" }, + { id: "case-topic", label: "Discussed", group: "case", groupLabel: "Case" }, + ], + assignments: {}, +}; +await writeFile( + path.join(corpus.transcripts, "tags.json"), + JSON.stringify(globalTags, null, 2), +); +const siteFile = path.join(corpus.transcripts, "sites", "demo-site", "tags.json"); +const { POST } = await import("./route"); +test.after(() => corpus.cleanup()); + +const present = (tag: unknown, site: unknown = "demo-site") => + callPost(POST, { op: "present", site, tag }); +const siteText = () => readFile(siteFile, "utf8").catch(() => null); +const siteRows = async () => JSON.parse((await siteText()) ?? "{}").tags; + +test("present merges one row, keeps the others, and null clears a field", async () => { + await rm(siteFile, { force: true }); + const a = await present({ id: "case-collab", secondary: true }); + assert.equal(a.status, 200, JSON.stringify(a.body)); + assert.deepEqual(a.body.row, { id: "case-collab", secondary: true }); + + const b = await present({ id: "case-topic", color: "#b48ead", order: 3 }); + assert.equal(b.status, 200, JSON.stringify(b.body)); + // The first row is kept; a later patch of it keeps its other fields. + const c = await present({ id: "case-collab", label: "With", hidden: false }); + assert.deepEqual(c.body.row, { + id: "case-collab", + label: "With", + hidden: false, + secondary: true, + }); + assert.deepEqual(await siteRows(), [ + { id: "case-collab", label: "With", hidden: false, secondary: true }, + { id: "case-topic", color: "#b48ead", order: 3 }, + ]); + + // Every allowed field can be cleared; a row left saying nothing goes. + const d = await present({ + id: "case-collab", + label: null, + hidden: null, + secondary: null, + }); + assert.equal(d.status, 200); + assert.equal(d.body.row, null); + assert.deepEqual(await siteRows(), [ + { id: "case-topic", color: "#b48ead", order: 3 }, + ]); + // A groupLabel is a site presentation field too. + const e = await present({ id: "case-topic", groupLabel: "Elsewhere" }); + assert.equal(e.status, 200); + assert.equal((e.body.row as { groupLabel?: string }).groupLabel, "Elsewhere"); +}); + +test("present refuses, writing nothing", async () => { + await rm(siteFile, { force: true }); + await present({ id: "case-topic", secondary: true }); + const before = await siteText(); + for (const [body, re] of [ + [{ op: "present", site: "demo-site", tag: { id: "case-nope", secondary: true } }, /no tag "case-nope" is defined in the corpus vocabulary — define it/], + [{ op: "present", site: "no-such-site", tag: { id: "case-topic", secondary: true } }, /Site "no-such-site" not found/], + [{ op: "present", site: "Bad Site!", tag: { id: "case-topic", secondary: true } }, /not a valid site id/], + [{ op: "present", tag: { id: "case-topic", secondary: true } }, /"site" must be a site id/], + [{ op: "present", site: "demo-site", tag: "case-topic" }, /"tag" must be an object/], + [{ op: "present", site: "demo-site", tag: { id: "case-topic", rules: [] } }, /"rules" is not a site presentation field/], + [{ op: "present", site: "demo-site", tag: { id: "case-topic", sites: ["x"] } }, /"sites" is not a site presentation field/], + [{ op: "present", site: "demo-site", tag: { id: "case-topic" } }, /name at least one/], + [{ op: "present", site: "demo-site", tag: { id: "case-topic", secondary: "yes" } }, /"secondary" has no usable value/], + [{ op: "define", site: "demo-site", tag: { id: "case-topic" } }, /"site" is for op "present" only/], + [{ op: "present", site: "demo-site", tag: { id: "case-topic", secondary: true }, extra: 1 }, /extra/], + ] as const) { + const r = await callPost(POST, body); + assert.equal(r.status, 400, JSON.stringify(body)); + assert.match(String(r.body.error), re, JSON.stringify(r.body)); + } + assert.equal(await siteText(), before, "nothing written"); +}); + +test("a site-only tag is refused without the advice to define it", async () => { + await writeFile( + siteFile, + JSON.stringify({ version: 1, tags: [{ id: "site-only", label: "Here only" }], assignments: {} }), + ); + const before = await siteText(); + const r = await present({ id: "site-only", secondary: true }); + assert.equal(r.status, 400); + assert.match(String(r.body.error), /"site-only" is a site-only tag of "demo-site"/); + assert.doesNotMatch(String(r.body.error), /define/); + assert.equal(await siteText(), before); +}); + +test("a site tags file that does not parse is named and left as it is", async () => { + await mkdir(path.dirname(siteFile), { recursive: true }); + const broken = '{"version":1,"tags":[{"id":"case-topic","color":"#fff"},'; + await writeFile(siteFile, broken); + const r = await present({ id: "case-collab", secondary: true }); + assert.equal(r.status, 400); + assert.ok(String(r.body.error).includes(siteFile), String(r.body.error)); + assert.match(String(r.body.error), /cannot be read as JSON/); + assert.equal(await siteText(), broken, "the file is untouched"); +}); diff --git a/editor/app/tags/actions.ts b/editor/app/tags/actions.ts @@ -3,8 +3,13 @@ import { revalidatePath } from "next/cache"; import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { listChannelConfigs } from "yt-dlp-transcript-common/controller/channels"; -import { existsSync } from "node:fs"; -import { isValidSiteId, siteConfigFile } from "yt-dlp-transcript-common/lib/site"; +import { existsSync, readFileSync } from "node:fs"; +import { + isValidSiteId, + siteConfigFile, + siteTagsFile, +} from "yt-dlp-transcript-common/lib/site"; +import { safeRevalidate } from "../lib/safeRevalidate"; import { TAG_ID_RE, patchSiteOverlay, @@ -100,9 +105,16 @@ export async function saveSiteTagDefsAction( // ONE row of one site's overlay — the `tags` op `present`. The site page saves // the whole list; an agent holding one tag sends only the fields it changes // (`null` clears one), and every other row and field is kept. Refused before -// anything is written: an unknown site, or a tag the corpus does not define (a -// site row for an undefined id would be a new site-only tag, which is a -// vocabulary decision, not a presentation one — and usually a typo). +// anything is written: +// - an unknown site; +// - a site tags file that exists but does not parse. readSiteTags reads that +// as "no overlay", and writing the patched row over it would drop every +// row the file held — the opposite of what this op promises; +// - a tag the corpus does not define. A site row for an undefined id would +// be a new site-only tag, which is a vocabulary decision, not a +// presentation one — and usually a typo. A site-only tag the site already +// has is refused too, without the advice to `define` it: that would make +// it a corpus tag on every site. export async function presentSiteTagAction( siteId: string, patch: Record<string, unknown>, @@ -116,18 +128,32 @@ export async function presentSiteTagAction( if (!existsSync(siteConfigFile(paths, siteId))) { return { ok: false, error: `Site "${siteId}" not found` }; } + const file = siteTagsFile(paths, siteId); + if (existsSync(file)) { + try { + JSON.parse(readFileSync(file, "utf8")); + } catch (err) { + return { + ok: false, + error: `${file} cannot be read as JSON (${err instanceof Error ? err.message : String(err)}) — fix or remove it first; nothing was written, so its rows are as they were`, + }; + } + } + const current = readSiteTags(paths, siteId); const id = typeof patch.id === "string" ? patch.id.trim().toLowerCase() : ""; if (id && !readGlobalTags(paths).tags.some((t) => t.id === id)) { return { ok: false, - error: `no tag "${id}" is defined in the corpus vocabulary — define it with op "define" first`, + error: current.tags.some((t) => t.id === id) + ? `"${id}" is a site-only tag of "${siteId}" (in ${file}), not a corpus tag — "present" sets how a site shows a corpus tag` + : `no tag "${id}" is defined in the corpus vocabulary — define it with op "define" first`, }; } - const current = readSiteTags(paths, siteId); const result = patchSiteOverlay(current.tags, patch); if (!result.ok) return result; writeSiteTags(paths, siteId, { ...current, assignments: {}, tags: result.tags }); - revalidatePath(`/sites/${siteId}/tags`); + // Guarded: the ops route and a unit test call this outside a page request. + safeRevalidate([`/sites/${siteId}/tags`]); return { ok: true, row: result.row }; } diff --git a/export/e2e/channel-find.spec.ts b/export/e2e/channel-find.spec.ts @@ -145,6 +145,92 @@ test.describe("channel finder", () => { await expect(opener(page)).toHaveCount(0); }); + test("is offered from 13 channels", async ({ page }) => { + await installRoutes(page, CHANNELS.slice(0, 13)); + await page.goto("/"); + await waitForHydration(page); + await expect(page.getByText("13 of 13 channels")).toBeVisible(); + await expect(opener(page)).toBeVisible(); + }); + + test("an empty open field never moves the row under a click: All and Reset channels land", async ({ + page, + }) => { + await installRoutes(page); + await page.goto("/"); + await waitForHydration(page); + const all = page.getByRole("checkbox", { name: "All", exact: true }); + await expect(all).toBeChecked(); + + // Open, leave empty, click All with a real press and release. + await opener(page).click(); + await expect(field(page)).toBeFocused(); + const at = await all.boundingBox(); + await page.mouse.move(at!.x + at!.width / 2, at!.y + at!.height / 2); + await page.mouse.down(); + // While the press is held the field is still there, so All has not moved. + await expect(field(page)).toBeVisible(); + expect((await all.boundingBox())!.x).toBe(at!.x); + await page.mouse.up(); + await expect(page.getByText("0 of 14 channels")).toBeVisible(); + await expect(all).not.toBeChecked(); + // …and only then does the empty field fold back to the magnifier. + await expect(field(page)).toHaveCount(0); + + // Reset channels from an open empty field: the click lands too. + await opener(page).click(); + await expect(field(page)).toBeFocused(); + await page.getByRole("button", { name: "Reset channels" }).click(); + await expect(page.getByText("14 of 14 channels")).toBeVisible(); + await expect(field(page)).toHaveCount(0); + }); + + test("while filtering, a group's None, box and count act on the channels listed", async ({ + page, + }) => { + await installRoutes(page); + await page.goto("/"); + await waitForHydration(page); + await opener(page).click(); + + // One match in a four-channel group: the count is matches-selected/matches. + await field(page).fill("talk"); + const one = groupCard(page, "Group One"); + await expect(one.locator("summary")).toContainText("1/1"); + await one.getByRole("button", { name: "None" }).click(); + await expect(page.getByText("13 of 14 channels")).toBeVisible(); + await expect(one.locator("summary")).toContainText("0/1"); + // The group's box re-selects just the match. + await page.getByRole("checkbox", { name: "Select all in Group One" }).click(); + await expect(page.getByText("14 of 14 channels")).toBeVisible(); + await one.getByRole("button", { name: "None" }).click(); + + // A matched group NAME lists the whole group, so None is the whole group. + await field(page).fill("reviewer"); + await groupCard(page, "Reviewers").getByRole("button", { name: "None" }).click(); + await expect(page.getByText("9 of 14 channels")).toBeVisible(); + + // No query: the whole group again. + await field(page).press("Escape"); + await expect(groupCard(page, "Group One").locator("summary")).toContainText("3/4"); + }); + + test("the live region is there before the first query, so the first count is announced", async ({ + page, + }) => { + await installRoutes(page); + await page.goto("/"); + await waitForHydration(page); + await opener(page).click(); + const live = page.getByTestId("channel-find-live"); + await expect(live).toHaveCount(1); + await expect(live).toHaveText(""); + await field(page).fill("kappa"); + await expect(live).toHaveText("1 channel matches"); + await field(page).fill("zzz"); + await expect(live).toHaveText("No channel matches"); + }); + test("narrows the groups by channel name, slug or group name, and Esc gives the panel back", async ({ page, }, testInfo) => { @@ -259,6 +345,11 @@ test.describe("channel finder", () => { await field(page).press("Escape"); await expect(field(page)).toHaveCount(0); await expect(opener(page)).toBeVisible(); + await expect(opener(page)).toBeFocused(); + // The second Esc is the sheet's. + await page.keyboard.press("Escape"); + await expect(page.getByTestId("filters-panel")).toHaveCount(0); + await expect(page.getByTestId("filters-trigger")).toBeVisible(); }); }); }); diff --git a/export/e2e/tag-chips.spec.ts b/export/e2e/tag-chips.spec.ts @@ -419,9 +419,15 @@ test.describe("curated tag chips", () => { await expect(more(page)).toHaveAttribute("open", ""); // The group label is inside, beside its chips. await expect(tagGroup(page, "case")).toContainText("Case"); - await expect(more(page)).toContainText("Tags: any"); + // No second "N selected" line inside: the summary says it. + await expect(more(page)).not.toContainText("Tags:"); await chip(page, TAG_TOPIC).click(); - await expect(moreSummary(page)).toContainText("1 selected"); + await expect(moreSummary(page)).toHaveText("More filters · 1 selected"); + await chip(page, TAG_COLLAB).click(); + await expect(moreSummary(page)).toHaveText( + "More filters · 2 selected, any of them", + ); + await chip(page, TAG_COLLAB).click(); await page.getByTestId("filters-panel").screenshot({ path: testInfo.outputPath("tag-more-open-desktop.png"), }); @@ -458,6 +464,36 @@ test.describe("curated tag chips", () => { await expect(moreSummary(page)).toContainText("1 selected"); }); + test("a saved profile with a secondary tag opens More filters with it lit", async ({ + page, + }) => { + await installRoutes(page); + await installSecondary(page, [TAG_COLLAB, TAG_TOPIC]); + // A window to seed localStorage on, then a reload so hydration reads + // it — the same route filter-profile-persistence.spec.ts takes. + await page.goto("/"); + await waitForHydration(page); + await page.evaluate((tag) => { + const snap = { channels: { included: [], excluded: [] }, tg: [tag] }; + window.localStorage.setItem( + "ytdlp-tb:export-filters", + JSON.stringify({ + v: 1, + working: snap, + profiles: { p1: snap }, + activeProfileName: "p1", + }), + ); + }, TAG_TOPIC); + await page.reload(); + await waitForHydration(page); + await openFilters(page); + + await expect(more(page)).toHaveAttribute("open", ""); + await expect(chip(page, TAG_TOPIC)).toHaveAttribute("aria-pressed", "true"); + await expect(moreSummary(page)).toHaveText("More filters · 1 selected"); + }); + test("mixed: the main row keeps its own tags, More filters the rest", async ({ page, }) => { diff --git a/plans/FACTS.md b/plans/FACTS.md @@ -337,8 +337,12 @@ untagged corpus** because an empty derivation leaves each summary byte-identical re-read 76k video directories to reach exactly the same state. **The site layer is presentation-only.** `sites/<id>/tags.json` relabels, recolours, -reorders, hides and may add site-only tags; it can never delete a corpus rule or an -assignment. A site-layer RULE is accepted by `mergeTagDefs` (harmless on a published def) +reorders, hides, moves a tag under the viewer's "More filters" (`secondary`) and may add +site-only tags; it can never delete a corpus rule or an assignment. At the site layer an +explicit `hidden: false` / `secondary: false` is KEPT (it overrides a corpus `true`); at the +corpus layer only `true` is stored. One row is changed by the `tags` op `present` +(`patchSiteOverlay`, `editor/app/tags/actions.ts` `presentSiteTagAction`), which refuses a +site tags file that does not parse rather than write over it. A site-layer RULE is accepted by `mergeTagDefs` (harmless on a published def) but **never tags a record**: rules are evaluated once at index time over records SHARED by every site carrying the channel, so there is no per-site record for a per-site hit to live in. Rules bind only from `transcripts/tags.json` — promote one there to make it fire. The @@ -5410,7 +5414,8 @@ Three branches off `4ac8ceda`, merged in order: `1a011d96` alone, then `tags/rul `curatedTagsStore.ts:9-17`. - Why, restated because it is the kind of rule people "fix": a record is shared by every site that carries its channel, so a site-layer rule could only tag records the OTHER sites also - publish. The site layer is presentation — `label/groupLabel/color/order/hidden`. + publish. The site layer is presentation — `label/groupLabel/color/order/hidden/secondary` + (`SITE_OVERLAY_FIELDS`, `common/lib/curatedTags.ts`). ### `--wait` polls a log route, and a dropped poll is not a failure