diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx index 6f11f071..ef0baabf 100644 --- a/plugins/stewards/app.tsx +++ b/plugins/stewards/app.tsx @@ -1385,7 +1385,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow({ const useStewardGlyph = glyph !== undefined && indicator !== "draft" && indicator !== "working-draft"; const count = countThreads(children); return ( -
  • +
  • {count > 0 ? ( @@ -1606,7 +1606,7 @@ const SidebarEffortRow = memo(function SidebarEffortRow({ className="flex size-4 shrink-0 items-center justify-center text-muted-foreground" onClick={() => setUserOpen(!open)} > - + ) : ( @@ -1639,7 +1639,7 @@ const SidebarEffortRow = memo(function SidebarEffortRow({
    ); return ( -
  • +
  • {root === undefined ? body : {body}} {mine.length > 0 ? (
    diff --git a/plugins/stewards/class-names.test.ts b/plugins/stewards/class-names.test.ts new file mode 100644 index 00000000..b9a68a41 --- /dev/null +++ b/plugins/stewards/class-names.test.ts @@ -0,0 +1,55 @@ +// BB-98: Tailwind's source scanner does not extract a utility that is glued to +// a template substitution (`bg-attention${transition}`), so no rule is emitted +// and the element renders without that class. Every class template literal +// needs a space before `${`. This guard fails if one is missing, so the unread +// "you" dot and the running phrase colour cannot go invisible again. +import { readFileSync, readdirSync } from "node:fs"; +import { dirname, join, relative, sep } from "node:path"; +import { fileURLToPath } from "node:url"; +import { describe, expect, it } from "vitest"; + +const root = dirname(fileURLToPath(import.meta.url)); + +// A class-ish token ending in a class character and glued to `${`. The token +// must contain a hyphen and an alphanumeric, which keeps the plugin's other +// template literals (paths, keys, dates) out without a full parser. +const GLUED = /[\s`"'(]([A-Za-z0-9_:/[\].-]*[A-Za-z0-9_/\]\)])\$\{/g; + +const isUtility = (token: string): boolean => token.includes("-") && /[A-Za-z0-9]/.test(token); + +/** Every non-test `.ts`/`.tsx` file in the plugin, with an absolute path. */ +function sourceFiles(dir: string, out: string[] = []): string[] { + for (const entry of readdirSync(dir, { withFileTypes: true })) { + if (entry.name === "node_modules" || entry.name === "dist") continue; + const path = join(dir, entry.name); + if (entry.isDirectory()) sourceFiles(path, out); + else if (/\.tsx?$/.test(entry.name) && !/\.test\.tsx?$/.test(entry.name)) out.push(path); + } + return out; +} + +/** Each glued utility in the plugin source, as `:: ${`. */ +function gluedUtilities(): string[] { + const found: string[] = []; + for (const path of sourceFiles(root)) { + const source = readFileSync(path, "utf8"); + for (const match of source.matchAll(GLUED)) { + if (!isUtility(match[1])) continue; + const line = source.slice(0, match.index).split("\n").length; + found.push(`${relative(root, path).split(sep).join("/")}:${line}: ${match[1]}\${`); + } + } + return found; +} + +describe("class template literals", () => { + it("flags a glued utility and not a spaced one", () => { + expect([..."`bg-attention${transition}`".matchAll(GLUED)].map((m) => m[1])).toEqual(["bg-attention"]); + expect([..."`bg-attention ${transition}`".matchAll(GLUED)]).toEqual([]); + expect([..."`border-2 ${border} ${transition}`".matchAll(GLUED)]).toEqual([]); + }); + + it("never glues a utility to a template substitution", () => { + expect(gluedUtilities()).toEqual([]); + }); +});