feat: File-Explorer für Agent-Ordner im Agent-Formular

This commit is contained in:
Meleki committed 2026-03-01 15:48:13 +01:00
1 parent 8e585443e2
commit 58c5ccb79b
4 files changed
+192 -4

No files matched your search

+12 -4
View File
@@ -4,11 +4,19 @@
let _feState = null;
function _feApiUrl(action, params = '') {
if (_feState && _feState.agentId) {
return `/api/workspace/agent/${action}?agentId=${_feState.agentId}${params ? '&' + params : ''}`;
}
return `/api/workspace/${action}?sessionId=${_feState.sessionId}${params ? '&' + params : ''}`;
}
function openFileExplorer(opts = {}) {
if (_feState) closeFileExplorer();
_feState = {
sessionId: opts.sessionId || getCurrentSessionId(),
sessionId: opts.sessionId || (!opts.agentId ? getCurrentSessionId() : null),
agentId: opts.agentId || null,
onSelect: opts.onSelect || null,
currentPath: '',
history: [],
@@ -102,7 +110,7 @@ async function feLoadDir(path) {
document.getElementById('feFooter').hidden = true;
try {
const resp = await fetch(`/api/workspace/tree?sessionId=${_feState.sessionId}&path=${encodeURIComponent(path)}`);
const resp = await fetch(_feApiUrl('tree', `path=${encodeURIComponent(path)}`));
if (!resp.ok) {
const err = await resp.json().catch(() => ({}));
sidebar.innerHTML = `<div class="fe-error">${err.error || 'Fehler'}</div>`;
@@ -206,7 +214,7 @@ async function feSelectFile(entry, itemEl) {
main.innerHTML = '<div class="fe-loading">Laden...</div>';
try {
const resp = await fetch(`/api/workspace/file?sessionId=${_feState.sessionId}&path=${encodeURIComponent(entry.path)}`);
const resp = await fetch(_feApiUrl('file', `path=${encodeURIComponent(entry.path)}`));
if (!resp.ok) {
main.innerHTML = '<div class="fe-error">Fehler beim Laden</div>';
return;
@@ -431,7 +439,7 @@ async function feDoSave() {
try {
const resp = await fetch(
`/api/workspace/file?sessionId=${_feState.sessionId}&path=${encodeURIComponent(path)}`,
_feApiUrl('file', `path=${encodeURIComponent(path)}`),
{ method: 'PUT', body: content }
);