1
0

feat: add task queue with human-in-the-loop approval + work orders + UI bug fixes

Task Queue system:
- New /tasks page with three-column layout (Pending/Active/Completed)
- Full CRUD API at /api/tasks with approve/veto/modify/pause/cancel/retry
- SQLite persistence in task_queue table
- WebSocket live updates via ws_manager
- Create task modal with agent assignment and priority
- Auto-approve rules for low-risk tasks
- HTMX polling for real-time column updates
- HOME TASK buttons now link to task queue with agent pre-selected
- MARKET HIRE buttons link to task queue with agent pre-selected

Work Order system:
- External submission API for agents/users (POST /work-orders/submit)
- Risk scoring and configurable auto-execution thresholds
- Dashboard at /work-orders/queue with approve/reject/execute flow
- Integration with swarm task system for execution

UI & Dashboard bug fixes:
- EVENTS: add startup event so page is never empty
- LEDGER: fix empty filter params in URL
- MISSION CONTROL: LLM backend and model now read from /health
- MISSION CONTROL: agent count fallback to /swarm/agents
- SWARM: HTMX fallback loads initial data if WebSocket is slow
- MEMORY: add edit/delete buttons for personal facts
- UPGRADES: add empty state guidance with links
- BRIEFING: add regenerate button and POST /briefing/regenerate endpoint

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexander Payne
2026-02-26 10:27:08 -05:00
parent 4e78f7102e
commit 5f9bbb8435
31 changed files with 3159 additions and 47 deletions

View File

@@ -26,6 +26,7 @@
<!-- Desktop nav -->
<div class="mc-header-right mc-desktop-nav">
<a href="/tasks" class="mc-test-link">TASKS</a>
<a href="/briefing" class="mc-test-link">BRIEFING</a>
<a href="/swarm/mission-control" class="mc-test-link">MISSION CONTROL</a>
<a href="/swarm/live" class="mc-test-link">SWARM</a>
@@ -37,6 +38,7 @@
<a href="/memory" class="mc-test-link">MEMORY</a>
<a href="/router/status" class="mc-test-link">ROUTER</a>
<a href="/self-modify/queue" class="mc-test-link">UPGRADES</a>
<a href="/work-orders/queue" class="mc-test-link">WORK ORDERS</a>
<a href="/creative/ui" class="mc-test-link">CREATIVE</a>
<a href="/mobile" class="mc-test-link" title="Mobile-optimized view">MOBILE</a>
<button id="enable-notifications" class="mc-test-link" style="background:none;cursor:pointer;" title="Enable notifications">&#x1F514;</button>
@@ -57,6 +59,7 @@
<span class="mc-time" id="clock-mobile"></span>
</div>
<a href="/" class="mc-mobile-link">HOME</a>
<a href="/tasks" class="mc-mobile-link">TASKS</a>
<a href="/briefing" class="mc-mobile-link">BRIEFING</a>
<a href="/swarm/live" class="mc-mobile-link">SWARM</a>
<a href="/spark/ui" class="mc-mobile-link">SPARK</a>
@@ -65,6 +68,7 @@
<a href="/swarm/events" class="mc-mobile-link">EVENTS</a>
<a href="/lightning/ledger" class="mc-mobile-link">LEDGER</a>
<a href="/memory" class="mc-mobile-link">MEMORY</a>
<a href="/work-orders/queue" class="mc-mobile-link">WORK ORDERS</a>
<a href="/creative/ui" class="mc-mobile-link">CREATIVE</a>
<a href="/voice/button" class="mc-mobile-link">VOICE</a>
<a href="/mobile" class="mc-mobile-link">MOBILE</a>

View File

@@ -151,14 +151,19 @@
<div class="container briefing-container py-4">
<div class="briefing-header mb-4">
<div class="briefing-greeting">Good morning.</div>
<div class="briefing-timestamp">
Briefing generated
<span class="briefing-ts-val">{{ briefing.generated_at.strftime('%Y-%m-%d %H:%M UTC') }}</span>
&mdash; covering
<span class="briefing-ts-val">{{ briefing.period_start.strftime('%H:%M') }}</span>
to
<span class="briefing-ts-val">{{ briefing.period_end.strftime('%H:%M UTC') }}</span>
<div style="display:flex; justify-content:space-between; align-items:flex-start;">
<div>
<div class="briefing-greeting">Good morning.</div>
<div class="briefing-timestamp">
Briefing generated
<span class="briefing-ts-val">{{ briefing.generated_at.strftime('%Y-%m-%d %H:%M UTC') }}</span>
&mdash; covering
<span class="briefing-ts-val">{{ briefing.period_start.strftime('%H:%M') }}</span>
to
<span class="briefing-ts-val">{{ briefing.period_end.strftime('%H:%M UTC') }}</span>
</div>
</div>
<button class="btn-refresh" id="btn-regenerate" onclick="regenerateBriefing()">REGENERATE</button>
</div>
</div>
@@ -184,4 +189,24 @@
</div>
</div>
<script>
async function regenerateBriefing() {
var btn = document.getElementById('btn-regenerate');
btn.textContent = 'REGENERATING...';
btn.disabled = true;
try {
var resp = await fetch('/briefing/regenerate', { method: 'POST' });
if (resp.ok) {
window.location.reload();
} else {
btn.textContent = 'FAILED';
setTimeout(function() { btn.textContent = 'REGENERATE'; btn.disabled = false; }, 2000);
}
} catch (e) {
btn.textContent = 'ERROR';
setTimeout(function() { btn.textContent = 'REGENERATE'; btn.disabled = false; }, 2000);
}
}
</script>
{% endblock %}

