fix: custom command execution via systemd-run für prozessunabhängigkeit

This commit is contained in:
Meleki committed 2026-02-27 13:34:14 +01:00
1 parent 2b8749ee3a
commit 73c6d38254
11 files changed
+242 -12

No files matched your search

+49 -1
View File
@@ -2,6 +2,35 @@
let _sessionImageData = null;
function _createCommandRow(container, name = '', command = '') {
const item = document.createElement('div');
item.className = 'custom-command-item';
item.innerHTML = `
<div class="custom-command-fields">
<input type="text" class="cmd-name" placeholder="Name (z.B. Deploy)" value="${_escAttr(name)}">
<input type="text" class="cmd-command" placeholder="Befehl (z.B. ./deploy.sh)" value="${_escAttr(command)}">
</div>
<button type="button" class="remove-cmd-btn">✕</button>
`;
item.querySelector('.remove-cmd-btn').addEventListener('click', () => item.remove());
container.appendChild(item);
}
function _escAttr(str) {
return str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
function _getCommandsFromUI(container) {
const items = container.querySelectorAll('.custom-command-item');
const commands = [];
for (const item of items) {
const name = item.querySelector('.cmd-name').value.trim();
const command = item.querySelector('.cmd-command').value.trim();
if (name || command) commands.push({ name, command });
}
return commands.length > 0 ? commands : null;
}
registerPage('session', {
async init(params) {
const sessionId = params.id;
@@ -27,6 +56,8 @@ registerPage('session', {
const cancelBtn = document.getElementById('sessionCancelBtn');
const deleteBtn = document.getElementById('sessionDeleteBtn');
const openChatBtn = document.getElementById('openChatBtn');
const commandsList = document.getElementById('customCommandsList');
const addCommandBtn = document.getElementById('addCommandBtn');
_sessionImageData = null;
@@ -43,12 +74,27 @@ registerPage('session', {
if (session.image) {
imagePreview.innerHTML = `<img src="${session.image}" alt="">`;
}
// Custom Commands laden
if (session.customCommands) {
try {
const cmds = typeof session.customCommands === 'string'
? JSON.parse(session.customCommands)
: session.customCommands;
for (const cmd of cmds) {
_createCommandRow(commandsList, cmd.name || '', cmd.command || '');
}
} catch (e) { /* ignore parse errors */ }
}
} else {
titleEl.textContent = 'Neue Session';
deleteBtn.hidden = true;
openChatBtn.disabled = true;
}
// Befehl hinzufügen
addCommandBtn.addEventListener('click', () => _createCommandRow(commandsList));
// Agents laden
const agents = await apiGetAgents();
agentSelect.innerHTML = '<option value="">-- Kein Agent --</option>';
@@ -94,13 +140,15 @@ registerPage('session', {
// Speichern
saveBtn.addEventListener('click', async () => {
const commands = _getCommandsFromUI(commandsList);
const data = {
name: nameEl.value.trim() || 'Unbenannt',
description: descEl.value.trim(),
image: _sessionImageData,
agentId: agentSelect.value || null,
context: contextEl.value || null,
workspace: workspaceEl.value.trim() || null
workspace: workspaceEl.value.trim() || null,
customCommands: commands
};
if (isNew) {