Changeset 0.30.2 cs2 (#202)
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit is contained in:
@@ -79,6 +79,13 @@
|
||||
'</select></div>' +
|
||||
'</div>' +
|
||||
|
||||
'<div class="form-row" style="gap:12px;margin-top:8px">' +
|
||||
'<div class="form-group" style="flex:1"><label>Custom Surface Package</label>' +
|
||||
'<select id="wfStageSurfacePkg" style="width:100%">' +
|
||||
'<option value="">— Built-in (use stage mode) —</option>' +
|
||||
'</select></div>' +
|
||||
'</div>' +
|
||||
|
||||
'<div id="wfFormBuilderWrap" style="display:none;margin-top:8px">' +
|
||||
'<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:6px">' +
|
||||
'<label style="margin:0;font-weight:600">Form Fields</label>' +
|
||||
@@ -103,6 +110,7 @@
|
||||
var _currentWf = null;
|
||||
var _editingStageId = null;
|
||||
var _personaCache = []; // [{id, name, icon}]
|
||||
var _surfacePkgCache = []; // [{id, title}]
|
||||
|
||||
// Load personas into the stage editor dropdown.
|
||||
async function _wfLoadPersonaSelect(selectedId) {
|
||||
@@ -138,6 +146,38 @@
|
||||
if (selectedId) sel.value = selectedId;
|
||||
}
|
||||
|
||||
// Load surface packages into the stage editor dropdown.
|
||||
async function _wfLoadSurfacePkgSelect(selectedId) {
|
||||
var sel = document.getElementById('wfStageSurfacePkg');
|
||||
if (!sel) return;
|
||||
|
||||
if (_surfacePkgCache.length === 0) {
|
||||
try {
|
||||
var resp = await fetch((window.__BASE__ || '') + '/api/v1/admin/packages', {
|
||||
headers: API._authHeaders ? API._authHeaders() : {},
|
||||
});
|
||||
var data = await resp.json();
|
||||
var pkgs = data.data || data || [];
|
||||
// Include packages that could have surface JS (type surface or workflow)
|
||||
_surfacePkgCache = pkgs.filter(function(p) {
|
||||
return p.type === 'surface' || p.type === 'workflow' || p.type === 'full';
|
||||
}).map(function(p) {
|
||||
return { id: p.id, title: p.title || p.id };
|
||||
});
|
||||
} catch (e) { /* no packages available */ }
|
||||
}
|
||||
|
||||
sel.innerHTML = '<option value="">— Built-in (use stage mode) —</option>';
|
||||
_surfacePkgCache.forEach(function(p) {
|
||||
var opt = document.createElement('option');
|
||||
opt.value = p.id;
|
||||
opt.textContent = p.title;
|
||||
sel.appendChild(opt);
|
||||
});
|
||||
|
||||
if (selectedId) sel.value = selectedId;
|
||||
}
|
||||
|
||||
// ── Loader (called from ADMIN_LOADERS.workflows) ──
|
||||
|
||||
sb.register('_loadAdminWorkflows', async function() {
|
||||
@@ -273,11 +313,15 @@
|
||||
} else if (s.stage_mode && s.stage_mode !== 'chat_only') {
|
||||
modeLabel = '<span class="badge badge-accent">' + esc(s.stage_mode.replace('_', ' ')) + '</span>';
|
||||
}
|
||||
var surfaceLabel = '';
|
||||
if (s.surface_pkg_id) {
|
||||
surfaceLabel = '<span class="badge badge-accent">pkg: ' + esc(s.surface_pkg_id) + '</span>';
|
||||
}
|
||||
html += '<div class="wf-stage-row" draggable="true" data-id="' + s.id + '" data-idx="' + i + '">' +
|
||||
'<span class="wf-stage-grip">⠿</span>' +
|
||||
'<span class="wf-stage-ord">' + i + '</span>' +
|
||||
'<span class="wf-stage-name">' + esc(s.name) + '</span>' +
|
||||
personaLabel + modeLabel +
|
||||
personaLabel + modeLabel + surfaceLabel +
|
||||
'<span class="badge">' + (s.history_mode || 'full') + '</span>' +
|
||||
'<button class="btn-small" data-action="_wfEditStage" data-args=\'' + JSON.stringify([s.id]) + '\'>Edit</button>' +
|
||||
'<button class="btn-small btn-danger" data-action="_wfDeleteStage" data-args=\'' + JSON.stringify([s.id]) + '\'>×</button>' +
|
||||
@@ -358,6 +402,7 @@
|
||||
_currentWf = null;
|
||||
_editingStageId = null;
|
||||
_personaCache = [];
|
||||
_surfacePkgCache = [];
|
||||
_wired = false;
|
||||
_loadAdminWorkflows();
|
||||
};
|
||||
@@ -402,6 +447,7 @@
|
||||
UI.toast('Deleted', 'success');
|
||||
_currentWf = null;
|
||||
_personaCache = [];
|
||||
_surfacePkgCache = [];
|
||||
_wired = false;
|
||||
_loadAdminWorkflows();
|
||||
} catch (e) {
|
||||
@@ -420,6 +466,7 @@
|
||||
document.getElementById('wfFormFields').innerHTML = '';
|
||||
_wfUpdateFormBuilderVisibility();
|
||||
await _wfLoadPersonaSelect('');
|
||||
await _wfLoadSurfacePkgSelect('');
|
||||
document.getElementById('wfStageEditor').style.display = '';
|
||||
};
|
||||
|
||||
@@ -462,6 +509,7 @@
|
||||
}
|
||||
|
||||
var personaId = document.getElementById('wfStagePersona').value || null;
|
||||
var surfacePkgId = document.getElementById('wfStageSurfacePkg').value || null;
|
||||
|
||||
var data = {
|
||||
name: name,
|
||||
@@ -470,6 +518,7 @@
|
||||
persona_id: personaId,
|
||||
system_prompt: document.getElementById('wfStagePrompt').value.trim() || undefined,
|
||||
form_template: formTemplate,
|
||||
surface_pkg_id: surfacePkgId,
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -512,6 +561,9 @@
|
||||
_wfPopulateFormBuilder(tpl);
|
||||
_wfUpdateFormBuilderVisibility();
|
||||
|
||||
// Surface package selector
|
||||
await _wfLoadSurfacePkgSelect(stage.surface_pkg_id || '');
|
||||
|
||||
document.getElementById('wfStageEditor').style.display = '';
|
||||
} catch (e) {
|
||||
UI.toast('Failed: ' + e.message, 'error');
|
||||
|
||||
Reference in New Issue
Block a user