Repository navigation
fix(pm-aggregator): show ready-for-agent dispatch state #5283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -135,12 +135,51 @@ import type { Source } from "./source.ts"; | |
| import { fixtureSource } from "./sources/fixtures.ts"; | ||
| import { liveSource } from "./sources/live.ts"; | ||
| import { buildQueueView, queueInputsStale } from "./queue-view.ts"; | ||
| import { dispatchStateFor, fetchRfaState, RFA_NOT_PICKED_UP } from "./sources/ready-for-agent.ts"; | ||
|
|
||
| const cfg = loadConfig(); | ||
| const commentsStore = new CommentsStore(cfg.commentsFile); | ||
| const roadmapAnnotationsStore = new RoadmapAnnotationsStore(cfg.roadmapAnnotationsFile); | ||
| const coverageStore = new CoverageSnapshotStore(cfg.coverageSnapshotFile); | ||
|
|
||
| async function readyAgentDispatchStates(items: Map<RefKey, GhItem>) { | ||
| const targets = [...items.values()].filter((item) => | ||
| item.labels.some((label) => label.toLowerCase() === "ready-for-agent") && /#\d+$/.test(item.ref), | ||
| ); | ||
| if (!targets.length) return []; | ||
| const observedAt = new Date().toISOString(); | ||
| if (cfg.source !== "live") { | ||
| // #4969 (Codex on PR #5283): fixtures mode must never read the live | ||
| // harness — deterministic fixture dispatch data, mirroring the | ||
| // health.ts fixtures boundary. The canned set has no picked-up | ||
| // work item, so every labelled fixture item is honestly | ||
| // "not picked up". | ||
| return targets.map((item) => ({ | ||
| ref: item.ref, | ||
| state: RFA_NOT_PICKED_UP, | ||
| provenance: { source: "ready-for-agent", observedAt, repository: item.ref.split("#")[0], mode: "fixtures" }, | ||
| })); | ||
| } | ||
| try { | ||
| const state = await fetchRfaState(cfg.readyForAgent.baseUrl); | ||
| return targets.map((item) => { | ||
| const match = /^(.*)#(\d+)$/.exec(item.ref); | ||
| if (!match) return null; | ||
| return { | ||
| ref: item.ref, | ||
| state: dispatchStateFor(state, match[1], Number(match[2])) || RFA_NOT_PICKED_UP, | ||
| provenance: { source: "ready-for-agent", observedAt, repository: match[1] }, | ||
| }; | ||
| }).filter((entry): entry is NonNullable<typeof entry> => entry !== null); | ||
| } catch { | ||
| return targets.map((item) => ({ | ||
| ref: item.ref, | ||
| state: "unavailable", | ||
| provenance: { source: "ready-for-agent", observedAt, repository: item.ref.split("#")[0], error: "harness read failed" }, | ||
| })); | ||
| } | ||
| } | ||
|
|
||
| /** #1220: the coverage snapshot behind the /projects panel — computed | ||
| * from the feed's items + the Project pool, rotated weekly by | ||
| * nextCoverageSnapshot, persisted only when it actually changes. */ | ||
|
|
@@ -2127,12 +2166,15 @@ async function handler(req: Request): Promise<Response> { | |
| return json(body); | ||
| } | ||
|
|
||
| const itemJsonMatch = /^\/api\/item\/(.+)\.json$/.exec(path); | ||
| const itemMatch = /^\/item\/(.+)$/.exec(path); | ||
| if (itemMatch) { | ||
| const matchedItemPath = itemJsonMatch ?? itemMatch; | ||
| if (matchedItemPath) { | ||
|
Comment on lines
+2171
to
+2172
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 66db0aa: an unresolved /api/item/.json now returns notFoundResponse(path) (structured JSON 404) while /item/ keeps the HTML 404. Covered by a new boot test asserting JSON 404 + content-type for the API path and HTML 404 for the page path. |
||
| // #2748: same guard as /discuss — JSON 400 on malformed encoding. | ||
| const id = decodePathSegment(itemMatch[1]); | ||
| const encodedId = matchedItemPath[1]; | ||
| const id = decodePathSegment(encodedId); | ||
| if (id === null) { | ||
| return json({ error: `malformed percent-encoding in path segment: ${itemMatch[1]}` }, 400); | ||
| return json({ error: `malformed percent-encoding in path segment: ${encodedId}` }, 400); | ||
| } | ||
| const [board, rows] = await Promise.all([source.board().catch(() => []), source.roadmap().catch(() => [])]); | ||
| const roadmapRow = rows.find((r) => r.subject === id); | ||
|
|
@@ -2175,6 +2217,14 @@ async function handler(req: Request): Promise<Response> { | |
| // item page carries the status-request control for that pool item. | ||
| const pooled = pool.find((p) => refs.includes(p.ref)); | ||
| const epicRollup = pooled?.kind === "Epic" ? buildEpicRollups(pool).get(pooled.ref) : undefined; | ||
| const dispatchStates = await readyAgentDispatchStates(items); | ||
| if (itemJsonMatch) { | ||
| return json({ | ||
| subject, | ||
| linkedItems: [...items.values()], | ||
| dispatchStates, | ||
| }); | ||
| } | ||
| const extras = { | ||
| dashComments, | ||
| ...(roadmapRow ? { roadmapAnnotations } : {}), | ||
|
|
@@ -2194,6 +2244,7 @@ async function handler(req: Request): Promise<Response> { | |
| : {}), | ||
| ...(epicRollup ? { epicRollup } : {}), | ||
| briefs, | ||
| ...(dispatchStates.length ? { dispatchStates } : {}), | ||
| activity: { | ||
| events: itemEvents, | ||
| globalHref: `/events?${activityQuery.toString()}`, | ||
|
|
@@ -2203,6 +2254,9 @@ async function handler(req: Request): Promise<Response> { | |
| }; | ||
| return html(renderItem(title, id, links, items, comments, prov(), extras)); | ||
| } | ||
| // #4969 (Codex on PR #5283): an unresolved /api/item/<id>.json id | ||
| // gets the structured JSON 404, not the HTML page response. | ||
| if (itemJsonMatch) return notFoundResponse(path); | ||
| return html( | ||
| `<h1>Not found</h1><p class="muted">no board item or roadmap row with subject <code>${esc(id)}</code></p>`, | ||
| 404, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
PM_AGG_SOURCE=fixtures(the default), opening the fixture dispatch-trial item now performs real GraphQL requests against the configured harness and attaches live dispatch state to canned issue data. Without a running harness, the same fixture instead reportsunavailable, making this surface environment-dependent. The existing harness integration inhealth.tsexplicitly skips live reads in fixtures mode. Apply the same boundary here and supply deterministic fixture dispatch data; the new boot test currently acceptsunavailablebecause it only checks that the state is truthy.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 66db0aa: fixtures mode (cfg.source !== live) no longer calls fetchRfaState — readyAgentDispatchStates returns deterministic fixture data (RFA_NOT_PICKED_UP with mode=fixtures provenance), mirroring the health.ts boundary. The boot test now asserts the exact state "not picked up" instead of any truthy state.