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
9 changes: 9 additions & 0 deletions pm-stack/aggregator/src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@ export const PAGES: PageDef[] = [
group: "work",
nav: "dropdown",
},
{
id: "search",
title: "Search",
route: "/search",
api: "/api/search.json",
blurb: "Search board and roadmap work by title or linked issue/PR ref.",
group: "work",
nav: "dropdown",
},
{
id: "events",
title: "Events",
Expand Down
44 changes: 43 additions & 1 deletion pm-stack/aggregator/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ import { buildEpicRollups, isEpicChildDone, type EpicRollup } from "./epics.ts";
import { effortWeight, handsLine, summarizeWeights, weightedLine } from "./weights.ts";
import { blockedSummary, depthLayout, hasGraphEdges } from "./graph.ts";
import { type AuthorIdentity } from "./registry.ts";
import type { SearchResult } from "./search-view.ts";

export function esc(s: unknown): string {
return String(s ?? "")
Expand All @@ -134,6 +135,11 @@ const CSS = `
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, sans-serif; background: #0e1117; color: #e6edf3; }
[id] { scroll-margin-top: 96px; }
nav { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; padding: 8px 16px; border-bottom: 1px solid #30363d; background: #161b22; position: sticky; top: 0; }
.navsearch { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.navsearch input, .search-page-form input { min-width: 12rem; padding: 7px 9px; border: 1px solid #30363d; border-radius: 6px; background: #0d1117; color: inherit; }
.navsearch button, .search-page-form button { padding: 7px 10px; border: 1px solid #30363d; border-radius: 6px; background: #21262d; color: inherit; cursor: pointer; }
.search-page-form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.search-page-form input { flex: 1; }
.navgroup { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.navgroup + .navgroup { border-left: 1px solid #30363d; padding-left: 12px; }
.navlabel { color: #8b949e; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-right: 4px; }
Expand Down Expand Up @@ -756,6 +762,10 @@ export function pageDropdown(active: string): string {
return `<select aria-label="Go to page" onchange="if(this.value)location.href=this.value"><option value="">Pages ▾</option>${groups}</select>`;
}

function globalSearch(): string {
return `<form class="navsearch" action="/search" method="get" role="search"><input type="search" name="q" aria-label="Search board and roadmap work" placeholder="Search work…" required><button type="submit">Search</button></form>`;
}

function layout(
title: string,
body: string,
Expand All @@ -775,11 +785,43 @@ function layout(
return `<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<title>${esc(title)} · aggregator</title><link rel="manifest" href="/manifest.webmanifest"><meta name="theme-color" content="#161b22"><meta name="mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"><meta name="apple-mobile-web-app-title" content="PM Stack"><link rel="apple-touch-icon" href="/icons/apple-touch-icon.png"><style>${CSS}</style><script type="module" src="/assets/datastar.js"></script></head>
<body><nav>${links}${dropdown}</nav><main>${chipsHtml}${body}
<body><nav>${links}${dropdown}${globalSearch()}</nav><main>${chipsHtml}${body}
<div class="foot"><details class="srcdetail"><summary>source detail</summary>board: ${esc(provenance.board)} · roadmap: ${esc(provenance.roadmap)} · items: ${esc(provenance.items)} · comments: ${esc(provenance.comments)} · quota: ${esc(provenance.quota)} · usage: ${esc(provenance.usage)} · attention: ${esc(provenance.attention)} · orchestration: ${esc(provenance.orchestration)} · dns: ${esc(provenance.dns)} · registry: ${esc(provenance.registry)} · aa: ${esc(provenance.aa)}</details><span class="kbd-hint">${KEY_HINT}</span> · tailnet: <a href="${TAILNET_URL}">${TAILNET_URL.replace("http://", "")}</a></div>
</main><script src="/assets/push-client.js?v=push-ux-2026-11-01" defer></script>${extra}${paletteHtml()}${KEYBOARD_SCRIPT}</body></html>`;
}

/** First-slice global search over board/roadmap subjects and linked refs. */
export function renderSearch(
query: string,
results: SearchResult[],
items: Map<RefKey, GhItem>,
provenance: Provenance,
detail?: ProvenanceDetail,
): string {
const cards = results
.map((result) => {
const badges = result.refs
.map((ref) => {
const item = items.get(ref);
return item
? itemBadge(item)
: `<a class="badge closed" href="${esc(refUrl(ref))}" title="Unresolved by the current item source">${esc(ref)} · unresolved</a>`;
})
.join(" ");
return `<div class="card"><a href="/item/${encodeURIComponent(result.id)}"><strong>${esc(result.title)}</strong></a><br><span class="muted">${result.kind} · ${esc(result.summary)}</span>${badges ? `<div class="strip">${badges}</div>` : ""}</div>`;
})
.join("");
const body = `<h1>Search</h1><p class="muted">Search board items and roadmap rows by subject, title, or linked issue/PR ref. Linked GitHub badges show their current projected state and whether the result is fixture-only.</p><form class="search-page-form" action="/search" method="get" role="search"><label for="search-query">Search work</label><input id="search-query" type="search" name="q" value="${esc(query)}" placeholder="Title or owner/repo#123"><button type="submit">Search</button></form>${query ? `<h2>${results.length} result${results.length === 1 ? "" : "s"} for “${esc(query)}”</h2>${cards || '<p class="muted">No matching work found.</p>'}` : '<p class="muted">Enter a title or issue/PR reference to search.</p>'}`;
return layout(
"Search",
body,
provenance,
"/search",
"",
detail ? freshnessChips(detail, ["board", "roadmap", "items"]) : "",
);
}

// --- Dashboard comments (#906 §2) ------------------------------------------

/** Object refs: the keys dashboard comment threads hang on. */
Expand Down
67 changes: 67 additions & 0 deletions pm-stack/aggregator/src/search-view.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import type { BoardItem, GhItem, RefKey, RoadmapRow } from "./model.ts";

export interface SearchResult {
kind: "board" | "roadmap";
id: string;
title: string;
summary: string;
refs: RefKey[];
}

function includesQuery(query: string, values: (string | undefined)[]): boolean {
return values.some((value) => value?.toLowerCase().includes(query));
}

/** Search the first-slice canonical subjects and their projected GitHub refs. */
export function searchWork(
board: BoardItem[],
rows: RoadmapRow[],
items: Map<RefKey, GhItem>,
rawQuery: string,
): SearchResult[] {
const query = rawQuery.trim().toLowerCase();
if (!query) return [];

const results: SearchResult[] = [];
for (const item of board) {
const refs = item.links.map((link) => link.ref);
const projectedTitles = refs.map((ref) => items.get(ref)?.title);
if (includesQuery(query, [item.id, item.title, item.repo, item.status, item.source, ...refs, ...projectedTitles])) {
results.push({
kind: "board",
id: item.id,
title: item.title,
summary: `${item.repo} · ${item.status}`,
refs,
});
}
}

for (const row of rows) {
const refs = row.links.map((link) => link.ref);
const projectedTitles = refs.map((ref) => items.get(ref)?.title);
if (
includesQuery(query, [
row.subject,
row.title,
row.area,
row.status,
row.horizon,
row.source,
row.notes,
...refs,
...projectedTitles,
])
) {
results.push({
kind: "roadmap",
id: row.subject,
title: row.title,
summary: `${row.area} · ${row.status} · ${row.horizon}`,
refs,
});
}
}

return results;
}
17 changes: 17 additions & 0 deletions pm-stack/aggregator/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import {
renderQueueShell,
buildRoadmapDrill,
renderRoadmap,
renderSearch,
renderServiceDetail,
renderSessions,
renderToday,
Expand All @@ -113,6 +114,7 @@ import { SW_SOURCE } from "./sw-source.ts";
import { renderAlerts, esc } from "./render.ts";
import { readJsonBody } from "./request-body.ts";
import { parseRegistryQuery, queryRegistry } from "./registry-view.ts";
import { searchWork } from "./search-view.ts";
import type { Source } from "./source.ts";
import { fixtureSource } from "./sources/fixtures.ts";
import { liveSource } from "./sources/live.ts";
Expand Down Expand Up @@ -432,6 +434,13 @@ async function roadmapContext() {
return { rows, items, pool: poolResult.pool, reconciliation, drill };
}

async function searchContext(query: string) {
const [board, rows] = await Promise.all([source.board(), source.roadmap()]);
const refs = [...new Set([...allRefs(board), ...allRefs(rows)])];
const items = await source.items(refs);
return { query, results: searchWork(board, rows, items, query), items };
}

// #1148: the watchdog derives NEEDS ORCHESTRATOR items from the
// current diagnoses (feed age + probes via the health assembly —
// its probe cache keeps this cheap — plus the orchestration
Expand Down Expand Up @@ -1320,6 +1329,14 @@ async function handler(req: Request): Promise<Response> {
),
);
}
if (path === "/search") {
const { query, results, items } = await searchContext(url.searchParams.get("q") ?? "");
return html(renderSearch(query, results, items, prov(), provDetail()));
}
if (path === "/api/search.json") {
const { query, results } = await searchContext(url.searchParams.get("q") ?? "");
return json({ query: query.trim(), total: results.length, results });
}
if (path === "/api/registry.json") {
const records = await source.registry();
// #1209: same query pipeline as /sessions — same params, same page.
Expand Down
1 change: 1 addition & 0 deletions pm-stack/aggregator/test/curation-1497.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const DECISIONS: Record<string, "primary" | "dropdown"> = {
attention: "primary",
board: "dropdown",
roadmap: "primary",
search: "dropdown",
quota: "primary",
dns: "dropdown",
"aa-explorer": "dropdown",
Expand Down
89 changes: 89 additions & 0 deletions pm-stack/aggregator/test/search-view.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { describe, expect, test } from "bun:test";
import type { BoardItem, GhItem, Provenance, ProvenanceDetail, RefKey, RoadmapRow } from "../src/model.ts";
import { renderSearch } from "../src/render.ts";
import { searchWork } from "../src/search-view.ts";

const ref = "developing-today/code#1212" as RefKey;
const board: BoardItem[] = [
{
id: "kaneo:pm-stack/task-1",
title: "Ship dashboard search",
repo: "developing-today/code",
source: "kaneo",
status: "in-progress",
links: [{ ref, relation: "implements" }],
},
];
const rows: RoadmapRow[] = [
{
id: 4,
subject: "grist:program/roadmap/7",
title: "Aggregator findability",
area: "Work",
status: "In Progress",
horizon: "November 2026",
source: "Grist",
notes: "Search across tracked issues",
links: [{ ref, relation: "tracks" }],
},
];
const projected = new Map<RefKey, GhItem>([
[
ref,
{
ref,
kind: "issue",
url: "https://github.com/developing-today/code/issues/1212",
title: "Add global search",
state: "open",
labels: [],
author: "octocat",
updatedAt: "2026-11-01T00:00:00Z",
resolution: "projector",
},
],
]);
const provenance = {
board: "live",
roadmap: "live",
items: "live",
comments: "live",
quota: "live",
usage: "live",
attention: "live",
orchestration: "live",
dns: "live",
registry: "live",
aa: "live",
} as Provenance;
const detail = Object.fromEntries(
Object.entries(provenance).map(([key, text]) => [key, { text, state: "live" }]),
) as ProvenanceDetail;

describe("global search first slice", () => {
test("finds canonical work by linked ref and projected GitHub title", () => {
expect(searchWork(board, rows, projected, "developing-today/code#1212").map((r) => r.kind)).toEqual([
"board",
"roadmap",
]);
expect(searchWork(board, rows, projected, "Add global search").map((r) => r.title)).toEqual([
"Ship dashboard search",
"Aggregator findability",
]);
});

test("returns an empty result for an unknown or blank query", () => {
expect(searchWork(board, rows, projected, "nothing matches")).toEqual([]);
expect(searchWork(board, rows, projected, " ")).toEqual([]);
});

test("renders linked item state, global search, and freshness chips", () => {
const results = searchWork(board, rows, projected, "1212");
const html = renderSearch("1212", results, projected, provenance, detail);
expect(html).toContain('action="/search"');
expect(html).toContain("Search board and roadmap work");
expect(html).toContain("Add global search");
expect(html).toContain("developing-today/code#1212");
expect(html).toContain("items · live");
});
});
17 changes: 17 additions & 0 deletions pm-stack/aggregator/test/slice3.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,23 @@ afterAll(() => {
});

describe("slice-3 routes", () => {
test("global search HTML and JSON share ref/title matching", async () => {
const q = encodeURIComponent("developing-today/code#902");
const data = (await (await fetch(`http://127.0.0.1:${port}/api/search.json?q=${q}`)).json()) as {
query: string;
total: number;
results: { title: string; refs: string[] }[];
};
expect(data.query).toBe("developing-today/code#902");
expect(data.total).toBeGreaterThan(0);
expect(data.results.some((result) => result.refs.includes("developing-today/code#902"))).toBe(true);

const html = await (await fetch(`http://127.0.0.1:${port}/search?q=${q}`)).text();
expect(html).toContain("Search board and roadmap work");
expect(html).toContain("developing-today/code#902");
expect(html).toContain("items · fixtures");
});

test("dns + sessions + pages routes serve", async () => {
const dns = await (await fetch(`http://127.0.0.1:${port}/dns`)).text();
expect(dns).toContain("DNS / domain register");
Expand Down