## Problem lib/services/queue.ts was not updated during workflow refactor (#147) and still used hardcoded queue labels: QueueLabel type, QUEUE_PRIORITY constant. ## Solution - Add getQueueLabelsWithPriority() to derive queue labels from workflow config - Add getQueuePriority() to get priority for any label - Update getTaskPriority() and getRoleForLabel() to accept workflow config - Update fetchProjectQueues() to use workflow-derived labels - Add getTotalQueuedCount() helper ## Files Changed - lib/services/queue.ts — use workflow config for all queue operations - lib/tools/status.ts — handle dynamic queue labels, include queueLabels in response ## Backward Compatibility - QueueLabel type kept as deprecated alias - QUEUE_PRIORITY kept as deprecated constant - All functions accept optional workflow parameter, default to DEFAULT_WORKFLOW
This commit is contained in:
@@ -9,8 +9,9 @@ import { jsonResult } from "openclaw/plugin-sdk";
|
||||
import type { ToolContext } from "../types.js";
|
||||
import { readProjects, getProject } from "../projects.js";
|
||||
import { log as auditLog } from "../audit.js";
|
||||
import { fetchProjectQueues, type QueueLabel } from "../services/queue.js";
|
||||
import { fetchProjectQueues, getTotalQueuedCount, getQueueLabelsWithPriority } from "../services/queue.js";
|
||||
import { requireWorkspaceDir, getPluginConfig } from "../tool-helpers.js";
|
||||
import { DEFAULT_WORKFLOW } from "../workflow.js";
|
||||
|
||||
export function createStatusTool(api: OpenClawPluginApi) {
|
||||
return (ctx: ToolContext) => ({
|
||||
@@ -31,6 +32,9 @@ export function createStatusTool(api: OpenClawPluginApi) {
|
||||
const pluginConfig = getPluginConfig(api);
|
||||
const projectExecution = (pluginConfig?.projectExecution as string) ?? "parallel";
|
||||
|
||||
// TODO: Load per-project workflow when supported
|
||||
const workflow = DEFAULT_WORKFLOW;
|
||||
|
||||
const data = await readProjects(workspaceDir);
|
||||
const projectIds = groupId ? [groupId] : Object.keys(data.projects);
|
||||
|
||||
@@ -40,30 +44,59 @@ export function createStatusTool(api: OpenClawPluginApi) {
|
||||
const project = getProject(data, pid);
|
||||
if (!project) return null;
|
||||
|
||||
const queues = await fetchProjectQueues(project);
|
||||
const count = (label: QueueLabel) => queues[label].length;
|
||||
const queues = await fetchProjectQueues(project, workflow);
|
||||
|
||||
// Build dynamic queue object with counts
|
||||
const queueCounts: Record<string, number> = {};
|
||||
for (const [label, issues] of Object.entries(queues)) {
|
||||
queueCounts[label] = issues.length;
|
||||
}
|
||||
|
||||
return {
|
||||
name: project.name,
|
||||
groupId: pid,
|
||||
roleExecution: project.roleExecution ?? "parallel",
|
||||
dev: { active: project.dev.active, issueId: project.dev.issueId, level: project.dev.level, startTime: project.dev.startTime },
|
||||
qa: { active: project.qa.active, issueId: project.qa.issueId, level: project.qa.level, startTime: project.qa.startTime },
|
||||
queue: { toImprove: count("To Improve"), toTest: count("To Test"), toDo: count("To Do") },
|
||||
dev: {
|
||||
active: project.dev.active,
|
||||
issueId: project.dev.issueId,
|
||||
level: project.dev.level,
|
||||
startTime: project.dev.startTime,
|
||||
},
|
||||
qa: {
|
||||
active: project.qa.active,
|
||||
issueId: project.qa.issueId,
|
||||
level: project.qa.level,
|
||||
startTime: project.qa.startTime,
|
||||
},
|
||||
queue: queueCounts,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
const filtered = projects.filter(Boolean);
|
||||
const filtered = projects.filter(Boolean) as NonNullable<typeof projects[number]>[];
|
||||
|
||||
// Calculate total queued across all projects
|
||||
const totalQueued = filtered.reduce(
|
||||
(sum, p) => sum + Object.values(p.queue).reduce((s, c) => s + c, 0),
|
||||
0,
|
||||
);
|
||||
|
||||
await auditLog(workspaceDir, "status", {
|
||||
projectCount: filtered.length,
|
||||
totalQueued: filtered.reduce((s, p) => s + p!.queue.toImprove + p!.queue.toTest + p!.queue.toDo, 0),
|
||||
totalQueued,
|
||||
});
|
||||
|
||||
// Include queue labels in response for context
|
||||
const queueLabels = getQueueLabelsWithPriority(workflow).map((q) => ({
|
||||
label: q.label,
|
||||
role: q.role,
|
||||
priority: q.priority,
|
||||
}));
|
||||
|
||||
return jsonResult({
|
||||
success: true,
|
||||
execution: { projectExecution },
|
||||
queueLabels,
|
||||
projects: filtered,
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user