mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 11:07:40 +01:00
feat(home): /control surfaces queue depth per project ('Nqueued' pill)
Adjacent gap from the queue-storage work — the home/ stack now writes
queue items but doesn't display them. Users on home/ /control had no
visibility into what was queued for each project, even though the
data is sitting in /tmp/agent-queue-<tab>.
Changes:
• /api/state response now annotates each project with queueLen by
reading /tmp/agent-queue-<project>.toLowerCase() and counting the
JSON array. File missing or unreadable → queueLen=0 (no badge).
• New .queue-pill CSS rule (blue, matches the broader pill palette).
• Project header renders '<N> queued' when queueLen > 0, sitting
next to the existing running/status pill.
Stays local-first: no DB dependency from home/. The /tmp mirror is
the right source because it's written by both the cloud route's PUT
(via /api/beacon/queue/[tab]) and home/ itself if invoked from a
direct API call. Cross-stack visibility without coupling.
tsc clean, npm run test:home 89/89.
This commit is contained in:
1 file changed
+18
-1
+18
-1
@@ -119,6 +119,7 @@ const INDEX_HTML = `<!doctype html>
|
||||
.status-pill { font-size: 11px; padding: 0.1rem 0.4rem; border-radius: 4px; font-weight: 500; }
|
||||
.status-pill.ready { background: #16a34a33; color: #4ade80; }
|
||||
.status-pill.working { background: #eab30833; color: #fbbf24; }
|
||||
.queue-pill { font-size: 11px; padding: 0.1rem 0.4rem; border-radius: 4px; background: #3b82f633; color: #93c5fd; font-weight: 500; }
|
||||
.outcomes { display: inline-flex; gap: 0.25rem; }
|
||||
.o { font-size: 13px; padding: 0 0.4rem; border-radius: 4px; font-weight: 600; line-height: 1.4; }
|
||||
.o.success { background: #16a34a33; color: #4ade80; }
|
||||
@@ -301,6 +302,7 @@ async function refresh() {
|
||||
if (st === 'working') return '<span class="status-pill working">working</span>';
|
||||
return '';
|
||||
})()}
|
||||
\${p.queueLen > 0 ? '<span class="queue-pill">' + p.queueLen + ' queued</span>' : ''}
|
||||
<span class="ts">\${compact(p.lastEventTs)}</span>
|
||||
</h2>
|
||||
\${reasonLine}
|
||||
@@ -340,8 +342,23 @@ const server = http.createServer((req, res) => {
|
||||
|
||||
if (url === "/api/state") {
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
// Annotate each project with the local /tmp/agent-queue-<tab> length so
|
||||
// the /control UI can surface a "Nqueued" badge. The file mirror is
|
||||
// written by both the cloud route (via /api/beacon/queue/[tab] PUT) and
|
||||
// home's own /api/dispatch when the cloud route can't reach this
|
||||
// machine. Reading the file lets home/ show queue depth without taking
|
||||
// a DB dep — keeping home/ local-first.
|
||||
const projects = assembleProjectList().map((p) => {
|
||||
let queueLen = 0;
|
||||
try {
|
||||
const raw = fs.readFileSync(path.join("/tmp", `agent-queue-${p.project.toLowerCase()}`), "utf8");
|
||||
const arr = JSON.parse(raw);
|
||||
if (Array.isArray(arr)) queueLen = arr.length;
|
||||
} catch { /* file missing or unreadable → no badge */ }
|
||||
return { ...p, queueLen };
|
||||
});
|
||||
res.end(JSON.stringify({
|
||||
projects: assembleProjectList(),
|
||||
projects,
|
||||
logPath: LOG_PATH,
|
||||
position: handle.position(),
|
||||
lastError,
|
||||
|
||||
Reference in new issue
Block a user