panel: show agent/bot accounts as their own category
Bot and sandbox teams had real spend that the panel structurally could not show: they have no member row, and the all-time query filtered to member:% teams. They now appear in an "Agents" category beside Admin, fed by the portal's new `agents` list, with spend and budget. Kept out of member counts and member aggregates — a collective expense, like the operator accounts already were. Read-only on the reporting path; the set-balance and set-credits write routes are untouched.
This commit is contained in:
1 parent
a5229103f6
commit
b9957e9d68
1 file changed
+38
+38
@@ -389,6 +389,24 @@ PAGE_HTML = """<!DOCTYPE html>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="agents-section" style="display:none;">
|
||||
<h3 style="margin:20px 0 8px;">Agents</h3>
|
||||
<p style="color:var(--muted);font-size:12px;margin:0 0 8px;">Bot and sandbox accounts. Not members — excluded from member counts; their usage is a collective expense.</p>
|
||||
<div class="table-scroll">
|
||||
<table id="table-agents">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Account</th>
|
||||
<th>Type</th>
|
||||
<th>Spend</th>
|
||||
<th>Budget</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="agent-rows"></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="admins-section" style="display:none;">
|
||||
<h3 style="margin:20px 0 8px;">Admin</h3>
|
||||
<p style="color:var(--muted);font-size:12px;margin:0 0 8px;">Operator accounts (SSO owner and bot). Not members — excluded from member counts; their usage is a collective expense.</p>
|
||||
@@ -459,6 +477,7 @@ async function load() {
|
||||
$('tot-spend-all').textContent = fmt(d.totals.total_all_time_spend ?? d.totals.total_spend);
|
||||
membersData = d.members || [];
|
||||
adminsData = d.admins || [];
|
||||
agentsData = d.agents || [];
|
||||
if (currentView === 'members') renderMembers();
|
||||
} catch (e) {
|
||||
flash('Could not load: ' + e.message, false);
|
||||
@@ -624,6 +643,7 @@ function renderTrends() {
|
||||
// ---- shared state ----
|
||||
let membersData = [];
|
||||
let adminsData = [];
|
||||
let agentsData = [];
|
||||
let modelsData = [];
|
||||
let currentView = 'members';
|
||||
let memberSort = { key: 'spend', dir: -1 }; // leaderboard default: most spend first
|
||||
@@ -653,6 +673,7 @@ function switchView(view) {
|
||||
// The Admin section is a members-view category; hide it in the Models view
|
||||
// (model usage already integrates admin spend into the totals).
|
||||
$('admins-section').style.display = view === 'members' ? '' : 'none';
|
||||
$('agents-section').style.display = view === 'members' ? '' : 'none';
|
||||
$('trends-section').style.display = view === 'trends' ? '' : 'none';
|
||||
$('tab-members').className = 'tab-btn' + (view === 'members' ? ' active' : '');
|
||||
$('tab-models').className = 'tab-btn' + (view === 'models' ? ' active' : '');
|
||||
@@ -767,6 +788,23 @@ function renderMembers() {
|
||||
}).join('');
|
||||
clearArrows('members', memberSort);
|
||||
|
||||
// Agents/bots — real spend, not members. Rendered before the admin block, which
|
||||
// returns early when there are no operator accounts.
|
||||
const agentSection = document.getElementById('agents-section');
|
||||
if (agentsData.length) {
|
||||
agentSection.style.display = '';
|
||||
$('agent-rows').innerHTML = agentsData.map(a => {
|
||||
const kind = String(a.alias).split(':')[0];
|
||||
const budget = (a.budget === null || a.budget === undefined) ? '—' : fmt(a.budget);
|
||||
return '<tr>' +
|
||||
'<td><strong>' + esc(a.alias) + '</strong></td>' +
|
||||
'<td><span class="pill manual" title="Agent account, not a member">' + esc(kind) + '</span></td>' +
|
||||
'<td class="num">' + fmt(a.spend) + '</td>' +
|
||||
'<td>' + budget + '</td>' +
|
||||
'</tr>';
|
||||
}).join('');
|
||||
} else { agentSection.style.display = 'none'; }
|
||||
|
||||
// Admin category — operator accounts (SSO owner + bot), separate from members.
|
||||
const adminSection = document.getElementById('admins-section');
|
||||
if (!adminsData.length) { adminSection.style.display = 'none'; return; }
|
||||
|
||||
Reference in new issue
Block a user