Custom Commands für Agents: gleiche Befehls-UI wie Sessions, im Chat werden Agent- und Session-Commands zusammengeführt

Backend:
- AgentRecord um CustomCommands-Feld erweitert
- DB-Migration: custom_commands Spalte für agents Tabelle
- Agent-CRUD (Create/Update) verarbeitet customCommands

Frontend:
- commands-ui.js: Shared Utility (createCommandRow, getCommandsFromUI, loadCommandsIntoUI) für Agent- und Session-Page
- Agent-Page: Benutzerdefinierte Befehle Sektion mit Typ-Dropdown
- Chat-Page: Lädt Agent-Commands + Session-Commands, zeigt beide mit Labels wenn beide vorhanden
- Session-Page: Refactored auf shared commands-ui.js Funktionen
- CSS: cmd-bar-label Styling für Agent:/Session: Trennung in der Command-Bar
This commit is contained in:
Meleki committed 2026-02-28 21:35:34 +01:00
1 parent ab234fde69
commit e79a69a364
9 files changed
+130 -62

No files matched your search

+35 -4
View File
@@ -57,13 +57,44 @@ registerPage('chat', {
titleEl.textContent = session.name || 'Unbenannt';
}
// Custom Command Buttons
// Custom Command Buttons (Agent + Session)
const cmdBar = document.getElementById('customCmdBar');
if (cmdBar) {
cmdBar.innerHTML = '';
let cmds = [];
try { cmds = JSON.parse(session.customCommands || '[]') || []; } catch(e) {}
cmds.forEach(cmd => {
let agentCmds = [];
if (session.agentId) {
try {
const agent = await apiGetAgent(session.agentId);
if (agent && agent.customCommands) {
agentCmds = JSON.parse(agent.customCommands) || [];
}
} catch(e) {}
}
let sessionCmds = [];
try { sessionCmds = JSON.parse(session.customCommands || '[]') || []; } catch(e) {}
const allCmds = agentCmds.concat(sessionCmds);
const hasAgentCmds = agentCmds.length > 0;
const hasSessionCmds = sessionCmds.length > 0;
const hasBoth = hasAgentCmds && hasSessionCmds;
if (hasBoth) {
const sep1 = document.createElement('span');
sep1.className = 'cmd-bar-label';
sep1.textContent = 'Agent:';
cmdBar.appendChild(sep1);
}
let sessionSepAdded = false;
let cmdIndex = 0;
allCmds.forEach((cmd, idx) => {
if (hasBoth && !sessionSepAdded && idx === agentCmds.length) {
const sep2 = document.createElement('span');
sep2.className = 'cmd-bar-label';
sep2.textContent = 'Session:';
cmdBar.appendChild(sep2);
sessionSepAdded = true;
}
if (!cmd.name || !cmd.command) return;
const type = cmd.type || 'background';
const btn = document.createElement('button');