View File

@@ -53,15 +53,15 @@
<!-- Filters -->
<div class="mc-filters">
<form method="get" action="/lightning/ledger" class="mc-filter-form">
<select name="tx_type" class="mc-select" onchange="this.form.submit()">
<form id="ledger-filter-form" class="mc-filter-form">
<select name="tx_type" class="mc-select" onchange="submitLedgerFilter()">
<option value="">All Types</option>
{% for t in tx_types %}
<option value="{{ t }}" {% if filter_type == t %}selected{% endif %}>{{ t }}</option>
{% endfor %}
</select>
<select name="status" class="mc-select" onchange="this.form.submit()">
<select name="status" class="mc-select" onchange="submitLedgerFilter()">
<option value="">All Statuses</option>
{% for s in tx_statuses %}
<option value="{{ s }}" {% if filter_status == s %}selected{% endif %}>{{ s }}</option>
@@ -69,6 +69,18 @@
</select>
</form>
</div>
<script>
function submitLedgerFilter() {
var form = document.getElementById('ledger-filter-form');
var params = new URLSearchParams();
var txType = form.querySelector('[name="tx_type"]').value;
var status = form.querySelector('[name="status"]').value;
if (txType) params.append('tx_type', txType);
if (status) params.append('status', status);
var qs = params.toString();
window.location.href = '/lightning/ledger' + (qs ? '?' + qs : '');
}
</script>
<!-- Transactions Table -->
<div class="mc-table-container">

View File

@@ -113,6 +113,11 @@
<div class="price-label">min bid</div>
<div class="price-stat">{{ agent.tasks_completed }} tasks won</div>
<div class="price-stat"><span class="earned">{{ agent.total_earned }} sats</span> earned</div>
<a href="/tasks?assign={{ agent.name | urlencode }}"
class="btn btn-sm"
style="margin-top:8px; background:var(--purple); color:#fff; border:none; border-radius:var(--radius-sm); padding:6px 16px; font-size:0.75rem; font-weight:600; letter-spacing:0.05em; display:inline-block; text-decoration:none;">
HIRE
</a>
</div>
</div>
{% endfor %}

View File

@@ -105,9 +105,13 @@
<div class="mc-facts-list">
{% if facts %}
<ul class="mc-fact-list">
<ul class="mc-fact-list" style="list-style: none; padding: 0;">
{% for fact in facts %}
<li class="memory-fact">{{ fact }}</li>
<li class="memory-fact" id="fact-{{ fact.id }}" style="display:flex; align-items:center; gap:8px; padding:6px 0; border-bottom:1px solid rgba(255,255,255,0.08);">
<span class="fact-content" style="flex:1;">{{ fact.content }}</span>
<button class="mc-btn mc-btn-small" onclick="editFact('{{ fact.id }}', this)" style="font-size:0.7rem; padding:2px 8px;">EDIT</button>
<button class="mc-btn mc-btn-small" onclick="deleteFact('{{ fact.id }}')" style="font-size:0.7rem; padding:2px 8px; color:#ef4444;">DEL</button>
</li>
{% endfor %}
</ul>
{% else %}
@@ -116,4 +120,40 @@
</div>
</div>
</div>
<script>
function deleteFact(id) {
if (!confirm('Delete this fact?')) return;
fetch('/memory/fact/' + id, { method: 'DELETE' })
.then(function(r) { if (r.ok) document.getElementById('fact-' + id).remove(); });
}
function editFact(id, btn) {
var li = document.getElementById('fact-' + id);
var span = li.querySelector('.fact-content');
var current = span.textContent.trim();
var input = document.createElement('input');
input.type = 'text'; input.value = current;
input.className = 'mc-input'; input.style.flex = '1';
span.replaceWith(input);
btn.textContent = 'SAVE';
btn.onclick = function() {
var val = input.value.trim();
if (!val) return;
fetch('/memory/fact/' + id, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ content: val })
}).then(function(r) {
if (r.ok) {
var newSpan = document.createElement('span');
newSpan.className = 'fact-content'; newSpan.style.flex = '1';
newSpan.textContent = val;
input.replaceWith(newSpan);
btn.textContent = 'EDIT';
btn.onclick = function() { editFact(id, btn); };
}
});
};
}
</script>
{% endblock %}

View File

