@anmol-srv/sigil 0.18.2 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -25
- package/dist/cli.js +1191 -790
- package/dist/daemon.js +664 -302
- package/dist/hooks/post-tool-use.js +1 -69
- package/dist/hooks/session-end.js +13 -236
- package/dist/hooks/stop.js +36 -246
- package/dist/hooks/user-prompt-submit.js +25 -288
- package/dist/mcp/worker-server.js +6 -0
- package/dist/npm-entry.js +10 -0
- package/dist/server.js +64 -56
- package/install.sh +207 -0
- package/integrations/hermes/README.md +30 -24
- package/integrations/hermes/plugin/README.md +1 -1
- package/integrations/hermes/plugin/__init__.py +68 -24
- package/knexfile.js +19 -22
- package/package.json +9 -28
- package/prompts/audm-decision.md +26 -1
- package/prompts/entity-extraction.md +32 -30
- package/prompts/graph-extraction.md +20 -2
- package/src/db/drivers/index.js +38 -15
- package/src/db/migrations/20260629120000_add-trace-event-attribution.cjs +29 -0
- package/src/db/migrations/20260629120001_add-llm-log-session-correlation.cjs +29 -0
- package/src/db/migrations/20260806120000_add-document-content.cjs +27 -0
- package/src/db/migrations/20260806120001_llm-log-model-nullable.cjs +36 -0
- package/src/db/migrations/20260811120000_add-relation-provenance.cjs +42 -0
- package/src/db/migrations/20260811130000_add-fact-visibility.cjs +67 -0
- package/src/db/migrations/20260813090000_rescore-defaulted-vital.cjs +57 -0
- package/src/db/migrations/20260814120000_create-ingestion-job.cjs +52 -0
- package/src/db/migrations/20260814120100_add-llm-log-queued-ms.cjs +8 -0
- package/src/db/migrations/20260814120200_add-active-fact-content-hash-index.cjs +16 -0
- package/src/db/migrations/20260814120300_create-relation-candidate-judgment.cjs +25 -0
- package/src/gui/web/app.css +851 -84
- package/src/gui/web/app.js +796 -383
- package/src/gui/web/cmdk.js +238 -0
- package/src/gui/web/components.js +64 -0
- package/src/gui/web/design/colors_and_type.css +6 -1
- package/src/gui/web/graph/GraphIsland.jsx +450 -0
- package/src/gui/web/graph/cluster.js +305 -0
- package/src/gui/web/graph/cluster.test.js +219 -0
- package/src/gui/web/health.js +117 -0
- package/src/gui/web/health.test.js +159 -0
- package/src/gui/web/icons.js +65 -0
- package/src/gui/web/index.html +310 -115
- package/src/gui/web/settings.js +386 -0
- package/src/gui/web/setup.js +2 -2
- package/src/gui/web/toast.js +6 -3
- package/src/gui/web/vendor/graph-island.js +52 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings — rendered from the daemon's schema, not hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Every control is generated from `settings.schema`, so a knob added to
|
|
5
|
+
* settings-schema.js shows up with no dashboard change and the page can never
|
|
6
|
+
* offer something the daemon won't honour.
|
|
7
|
+
*
|
|
8
|
+
* The shape is deliberate. Forty-five controls in one scroll is the drift
|
|
9
|
+
* DESIGN.md warns about — the rest of the dashboard reveals one section at a
|
|
10
|
+
* time. Navigation is a rail: search at the top, then categories grouped by
|
|
11
|
+
* tier. Ten categories outgrow horizontal tabs (they cramp and then wrap); a
|
|
12
|
+
* vertical list has room for a label per row and stays readable as the schema
|
|
13
|
+
* grows. Nothing is hidden — everything stays one click away, and search cuts
|
|
14
|
+
* across every group at once.
|
|
15
|
+
*
|
|
16
|
+
* `extras` is why the rail is the WHOLE page rather than a widget on it. The
|
|
17
|
+
* Settings view used to be a stack of hand-written panels (the provider
|
|
18
|
+
* readout, the config-file dump, the RPC catalog, the danger zone) with this
|
|
19
|
+
* schema-driven rail wedged in the middle — two competing organisations on one
|
|
20
|
+
* screen, so "where do I change X" had two different answers depending on
|
|
21
|
+
* which X. An extra is a category whose body is an existing DOM node instead
|
|
22
|
+
* of generated rows: same rail, same panel, same heading. The nodes are parked
|
|
23
|
+
* in a hidden holder between visits because this page re-renders itself with
|
|
24
|
+
* innerHTML, which would otherwise destroy markup and listeners it does not
|
|
25
|
+
* own.
|
|
26
|
+
*
|
|
27
|
+
* Controls are chosen by what the value IS, not by its JS type. A similarity
|
|
28
|
+
* threshold is a position in a range, so it gets a slider you can feel plus a
|
|
29
|
+
* number you can type; a port is an arbitrary integer, so it stays a field. A
|
|
30
|
+
* boolean is a state you flip, so it gets a switch rather than a checkbox
|
|
31
|
+
* borrowed from a form.
|
|
32
|
+
*/
|
|
33
|
+
import { icon } from './icons.js';
|
|
34
|
+
import { confirmDialog } from './components.js';
|
|
35
|
+
|
|
36
|
+
const esc = (v) => String(v ?? '').replace(/[&<>"']/g, (c) => (
|
|
37
|
+
{ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
38
|
+
|
|
39
|
+
const CATEGORY_ICON = {
|
|
40
|
+
general: 'home', ingest: 'plus', memory: 'layers', search: 'search',
|
|
41
|
+
jev: 'graph', hebbian: 'graph', providers: 'database', engine: 'cpu', server: 'monitor',
|
|
42
|
+
output: 'doc', developer: 'terminal', danger: 'alert',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A slider only helps when the range has a graspable number of stops. 0–1 by
|
|
47
|
+
* 0.01 is a feel you can drag; a port across 64,511 values is a number you
|
|
48
|
+
* type, and pretending otherwise makes it unusable.
|
|
49
|
+
*/
|
|
50
|
+
const SLIDER_MAX_STOPS = 200;
|
|
51
|
+
function isSliderish(d) {
|
|
52
|
+
if (d.type !== 'number' || d.min == null || d.max == null) return false;
|
|
53
|
+
const step = d.step || 1;
|
|
54
|
+
const stops = (d.max - d.min) / step;
|
|
55
|
+
return stops > 1 && stops <= SLIDER_MAX_STOPS;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const fieldId = (path) => `set-${path.replace(/\./g, '-')}`;
|
|
59
|
+
|
|
60
|
+
function control(d) {
|
|
61
|
+
const id = fieldId(d.path);
|
|
62
|
+
const common = `id="${id}" data-path="${esc(d.path)}" data-type="${d.type}"`;
|
|
63
|
+
|
|
64
|
+
if (d.type === 'boolean') {
|
|
65
|
+
return `<button type="button" role="switch" class="set-switch" ${common}
|
|
66
|
+
aria-checked="${d.value ? 'true' : 'false'}" aria-labelledby="${id}-label">
|
|
67
|
+
<span class="set-switch-track"><span class="set-switch-thumb"></span></span>
|
|
68
|
+
</button>`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (d.type === 'enum') {
|
|
72
|
+
// A handful of named options is a segmented control, not a dropdown you
|
|
73
|
+
// have to open to discover what the choices even are.
|
|
74
|
+
return `<div class="set-segmented" role="radiogroup" ${common} aria-labelledby="${id}-label">
|
|
75
|
+
${d.options.map((o) => `<button type="button" role="radio" class="set-seg${o === d.value ? ' on' : ''}"
|
|
76
|
+
aria-checked="${o === d.value}" data-value="${esc(o)}">${esc(o)}</button>`).join('')}
|
|
77
|
+
</div>`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (isSliderish(d)) {
|
|
81
|
+
return `<div class="set-range">
|
|
82
|
+
<input type="range" ${common} value="${esc(d.value ?? d.min)}"
|
|
83
|
+
min="${d.min}" max="${d.max}" step="${d.step ?? 1}" aria-labelledby="${id}-label">
|
|
84
|
+
<output class="set-range-out" for="${id}">${esc(d.value ?? d.min)}</output>
|
|
85
|
+
</div>`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (d.type === 'number') {
|
|
89
|
+
return `<input class="input set-input" type="number" ${common} value="${esc(d.value ?? '')}"
|
|
90
|
+
${d.min != null ? `min="${d.min}"` : ''} ${d.max != null ? `max="${d.max}"` : ''}
|
|
91
|
+
${d.step != null ? `step="${d.step}"` : ''} aria-labelledby="${id}-label">`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return `<input class="input set-input" type="text" ${common} value="${esc(d.value ?? '')}"
|
|
95
|
+
placeholder="${esc(d.placeholder || '')}" autocomplete="off" spellcheck="false" aria-labelledby="${id}-label">`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function row(d) {
|
|
99
|
+
const id = fieldId(d.path);
|
|
100
|
+
return `<div class="set-row" data-row="${esc(d.path)}" data-search="${esc((d.label + ' ' + (d.help || '') + ' ' + d.path).toLowerCase())}">
|
|
101
|
+
<div class="set-row-text">
|
|
102
|
+
<span class="set-row-label" id="${id}-label">${esc(d.label)}${d.restart ? '<span class="set-restart" title="Read only at daemon boot">restart</span>' : ''}</span>
|
|
103
|
+
${d.help ? `<p class="set-row-help">${esc(d.help)}</p>` : ''}
|
|
104
|
+
<div class="set-row-error" data-error-for="${esc(d.path)}"></div>
|
|
105
|
+
</div>
|
|
106
|
+
<div class="set-row-control">${control(d)}</div>
|
|
107
|
+
</div>`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function initSettings({ rpc, toast, mount, extras = [], sectionExtras = {} }) {
|
|
111
|
+
const host = typeof mount === 'string' ? document.querySelector(mount) : mount;
|
|
112
|
+
if (!host) return { refresh: () => {} };
|
|
113
|
+
|
|
114
|
+
let schema = null;
|
|
115
|
+
let active = null;
|
|
116
|
+
let query = '';
|
|
117
|
+
|
|
118
|
+
const flat = () => schema.flat;
|
|
119
|
+
const el = (sel) => host.querySelector(sel);
|
|
120
|
+
|
|
121
|
+
const valueOf = (node) => {
|
|
122
|
+
const t = node.dataset.type;
|
|
123
|
+
if (t === 'boolean') return node.getAttribute('aria-checked') === 'true';
|
|
124
|
+
if (t === 'enum') return node.querySelector('.set-seg.on')?.dataset.value ?? '';
|
|
125
|
+
if (t === 'number') return node.value === '' ? '' : Number(node.value);
|
|
126
|
+
return node.value;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
function dirty() {
|
|
130
|
+
const out = {};
|
|
131
|
+
for (const node of host.querySelectorAll('[data-path]')) {
|
|
132
|
+
const def = flat().get(node.dataset.path);
|
|
133
|
+
if (!def) continue;
|
|
134
|
+
const now = valueOf(node);
|
|
135
|
+
const was = def.value ?? (def.type === 'boolean' ? false : '');
|
|
136
|
+
if (String(now) !== String(was)) out[node.dataset.path] = now;
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function syncBar() {
|
|
142
|
+
const n = Object.keys(dirty()).length;
|
|
143
|
+
const bar = el('.set-bar');
|
|
144
|
+
if (!bar) return;
|
|
145
|
+
bar.classList.toggle('on', n > 0);
|
|
146
|
+
const count = el('.set-bar-count');
|
|
147
|
+
if (count) count.textContent = n ? `${n} unsaved change${n === 1 ? '' : 's'}` : '';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function visibleCount(section) {
|
|
151
|
+
// An extra owns handwritten markup, so there are no rows to count and
|
|
152
|
+
// nothing for the search index to match; it stays listed but scores zero.
|
|
153
|
+
if (section.extra) return query ? 0 : 1;
|
|
154
|
+
if (!query) return section.settings.length;
|
|
155
|
+
return section.settings.filter((d) => (`${d.label} ${d.help || ''} ${d.path}`).toLowerCase().includes(query)).length;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Extras come first inside a tier so the concrete thing (which database, which
|
|
159
|
+
// provider) sits above the knobs that tune it.
|
|
160
|
+
const allSections = () => [...extras.map((x) => ({ ...x, extra: true })), ...schema.sections];
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Put every extra back in its holder. Called before the rail re-renders,
|
|
164
|
+
* because render() replaces host.innerHTML — an extra still mounted in the
|
|
165
|
+
* body would be dropped on the floor along with its listeners.
|
|
166
|
+
*/
|
|
167
|
+
function parkExtras() {
|
|
168
|
+
const holder = document.getElementById('settings-extras');
|
|
169
|
+
if (!holder) return;
|
|
170
|
+
const nodes = [...extras.map((x) => x.node), ...Object.values(sectionExtras)];
|
|
171
|
+
for (const selector of nodes) {
|
|
172
|
+
const node = document.querySelector(selector);
|
|
173
|
+
if (node && node.parentElement !== holder) holder.appendChild(node);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function render() {
|
|
178
|
+
parkExtras();
|
|
179
|
+
const grouped = schema.tiers.map((t) => ({
|
|
180
|
+
...t,
|
|
181
|
+
sections: allSections().filter((sec) => (sec.tier || 'system') === t.id),
|
|
182
|
+
})).filter((g) => g.sections.length);
|
|
183
|
+
// Rail order, not schema order: the fallback category has to be the row a
|
|
184
|
+
// reader's eye lands on, which is the first row of the first tier.
|
|
185
|
+
const sections = grouped.flatMap((g) => g.sections);
|
|
186
|
+
|
|
187
|
+
// Follow the hits. Searching from a category with no matches used to render
|
|
188
|
+
// "no setting matches" while the term hit rows in another group.
|
|
189
|
+
if (query) {
|
|
190
|
+
const here = sections.find((sec) => sec.id === active);
|
|
191
|
+
if (!here || !visibleCount(here)) {
|
|
192
|
+
const hit = sections.find((sec) => visibleCount(sec) > 0);
|
|
193
|
+
if (hit) active = hit.id;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
if (!sections.some((sec) => sec.id === active)) active = sections[0]?.id ?? null;
|
|
197
|
+
|
|
198
|
+
const railGroup = (g) => {
|
|
199
|
+
const items = g.sections.map((sec) => {
|
|
200
|
+
const n = visibleCount(sec);
|
|
201
|
+
return `<button class="set-nav-item${sec.id === active ? ' active' : ''}${query && !n ? ' dim' : ''}"
|
|
202
|
+
type="button" data-cat="${esc(sec.id)}" aria-current="${sec.id === active ? 'page' : 'false'}">
|
|
203
|
+
${icon(CATEGORY_ICON[sec.id] || 'sliders')}<span>${esc(sec.title)}</span>
|
|
204
|
+
${query ? `<span class="set-nav-count">${n}</span>` : ''}
|
|
205
|
+
</button>`;
|
|
206
|
+
}).join('');
|
|
207
|
+
return `<div class="set-nav-section">
|
|
208
|
+
<div class="set-nav-group">${esc(g.label)}</div>${items}
|
|
209
|
+
</div>`;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const sec = sections.find((x) => x.id === active);
|
|
213
|
+
const sectionExtraNode = sec.extra ? null : sectionExtras[sec.id];
|
|
214
|
+
const rows = sec.extra ? '' : sec.settings
|
|
215
|
+
.filter((d) => !query || (`${d.label} ${d.help || ''} ${d.path}`).toLowerCase().includes(query))
|
|
216
|
+
.map(row).join('');
|
|
217
|
+
const tierOf = schema.tiers.find((t) => t.id === (sec.tier || 'system'));
|
|
218
|
+
|
|
219
|
+
host.innerHTML = `
|
|
220
|
+
<div class="set-shell">
|
|
221
|
+
<nav class="set-nav" aria-label="Settings categories">
|
|
222
|
+
<label class="set-search">
|
|
223
|
+
${icon('search')}
|
|
224
|
+
<input type="search" placeholder="Search settings…" aria-label="Search settings" value="${esc(query)}" autocomplete="off">
|
|
225
|
+
</label>
|
|
226
|
+
${grouped.map(railGroup).join('')}
|
|
227
|
+
</nav>
|
|
228
|
+
<div class="set-panel">
|
|
229
|
+
<header class="set-panel-head">
|
|
230
|
+
<h3>${esc(sec.title)}</h3>
|
|
231
|
+
${sec.help ? `<p>${esc(sec.help)}</p>`
|
|
232
|
+
: tierOf?.help ? `<p>${esc(tierOf.help)}</p>` : ''}
|
|
233
|
+
</header>
|
|
234
|
+
<div class="set-body${sec.extra ? ' set-body-extra' : ''}">
|
|
235
|
+
${sec.extra ? '' : `${sectionExtraNode ? '<div class="set-inline-extra"></div>' : ''}${rows || `<div class="empty">No setting matches “${esc(query)}”. Try a different word, or clear the search.</div>`}`}
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
${sec.extra ? '' : `<div class="set-bar" role="status">
|
|
240
|
+
<span class="set-bar-count"></span>
|
|
241
|
+
<button class="btn" type="button" data-act="revert">Revert</button>
|
|
242
|
+
<button class="btn primary" type="button" data-act="save">Save changes</button>
|
|
243
|
+
</div>`}`;
|
|
244
|
+
|
|
245
|
+
// An extra's body is a live node, not markup — mount it after the wipe.
|
|
246
|
+
if (sec.extra) {
|
|
247
|
+
const node = document.querySelector(sec.node);
|
|
248
|
+
if (node) el('.set-body').appendChild(node);
|
|
249
|
+
else el('.set-body').innerHTML = '<div class="empty">This section failed to mount.</div>';
|
|
250
|
+
} else if (sectionExtraNode) {
|
|
251
|
+
const node = document.querySelector(sectionExtraNode);
|
|
252
|
+
if (node) el('.set-inline-extra').appendChild(node);
|
|
253
|
+
}
|
|
254
|
+
syncBar();
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async function load() {
|
|
258
|
+
parkExtras();
|
|
259
|
+
host.innerHTML = '<div class="empty">Loading settings…</div>';
|
|
260
|
+
try {
|
|
261
|
+
const { sections, tiers } = await rpc('settings.schema');
|
|
262
|
+
schema = {
|
|
263
|
+
sections,
|
|
264
|
+
// Fall back rather than crash if an older daemon has no tiers: the
|
|
265
|
+
// page still works as a flat category list.
|
|
266
|
+
tiers: tiers?.length ? tiers : [{ id: 'advanced', label: 'All settings', help: null }],
|
|
267
|
+
flat: new Map(sections.flatMap((s) => s.settings.map((d) => [d.path, d]))),
|
|
268
|
+
};
|
|
269
|
+
// render() picks the landing category in rail order; only clear a stale one.
|
|
270
|
+
if (active && ![...sections, ...extras].some((s) => s.id === active)) active = null;
|
|
271
|
+
render();
|
|
272
|
+
} catch (err) {
|
|
273
|
+
host.innerHTML = `<div class="empty">Couldn’t load settings: ${esc(err.message)}</div>`;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// ── interaction ──────────────────────────────────────────────────────
|
|
278
|
+
host.addEventListener('click', async (e) => {
|
|
279
|
+
const tab = e.target.closest('[data-cat]');
|
|
280
|
+
if (tab) {
|
|
281
|
+
// Switching category with unsaved edits would silently discard them.
|
|
282
|
+
if (Object.keys(dirty()).length && !(await confirmDialog({
|
|
283
|
+
title: 'Discard unsaved changes?',
|
|
284
|
+
message: 'You have edits on this page that have not been saved. Leaving this category throws them away.',
|
|
285
|
+
confirmLabel: 'Discard',
|
|
286
|
+
cancelLabel: 'Keep editing',
|
|
287
|
+
danger: true,
|
|
288
|
+
}))) return;
|
|
289
|
+
active = tab.dataset.cat;
|
|
290
|
+
render();
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const sw = e.target.closest('.set-switch');
|
|
295
|
+
if (sw) {
|
|
296
|
+
sw.setAttribute('aria-checked', sw.getAttribute('aria-checked') === 'true' ? 'false' : 'true');
|
|
297
|
+
syncBar();
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const seg = e.target.closest('.set-seg');
|
|
302
|
+
if (seg) {
|
|
303
|
+
for (const b of seg.parentElement.querySelectorAll('.set-seg')) {
|
|
304
|
+
const on = b === seg;
|
|
305
|
+
b.classList.toggle('on', on);
|
|
306
|
+
b.setAttribute('aria-checked', String(on));
|
|
307
|
+
}
|
|
308
|
+
syncBar();
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
const act = e.target.closest('[data-act]')?.dataset.act;
|
|
313
|
+
if (act === 'revert') { load(); return; }
|
|
314
|
+
if (act !== 'save') return;
|
|
315
|
+
|
|
316
|
+
const updates = dirty();
|
|
317
|
+
if (!Object.keys(updates).length) return;
|
|
318
|
+
const btn = e.target.closest('[data-act="save"]');
|
|
319
|
+
btn.disabled = true;
|
|
320
|
+
host.querySelectorAll('.set-row-error').forEach((n) => { n.textContent = ''; });
|
|
321
|
+
|
|
322
|
+
try {
|
|
323
|
+
const res = await rpc('settings.set', { updates });
|
|
324
|
+
if (!res.ok) {
|
|
325
|
+
// Errors land on the field that caused them, and the row is marked so
|
|
326
|
+
// it is findable without hunting the category.
|
|
327
|
+
for (const [path, msg] of Object.entries(res.errors || {})) {
|
|
328
|
+
const slot = host.querySelector(`[data-error-for="${path}"]`);
|
|
329
|
+
if (slot) slot.textContent = msg;
|
|
330
|
+
host.querySelector(`[data-row="${path}"]`)?.classList.add('invalid');
|
|
331
|
+
}
|
|
332
|
+
toast({ variant: 'error', message: 'Some settings were not saved.', hint: 'The fields with a message were rejected; nothing was written.' });
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
await load();
|
|
336
|
+
toast({
|
|
337
|
+
variant: 'success',
|
|
338
|
+
message: `Saved ${res.changed.length} setting${res.changed.length === 1 ? '' : 's'}.`,
|
|
339
|
+
hint: res.restartRequired
|
|
340
|
+
? `${res.restartFor.join(', ')} ${res.restartFor.length === 1 ? 'takes' : 'take'} effect after a daemon restart.`
|
|
341
|
+
: undefined,
|
|
342
|
+
});
|
|
343
|
+
} catch (err) {
|
|
344
|
+
toast({ variant: 'error', message: `Couldn’t save: ${err.message}`, code: err.code });
|
|
345
|
+
} finally {
|
|
346
|
+
btn.disabled = false;
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
host.addEventListener('input', (e) => {
|
|
351
|
+
const search = e.target.closest('.set-search input');
|
|
352
|
+
if (search) {
|
|
353
|
+
query = search.value.trim().toLowerCase();
|
|
354
|
+
const at = search.selectionStart;
|
|
355
|
+
render();
|
|
356
|
+
const next = el('.set-search input');
|
|
357
|
+
next.focus();
|
|
358
|
+
next.setSelectionRange(at, at);
|
|
359
|
+
return;
|
|
360
|
+
}
|
|
361
|
+
const range = e.target.closest('input[type="range"]');
|
|
362
|
+
if (range) {
|
|
363
|
+
// Live readout: a slider without its value is a guess.
|
|
364
|
+
range.parentElement.querySelector('.set-range-out').textContent = range.value;
|
|
365
|
+
}
|
|
366
|
+
if (e.target.closest('[data-path]')) syncBar();
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
// Keyboard parity for the custom controls — a switch that only responds to
|
|
370
|
+
// the mouse is not a control, it is a picture of one.
|
|
371
|
+
host.addEventListener('keydown', (e) => {
|
|
372
|
+
const sw = e.target.closest('.set-switch');
|
|
373
|
+
if (sw && (e.key === ' ' || e.key === 'Enter')) { e.preventDefault(); sw.click(); }
|
|
374
|
+
const seg = e.target.closest('.set-seg');
|
|
375
|
+
if (seg && (e.key === 'ArrowRight' || e.key === 'ArrowLeft')) {
|
|
376
|
+
e.preventDefault();
|
|
377
|
+
const all = [...seg.parentElement.querySelectorAll('.set-seg')];
|
|
378
|
+
const i = all.indexOf(seg);
|
|
379
|
+
const nextEl = all[(i + (e.key === 'ArrowRight' ? 1 : all.length - 1)) % all.length];
|
|
380
|
+
nextEl.click();
|
|
381
|
+
nextEl.focus();
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
return { refresh: load };
|
|
386
|
+
}
|
package/src/gui/web/setup.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import { rpc } from './api.js';
|
|
14
14
|
import { toast } from './toast.js';
|
|
15
|
-
import { connectorCard } from './components.js';
|
|
15
|
+
import { connectorCard, fieldControl } from './components.js';
|
|
16
16
|
|
|
17
17
|
const $ = (s, r = document) => r.querySelector(s);
|
|
18
18
|
const esc = (v) => String(v ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
@@ -112,7 +112,7 @@ function fieldInputs(fields, sharedNote) {
|
|
|
112
112
|
return note + fields.map((f) => `
|
|
113
113
|
<label class="field">
|
|
114
114
|
<span class="label">${esc(f.label)}${f.optional ? ' <span class="muted text-xs">(optional)</span>' : ''}</span>
|
|
115
|
-
|
|
115
|
+
${fieldControl(f, 'data-setup-field')}
|
|
116
116
|
</label>`).join('');
|
|
117
117
|
}
|
|
118
118
|
|
package/src/gui/web/toast.js
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
* Central toast feedback — the only channel for transient status/errors.
|
|
3
3
|
* Design-system styled: a sharp surface-1 panel with a hairline border, a 7px
|
|
4
4
|
* status square (red/green/amber/brand) and an optional mono error code.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Everything auto-dismisses — errors linger longer because they carry more to
|
|
6
|
+
* read, but a toast nobody closes should not become permanent furniture. Pass
|
|
7
|
+
* `timeout: 0` for the rare case that must stay until code dismisses it (an
|
|
8
|
+
* in-flight "saving…" that its own callback clears). Replaces every inline
|
|
9
|
+
* `out.textContent = …` / `alert()` in the old GUI.
|
|
7
10
|
*/
|
|
8
11
|
function host() {
|
|
9
12
|
return document.getElementById('toasts');
|
|
@@ -52,7 +55,7 @@ export function toast({ variant = 'info', message = '', hint, code, timeout } =
|
|
|
52
55
|
el.append(sq, body, x);
|
|
53
56
|
stack.appendChild(el);
|
|
54
57
|
|
|
55
|
-
const ttl = timeout != null ? timeout : (variant === 'error' ?
|
|
58
|
+
const ttl = timeout != null ? timeout : (variant === 'error' ? 9000 : 4000);
|
|
56
59
|
if (ttl > 0) setTimeout(remove, ttl);
|
|
57
60
|
return remove;
|
|
58
61
|
}
|