Skip to content
Open
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
19 changes: 18 additions & 1 deletion lib/home/__tests__/findStarterTemplate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,24 @@ const template = (over: Partial<AgentTemplateRow>): AgentTemplateRow =>
}) as AgentTemplateRow;

describe("findStarterTemplate", () => {
it("prefers the Weekly Performance Dashboard template", () => {
it("prefers the weekly valuation + streams template above all others", () => {
const templates = [
template({ id: "a", title: "Run Performance Report", tags: ["Report"] }),
template({
id: "b",
title: "Weekly Performance Dashboard",
tags: ["Report"],
}),
template({
id: "c",
title: "Weekly valuation + streams report",
tags: ["Report"],
}),
];
expect(findStarterTemplate(templates)?.id).toBe("c");
});

it("falls back to the Weekly Performance Dashboard template", () => {
const templates = [
template({ id: "a", title: "Run Performance Report", tags: ["Report"] }),
template({
Expand Down
19 changes: 12 additions & 7 deletions lib/home/findStarterTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
import type { AgentTemplateRow } from "@/types/AgentTemplates";

const PREFERRED_TITLE = "Weekly Performance Dashboard";
/** Most-preferred first — the valuation report is the video's hero flow (chat#1850). */
const PREFERRED_TITLES = [
"Weekly valuation + streams report",
"Weekly Performance Dashboard",
];

/**
* Picks the agent template behind the homepage starter task (DRY — the
* task's prompt comes from the existing /agents templates, never a
* hand-written string; recoupable/chat#1850 review). Prefers the weekly
* dashboard template, falls back to any Report-tagged agent, and returns
* undefined (card hidden) when none exist.
* valuation report, then the weekly dashboard, falls back to any
* Report-tagged agent, and returns undefined (card hidden) when none exist.
*/
export function findStarterTemplate(
templates: AgentTemplateRow[] | undefined,
): AgentTemplateRow | undefined {
if (!templates?.length) return undefined;
return (
templates.find((t) => t.title === PREFERRED_TITLE) ??
templates.find((t) => (t.tags ?? []).includes("Report"))
);
for (const title of PREFERRED_TITLES) {
const match = templates.find((t) => t.title === title);
if (match) return match;
}
return templates.find((t) => (t.tags ?? []).includes("Report"));
}
Loading