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
2 changes: 2 additions & 0 deletions pm-stack/aggregator/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ export interface RoadmapRow {
source: string;
notes: string;
links: Link[];
/** Grist UI link for this row's document (#1136), when known. */
gristUrl?: string;
}

/** Where each facet's data came from, shown in the UI footer. */
Expand Down
17 changes: 13 additions & 4 deletions pm-stack/aggregator/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
type NeedsOrder,
} from "./tier-items.ts";
import { githubCommentUrl } from "./comments.ts";
import { serviceHomeLinks, type ItemServiceLink } from "./service-links.ts";
import { aaCaiPoints, aaPoints, summarizeAa } from "./aa.ts";
import { summarizeDns } from "./dns.ts";
import { ageMsText, feedAgeText } from "./feed.ts";
Expand Down Expand Up @@ -1404,7 +1405,8 @@ export function renderBoardBody(
statusCtl = `${actionBadgesHtml(act.actionsByObject?.get(objectRef))}${statusRequestHtml(objectRef, pooled.ref, pooled.status ?? null, { identities: act.identities })}`;
}
}
return `<div class="card"><a href="/item/${encodeURIComponent(item.id)}">${src}${esc(item.title)}</a>${cmt}<br>${repo}${stripHtml(items, item.links)}${statusCtl}</div>`;
const kaneo = item.kaneoUrl ? ` <a class="badge" href="${esc(item.kaneoUrl)}">Kaneo ↗</a>` : "";
return `<div class="card"><a href="/item/${encodeURIComponent(item.id)}">${src}${esc(item.title)}</a>${cmt}<br>${repo}${kaneo}${stripHtml(items, item.links)}${statusCtl}</div>`;
})
.join("");
// The in-flight lane is dated by the orchestration section that
Expand Down Expand Up @@ -1473,7 +1475,8 @@ function roadmapCard(row: RoadmapRow, items: Map<RefKey, GhItem>, counts?: Map<s
.map(itemBadge)
.join(" ");
const cmt = counts ? commentBadge(row.subject, counts) : "";
return `<div class="card"><a href="/item/${encodeURIComponent(row.subject)}">${esc(row.title)}</a>${cmt}<br><span class="badge ${esc(row.status.toLowerCase().replace(/[^a-z]/g, "-"))}">${esc(row.status)}</span> <span class="muted">${esc(row.area)} · ${esc(row.horizon)}</span>${refBadges}</div>`;
const grist = row.gristUrl ? ` <a class="badge" href="${esc(row.gristUrl)}">Grist ↗</a>` : "";
return `<div class="card"><a href="/item/${encodeURIComponent(row.subject)}">${esc(row.title)}</a>${cmt}<br><span class="badge ${esc(row.status.toLowerCase().replace(/[^a-z]/g, "-"))}">${esc(row.status)}</span> <span class="muted">${esc(row.area)} · ${esc(row.horizon)}</span>${refBadges}${grist}</div>`;
}

