Repository navigation
fix(tui): disclose capped queue samples through topology and Pulse #1175
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
e2ed672
634c787
5ef2296
f803ab6
32d49d7
c4a5e88
ea216af
7aca8b0
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 |
|---|---|---|
|
|
@@ -166,7 +166,7 @@ function queueFacts(snap: FleetSnapshot, session: string | null | undefined): { | |
| rows.push({ role, row }); | ||
| } | ||
| const primary = rows[0]; | ||
| if (!primary) return { count: 0, work: "—", now: "—" }; | ||
| if (!primary) return { count: 0, work: queueIncomplete(snap) ? "unknown" : "—", now: queueIncomplete(snap) ? "not in sample" : "—" }; | ||
| const slice = primary.row.tags?.find((tag) => tag.startsWith("slice:"))?.slice("slice:".length); | ||
| const work = slice?.match(/^OPR(?:\.\d+){3}\.(\d+)$/)?.[1] | ||
| ? `S${slice.slice(slice.lastIndexOf(".") + 1)}` | ||
|
|
@@ -176,6 +176,21 @@ function queueFacts(snap: FleetSnapshot, session: string | null | undefined): { | |
| return { count: rows.length, work, now }; | ||
| } | ||
|
|
||
| function queueIncomplete(snap: FleetSnapshot): boolean { | ||
| return snap.queueCoverage === "partial" || snap.queueCoverage === "unavailable"; | ||
| } | ||
|
|
||
| function queueCount(snap: FleetSnapshot, count: number): string | number { | ||
| return queueIncomplete(snap) ? count ? `${count}+` : "?" : count || "·"; | ||
|
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. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Keep sampled queue counts visible in narrow Q columns.
🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| function queueSampleLines(snap: FleetSnapshot, width: number): ContentLine[] { | ||
| return queueIncomplete(snap) ? wrapDetailLines([ | ||
| { text: snap.queueCoverage === "unavailable" ? "Queue sample incomplete: a list read failed." : "Queue sample may be incomplete: a list reached its cap." }, | ||
| { text: "Counts are lower bounds; unlisted work is unknown." }, | ||
| ], width) : []; | ||
| } | ||
|
|
||
| function number(value: number | null | undefined): string { | ||
| return value == null ? "—" : value.toLocaleString("en-US"); | ||
| } | ||
|
|
@@ -214,8 +229,8 @@ function rowsForAgent(snap: FleetSnapshot, session: string, sources: Array<Fleet | |
| return rows; | ||
| } | ||
|
|
||
| function workRows(rows: FleetSnapshot["attention"], width: number): ContentLine[] { | ||
| if (rows.length === 0) return [fieldLine({ label: "rows", value: "none in the served bounded lists" })]; | ||
| function workRows(rows: FleetSnapshot["attention"], width: number, incomplete = false): ContentLine[] { | ||
| if (rows.length === 0) return [fieldLine({ label: "rows", value: incomplete ? "not in sample; work unknown" : "none in the served bounded lists" })]; | ||
| return rows.flatMap((row) => { | ||
| const summary = row.summary?.trim() || row.body.split("\n").find((line) => line.trim())?.trim() || "no summary served"; | ||
| return [ | ||
|
|
@@ -239,7 +254,7 @@ function agentDetailLines( | |
| const pendingRows = session ? rowsForAgent(snap, session, [snap.pending]) : []; | ||
| const recentRows = session ? rowsForAgent(snap, session, [snap.recentlyFinished]) : []; | ||
| const needs = session ? snap.needs.filter((item) => item.target === session) : []; | ||
| const visibleAssigned = currentRows.length + pendingRows.length; | ||
| const visibleAssigned = new Set([...currentRows, ...pendingRows].map(row => row.qitemId)).size; | ||
| const assigned = agent.assignedWorkCount ?? visibleAssigned; | ||
| const pending = agent.pendingWorkCount ?? pendingRows.length; | ||
| const inProgress = agent.inProgressWorkCount ?? currentRows.filter((row) => row.state === "in-progress").length; | ||
|
|
@@ -300,15 +315,16 @@ function agentDetailLines( | |
| local: found.host === snap.hosts[0], | ||
| }, contentWidth), | ||
| }, | ||
| { title: `CURRENT WORK · ${currentRows.length}`, lines: workRows(currentRows, contentWidth) }, | ||
| { title: `CURRENT WORK · ${currentRows.length}${queueIncomplete(snap) ? " sampled" : ""}`, lines: workRows(currentRows, contentWidth, queueIncomplete(snap)) }, | ||
| { | ||
| title: "QUEUE", | ||
| lines: [ | ||
| ...wrapDetailValue("depth", `${assigned} assigned · ${pending} pending · ${inProgress} in progress · ${blocked} blocked`, contentWidth), | ||
| ...queueSampleLines(snap, contentWidth), | ||
| ...wrapDetailValue("depth", `${agent.assignedWorkCount == null && queueIncomplete(snap) ? `${assigned}+` : assigned} assigned · ${agent.pendingWorkCount == null && queueIncomplete(snap) ? `${pending}+` : pending} pending · ${agent.inProgressWorkCount == null && queueIncomplete(snap) ? `${inProgress}+` : inProgress} in progress · ${agent.blockedWorkCount == null && queueIncomplete(snap) ? `${blocked}+` : blocked} blocked`, contentWidth), | ||
| ...(agent.assignedWorkCount == null ? wrapDetailValue("basis", `${visibleAssigned} rows visible in bounded list reads; complete count not served`, contentWidth) : []), | ||
| ], | ||
| }, | ||
| { title: `UP NEXT · ${pending}`, lines: workRows(pendingRows, contentWidth) }, | ||
| { title: `UP NEXT · ${pending}${queueIncomplete(snap) ? " · sampled rows" : ""}`, lines: workRows(pendingRows, contentWidth, queueIncomplete(snap)) }, | ||
| { title: `NEEDS YOU · ${needs.length || agent.activity?.needsInput?.count || 0}`, lines: needsRows }, | ||
| ...(recentRows.length ? [{ title: "RECENTLY FINISHED · bounded window", lines: workRows(recentRows, contentWidth) }] : []), | ||
| { | ||
|
|
@@ -636,6 +652,7 @@ function instanceContentLines( | |
| } | ||
|
|
||
| lines.push(healthSummaryLine(snap, scope, contentWidth)); | ||
| lines.push(...queueSampleLines(snap, contentWidth)); | ||
| lines.push({ text: state.filter ? `/ filter instance rows: ${state.filter} · / replace · esc clear` : "/ filter instance rows…" }); | ||
| const columns = instanceAgentColumns(contentWidth); | ||
| lines.push({ text: tableRow(columns, { rig: "RIG", pod: "POD", seat: "SEAT", runtime: "RT", context: "CTX", status: "STATE", queue: "Q", work: "WORK", now: "NOW" }) }); | ||
|
|
@@ -675,7 +692,7 @@ function instanceContentLines( | |
| runtime: runtimeShort(agent.runtime), | ||
| context: contextCompact(agent.context, contentWidth < 110), | ||
| status: stateCell.word, | ||
| queue: queue.count || "·", | ||
| queue: queueCount(snap, queue.count), | ||
| work: queue.work, | ||
| now: queue.now, | ||
| }), | ||
|
|
@@ -684,7 +701,7 @@ function instanceContentLines( | |
| }); | ||
| } | ||
| } | ||
| lines.push({ text: "" }, { text: host.rigs.some(r => r.inventoryUnavailable) ? `${host.rigs.length} rigs · inventory incomplete · ${seatCount} seats read` : `${host.rigs.length} rigs · ${seatCount} seats · ${workingCount} working · ${attentionCount} need attention · ${openCount} open rows` }); | ||
| lines.push({ text: "" }, { text: host.rigs.some(r => r.inventoryUnavailable) ? `${host.rigs.length} rigs · inventory incomplete · ${seatCount} seats read` : `${host.rigs.length} rigs · ${seatCount} seats · ${workingCount} working · ${attentionCount} need attention · ${openCount}${queueIncomplete(snap) ? "+ sampled" : ""} open rows` }); | ||
| lines.push(...recentLines(snap, scope, contentWidth, false, state.timeZone)); | ||
| return lines; | ||
| } | ||
|
|
@@ -853,6 +870,7 @@ function contentLines(state: ViewState, snap: FleetSnapshot, contentWidth: numbe | |
| return lines; | ||
| } | ||
| const agentCols = agentColumns(contentWidth); | ||
| lines.push(...queueSampleLines(snap, contentWidth)); | ||
| const narrowFactory = !agentCols.some(([key]) => key === "model"); | ||
| if (narrowFactory) lines.push({ text: "MODEL/NOW/ACTIONS on drill (enter)" }); | ||
| lines.push({ | ||
|
|
@@ -898,7 +916,7 @@ function contentLines(state: ViewState, snap: FleetSnapshot, contentWidth: numbe | |
| model: tableModel(a.model), | ||
| context: contextCompact(a.context, narrowFactory), | ||
| status: stateCell.word, | ||
| queue: queue.count || "·", | ||
| queue: queueCount(snap, queue.count), | ||
| work: queue.work, | ||
| now: queue.now, | ||
| actions: actionsCell, | ||
|
|
@@ -910,7 +928,7 @@ function contentLines(state: ViewState, snap: FleetSnapshot, contentWidth: numbe | |
| lines.push({ text: "" }); | ||
| const working = rows.filter((agent) => ["active", "working", "running"].includes(agent.status)).length; | ||
| const attention = rows.filter((agent) => /attention|needs|blocked|unknown|failed/.test(agent.status)).length; | ||
| lines.push({ text: `${rows.length} seats · ${working} working · ${attention} need attention · ${rows.reduce((n, agent) => n + queueFacts(snap, agent.session).count, 0)} open rows` }); | ||
| lines.push({ text: `${rows.length} seats · ${working} working · ${attention} need attention · ${rows.reduce((n, agent) => n + queueFacts(snap, agent.session).count, 0)}${queueIncomplete(snap) ? "+ sampled" : ""} open rows` }); | ||
| if (!podFilter) lines.push(...recentLines(snap, { kind: "rig", rig: rig.name }, contentWidth, false, state.timeZone)); | ||
| return lines; | ||
| } | ||
|
|
||
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Preserve an authoritative zero-work result.
If an agent has
assignedWorkCount: 0and no matching queue rows, a different seat can still makequeueCoveragepartial. This branch then displaysunknownandnot in samplefor an agent whose inventory reports no assigned work. The empty-row text in the agent detail has the same problem. Pass the agent’s authoritative count into these decisions, and use unknown only when that count is absent.🤖 Prompt for AI Agents