@@ -187,16 +187,24 @@ async function loadHealth() {
try {
const response = await fetch('/health');
const data = await response.json();
// Format uptime
const uptime = data.uptime_seconds;
let uptimeStr;
if (uptime < 60) uptimeStr = Math.floor(uptime) + 's';
else if (uptime < 3600) uptimeStr = Math.floor(uptime / 60) + 'm';
else uptimeStr = Math.floor(uptime / 3600) + 'h ' + Math.floor((uptime % 3600) / 60) + 'm';
document.getElementById('metric-uptime').textContent = uptimeStr;
// LLM backend and model from /health response
if (data.llm_backend) {
document.getElementById('hb-backend').textContent = data.llm_backend;
}
if (data.llm_model) {
document.getElementById('hb-model').textContent = data.llm_model;
}
} catch (error) {
console.error('Failed to load health:', error);
}
@@ -207,11 +215,22 @@ async function loadSwarmStats() {
try {
const response = await fetch('/swarm');
const data = await response.json();
document.getElementById('metric-agents').textContent = data.agents || 0;
document.getElementById('metric-tasks').textContent =
var agentCount = data.agents || 0;
// Fallback: if /swarm returns 0, try /swarm/agents for a direct count
if (agentCount === 0) {
try {
const agentResp = await fetch('/swarm/agents');
const agentData = await agentResp.json();
if (Array.isArray(agentData.agents)) {
agentCount = agentData.agents.length;
}
} catch (e) { /* ignore fallback failure */ }
}
document.getElementById('metric-agents').textContent = agentCount;
document.getElementById('metric-tasks').textContent =
(data.tasks_pending || 0) + (data.tasks_running || 0);
} catch (error) {
console.error('Failed to load swarm stats:', error);
}
@@ -222,16 +241,12 @@ async function loadLightningStats() {
try {
const response = await fetch('/serve/status');
const data = await response.json();
document.getElementById('metric-earned').textContent = data.total_earned_sats || 0;
// Update heartbeat backend
document.getElementById('hb-backend').textContent = data.backend || '-';
document.getElementById('hb-model').textContent = 'llama3.2'; // From config
} catch (error) {
console.error('Failed to load lightning stats:', error);
document.getElementById('metric-earned').textContent = '-';
// /serve may not be running — default to 0 instead of '-'
document.getElementById('metric-earned').textContent = '0';
}
}

View File

@@ -35,13 +35,11 @@
hx-swap="outerHTML">
CHAT
</button>
<button class="mc-btn-clear flex-fill"
style="font-size:9px; padding:4px 6px;"
hx-get="/swarm/tasks/panel?agent_id={{ agent.id }}"
hx-target="#main-panel"
hx-swap="outerHTML">
<a class="mc-btn-clear flex-fill"
style="font-size:9px; padding:4px 6px; text-decoration:none; text-align:center;"
href="/tasks?assign={{ agent.name | urlencode }}">
TASK
</button>
</a>
</div>
</div>

View File

@@ -0,0 +1,105 @@
<div id="task-{{ task.id }}" class="task-card priority-{{ task.priority.value }}">
<div class="task-card-title">{{ task.title | e }}</div>
{% if task.description %}
<div class="task-card-desc">{{ task.description | e }}</div>
{% endif %}
<div class="task-card-meta">
<span class="task-badge task-badge-{{ task.priority.value }}">{{ task.priority.value | upper }}</span>
<span class="task-badge task-badge-{{ task.status.value }}">{{ task.status.value | replace("_", " ") | upper }}</span>
<span class="task-badge">{{ task.assigned_to | e }}</span>
<span class="task-badge">by {{ task.created_by | e }}</span>
</div>
{% if task.steps %}
<div class="task-steps">
{% for step in task.steps %}
<div class="task-step {{ step.status if step.status else 'pending' }}">
{% if step.status == 'completed' %}&#10003;{% elif step.status == 'running' %}&#9654;{% else %}&#9675;{% endif %}
{{ step.description if step.description else step }}
</div>
{% endfor %}
</div>
{% endif %}
{% if task.result %}
<div class="task-result" title="Click to expand">{{ task.result | e }}</div>
{% endif %}
<!-- Action buttons based on status -->
{% if task.status.value == 'pending_approval' %}
<div class="task-actions">
<button class="task-btn task-btn-approve"
hx-post="/tasks/{{ task.id }}/approve"
hx-target="#task-{{ task.id }}"
hx-swap="outerHTML">APPROVE</button>
<button class="task-btn task-btn-modify"
onclick="toggleModify('{{ task.id }}')">MODIFY</button>
<button class="task-btn task-btn-veto"
hx-post="/tasks/{{ task.id }}/veto"
hx-target="#task-{{ task.id }}"
hx-swap="outerHTML">VETO</button>
</div>
<!-- Inline modify form (hidden by default) -->
<form id="modify-{{ task.id }}" style="display:none; margin-top:8px;"
hx-post="/tasks/{{ task.id }}/modify"
hx-target="#task-{{ task.id }}"
hx-swap="outerHTML">
<input type="text" name="title" value="{{ task.title | e }}" style="width:100%; padding:4px; margin-bottom:4px; background:var(--bg-tertiary); color:var(--text); border:1px solid var(--border); border-radius:4px; font-size:0.8rem;">
<textarea name="description" style="width:100%; padding:4px; margin-bottom:4px; background:var(--bg-tertiary); color:var(--text); border:1px solid var(--border); border-radius:4px; font-size:0.8rem; min-height:40px;">{{ task.description | e }}</textarea>
<button type="submit" class="task-btn task-btn-approve" style="font-size:0.65rem;">SAVE</button>
<button type="button" class="task-btn task-btn-cancel" style="font-size:0.65rem;" onclick="toggleModify('{{ task.id }}')">CANCEL</button>
</form>
{% elif task.status.value == 'approved' %}
<div class="task-actions">
<span style="font-size:0.7rem; color:var(--green);">Approved &mdash; waiting to run</span>
<button class="task-btn task-btn-veto"
hx-post="/tasks/{{ task.id }}/veto"
hx-target="#task-{{ task.id }}"
hx-swap="outerHTML">VETO</button>
</div>
{% elif task.status.value == 'running' %}
<div class="task-actions">
<button class="task-btn task-btn-pause"
hx-post="/tasks/{{ task.id }}/pause"
hx-target="#task-{{ task.id }}"
hx-swap="outerHTML">PAUSE</button>
<button class="task-btn task-btn-cancel"
hx-post="/tasks/{{ task.id }}/cancel"
hx-target="#task-{{ task.id }}"
hx-swap="outerHTML">CANCEL</button>
</div>
{% elif task.status.value == 'paused' %}
<div class="task-actions">
<button class="task-btn task-btn-approve"
hx-post="/tasks/{{ task.id }}/approve"
hx-target="#task-{{ task.id }}"
hx-swap="outerHTML">RESUME</button>
<button class="task-btn task-btn-cancel"
hx-post="/tasks/{{ task.id }}/cancel"
hx-target="#task-{{ task.id }}"
hx-swap="outerHTML">CANCEL</button>
</div>
{% elif task.status.value == 'failed' %}
<div class="task-actions">
<button class="task-btn task-btn-retry"
hx-post="/tasks/{{ task.id }}/retry"
hx-target="#task-{{ task.id }}"
hx-swap="outerHTML">RETRY</button>
</div>
{% endif %}
<div class="task-time">{{ task.created_at[:16].replace("T", " ") }}</div>
</div>
<script>
function toggleModify(id) {
var form = document.getElementById('modify-' + id);
form.style.display = form.style.display === 'none' ? 'block' : 'none';
}
</script>

View File

@@ -0,0 +1,9 @@
{% if tasks %}
{% for task in tasks %}
{% include "partials/task_card.html" %}
{% endfor %}
{% else %}
<div class="empty-column">
{% if section == 'pending' %}No pending tasks{% elif section == 'active' %}No active tasks{% else %}No completed tasks yet{% endif %}
</div>
{% endif %}

View File

@@ -0,0 +1,84 @@
<div id="wo-{{ wo.id }}" class="card" style="padding: 14px; margin-bottom: 12px; border-left: 3px solid {% if wo.priority.value == 'critical' %}var(--danger){% elif wo.priority.value == 'high' %}var(--amber){% elif wo.priority.value == 'medium' %}var(--info, #4ea8de){% else %}var(--text-dim){% endif %};">
<div class="d-flex justify-content-between align-items-start" style="margin-bottom: 8px;">
<div>
<strong style="font-size: 0.9rem;">{{ wo.title | e }}</strong>
<div style="margin-top: 4px; display: flex; gap: 6px; flex-wrap: wrap;">
<span class="badge" style="font-size: 0.65rem; background: {% if wo.priority.value == 'critical' %}var(--danger){% elif wo.priority.value == 'high' %}var(--amber){% elif wo.priority.value == 'medium' %}var(--info, #4ea8de){% else %}var(--bg-tertiary){% endif %}; color: {% if wo.priority.value in ('critical', 'high') %}#000{% else %}var(--text-primary, #fff){% endif %};">
{{ wo.priority.value | upper }}
</span>
<span class="badge" style="font-size: 0.65rem; background: var(--bg-tertiary);">
{{ wo.category.value | upper }}
</span>
<span class="badge" style="font-size: 0.65rem; background: var(--bg-tertiary);">
{{ wo.submitter | e }}
</span>
{% if wo.execution_mode %}
<span class="badge" style="font-size: 0.65rem; background: {% if wo.execution_mode == 'auto' %}var(--success){% else %}var(--bg-tertiary){% endif %}; color: {% if wo.execution_mode == 'auto' %}#000{% else %}var(--text-primary, #fff){% endif %};">
{{ wo.execution_mode | upper }}
</span>
{% endif %}
</div>
</div>
<div style="font-size: 0.65rem; color: var(--text-muted); text-align: right; white-space: nowrap;">
{{ wo.status.value | upper }}<br>
{{ wo.created_at[:16].replace("T", " ") }}
</div>
</div>
{% if wo.description %}
<div style="font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; max-height: 3em; overflow: hidden;">
{{ wo.description | e }}
</div>
{% endif %}
{% if wo.related_files %}
<div style="font-size: 0.7rem; font-family: monospace; color: var(--text-dim); margin-bottom: 8px;">
{{ wo.related_files | join(", ") | e }}
</div>
{% endif %}
{% if wo.result %}
<div style="font-size: 0.75rem; color: var(--success); margin-bottom: 8px;">
{{ wo.result | e }}
</div>
{% endif %}
{% if wo.rejection_reason %}
<div style="font-size: 0.75rem; color: var(--danger); margin-bottom: 8px;">
Rejected: {{ wo.rejection_reason | e }}
</div>
{% endif %}
<!-- Action buttons based on status -->
{% if wo.status.value in ('submitted', 'triaged') %}
<div class="d-flex gap-2" style="margin-top: 8px;">
<button class="btn mc-btn-send" style="font-size: 0.7rem; padding: 4px 16px;"
hx-post="/work-orders/{{ wo.id }}/approve"
hx-target="#wo-{{ wo.id }}"
hx-swap="outerHTML">
APPROVE
</button>
<button class="btn" style="font-size: 0.7rem; padding: 4px 16px; background: var(--danger); color: #fff; border: none; border-radius: var(--radius-md, 4px);"
hx-post="/work-orders/{{ wo.id }}/reject"
hx-target="#wo-{{ wo.id }}"
hx-swap="outerHTML">
REJECT
</button>
</div>
{% elif wo.status.value == 'approved' %}
<div style="margin-top: 8px;">
<button class="btn mc-btn-send" style="font-size: 0.7rem; padding: 4px 16px;"
hx-post="/work-orders/{{ wo.id }}/execute"
hx-target="#wo-{{ wo.id }}"
hx-swap="outerHTML">
EXECUTE
</button>
</div>
{% elif wo.status.value == 'in_progress' %}
<div style="margin-top: 8px; font-size: 0.7rem; color: var(--amber);">
Executing...
</div>
{% endif %}
</div>

View File

@@ -0,0 +1,15 @@
{% if orders %}
{% for wo in orders %}
{% include "partials/work_order_card.html" %}
{% endfor %}
{% else %}
<div style="color: var(--text-muted); font-size: 0.8rem; padding: 12px 0;">
{% if section == "pending" %}
No pending work orders.
{% elif section == "active" %}
No active work orders.
{% else %}
No work orders found.
{% endif %}
</div>
{% endif %}

View File

@@ -440,5 +440,17 @@ function addLog(message, type) {
}
connect();
// HTMX fallback: load initial data via REST if WebSocket is slow
setTimeout(function() {
if (document.getElementById('stat-agents').textContent === '-') {
refreshStats();
fetch('/swarm/agents').then(function(r) { return r.json(); }).then(function(data) {
if (data.agents && data.agents.length > 0) {
updateAgentsList(data.agents);
}
}).catch(function() {});
}
}, 2000);
</script>
{% endblock %}

View File

@@ -0,0 +1,357 @@
{% extends "base.html" %}
{% block title %}Task Queue - Timmy Time{% endblock %}
{% block extra_styles %}
<style>
.tasks-container { max-width: 1400px; margin: 0 auto; }
.tasks-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
}
.tasks-title {
font-size: 1.3rem;
font-weight: 700;
color: var(--text-bright);
letter-spacing: 0.08em;
}
.tasks-columns {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 16px;
}
@media (max-width: 992px) {
.tasks-columns { grid-template-columns: 1fr; }
}
.task-column-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.task-column-title {
font-size: 0.75rem;
font-weight: 700;
letter-spacing: 0.1em;
color: var(--text-dim);
}
.task-card {
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 12px;
margin-bottom: 10px;
background: rgba(24, 10, 45, 0.6);
transition: border-color 0.2s;
}
.task-card:hover { border-color: rgba(124, 58, 237, 0.3); }
.task-card.priority-urgent { border-left: 3px solid var(--red, #ef4444); }
.task-card.priority-high { border-left: 3px solid var(--amber, #f59e0b); }
.task-card.priority-normal { border-left: 3px solid var(--info, #4ea8de); }
.task-card.priority-low { border-left: 3px solid var(--text-dim); }
.task-card-title {
font-weight: 600;
font-size: 0.9rem;
color: var(--text-bright);
margin-bottom: 4px;
}
.task-card-desc {
font-size: 0.8rem;
color: var(--text);
margin-bottom: 6px;
max-height: 3em;
overflow: hidden;
}
.task-card-meta {
display: flex;
gap: 6px;
flex-wrap: wrap;
margin-bottom: 8px;
}
.task-badge {
font-size: 0.65rem;
padding: 0.15em 0.5em;
border-radius: 3px;
font-weight: 600;
letter-spacing: 0.05em;
background: var(--bg-tertiary);
color: var(--text);
}
.task-badge-urgent { background: rgba(239,68,68,0.2); color: var(--red, #ef4444); }
.task-badge-high { background: rgba(245,158,11,0.2); color: var(--amber, #f59e0b); }
.task-badge-running { background: rgba(59,130,246,0.2); color: #60a5fa; }
.task-badge-completed { background: rgba(16,185,129,0.2); color: var(--green, #10b981); }
.task-badge-failed { background: rgba(239,68,68,0.2); color: var(--red, #ef4444); }
.task-badge-vetoed { background: rgba(107,114,128,0.2); color: #9ca3af; }
.task-badge-paused { background: rgba(245,158,11,0.2); color: var(--amber, #f59e0b); }
.task-actions {
display: flex;
gap: 6px;
flex-wrap: wrap;
}
.task-btn {
font-size: 0.7rem;
padding: 4px 12px;
border: none;
border-radius: var(--radius-sm, 4px);
cursor: pointer;
font-weight: 600;
letter-spacing: 0.04em;
font-family: var(--font);
}
.task-btn-approve { background: var(--green, #10b981); color: #000; }
.task-btn-approve:hover { opacity: 0.85; }
.task-btn-modify { background: var(--purple, #7c3aed); color: #fff; }
.task-btn-modify:hover { opacity: 0.85; }
.task-btn-veto { background: var(--red, #ef4444); color: #fff; }
.task-btn-veto:hover { opacity: 0.85; }
.task-btn-pause { background: var(--amber, #f59e0b); color: #000; }
.task-btn-cancel { background: var(--bg-tertiary); color: var(--text); border: 1px solid var(--border); }
.task-btn-retry { background: var(--info, #4ea8de); color: #000; }
.task-result {
font-size: 0.75rem;
color: var(--text);
margin-top: 6px;
padding: 6px;
background: rgba(0,0,0,0.2);
border-radius: 4px;
max-height: 4em;
overflow: hidden;
cursor: pointer;
}
.task-result.expanded { max-height: none; }
.task-steps {
margin-top: 6px;
font-size: 0.7rem;
}
.task-step { padding: 2px 0; color: var(--text-dim); }
.task-step.running { color: #60a5fa; }
.task-step.completed { color: var(--green, #10b981); }
.task-time {
font-size: 0.6rem;
color: var(--text-dim);
font-family: var(--font);
margin-top: 4px;
}
/* Create modal */
.task-modal-overlay {
display: none;
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: rgba(0,0,0,0.6);
z-index: 1000;
align-items: center;
justify-content: center;
}
.task-modal-overlay.open { display: flex; }
.task-modal {
background: var(--bg-secondary, #1a0a2e);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: 24px;
max-width: 480px;
width: 90%;
}
.task-modal h3 {
margin: 0 0 16px;
font-size: 1rem;
color: var(--text-bright);
}
.task-modal label {
display: block;
font-size: 0.75rem;
color: var(--text-dim);
margin-bottom: 4px;
letter-spacing: 0.05em;
}
.task-modal input, .task-modal textarea, .task-modal select {
width: 100%;
padding: 8px;
margin-bottom: 12px;
border: 1px solid var(--border);
border-radius: var(--radius-sm);
background: var(--bg-tertiary, #0a0f1e);
color: var(--text);
font-family: var(--font);
font-size: 0.85rem;
}
.task-modal textarea { min-height: 80px; resize: vertical; }
.task-modal-actions {
display: flex;
gap: 8px;
justify-content: flex-end;
margin-top: 8px;
}
.empty-column {
text-align: center;
padding: 24px;
color: var(--text-dim);
font-size: 0.8rem;
}
</style>
{% endblock %}
{% block content %}
<div class="tasks-container py-3">
<div class="tasks-header">
<div class="tasks-title">TASK QUEUE</div>
<button class="task-btn task-btn-approve" onclick="openCreateModal()" style="padding:6px 16px; font-size:0.8rem;">+ ADD TASK</button>
</div>
<div class="tasks-columns">
<!-- PENDING APPROVAL -->
<div class="card mc-panel">
<div class="card-header mc-panel-header task-column-header">
<span class="task-column-title">// PENDING APPROVAL</span>
<span class="badge badge-warning" id="pending-count">{{ pending_count }}</span>
</div>
<div class="card-body p-2" id="pending-list"
hx-get="/tasks/pending" hx-trigger="every 15s" hx-swap="innerHTML">
{% if pending %}
{% for task in pending %}
{% include "partials/task_card.html" %}
{% endfor %}
{% else %}
<div class="empty-column">No pending tasks</div>
{% endif %}
</div>
</div>
<!-- ACTIVE -->
<div class="card mc-panel">
<div class="card-header mc-panel-header task-column-header">
<span class="task-column-title">// ACTIVE</span>
<span class="badge badge-info" id="active-count">{{ active | length }}</span>
</div>
<div class="card-body p-2" id="active-list"
hx-get="/tasks/active" hx-trigger="every 10s" hx-swap="innerHTML">
{% if active %}
{% for task in active %}
{% include "partials/task_card.html" %}
{% endfor %}
{% else %}
<div class="empty-column">No active tasks</div>
{% endif %}
</div>
</div>
<!-- COMPLETED -->
<div class="card mc-panel">
<div class="card-header mc-panel-header task-column-header">
<span class="task-column-title">// COMPLETED</span>
<span class="badge badge-secondary" id="completed-count">{{ completed | length }}</span>
</div>
<div class="card-body p-2" id="completed-list" style="max-height: 70vh; overflow-y: auto;"
hx-get="/tasks/completed" hx-trigger="every 30s" hx-swap="innerHTML">
{% if completed %}
{% for task in completed %}
{% include "partials/task_card.html" %}
{% endfor %}
{% else %}
<div class="empty-column">No completed tasks yet</div>
{% endif %}
</div>
</div>
</div>
</div>
<!-- Create Task Modal -->
<div class="task-modal-overlay" id="create-modal">
<div class="task-modal">
<h3>Create Task</h3>
<form id="create-task-form" hx-post="/tasks/create" hx-target="#pending-list" hx-swap="afterbegin" hx-on::after-request="closeCreateModal()">
<label>Title</label>
<input type="text" name="title" required placeholder="Short description of the task">
<label>Description</label>
<textarea name="description" placeholder="Full task details (optional)"></textarea>
<label>Assign To</label>
<select name="assigned_to" id="modal-assigned-to">
{% for agent in agents %}
<option value="{{ agent.name }}" {% if pre_assign == agent.name %}selected{% endif %}>{{ agent.name }}</option>
{% endfor %}
</select>
<label>Priority</label>
<select name="priority">
<option value="low">Low</option>
<option value="normal" selected>Normal</option>
<option value="high">High</option>
<option value="urgent">Urgent</option>
</select>
<div class="task-modal-actions">
<button type="button" class="task-btn task-btn-cancel" onclick="closeCreateModal()">CANCEL</button>
<button type="submit" class="task-btn task-btn-approve">CREATE</button>
</div>
</form>
</div>
</div>
<script>
function openCreateModal(agentName) {
document.getElementById('create-modal').classList.add('open');
if (agentName) {
var sel = document.getElementById('modal-assigned-to');
for (var i = 0; i < sel.options.length; i++) {
if (sel.options[i].value === agentName) { sel.selectedIndex = i; break; }
}
}
}
function closeCreateModal() {
document.getElementById('create-modal').classList.remove('open');
document.getElementById('create-task-form').reset();
}
// Close on overlay click
document.getElementById('create-modal').addEventListener('click', function(e) {
if (e.target === this) closeCreateModal();
});
// Close on Escape
document.addEventListener('keydown', function(e) {
if (e.key === 'Escape') closeCreateModal();
});
// Toggle result expansion
document.addEventListener('click', function(e) {
if (e.target.classList.contains('task-result')) {
e.target.classList.toggle('expanded');
}
});
// WebSocket live updates for task events
(function() {
var protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
var ws;
function connectTaskWs() {
try {
ws = new WebSocket(protocol + '//' + window.location.host + '/ws');
ws.onmessage = function(event) {
try {
var msg = JSON.parse(event.data);
if (msg.type === 'task_event') {
// Refresh the relevant column
htmx.trigger('#pending-list', 'htmx:trigger');
htmx.trigger('#active-list', 'htmx:trigger');
htmx.trigger('#completed-list', 'htmx:trigger');
}
} catch(e) {}
};
ws.onclose = function() {
setTimeout(connectTaskWs, 5000);
};
} catch(e) {}
}
connectTaskWs();
})();
// Open create modal from URL param (?assign=timmy)
var params = new URLSearchParams(window.location.search);
if (params.get('assign')) {
openCreateModal(params.get('assign'));
}
</script>
{% endblock %}

View File

@@ -59,9 +59,13 @@
{% endfor %}
</div>
{% else %}
<div class="mc-empty-state">
<div class="mc-empty-state" style="padding:2rem; text-align:center;">
<p>No pending upgrades.</p>
<p class="mc-text-secondary">Proposed modifications will appear here for review.</p>
<p class="mc-text-secondary" style="margin-bottom:1rem;">Upgrades are proposed by the self-modification system when Timmy identifies improvements. You can also trigger them via work orders or the task queue.</p>
<div style="display:flex; gap:0.75rem; justify-content:center; flex-wrap:wrap;">
<a href="/work-orders/queue" class="mc-btn mc-btn-secondary" style="text-decoration:none;">View Work Orders</a>
<a href="/tasks" class="mc-btn mc-btn-secondary" style="text-decoration:none;">View Task Queue</a>
</div>
</div>
{% endif %}
</div>

View File

@@ -0,0 +1,145 @@
{% extends "base.html" %}
{% block title %}Work Orders — Timmy Time{% endblock %}
{% block content %}
<div class="container-fluid" style="max-width: 1200px; padding: 24px;">
<!-- Header -->
<div class="d-flex justify-content-between align-items-center" style="margin-bottom: 24px;">
<div>
<h2 style="margin: 0; font-size: 1.5rem;">WORK ORDERS</h2>
<div style="font-size: 0.75rem; color: var(--text-muted); letter-spacing: 0.1em; margin-top: 4px;">
SUBMIT &middot; REVIEW &middot; EXECUTE
</div>
</div>
<div class="d-flex gap-2">
<span class="badge" style="background: var(--amber); color: #000; font-size: 0.75rem;">
{{ pending_count }} PENDING
</span>
<button class="btn mc-btn-send" style="font-size: 0.75rem; padding: 6px 16px;"
onclick="document.getElementById('submit-form').style.display = document.getElementById('submit-form').style.display === 'none' ? 'block' : 'none'">
+ NEW
</button>
</div>
</div>
<!-- Submit Form (hidden by default) -->
<div id="submit-form" class="card" style="display: none; margin-bottom: 24px; padding: 20px;">
<h3 style="font-size: 0.875rem; margin-bottom: 16px; letter-spacing: 0.1em;">SUBMIT WORK ORDER</h3>
<form hx-post="/work-orders/submit"
hx-target="#submit-result"
hx-swap="innerHTML"
hx-on::after-request="if(event.detail.successful){this.reset(); setTimeout(()=>htmx.trigger('#pending-section','load'),500);}"
class="d-flex flex-column gap-3">
<div>
<label style="font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.15em;">TITLE</label>
<input type="text" name="title" class="form-control mc-input" placeholder="Brief title for this work order" required />
</div>
<div>
<label style="font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.15em;">DESCRIPTION</label>
<textarea name="description" class="form-control mc-input" rows="3" placeholder="Detailed description..."></textarea>
</div>
<div class="d-flex gap-3">
<div style="flex: 1;">
<label style="font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.15em;">PRIORITY</label>
<select name="priority" class="form-control mc-input">
{% for p in priorities %}
<option value="{{ p }}" {{ "selected" if p == "medium" else "" }}>{{ p | upper }}</option>
{% endfor %}
</select>
</div>
<div style="flex: 1;">
<label style="font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.15em;">CATEGORY</label>
<select name="category" class="form-control mc-input">
{% for c in categories %}
<option value="{{ c }}" {{ "selected" if c == "suggestion" else "" }}>{{ c | upper }}</option>
{% endfor %}
</select>
</div>
<div style="flex: 1;">
<label style="font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.15em;">SUBMITTER</label>
<input type="text" name="submitter" class="form-control mc-input" value="dashboard" />
</div>
</div>
<div>
<label style="font-size: 0.7rem; color: var(--text-muted); letter-spacing: 0.15em;">RELATED FILES (comma-separated)</label>
<input type="text" name="related_files" class="form-control mc-input" placeholder="src/timmy/agent.py, src/config.py" />
</div>
<input type="hidden" name="submitter_type" value="user" />
<div class="d-flex justify-content-between align-items-center">
<div id="submit-result" style="font-size: 0.75rem;"></div>
<button type="submit" class="btn mc-btn-send" style="padding: 8px 24px;">SUBMIT</button>
</div>
</form>
</div>
<!-- Pending Queue -->
<div class="card" style="margin-bottom: 24px; padding: 20px;">
<h3 style="font-size: 0.875rem; margin-bottom: 16px; letter-spacing: 0.1em;">
INCOMING QUEUE
</h3>
<div id="pending-section"
hx-get="/work-orders/queue/pending"
hx-trigger="load, every 30s"
hx-swap="innerHTML">
{% if pending %}
{% for wo in pending %}
{% include "partials/work_order_card.html" %}
{% endfor %}
{% else %}
<div style="color: var(--text-muted); font-size: 0.8rem; padding: 12px 0;">
No pending work orders. Use the + NEW button or the API to submit one.
</div>
{% endif %}
</div>
</div>
<!-- Active Work -->
<div class="card" style="margin-bottom: 24px; padding: 20px;">
<h3 style="font-size: 0.875rem; margin-bottom: 16px; letter-spacing: 0.1em;">
ACTIVE WORK
</h3>
<div id="active-section"
hx-get="/work-orders/queue/active"
hx-trigger="load, every 15s"
hx-swap="innerHTML">
{% if active %}
{% for wo in active %}
{% include "partials/work_order_card.html" %}
{% endfor %}
{% else %}
<div style="color: var(--text-muted); font-size: 0.8rem; padding: 12px 0;">
No work orders currently in progress.
</div>
{% endif %}
</div>
</div>
<!-- History -->
<div class="card" style="padding: 20px;">
<h3 style="font-size: 0.875rem; margin-bottom: 16px; letter-spacing: 0.1em;">
HISTORY
</h3>
{% if completed or rejected %}
{% for wo in completed %}
{% include "partials/work_order_card.html" %}
{% endfor %}
{% for wo in rejected %}
{% include "partials/work_order_card.html" %}
{% endfor %}
{% else %}
<div style="color: var(--text-muted); font-size: 0.8rem; padding: 12px 0;">
No completed or rejected work orders yet.
</div>
{% endif %}
</div>
</div>
{% endblock %}