function timelineTable(
Expand Down Expand Up @@ -1553,6 +1556,8 @@ export interface ItemExtras {
actions?: DashAction[];
/** Set when one of the item's refs is in the Project pool (#1154). */
statusRequest?: { objectRef: string; targetRef: RefKey; currentStatus: string | null };
/** Outbound links to the live services this item lives in (#1136). */
serviceLinks?: ItemServiceLink[];
}

export function renderItem(
Expand Down Expand Up @@ -1596,9 +1601,12 @@ export function renderItem(
extras?.statusRequest && extras.formOpts
? `<h2>Request status change</h2>${actionBadgesHtml(extras.actions)}${statusRequestHtml(extras.statusRequest.objectRef, extras.statusRequest.targetRef, extras.statusRequest.currentStatus, { identities: extras.formOpts.identities })}`
: "";
const svcLinks = extras?.serviceLinks?.length
? `<p>Live services: ${extras.serviceLinks.map((s) => `<a href="${esc(s.url)}">${esc(s.label)} ↗</a>`).join(" · ")}</p>`
: "";
return layout(
title,
`<h1>${esc(title)}</h1><p class="muted">subject: <code>${esc(subject)}</code></p>${stripHtml(items, links)}
`<h1>${esc(title)}</h1><p class="muted">subject: <code>${esc(subject)}</code></p>${svcLinks}${stripHtml(items, links)}
<h2>Linked issues / PRs</h2><div class="tblwrap"><table><tr><th>Ref</th><th>Title</th><th>Labels</th><th>Updated</th></tr>${refRows || '<tr><td colspan="4" class="muted">none resolved</td></tr>'}</table></div>
${noteList ? `<h2>Planning notes</h2><ul>${noteList}</ul>` : ""}
<h2>Activity stream</h2><div class="tblwrap"><table><tr><th>When</th><th>Kind</th><th>Author</th><th>Body</th></tr>${commentRows || '<tr><td colspan="4" class="muted">no comments</td></tr>'}</table></div>
Expand Down Expand Up @@ -4561,7 +4569,7 @@ export function renderProjects(
if (!pool.length) {
return layout(
"Projects",
`<h1>Projects — GitHub Project pool</h1><div class="banner">No Project pool in the current fleet feed — the collector embeds it from the org Project <a href="${PROJECT_URL}">Developing Today (#4)</a> when a Projects token is available on the sandbox. Items on the board/roadmap fall back to the projector/fixtures chain until the pool lands.</div>`,
`<h1>Projects — GitHub Project pool</h1><div class="banner">No Project pool in the current fleet feed — the collector embeds it from the org Project <a href="${PROJECT_URL}">Developing Today (#4)</a> when a Projects token is available on the sandbox. Items on the board/roadmap fall back to the projector/fixtures chain until the pool lands.</div><p class="muted">Live services: ${serviceHomeLinks().map((s) => `<a href="${esc(s.url)}">${esc(s.label)} ↗</a>`).join(" · ")}</p>`,
provenance,
"/projects",
);
Expand Down Expand Up @@ -4594,6 +4602,7 @@ export function renderProjects(
const body = `<h1>Projects — GitHub Project pool</h1>
<p class="muted">${pool.length} items from the org Project <a href="${PROJECT_URL}">Developing Today (#4)</a>, read live by the fleet-feed collector (GraphQL, read-only) and carried in the feed. This pool is the resolution source for board/roadmap GitHub items. Where the Project Status and the derived state disagree, the card shows ⚠ with both values. Machine-first: <a href="/api/projects.json">/api/projects.json</a>.</p>
<div class="chips">${chips}</div>
<p class="muted">Live services: ${serviceHomeLinks().map((s) => `<a href="${esc(s.url)}">${esc(s.label)} ↗</a>`).join(" · ")}</p>
${cards || '<p class="muted">No items in this area.</p>'}`;
return layout(
"Projects",
Expand Down
2 changes: 2 additions & 0 deletions pm-stack/aggregator/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ActionsStore, validateNewAction } from "./actions.ts";
import { checkActionAgainstItem, effectiveNeedsOrder, effectiveStandingAuto, findTierItem } from "./tier-items.ts";
import { CommentsStore, validateNewComment } from "./comments.ts";
import { loadConfig } from "./config.ts";
import { itemServiceLinks } from "./service-links.ts";
import { loadFeed } from "./feed.ts";
import { buildHealth, recordRender, type HealthView } from "./health.ts";
import { PAGES } from "./pages.ts";
Expand Down Expand Up @@ -756,6 +757,7 @@ async function handler(req: Request): Promise<Response> {
const extras = {
dashComments,
formRef: id,
serviceLinks: itemServiceLinks(subject),
formOpts: await commentFormOpts(refs),
sessions,
actions: allActions.filter((a) => wanted.has(a.objectRef)),
Expand Down
70 changes: 70 additions & 0 deletions pm-stack/aggregator/src/service-links.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Service-link registry (#1136): service id -> URL templates for the live
// stack services the dashboard hands the reader off to. One module owns
// the URL shapes; sources and renderers never scatter string literals.
// Browser forms only: the public hostname for Kaneo, the tailnet
// MagicDNS hostname for the rest — never loopback or raw IPs (the
// dashboard is read over the tailnet; a loopback link strands the reader).
import type { BoardItem, RoadmapRow } from "./model.ts";

export const TAILNET_HOST = "amd-6.raptor-pumpkinseed.ts.net";

export type ServiceId = "kaneo" | "grist" | "pad" | "ready-for-agent";

export interface ServiceLinkDef {
label: string;
/** Browser home for the service. */
home: string;
}

export const SERVICE_LINKS: Record<ServiceId, ServiceLinkDef> = {
kaneo: { label: "Kaneo", home: "https://kaneo.security.cab" },
grist: { label: "Grist", home: `http://${TAILNET_HOST}:8484` },
pad: { label: "Pad", home: `http://${TAILNET_HOST}:7777` },
"ready-for-agent": { label: "ready-for-agent", home: `http://${TAILNET_HOST}:6056` },
};

/**
* Kaneo task deep link. Route shape verified against the live Kaneo web
* bundle on 2026-10-29: /dashboard/workspace/$workspaceId/project/$projectId/task/$taskId
* (the app's own by-ticket route redirects to exactly this canonical form).
*/
export function kaneoTaskUrl(workspaceId: string, projectId: string, taskId: string): string {
return `${SERVICE_LINKS.kaneo.home}/dashboard/workspace/${encodeURIComponent(workspaceId)}/project/${encodeURIComponent(projectId)}/task/${encodeURIComponent(taskId)}`;
}

/** Kaneo project (board) deep link — same verified route family. */
export function kaneoProjectUrl(workspaceId: string, projectId: string): string {
return `${SERVICE_LINKS.kaneo.home}/dashboard/workspace/${encodeURIComponent(workspaceId)}/project/${encodeURIComponent(projectId)}`;
}

/** Grist document link; the roadmap table lives in this document. */
export function gristDocUrl(docId: string): string {
return `${SERVICE_LINKS.grist.home}/doc/${encodeURIComponent(docId)}`;
}

export interface ItemServiceLink {
service: ServiceId;
label: string;
url: string;
}

/** The outbound service links carried by one board item / roadmap row. */
export function itemServiceLinks(subject: BoardItem | RoadmapRow): ItemServiceLink[] {
const out: ItemServiceLink[] = [];
if ("kaneoUrl" in subject && subject.kaneoUrl) {
out.push({ service: "kaneo", label: "Kaneo card", url: subject.kaneoUrl });
}
if ("gristUrl" in subject && subject.gristUrl) {
out.push({ service: "grist", label: "Grist roadmap document", url: subject.gristUrl });
}
return out;
}

/** Home links for every stack service (projects-page strip, #1136). */
export function serviceHomeLinks(): ItemServiceLink[] {
return (Object.keys(SERVICE_LINKS) as ServiceId[]).map((id) => ({
service: id,
label: SERVICE_LINKS[id].label,
url: SERVICE_LINKS[id].home,
}));
}
2 changes: 2 additions & 0 deletions pm-stack/aggregator/src/sources/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
refUrl,
} from "../model.ts";
import { buildAttentionFlags } from "../derive.ts";
import { gristDocUrl } from "../service-links.ts";
import { recordFromSessionEntry } from "../registry.ts";
import type { Source } from "../source.ts";

Expand Down Expand Up @@ -208,6 +209,7 @@ export const FIXTURE_ROADMAP: RoadmapRow[] = (seed.rows as SeedRow[]).map((r, i)
source: r.Source,
notes: r.Notes,
links: [...refs].map((ref) => link(ref)),
gristUrl: gristDocUrl(GRIST_DOC),
};
});

Expand Down
7 changes: 5 additions & 2 deletions pm-stack/aggregator/src/sources/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { isProjectPoolItem, poolItemToGhItem } from "../projects.ts";
import { INITIAL_STANDING_AUTO, sanitizeTierItemExtensions, withUserFallbacks } from "../tier-items.ts";
import { overlayQuotaCurrent, parseQuotaCurrent } from "../quota-current.ts";
import { SnapshotStore } from "../snapshots.ts";
import { gristDocUrl, kaneoTaskUrl } from "../service-links.ts";
import { fixtureSource } from "./fixtures.ts";
import { mapServerSessions, type MappedSessions } from "./opencode.ts";
import {
Expand Down Expand Up @@ -105,7 +106,7 @@ const KANEO_PROJECT_REPOS: Record<string, string> = {
async function kaneoProjects(
cfg: Config,
cookie: string,
): Promise<{ id: string; slug: string; name: string; repo: string }[]> {
): Promise<{ id: string; slug: string; name: string; repo: string; workspaceId: string }[]> {
const ws = await getJson(`${cfg.kaneo.baseUrl}/api/workspace`, { Cookie: cookie });
if (!ws.ok) throw new Error("kaneo workspace read failed");
const workspaces = ws.json as { id: string }[];
Expand All @@ -118,6 +119,7 @@ async function kaneoProjects(
slug: p.slug,
name: p.name,
repo: KANEO_PROJECT_REPOS[p.slug] ?? `developing-today/${p.slug}`,
workspaceId,
}));
}

Expand Down Expand Up @@ -157,7 +159,7 @@ async function kaneoBoard(cfg: Config, cookie: string): Promise<BoardItem[]> {
status: col.id,
priority: t.priority,
updatedAt: t.createdAt,
kaneoUrl: cfg.kaneo.baseUrl,
kaneoUrl: kaneoTaskUrl(p.workspaceId, p.id, t.id),
links,
});
}
Expand Down Expand Up @@ -196,6 +198,7 @@ async function gristRoadmap(cfg: Config): Promise<RoadmapRow[]> {
source,
notes,
links,
gristUrl: gristDocUrl(cfg.grist.docId),
};
});
}
Expand Down
99 changes: 99 additions & 0 deletions pm-stack/aggregator/test/service-links.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { describe, expect, test } from "bun:test";
import type { BoardItem, Provenance, RoadmapRow } from "../src/model.ts";
import { renderBoardBody, renderItem, renderProjects, renderRoadmap } from "../src/render.ts";
import {
SERVICE_LINKS,
gristDocUrl,
itemServiceLinks,
kaneoProjectUrl,
kaneoTaskUrl,
serviceHomeLinks,
} from "../src/service-links.ts";
import { FIXTURE_ROADMAP } from "../src/sources/fixtures.ts";

const PROV: Provenance = {
board: "x", roadmap: "x", items: "x", comments: "x", quota: "x", usage: "x",
attention: "x", orchestration: "x", dns: "x", registry: "x", aa: "x",
};

describe("service-link registry (#1136)", () => {
test("homes are browser forms — no loopback, no raw IPs", () => {
for (const def of Object.values(SERVICE_LINKS)) {
expect(def.home).not.toContain("127.0.0.1");
expect(def.home).not.toContain("localhost");
}
expect(SERVICE_LINKS.kaneo.home).toBe("https://kaneo.security.cab");
expect(SERVICE_LINKS.pad.home).toBe("http://amd-6.raptor-pumpkinseed.ts.net:7777");
expect(SERVICE_LINKS.grist.home).toBe("http://amd-6.raptor-pumpkinseed.ts.net:8484");
});

test("kaneo deep links use the verified dashboard route", () => {
expect(kaneoTaskUrl("ws1", "proj1", "task1")).toBe(
"https://kaneo.security.cab/dashboard/workspace/ws1/project/proj1/task/task1",
);
expect(kaneoProjectUrl("ws1", "proj1")).toBe(
"https://kaneo.security.cab/dashboard/workspace/ws1/project/proj1",
);
});

test("grist doc link targets the roadmap document on the tailnet host", () => {
expect(gristDocUrl("czYHYKgG9SHcm9CPwiKEq1")).toBe(
"http://amd-6.raptor-pumpkinseed.ts.net:8484/doc/czYHYKgG9SHcm9CPwiKEq1",
);
});

test("itemServiceLinks reads the URLs the sources set", () => {
const item: BoardItem = {
id: "kaneo:code/t1", title: "t", repo: "developing-today/code", source: "kaneo",
status: "in-progress", kaneoUrl: kaneoTaskUrl("w", "p", "t1"), links: [],
};
expect(itemServiceLinks(item)).toEqual([
{ service: "kaneo", label: "Kaneo card", url: kaneoTaskUrl("w", "p", "t1") },
]);
const row: RoadmapRow = {
id: 1, subject: "grist:doc/Roadmap/1", title: "r", area: "a", status: "s",
horizon: "h", source: "", notes: "", links: [], gristUrl: gristDocUrl("doc"),
};
expect(itemServiceLinks(row).map((l) => l.service)).toEqual(["grist"]);
expect(serviceHomeLinks().map((l) => l.service)).toEqual(["kaneo", "grist", "pad", "ready-for-agent"]);
});
});

describe("service links render (#1136)", () => {
test("board cards link out to the Kaneo card", () => {
const url = kaneoTaskUrl("w", "p", "t1");
const item: BoardItem = {
id: "kaneo:code/t1", title: "Card title", repo: "developing-today/code", source: "kaneo",
status: "in-progress", kaneoUrl: url, links: [],
};
const html = renderBoardBody([item], new Map());
expect(html).toContain(`href="${url}"`);
expect(html).toContain("Kaneo ↗");
});

test("roadmap cards link out to the Grist document", () => {
const html = renderRoadmap(FIXTURE_ROADMAP, new Map(), PROV);
expect(html).toContain(`href="${gristDocUrl("czYHYKgG9SHcm9CPwiKEq1")}"`);
expect(html).toContain("Grist ↗");
});

test("item pages carry a Live services line", () => {
const url = kaneoTaskUrl("w", "p", "t1");
const html = renderItem("Card title", "kaneo:code/t1", [], [], new Map(), [], PROV, {
dashComments: [],
formRef: "kaneo:code/t1",
formOpts: { identities: [] },
sessions: [],
serviceLinks: [{ service: "kaneo", label: "Kaneo card", url }],
});
expect(html).toContain("Live services:");
expect(html).toContain(`href="${url}"`);
});

test("projects page carries the service strip", () => {
const html = renderProjects([], PROV);
expect(html).toContain("Live services:");
expect(html).toContain('href="https://kaneo.security.cab"');
expect(html).toContain('href="http://amd-6.raptor-pumpkinseed.ts.net:7777"');
});
});
Loading