Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins/stewards/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ const SidebarThreadRow = memo(function SidebarThreadRow({
const useStewardGlyph = glyph !== undefined && indicator !== "draft" && indicator !== "working-draft";
const count = countThreads(children);
return (
<li className={`flex flex-col${entered ? " motion-safe:animate-in fade-in-0 slide-in-from-top-1 duration-200" : ""}`}>
<li className={`flex flex-col ${entered ? " motion-safe:animate-in fade-in-0 slide-in-from-top-1 duration-200" : ""}`}>
<ThreadActionsContextMenu thread={actionTarget(thread)}>
<div className={`flex items-center gap-1 rounded-md py-0.5 pr-1 hover:bg-state-hover ${selected ? "bg-state-active" : ""}`} style={{ paddingLeft: `${4 + depth * 14}px` }} title={titleAttr}>
{count > 0 ? (
Expand Down Expand Up @@ -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)}
>
<Icon name="ChevronRight" className={`size-3.5 motion-safe:transition-transform motion-safe:duration-200${open ? " rotate-90" : ""}`} />
<Icon name="ChevronRight" className={`size-3.5 motion-safe:transition-transform motion-safe:duration-200 ${open ? " rotate-90" : ""}`} />
</button>
) : (
<span className="flex size-4 shrink-0 items-center justify-center" />
Expand Down Expand Up @@ -1639,7 +1639,7 @@ const SidebarEffortRow = memo(function SidebarEffortRow({
</div>
);
return (
<li className={`flex flex-col${entered ? " motion-safe:animate-in fade-in-0 slide-in-from-top-1 duration-200" : ""}`}>
<li className={`flex flex-col ${entered ? " motion-safe:animate-in fade-in-0 slide-in-from-top-1 duration-200" : ""}`}>
{root === undefined ? body : <ThreadActionsContextMenu thread={actionTarget(root)}>{body}</ThreadActionsContextMenu>}
{mine.length > 0 ? (
<div className="flex flex-col gap-1 pb-1" style={{ paddingLeft: "40px" }}>
Expand Down
55 changes: 55 additions & 0 deletions plugins/stewards/class-names.test.ts
Original file line number Diff line number Diff line change
@@ -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 `<file>:<line>: <token>${`. */
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([]);
});
});
Loading