Skip to content

Commit 23aa355

Browse files
committed
fix(dashboard): bind loopback, fallback JSON, prevent XSS
1 parent e85554a commit 23aa355

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

dashboard/index.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,12 @@ <h1>Promptimprover Swarm Dashboard</h1>
3535
const tr = document.createElement('tr');
3636
const fmtTime = new Date(log.timestamp).toLocaleTimeString();
3737
const reason = log.reasoning_path && log.reasoning_path.length > 60 ? log.reasoning_path.slice(0,57) + '...' : log.reasoning_path;
38-
tr.innerHTML = `
39-
<td>${fmtTime}</td>
40-
<td>${log.span_id || 'N/A'}</td>
41-
<td>${log.persona || 'Unknown'}</td>
42-
<td>${log.action_type || 'Unknown'}</td>
43-
<td>${log.metrics?.total_tokens || 0}</td>
44-
<td>${reason || ''}</td>
45-
`;
38+
['time', 'span', 'persona', 'action', 'tokens', 'reasoning'].forEach((k, i) => {
39+
const td = document.createElement('td');
40+
const values = [fmtTime, log.span_id || 'N/A', log.persona || 'Unknown', log.action_type || 'Unknown', log.metrics?.total_tokens || 0, reason || ''];
41+
td.textContent = values[i];
42+
tr.appendChild(td);
43+
});
4644
tbody.appendChild(tr);
4745
});
4846
}

dashboard/server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const PORT = 3000;
1111

1212
// Helper: read last N lines from trace file
1313
async function readLastLines(filePath, maxLines = 20) {
14+
if (!fs.existsSync(filePath)) return [];
1415
const stream = fs.createReadStream(filePath, { encoding: 'utf8' });
1516
let data = '';
1617
stream.on('data', chunk => { data += chunk; });
@@ -56,6 +57,6 @@ const server = http.createServer(async (req, res) => {
5657
}
5758
});
5859

59-
server.listen(PORT, () => {
60-
console.log(`Promptimprover dashboard listening on http://localhost:${PORT}`);
60+
server.listen(PORT, '127.0.0.1', () => {
61+
console.log(`Promptimprover dashboard listening on http://127.0.0.1:${PORT}`);
6162
});

0 commit comments

Comments
 (0)