diff --git a/pm-stack/aggregator/src/model.ts b/pm-stack/aggregator/src/model.ts index 15a480d089..2be209857f 100644 --- a/pm-stack/aggregator/src/model.ts +++ b/pm-stack/aggregator/src/model.ts @@ -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. */ diff --git a/pm-stack/aggregator/src/render.ts b/pm-stack/aggregator/src/render.ts index cfee5d640e..bf87571a7c 100644 --- a/pm-stack/aggregator/src/render.ts +++ b/pm-stack/aggregator/src/render.ts @@ -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"; @@ -1404,7 +1405,8 @@ export function renderBoardBody( statusCtl = `${actionBadgesHtml(act.actionsByObject?.get(objectRef))}${statusRequestHtml(objectRef, pooled.ref, pooled.status ?? null, { identities: act.identities })}`; } } - return `
${src}${esc(item.title)}${cmt}
${repo}${stripHtml(items, item.links)}${statusCtl}
`; + const kaneo = item.kaneoUrl ? ` Kaneo ↗` : ""; + return `
${src}${esc(item.title)}${cmt}
${repo}${kaneo}${stripHtml(items, item.links)}${statusCtl}
`; }) .join(""); // The in-flight lane is dated by the orchestration section that @@ -1473,7 +1475,8 @@ function roadmapCard(row: RoadmapRow, items: Map, counts?: Map${esc(row.title)}${cmt}
${esc(row.status)} ${esc(row.area)} · ${esc(row.horizon)}${refBadges}`; + const grist = row.gristUrl ? ` Grist ↗` : ""; + return `
${esc(row.title)}${cmt}
${esc(row.status)} ${esc(row.area)} · ${esc(row.horizon)}${refBadges}${grist}
`; } function timelineTable( @@ -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( @@ -1596,9 +1601,12 @@ export function renderItem( extras?.statusRequest && extras.formOpts ? `

Request status change

${actionBadgesHtml(extras.actions)}${statusRequestHtml(extras.statusRequest.objectRef, extras.statusRequest.targetRef, extras.statusRequest.currentStatus, { identities: extras.formOpts.identities })}` : ""; + const svcLinks = extras?.serviceLinks?.length + ? `

Live services: ${extras.serviceLinks.map((s) => `${esc(s.label)} ↗`).join(" · ")}

` + : ""; return layout( title, - `

${esc(title)}

subject: ${esc(subject)}

${stripHtml(items, links)} + `

${esc(title)}

subject: ${esc(subject)}

${svcLinks}${stripHtml(items, links)}

Linked issues / PRs

${refRows || ''}
RefTitleLabelsUpdated
none resolved
${noteList ? `

Planning notes

` : ""}

Activity stream

${commentRows || ''}
WhenKindAuthorBody
no comments
@@ -4561,7 +4569,7 @@ export function renderProjects( if (!pool.length) { return layout( "Projects", - `

Projects — GitHub Project pool

`, + `

Projects — GitHub Project pool

Live services: ${serviceHomeLinks().map((s) => `${esc(s.label)} ↗`).join(" · ")}

`, provenance, "/projects", ); @@ -4594,6 +4602,7 @@ export function renderProjects( const body = `

Projects — GitHub Project pool

${pool.length} items from the org Project Developing Today (#4), 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: /api/projects.json.

${chips}
+

Live services: ${serviceHomeLinks().map((s) => `${esc(s.label)} ↗`).join(" · ")}

${cards || '

No items in this area.

'}`; return layout( "Projects", diff --git a/pm-stack/aggregator/src/server.ts b/pm-stack/aggregator/src/server.ts index 5234368fe9..3d262a5294 100644 --- a/pm-stack/aggregator/src/server.ts +++ b/pm-stack/aggregator/src/server.ts @@ -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"; @@ -756,6 +757,7 @@ async function handler(req: Request): Promise { const extras = { dashComments, formRef: id, + serviceLinks: itemServiceLinks(subject), formOpts: await commentFormOpts(refs), sessions, actions: allActions.filter((a) => wanted.has(a.objectRef)), diff --git a/pm-stack/aggregator/src/service-links.ts b/pm-stack/aggregator/src/service-links.ts new file mode 100644 index 0000000000..8f2b9bc1df --- /dev/null +++ b/pm-stack/aggregator/src/service-links.ts @@ -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 = { + 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, + })); +} diff --git a/pm-stack/aggregator/src/sources/fixtures.ts b/pm-stack/aggregator/src/sources/fixtures.ts index 600985c291..80b7addc28 100644 --- a/pm-stack/aggregator/src/sources/fixtures.ts +++ b/pm-stack/aggregator/src/sources/fixtures.ts @@ -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"; @@ -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), }; }); diff --git a/pm-stack/aggregator/src/sources/live.ts b/pm-stack/aggregator/src/sources/live.ts index ae9bbd44db..fd650b22e4 100644 --- a/pm-stack/aggregator/src/sources/live.ts +++ b/pm-stack/aggregator/src/sources/live.ts @@ -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 { @@ -105,7 +106,7 @@ const KANEO_PROJECT_REPOS: Record = { 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 }[]; @@ -118,6 +119,7 @@ async function kaneoProjects( slug: p.slug, name: p.name, repo: KANEO_PROJECT_REPOS[p.slug] ?? `developing-today/${p.slug}`, + workspaceId, })); } @@ -157,7 +159,7 @@ async function kaneoBoard(cfg: Config, cookie: string): Promise { status: col.id, priority: t.priority, updatedAt: t.createdAt, - kaneoUrl: cfg.kaneo.baseUrl, + kaneoUrl: kaneoTaskUrl(p.workspaceId, p.id, t.id), links, }); } @@ -196,6 +198,7 @@ async function gristRoadmap(cfg: Config): Promise { source, notes, links, + gristUrl: gristDocUrl(cfg.grist.docId), }; }); } diff --git a/pm-stack/aggregator/test/service-links.test.ts b/pm-stack/aggregator/test/service-links.test.ts new file mode 100644 index 0000000000..92103b2058 --- /dev/null +++ b/pm-stack/aggregator/test/service-links.test.ts @@ -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"'); + }); +});