@leitwerk-dev/ui 0.3.1 → 0.4.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/dist/assets/ApiTokensPage-DCmYvZdE.js +1 -0
- package/dist/assets/ChronicleMarkdown-6T_LF-3B.js +1 -0
- package/dist/assets/FutureLaunchDetailPage-D5Gc8YmZ.js +1 -0
- package/dist/assets/GenericLauncher-4BQGl6fT.js +4 -0
- package/dist/assets/GenericLauncher-DRUMMTd7.css +1 -0
- package/dist/assets/HomePage-mb9RzXht.js +1 -0
- package/dist/assets/ProcessActionsMenu-CEzADnZT.js +1 -0
- package/dist/assets/ProcessDetailPage-0c-fMf4Y.js +14 -0
- package/dist/assets/ProcessDetailPage-km76G8wj.css +1 -0
- package/dist/assets/ProcessFlowDiagram-DI5KZ2Qj.js +1 -0
- package/dist/assets/ProcessFlowDiagram-NQ6oEZi7.css +1 -0
- package/dist/assets/ProcessesPage-CVvENTJg.js +1 -0
- package/dist/assets/ScheduleDateTimePicker-2eJ0jBQ-.css +1 -0
- package/dist/assets/ScheduleDateTimePicker-fg0Vau5Z.js +3 -0
- package/dist/assets/SettingsPage-BHSV4rl7.css +1 -0
- package/dist/assets/SettingsPage-CbNM5RWn.js +2 -0
- package/dist/assets/SkillsPage-rCSwSz89.js +2 -0
- package/dist/assets/WatchersPage-D-uT5vWk.js +1 -0
- package/dist/assets/WikiPage-BNdWnJ6L.js +1 -0
- package/dist/assets/WikiPage-Bvnhxl3m.css +1 -0
- package/dist/assets/http-client-Cvi3zOou.js +2 -0
- package/dist/assets/http-contracts-public-BXXSFKbw.js +1 -0
- package/dist/assets/index-DybyOt1_.css +1 -0
- package/dist/assets/{index-client-BYQviCtQ.js → index-client-BSAA7n1a.js} +2 -2
- package/dist/assets/index-gVt2yBO1.js +21 -0
- package/dist/assets/mermaid-render.worker-BN0bcvGc.js +6398 -0
- package/dist/assets/retry-config.svelte-HNNF65qc.js +1 -0
- package/dist/assets/settings-Dk5UoSQa.js +1 -0
- package/dist/index.html +4 -7
- package/package.json +10 -9
- package/src/App.svelte +9 -0
- package/src/chronicle/components/ChronicleActionSection.svelte +10 -2
- package/src/chronicle/components/ChronicleEntryHeader.svelte +4 -16
- package/src/chronicle/components/ChronicleFlow.svelte +24 -6
- package/src/chronicle/components/ChronicleLiveTail.svelte +52 -24
- package/src/chronicle/components/ChronicleProcessErrorSection.svelte +14 -0
- package/src/chronicle/components/ChronicleQuestionRequest.svelte +1 -1
- package/src/chronicle/components/ChronicleRecoverySection.svelte +14 -10
- package/src/chronicle/components/ChronicleStartupRecoverySection.svelte +14 -10
- package/src/chronicle/components/ChronicleThinkingSection.svelte +8 -2
- package/src/chronicle/components/ChronicleToolApproval.svelte +120 -17
- package/src/chronicle/components/ChronicleToolCallItem.svelte +32 -6
- package/src/chronicle/components/ChronicleTurnCluster.svelte +6 -6
- package/src/chronicle/components/ChronicleTurnProgress.svelte +10 -4
- package/src/chronicle/components/ChronicleTurnRail.svelte +1 -0
- package/src/chronicle/components/RecoveryModelControl.svelte +14 -13
- package/src/chronicle/lib/chronicle-projection.ts +74 -376
- package/src/chronicle/lib/chronicle-selectable-items.ts +23 -3
- package/src/chronicle/lib/recovery-model.ts +17 -0
- package/src/components/ConversationTreeDiagram.svelte +93 -30
- package/src/components/FormFieldRenderer.svelte +184 -27
- package/src/components/GenericLauncher.svelte +378 -166
- package/src/components/NamedSelectionList.svelte +77 -0
- package/src/components/ProcessSettings.svelte +110 -0
- package/src/components/ScheduleDateTimePicker.svelte +9 -4
- package/src/components/SettingsField.svelte +317 -0
- package/src/components/SettingsOverview.svelte +237 -0
- package/src/components/SkillSelector.svelte +15 -3
- package/src/components/launcher-form-copy.ts +2 -1
- package/src/components/launcher-model-config.ts +8 -7
- package/src/components/launcher-selections.ts +123 -0
- package/src/lib/api.ts +89 -43
- package/src/lib/http-client.ts +20 -1
- package/src/lib/instance-tree-layout.ts +41 -10
- package/src/lib/primary-path-detail.ts +56 -341
- package/src/lib/primary-path-replay.ts +8 -9
- package/src/lib/process-history.ts +57 -0
- package/src/lib/processes.svelte.ts +71 -79
- package/src/lib/reasoning-history.ts +31 -23
- package/src/lib/router-logic.ts +101 -51
- package/src/lib/router.svelte.ts +4 -4
- package/src/lib/settings.ts +114 -0
- package/src/lib/wiki.ts +34 -0
- package/src/pages/ProcessDetailPage.svelte +55 -344
- package/src/pages/ProcessFlowDiagram.svelte +39 -684
- package/src/pages/SettingsPage.svelte +265 -0
- package/src/pages/SkillsPage.svelte +26 -12
- package/src/pages/WikiPage.svelte +9 -0
- package/src/pages/process-detail/ProcessDetailChronicle.svelte +57 -13
- package/src/pages/process-detail/ProcessDetailHeader.svelte +9 -3
- package/src/pages/process-detail/TicketCreationComposer.svelte +49 -10
- package/src/pages/process-detail/inspector/ExecutionDetails.svelte +210 -0
- package/src/pages/process-detail/inspector/InspectionEvidence.svelte +48 -0
- package/src/pages/process-detail/inspector/InspectionMessage.svelte +71 -0
- package/src/pages/process-detail/inspector/ProcessInspector.svelte +144 -0
- package/src/pages/process-detail/inspector/ProcessModelEditor.svelte +161 -0
- package/src/pages/process-detail/inspector/ProcessReference.svelte +166 -0
- package/src/pages/process-detail/inspector/inspection-activity.ts +118 -0
- package/src/pages/process-detail/inspector/inspection-data.svelte.ts +107 -0
- package/src/pages/process-detail/inspector/inspection-tool-call.ts +30 -0
- package/src/pages/process-detail/inspector/inspector-navigation.ts +190 -0
- package/src/pages/process-detail/inspector/model-source-label.ts +17 -0
- package/src/pages/process-detail/process-detail-actions.svelte.ts +10 -0
- package/src/pages/process-detail/process-detail-chronicle-scroll.svelte.ts +18 -2
- package/src/pages/process-detail/process-detail-view-model.ts +2 -2
- package/src/shell/AppShell.svelte +5 -0
- package/src/shell/Sidebar.svelte +10 -0
- package/src/test-support/mount.ts +34 -0
- package/dist/assets/ApiTokensPage-ClJp9PYr.js +0 -1
- package/dist/assets/ChronicleMarkdown-lqwX9Ywa.js +0 -16
- package/dist/assets/FutureLaunchDetailPage-ygp-IdXC.js +0 -1
- package/dist/assets/GenericLauncher-CExW6wei.css +0 -1
- package/dist/assets/GenericLauncher-DOwsERpB.js +0 -1
- package/dist/assets/HomePage-D1J-Rmsw.js +0 -1
- package/dist/assets/PageHeader-DPuQInDo.css +0 -1
- package/dist/assets/PageHeader-sphJnWL1.js +0 -1
- package/dist/assets/ProcessActionsMenu-DV9zaxNS.js +0 -1
- package/dist/assets/ProcessDetailPage-BW1M2IH8.js +0 -14
- package/dist/assets/ProcessDetailPage-Cth6A0DN.css +0 -1
- package/dist/assets/ProcessFlowDiagram-Cz8wNicU.css +0 -1
- package/dist/assets/ProcessFlowDiagram-Dx2wheGN.js +0 -2
- package/dist/assets/ProcessesPage-CSPH5L7E.js +0 -1
- package/dist/assets/ScheduleDateTimePicker-DmojMRxN.js +0 -1
- package/dist/assets/ScheduleDateTimePicker-uacJAkIq.css +0 -1
- package/dist/assets/SkillsPage-KnLql0n1.js +0 -2
- package/dist/assets/WatchersPage-B4jf3Ywp.js +0 -1
- package/dist/assets/http-client-VpPXJwbR.js +0 -2
- package/dist/assets/index-DPCokDbS.js +0 -6
- package/dist/assets/index-DtEI5gsQ.css +0 -1
- package/dist/assets/mermaid-render.worker-QW2WZpEE.js +0 -6393
- package/dist/assets/process-terminal-display-BQRQwGod.js +0 -1
- package/dist/assets/router.svelte-EEldxHlO.js +0 -1
- package/src/chronicle/components/ChronicleReasoningDetailsOverlay.svelte +0 -855
- package/src/components/ProcessInfoOverlay.svelte +0 -1221
- package/src/lib/flow-layout.ts +0 -319
- package/src/pages/process-detail/OverlayFrame.svelte +0 -58
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { NamedSelection, SettingChoice } from "@leitwerk-dev/protocol/http-contracts";
|
|
3
|
+
import { tick } from "svelte";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
rows,
|
|
7
|
+
choices,
|
|
8
|
+
busy,
|
|
9
|
+
id,
|
|
10
|
+
onChange,
|
|
11
|
+
}: {
|
|
12
|
+
rows: NamedSelection[];
|
|
13
|
+
choices: readonly SettingChoice[];
|
|
14
|
+
busy: boolean;
|
|
15
|
+
id: string;
|
|
16
|
+
onChange: (rows: NamedSelection[]) => void;
|
|
17
|
+
} = $props();
|
|
18
|
+
function update(rowId: string, change: Partial<NamedSelection>) {
|
|
19
|
+
onChange(rows.map((row) => (row.id === rowId ? { ...row, ...change } : row)));
|
|
20
|
+
}
|
|
21
|
+
async function add() {
|
|
22
|
+
const rowId = crypto.randomUUID();
|
|
23
|
+
onChange([...rows, { id: rowId, name: "", values: [] }]);
|
|
24
|
+
await tick();
|
|
25
|
+
document.getElementById(`${id}-${rowId}`)?.focus();
|
|
26
|
+
}
|
|
27
|
+
async function remove(rowId: string) {
|
|
28
|
+
onChange(rows.filter((row) => row.id !== rowId));
|
|
29
|
+
await tick();
|
|
30
|
+
document.getElementById(`${id}-add`)?.focus();
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<div class="named-selections">
|
|
35
|
+
{#each rows as row, index (row.id)}
|
|
36
|
+
<fieldset disabled={busy}>
|
|
37
|
+
<legend>{row.name || `Group ${index + 1}`}</legend>
|
|
38
|
+
<div class="row-heading">
|
|
39
|
+
<label for={`${id}-${row.id}`}>Group name
|
|
40
|
+
<input id={`${id}-${row.id}`} value={row.name} required oninput={(event) => update(row.id, { name: event.currentTarget.value })} />
|
|
41
|
+
</label>
|
|
42
|
+
<button type="button" aria-label={`Remove ${row.name || `group ${index + 1}`}`} onclick={() => remove(row.id)}>Remove group</button>
|
|
43
|
+
</div>
|
|
44
|
+
<p aria-live="polite">{row.values.length} selected</p>
|
|
45
|
+
<div class="options">
|
|
46
|
+
{#each choices as choice (choice.value)}
|
|
47
|
+
<label class="option">
|
|
48
|
+
<input type="checkbox" checked={row.values.includes(choice.value)} disabled={Boolean(choice.disabledReason) && !row.values.includes(choice.value)} onchange={(event) => update(row.id, { values: event.currentTarget.checked ? [...new Set([...row.values, choice.value])] : row.values.filter((value) => value !== choice.value) })} />
|
|
49
|
+
<span>{choice.label}{choice.disabledReason ? ` — ${choice.disabledReason}` : ""}</span>
|
|
50
|
+
</label>
|
|
51
|
+
{/each}
|
|
52
|
+
</div>
|
|
53
|
+
</fieldset>
|
|
54
|
+
{:else}
|
|
55
|
+
<p>No groups. Add a group, name it, then search for its members.</p>
|
|
56
|
+
{/each}
|
|
57
|
+
<button id={`${id}-add`} type="button" disabled={busy} onclick={add}>Add group</button>
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<style>
|
|
61
|
+
.named-selections { display: grid; gap: 1.25rem; min-width: 0; }
|
|
62
|
+
fieldset { border: 0; border-top: 1px solid var(--chronicle-border); padding: 1rem 0 0; min-width: 0; }
|
|
63
|
+
legend { font-weight: 600; overflow-wrap: anywhere; }
|
|
64
|
+
.row-heading { display: flex; gap: 1rem; align-items: end; }
|
|
65
|
+
.row-heading label { flex: 1; min-width: 0; font-size: var(--type-body-sm); }
|
|
66
|
+
input:not([type="checkbox"]) { display: block; width: 100%; margin-top: .4rem; min-height: 44px; border: 1px solid var(--chronicle-border-strong); border-radius: var(--radius-sm); padding: .7rem; background: var(--chronicle-panel-surface); color: var(--chronicle-text); font: inherit; }
|
|
67
|
+
p { color: var(--chronicle-text-muted); font-size: var(--type-body-sm); }
|
|
68
|
+
.options { max-height: 16rem; overflow: auto; }
|
|
69
|
+
.option { display: flex; gap: .75rem; align-items: center; min-height: 44px; cursor: pointer; }
|
|
70
|
+
.option span { overflow-wrap: anywhere; min-width: 0; }
|
|
71
|
+
input[type="checkbox"] { flex: 0 0 auto; accent-color: var(--chronicle-accent); }
|
|
72
|
+
button { min-height: 44px; justify-self: start; padding: .5rem .85rem; border: 1px solid var(--chronicle-border-strong); border-radius: var(--radius-sm); background: var(--chronicle-panel-surface); color: var(--chronicle-text); font: inherit; cursor: pointer; }
|
|
73
|
+
button:hover:not(:disabled), .option:hover { background: var(--chronicle-panel-muted); }
|
|
74
|
+
button:disabled { opacity: .6; cursor: default; }
|
|
75
|
+
button:focus-visible, input:focus-visible { outline: 2px solid var(--chronicle-accent); outline-offset: 3px; }
|
|
76
|
+
@media (max-width: 600px) { .row-heading { flex-direction: column; align-items: stretch; } }
|
|
77
|
+
</style>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ResolvedSetting, ScopedSettingsSnapshot } from "@leitwerk-dev/domain";
|
|
3
|
+
import { onMount, tick } from "svelte";
|
|
4
|
+
import {
|
|
5
|
+
bindPrimaryRepository,
|
|
6
|
+
fetchProcessSettings,
|
|
7
|
+
onSettingsChanged,
|
|
8
|
+
type ProcessSettingsView,
|
|
9
|
+
SettingsRequestError,
|
|
10
|
+
settingsPath,
|
|
11
|
+
} from "../lib/settings.js";
|
|
12
|
+
|
|
13
|
+
let { instanceId, refreshVersion }: { instanceId: string; refreshVersion?: string } = $props();
|
|
14
|
+
let data = $state<ProcessSettingsView | null>(null);
|
|
15
|
+
let error = $state("");
|
|
16
|
+
let primary = $state("");
|
|
17
|
+
let busy = $state(false);
|
|
18
|
+
let dirty = $state(false);
|
|
19
|
+
let expectedPrimary = $state<string | null>(null);
|
|
20
|
+
let conflict = $state(false);
|
|
21
|
+
let notice = $state("");
|
|
22
|
+
let loadId = 0;
|
|
23
|
+
let alive = true;
|
|
24
|
+
const source = (setting: ResolvedSetting) =>
|
|
25
|
+
setting.sources
|
|
26
|
+
.map((item) => `${item.label}${item.revision ? ` (revision ${item.revision})` : ""}`)
|
|
27
|
+
.join(" → ");
|
|
28
|
+
async function load() {
|
|
29
|
+
const token = ++loadId;
|
|
30
|
+
try {
|
|
31
|
+
const result = await fetchProcessSettings(instanceId);
|
|
32
|
+
if (alive && token === loadId) {
|
|
33
|
+
data = result;
|
|
34
|
+
if (!dirty) {
|
|
35
|
+
primary = result.primaryRepositoryKey ?? "";
|
|
36
|
+
expectedPrimary = result.primaryRepositoryKey;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} catch (caught) {
|
|
40
|
+
if (alive && token === loadId)
|
|
41
|
+
error = caught instanceof Error ? caught.message : "Could not load settings";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
$effect(() => {
|
|
45
|
+
refreshVersion;
|
|
46
|
+
void load();
|
|
47
|
+
});
|
|
48
|
+
onMount(() => {
|
|
49
|
+
const unsubscribe = onSettingsChanged(load);
|
|
50
|
+
return () => {
|
|
51
|
+
alive = false;
|
|
52
|
+
unsubscribe();
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
async function bind() {
|
|
56
|
+
if (!data) return;
|
|
57
|
+
busy = true;
|
|
58
|
+
error = "";
|
|
59
|
+
try {
|
|
60
|
+
await bindPrimaryRepository(instanceId, primary || null, expectedPrimary);
|
|
61
|
+
dirty = false;
|
|
62
|
+
conflict = false;
|
|
63
|
+
notice = "Primary repository saved. Future steps will use these defaults.";
|
|
64
|
+
await load();
|
|
65
|
+
window.dispatchEvent(new Event("leitwerk:settings-changed"));
|
|
66
|
+
} catch (caught) {
|
|
67
|
+
error = caught instanceof Error ? caught.message : "Could not bind primary repository";
|
|
68
|
+
conflict = caught instanceof SettingsRequestError && caught.status === 409;
|
|
69
|
+
if (conflict) await load();
|
|
70
|
+
} finally {
|
|
71
|
+
busy = false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
{#snippet snapshot(value: ScopedSettingsSnapshot)}
|
|
77
|
+
<dl>{#each value.values as setting}<dt>{setting.key}</dt><dd>{setting.value === null ? "YAML / catalog default" : String(setting.value)} <span>from {source(setting)}</span></dd>{/each}</dl>
|
|
78
|
+
{/snippet}
|
|
79
|
+
|
|
80
|
+
<section class="process-settings">
|
|
81
|
+
<h3>Scoped settings</h3><p><a href={settingsPath()}>Edit instance defaults</a>{#each data?.repositories ?? [] as repository} · <a href={settingsPath(repository.subjectId)}>{repository.key} settings</a>{/each}</p>
|
|
82
|
+
{#if error}<p role="alert">{error}</p>{/if}
|
|
83
|
+
{#if data}
|
|
84
|
+
{#each data.explanations as explanation}<p>{explanation}</p>{/each}
|
|
85
|
+
{#if data.repositories.length > 1}<form onsubmit={(event) => { event.preventDefault(); void bind(); }}><label for="primary-settings-repository">Primary repository for model defaults</label><select id="primary-settings-repository" bind:value={primary} onchange={() => { dirty = true; notice = ""; }} disabled={busy}><option value="">Use Instance settings</option>{#each data.repositories as repository}<option value={repository.key}>{repository.key}</option>{/each}</select><button type="submit" disabled={busy || conflict}>Save primary repository</button></form>{/if}
|
|
86
|
+
{#if conflict}<p>Current saved primary repository: {data.primaryRepositoryKey ?? "Instance settings"}. Your selection is preserved.</p><button type="button" disabled={busy} onclick={async () => { expectedPrimary = data?.primaryRepositoryKey ?? null; conflict = false; error = ""; await tick(); document.getElementById("primary-settings-repository")?.focus(); }}>Keep selection and use latest binding</button>{/if}
|
|
87
|
+
{#if notice}<p role="status">{notice}</p>{/if}
|
|
88
|
+
<details><summary>Defaults for future steps</summary><p>Current scoped defaults. Explicit model choices on the process or action take precedence.</p>{#each data.future as future}<details><summary>{future.turnId}</summary>{#if future.error}<p role="alert">{future.error}</p>{:else if future.settings}{@render snapshot(future.settings)}{/if}</details>{/each}</details>
|
|
89
|
+
<details><summary>Captured settings · {data.captured.length} prepared steps</summary><p>Values retained for each prepared start, including recovery.</p>{#each data.captured as captured}<details><summary>{captured.turnId} · {new Date(captured.createdAt).toLocaleString()} · {captured.state}</summary>{@render snapshot(captured.settings)}</details>{:else}<p>No settings have been captured for this process yet.</p>{/each}</details>
|
|
90
|
+
{/if}
|
|
91
|
+
</section>
|
|
92
|
+
|
|
93
|
+
<style>
|
|
94
|
+
.process-settings { margin: 1.5rem 0; border-top: 1px solid var(--chronicle-border); padding-top: 1.5rem; }
|
|
95
|
+
h3 { margin: 0 0 .5rem; font-size: var(--type-title-sm); }
|
|
96
|
+
p { line-height: 1.5; }
|
|
97
|
+
a { color: var(--chronicle-link); text-underline-offset: 3px; }
|
|
98
|
+
details { margin: .8rem 0; }
|
|
99
|
+
details details { margin-left: .75rem; }
|
|
100
|
+
summary { cursor: pointer; min-height: 44px; padding-block: .6rem; }
|
|
101
|
+
summary:focus-visible, a:focus-visible, button:focus-visible, select:focus-visible { outline: 2px solid var(--chronicle-accent); outline-offset: 3px; }
|
|
102
|
+
pre, dd { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
103
|
+
dt { font-weight: 600; margin-top: .65rem; overflow-wrap: anywhere; }
|
|
104
|
+
dd { margin: .25rem 0; }
|
|
105
|
+
dd span { color: var(--chronicle-text-muted); }
|
|
106
|
+
form { display: grid; gap: .65rem; margin: 1rem 0; }
|
|
107
|
+
select, button { min-height: 44px; padding: .6rem; max-width: 100%; border: 1px solid var(--chronicle-border-strong); border-radius: var(--radius-sm); background: var(--chronicle-panel-surface); color: var(--chronicle-text); font: inherit; }
|
|
108
|
+
button { cursor: pointer; }
|
|
109
|
+
[role="alert"] { color: var(--chronicle-danger); }
|
|
110
|
+
</style>
|
|
@@ -5,6 +5,8 @@ import {
|
|
|
5
5
|
} from "./launcher-schedule.js";
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
|
+
invalid?: boolean;
|
|
9
|
+
describedBy?: string;
|
|
8
10
|
dateId: string;
|
|
9
11
|
hourId: string;
|
|
10
12
|
minuteId: string;
|
|
@@ -19,6 +21,8 @@ interface Props {
|
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
let {
|
|
24
|
+
invalid = false,
|
|
25
|
+
describedBy = undefined,
|
|
22
26
|
dateId,
|
|
23
27
|
hourId,
|
|
24
28
|
minuteId,
|
|
@@ -43,9 +47,9 @@ const markerAttrs = $derived(
|
|
|
43
47
|
);
|
|
44
48
|
</script>
|
|
45
49
|
|
|
46
|
-
<div class="schedule-date-time-picker" data-section={dataSection} data-time-format="24-hour">
|
|
50
|
+
<div class="schedule-date-time-picker" class:invalid data-section={dataSection} data-time-format="24-hour">
|
|
47
51
|
<input
|
|
48
|
-
id={dateId}
|
|
52
|
+
id={dateId} aria-invalid={invalid} aria-describedby={describedBy}
|
|
49
53
|
{...markerAttrs}
|
|
50
54
|
type="date"
|
|
51
55
|
value={dateValue}
|
|
@@ -53,7 +57,7 @@ const markerAttrs = $derived(
|
|
|
53
57
|
/>
|
|
54
58
|
<div class="schedule-time-picker">
|
|
55
59
|
<select
|
|
56
|
-
id={hourId}
|
|
60
|
+
id={hourId} aria-invalid={invalid} aria-describedby={describedBy}
|
|
57
61
|
value={hourValue}
|
|
58
62
|
aria-label="Hour (24-hour)"
|
|
59
63
|
onchange={(event) => onHourChange((event.currentTarget as HTMLSelectElement).value)}
|
|
@@ -65,7 +69,7 @@ const markerAttrs = $derived(
|
|
|
65
69
|
</select>
|
|
66
70
|
<span class="schedule-time-separator" aria-hidden="true">:</span>
|
|
67
71
|
<select
|
|
68
|
-
id={minuteId}
|
|
72
|
+
id={minuteId} aria-invalid={invalid} aria-describedby={describedBy}
|
|
69
73
|
value={minuteValue}
|
|
70
74
|
aria-label="Minute"
|
|
71
75
|
onchange={(event) => onMinuteChange((event.currentTarget as HTMLSelectElement).value)}
|
|
@@ -79,6 +83,7 @@ const markerAttrs = $derived(
|
|
|
79
83
|
</div>
|
|
80
84
|
|
|
81
85
|
<style>
|
|
86
|
+
.schedule-date-time-picker.invalid { border-color: var(--chronicle-danger); }
|
|
82
87
|
.schedule-date-time-picker {
|
|
83
88
|
display: grid;
|
|
84
89
|
grid-template-columns: minmax(0, 1fr) auto;
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ResolvedSetting } from "@leitwerk-dev/domain";
|
|
3
|
+
import type {
|
|
4
|
+
SettingChoice,
|
|
5
|
+
SettingFieldView,
|
|
6
|
+
SettingsPreview,
|
|
7
|
+
} from "@leitwerk-dev/protocol/http-contracts";
|
|
8
|
+
import { type NamedSelection, settingSelectionValues } from "@leitwerk-dev/protocol/http-contracts";
|
|
9
|
+
import { tick, untrack } from "svelte";
|
|
10
|
+
import {
|
|
11
|
+
changeSettings,
|
|
12
|
+
fetchSettingsChoices,
|
|
13
|
+
fetchSettingsPreview,
|
|
14
|
+
type SettingsChange,
|
|
15
|
+
SettingsRequestError,
|
|
16
|
+
} from "../lib/settings.js";
|
|
17
|
+
import NamedSelectionList from "./NamedSelectionList.svelte";
|
|
18
|
+
|
|
19
|
+
let {
|
|
20
|
+
field,
|
|
21
|
+
subjectId,
|
|
22
|
+
onSaved,
|
|
23
|
+
}: { field: SettingFieldView; subjectId: string; onSaved: (preview: SettingsPreview) => void } =
|
|
24
|
+
$props();
|
|
25
|
+
let editing = $state(false);
|
|
26
|
+
let search = $state("");
|
|
27
|
+
let value = $state<unknown>(null);
|
|
28
|
+
let revision = $state(0);
|
|
29
|
+
let busy = $state(false);
|
|
30
|
+
let error = $state("");
|
|
31
|
+
let notice = $state("");
|
|
32
|
+
let conflict = $state(false);
|
|
33
|
+
let combined = $state<ResolvedSetting | null>(null);
|
|
34
|
+
let previewError = $state("");
|
|
35
|
+
let remoteChoices = $state<SettingChoice[]>([]);
|
|
36
|
+
let choicesLoading = $state(false);
|
|
37
|
+
let choicesError = $state("");
|
|
38
|
+
let choicesLoaded = $state(false);
|
|
39
|
+
let choicesRefresh = $state(0);
|
|
40
|
+
const mergeChoices = (...lists: SettingChoice[][]) => [
|
|
41
|
+
...new Map(lists.flat().map((choice) => [choice.value, choice])).values(),
|
|
42
|
+
];
|
|
43
|
+
const choices = $derived(
|
|
44
|
+
field.choicesDeferred ? mergeChoices(field.choices, remoteChoices) : field.choices,
|
|
45
|
+
);
|
|
46
|
+
const searchMinimum = $derived(field.form.search?.minimumLength ?? 0);
|
|
47
|
+
const needsSearch = $derived(searchMinimum > 0 && search.trim().length < searchMinimum);
|
|
48
|
+
const inputId = $derived(`setting-${subjectId}-${field.key}`);
|
|
49
|
+
const activeOverride = $derived(field.override && !field.override.reset ? field.override : null);
|
|
50
|
+
const selected = $derived(settingSelectionValues(value));
|
|
51
|
+
const retainedChoices = (saved: unknown) =>
|
|
52
|
+
remoteChoices.filter(
|
|
53
|
+
(choice) =>
|
|
54
|
+
selected.includes(choice.value) || settingSelectionValues(saved).includes(choice.value),
|
|
55
|
+
);
|
|
56
|
+
const selectionChoices = $derived([
|
|
57
|
+
...selected
|
|
58
|
+
.filter((value) => !choices.some((choice) => choice.value === value))
|
|
59
|
+
.map((value) => ({ value, label: `${value} (unavailable)`, disabledReason: undefined })),
|
|
60
|
+
...choices,
|
|
61
|
+
]);
|
|
62
|
+
const visibleChoices = $derived(
|
|
63
|
+
selectionChoices.filter(
|
|
64
|
+
(choice) =>
|
|
65
|
+
selected.includes(choice.value) ||
|
|
66
|
+
(searchMinimum > 0
|
|
67
|
+
? !needsSearch || field.choices.some((saved) => saved.value === choice.value)
|
|
68
|
+
: choice.label.toLowerCase().includes(search.trim().toLowerCase())),
|
|
69
|
+
),
|
|
70
|
+
);
|
|
71
|
+
function toggleChoice(choice: string, checked: boolean) {
|
|
72
|
+
value = checked
|
|
73
|
+
? [...new Set([...selected, choice])]
|
|
74
|
+
: selected.filter((entry) => entry !== choice);
|
|
75
|
+
}
|
|
76
|
+
function formatSelection(raw: unknown) {
|
|
77
|
+
if (
|
|
78
|
+
Array.isArray(raw) &&
|
|
79
|
+
raw.length &&
|
|
80
|
+
field.choicesDeferred &&
|
|
81
|
+
!choicesLoaded &&
|
|
82
|
+
raw.some((value) => !choices.some((choice) => choice.value === value))
|
|
83
|
+
)
|
|
84
|
+
return `${raw.length} selected`;
|
|
85
|
+
return Array.isArray(raw)
|
|
86
|
+
? raw
|
|
87
|
+
.map(
|
|
88
|
+
(value) =>
|
|
89
|
+
choices.find((choice) => choice.value === value)?.label ?? `${value} (unavailable)`,
|
|
90
|
+
)
|
|
91
|
+
.join("; ") || "None selected"
|
|
92
|
+
: format(raw);
|
|
93
|
+
}
|
|
94
|
+
const format = (raw: unknown): string =>
|
|
95
|
+
field.form.control === "named-selection-list" && Array.isArray(raw)
|
|
96
|
+
? raw.map((row: NamedSelection) => `${row.name}: ${formatSelection(row.values)}`).join("\n") ||
|
|
97
|
+
"No groups"
|
|
98
|
+
: raw === null
|
|
99
|
+
? "Runtime default (YAML or model catalog)"
|
|
100
|
+
: raw === ""
|
|
101
|
+
? "Empty"
|
|
102
|
+
: typeof raw === "string"
|
|
103
|
+
? raw
|
|
104
|
+
: JSON.stringify(raw);
|
|
105
|
+
const sources = (resolved: ResolvedSetting | null) =>
|
|
106
|
+
resolved?.sources.map((source) => source.label).join(" → ") ?? "Unavailable";
|
|
107
|
+
|
|
108
|
+
async function begin() {
|
|
109
|
+
search = "";
|
|
110
|
+
value = activeOverride ? activeOverride.value : (field.effective?.value ?? null);
|
|
111
|
+
revision = field.override?.revision ?? 0;
|
|
112
|
+
error = "";
|
|
113
|
+
notice = "";
|
|
114
|
+
conflict = false;
|
|
115
|
+
editing = true;
|
|
116
|
+
combined = null;
|
|
117
|
+
previewError = "";
|
|
118
|
+
await tick();
|
|
119
|
+
document.getElementById(inputId)?.focus();
|
|
120
|
+
}
|
|
121
|
+
async function cancel() {
|
|
122
|
+
editing = false;
|
|
123
|
+
error = "";
|
|
124
|
+
await tick();
|
|
125
|
+
document.getElementById(`${inputId}-edit`)?.focus();
|
|
126
|
+
}
|
|
127
|
+
function change(reset = false): SettingsChange {
|
|
128
|
+
return { subjectId, key: field.key, value, mode: "replace", reset, expectedRevision: revision };
|
|
129
|
+
}
|
|
130
|
+
$effect(() => {
|
|
131
|
+
if (!field.choicesDeferred) return;
|
|
132
|
+
const saved = field.effective?.value;
|
|
133
|
+
if (!editing && (!Array.isArray(saved) || !saved.length)) return;
|
|
134
|
+
const id = subjectId;
|
|
135
|
+
const key = field.key;
|
|
136
|
+
const query = editing ? search.trim() : "";
|
|
137
|
+
void choicesRefresh;
|
|
138
|
+
if (searchMinimum > 0) {
|
|
139
|
+
remoteChoices = untrack(() => retainedChoices(saved));
|
|
140
|
+
if (!editing || query.length < searchMinimum) {
|
|
141
|
+
choicesLoading = false;
|
|
142
|
+
choicesError = "";
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const controller = new AbortController();
|
|
147
|
+
choicesLoading = true;
|
|
148
|
+
choicesError = "";
|
|
149
|
+
const timer = setTimeout(() => {
|
|
150
|
+
void fetchSettingsChoices(id, key, query, controller.signal)
|
|
151
|
+
.then((result) => {
|
|
152
|
+
if (controller.signal.aborted) return;
|
|
153
|
+
remoteChoices = mergeChoices(retainedChoices(saved), result.choices);
|
|
154
|
+
choicesLoaded = true;
|
|
155
|
+
})
|
|
156
|
+
.catch((caught: unknown) => {
|
|
157
|
+
if (!controller.signal.aborted)
|
|
158
|
+
choicesError =
|
|
159
|
+
caught instanceof Error ? caught.message : "Could not load options. Try again.";
|
|
160
|
+
})
|
|
161
|
+
.finally(() => {
|
|
162
|
+
if (!controller.signal.aborted) choicesLoading = false;
|
|
163
|
+
});
|
|
164
|
+
}, 200);
|
|
165
|
+
return () => {
|
|
166
|
+
controller.abort();
|
|
167
|
+
clearTimeout(timer);
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
$effect(() => {
|
|
171
|
+
if (!editing || field.form.control !== "named-selection-list") return;
|
|
172
|
+
const draft = change();
|
|
173
|
+
let current = true;
|
|
174
|
+
const timer = setTimeout(() => {
|
|
175
|
+
void changeSettings(draft, true)
|
|
176
|
+
.then((result) => {
|
|
177
|
+
if (!current) return;
|
|
178
|
+
const updated = result.fields.find((candidate) => candidate.key === field.key);
|
|
179
|
+
combined = updated?.effective ?? null;
|
|
180
|
+
previewError = updated?.error ?? "";
|
|
181
|
+
})
|
|
182
|
+
.catch((caught: unknown) => {
|
|
183
|
+
if (current)
|
|
184
|
+
previewError = caught instanceof Error ? caught.message : "Could not preview setting";
|
|
185
|
+
});
|
|
186
|
+
}, 250);
|
|
187
|
+
return () => {
|
|
188
|
+
current = false;
|
|
189
|
+
clearTimeout(timer);
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
async function save(reset = false) {
|
|
193
|
+
if (busy) return;
|
|
194
|
+
if (!editing) revision = field.override?.revision ?? 0;
|
|
195
|
+
const draft = change(reset);
|
|
196
|
+
const notifySaved = onSaved;
|
|
197
|
+
busy = true;
|
|
198
|
+
error = "";
|
|
199
|
+
notice = "";
|
|
200
|
+
try {
|
|
201
|
+
const result = await changeSettings(draft);
|
|
202
|
+
notifySaved(result);
|
|
203
|
+
editing = false;
|
|
204
|
+
conflict = false;
|
|
205
|
+
notice = reset ? "Inherited value restored." : "Saved. Future steps will use this setting.";
|
|
206
|
+
window.dispatchEvent(new Event("leitwerk:settings-changed"));
|
|
207
|
+
busy = false;
|
|
208
|
+
await tick();
|
|
209
|
+
document.getElementById(`${inputId}-edit`)?.focus();
|
|
210
|
+
} catch (caught) {
|
|
211
|
+
error =
|
|
212
|
+
caught instanceof Error ? caught.message : "Could not save setting. Your draft is preserved.";
|
|
213
|
+
conflict = caught instanceof SettingsRequestError && caught.status === 409;
|
|
214
|
+
if (conflict) {
|
|
215
|
+
try {
|
|
216
|
+
notifySaved(await fetchSettingsPreview(draft.subjectId));
|
|
217
|
+
} catch {
|
|
218
|
+
/* Keep the draft and original error. */
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
} finally {
|
|
222
|
+
busy = false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async function useLatestRevision() {
|
|
226
|
+
revision = field.override?.revision ?? 0;
|
|
227
|
+
conflict = false;
|
|
228
|
+
error = "";
|
|
229
|
+
await tick();
|
|
230
|
+
document.getElementById(inputId)?.focus();
|
|
231
|
+
}
|
|
232
|
+
</script>
|
|
233
|
+
|
|
234
|
+
<section class="setting-field" aria-labelledby={`${inputId}-heading`}>
|
|
235
|
+
<div class="field-heading">
|
|
236
|
+
<div><h3 id={`${inputId}-heading`}>{field.form.label}</h3>{#if field.form.description}<p class="description">{field.form.description}</p>{/if}</div>
|
|
237
|
+
{#if !editing}<button id={`${inputId}-edit`} type="button" onclick={begin} disabled={busy}>{activeOverride ? "Edit override" : "Override"}</button>{/if}
|
|
238
|
+
</div>
|
|
239
|
+
<div class="effective"><span class="source">Effective value · {sources(field.effective)}</span><p class:multiline-value={field.form.control === "textarea" || field.form.control === "named-selection-list"}>{field.effective ? (field.form.control === "multiselect" ? formatSelection(field.effective.value) : format(field.effective.value)) : "Unavailable"}</p></div>
|
|
240
|
+
{#if field.error}<p class="error" role="alert">{field.error}</p>{/if}
|
|
241
|
+
{#if editing}
|
|
242
|
+
<form onsubmit={(event) => { event.preventDefault(); void save(); }}>
|
|
243
|
+
<label for={inputId}>{field.form.label} override</label>
|
|
244
|
+
{#if choicesLoading}<p class="source" role="status">{searchMinimum > 0 ? "Searching…" : "Loading options…"}</p>{/if}
|
|
245
|
+
{#if choicesError}<p class="error" role="alert">{choicesError}</p><button type="button" onclick={() => choicesRefresh++}>{searchMinimum > 0 ? "Retry search" : "Retry options"}</button>{/if}
|
|
246
|
+
{#if field.form.control === "named-selection-list"}
|
|
247
|
+
<input id={inputId} type="search" placeholder={field.form.search?.placeholder ?? "Search options"} bind:value={search} disabled={busy} onkeydown={(event) => { if (event.key === "Enter") event.preventDefault(); }} />
|
|
248
|
+
{#if needsSearch}<p class="description">Type at least {searchMinimum} characters to search.</p>{/if}
|
|
249
|
+
{#if choicesLoaded && !needsSearch && !choicesLoading && !choicesError && !remoteChoices.some((choice) => !selected.includes(choice.value))}<p class="description" role="status">No additional matches. Try a different search.</p>{/if}
|
|
250
|
+
<NamedSelectionList rows={Array.isArray(value) ? value as NamedSelection[] : []} choices={visibleChoices} {busy} id={inputId} onChange={(rows) => value = rows} />
|
|
251
|
+
{:else if field.form.control === "multiselect"}
|
|
252
|
+
<input id={inputId} type="search" placeholder={field.form.search?.placeholder ?? "Search options"} bind:value={search} disabled={busy} onkeydown={(event) => { if (event.key === "Enter") event.preventDefault(); }} aria-describedby={`${inputId}-count${searchMinimum > 0 ? ` ${inputId}-search-help` : ""}`} />
|
|
253
|
+
<p id={`${inputId}-count`} class="source" aria-live="polite">{selected.length} selected</p>
|
|
254
|
+
{#if searchMinimum > 0}<p id={`${inputId}-search-help`} class="description">{needsSearch ? `Type at least ${searchMinimum} characters to search.` : "Select options from the matches below."}</p>{/if}
|
|
255
|
+
<div class="choices" role="group" aria-label={field.form.label}>
|
|
256
|
+
{#each visibleChoices as choice (choice.value)}
|
|
257
|
+
<label class="choice"><input type="checkbox" checked={selected.includes(choice.value)} disabled={busy || (Boolean(choice.disabledReason) && !selected.includes(choice.value))} onchange={(event) => toggleChoice(choice.value, event.currentTarget.checked)} /><span>{choice.label}{choice.disabledReason ? ` — ${choice.disabledReason}` : ""}</span></label>
|
|
258
|
+
{:else}{#if !choicesLoading && !choicesError && !needsSearch}<p class="description">No matching options. Try a different search.</p>{/if}{/each}
|
|
259
|
+
</div>
|
|
260
|
+
{:else if field.form.control === "model" || field.form.control === "select"}
|
|
261
|
+
<select id={inputId} value={String(value ?? "")} onchange={(event) => { value = event.currentTarget.value || (field.form.control === "model" ? null : ""); }} disabled={busy}>
|
|
262
|
+
{#if field.form.control === "model"}<option value="">Use YAML / catalog default</option>{/if}
|
|
263
|
+
{#if typeof value === "string" && !choices.some((choice) => choice.value === value)}<option value={value}>{value} (unavailable)</option>{/if}
|
|
264
|
+
{#each choices as choice (choice.value)}<option value={choice.value} disabled={Boolean(choice.disabledReason)}>{choice.label}{choice.disabledReason ? ` — ${choice.disabledReason}` : ""}</option>{/each}
|
|
265
|
+
</select>
|
|
266
|
+
{:else if field.form.control === "textarea"}
|
|
267
|
+
<textarea id={inputId} rows="6" value={String(value ?? "")} oninput={(event) => { value = event.currentTarget.value; }} disabled={busy}></textarea>
|
|
268
|
+
{:else if field.form.control === "checkbox"}
|
|
269
|
+
<input id={inputId} type="checkbox" checked={Boolean(value)} onchange={(event) => { value = event.currentTarget.checked; }} disabled={busy} />
|
|
270
|
+
{:else if field.form.control === "number"}
|
|
271
|
+
<input id={inputId} type="number" value={Number(value)} oninput={(event) => { value = event.currentTarget.valueAsNumber; }} disabled={busy} />
|
|
272
|
+
{:else}
|
|
273
|
+
<input id={inputId} type="text" value={String(value ?? "")} oninput={(event) => { value = event.currentTarget.value; }} disabled={busy} />
|
|
274
|
+
{/if}
|
|
275
|
+
{#if field.form.control === "named-selection-list" && combined}<div class="combined"><span class="source">Group preview</span><p class="multiline-value">{format(combined.value)}</p></div>{/if}
|
|
276
|
+
{#if previewError}<p class="error">{previewError}</p>{/if}
|
|
277
|
+
<div class="actions"><button class="save" type="submit" disabled={busy || conflict}>{busy ? "Saving…" : "Save override"}</button><button type="button" onclick={cancel} disabled={busy}>Cancel</button></div>
|
|
278
|
+
</form>
|
|
279
|
+
{/if}
|
|
280
|
+
{#if activeOverride}<button class="inherit" type="button" onclick={() => save(true)} disabled={busy || conflict}>Use inherited value</button>{/if}
|
|
281
|
+
{#if error}<p class="error" role="alert">{error}</p>{/if}
|
|
282
|
+
{#if conflict}<p>Current saved value: {format(field.override?.value)}. Compare it with your draft above.</p><button type="button" onclick={useLatestRevision} disabled={busy}>Keep draft and use latest revision</button>{/if}
|
|
283
|
+
{#if notice}<p class="notice" role="status">{notice}</p>{/if}
|
|
284
|
+
</section>
|
|
285
|
+
|
|
286
|
+
<style>
|
|
287
|
+
.setting-field { padding: 1.4rem 0; border-top: 1px solid var(--chronicle-border); }
|
|
288
|
+
.field-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
|
|
289
|
+
h3 { margin: 0; font-size: var(--type-body-lg); }
|
|
290
|
+
p { margin: .5rem 0; line-height: 1.5; overflow-wrap: anywhere; }
|
|
291
|
+
.description { color: var(--chronicle-text-muted); max-width: 65ch; font-size: var(--type-body-sm); }
|
|
292
|
+
.source { color: var(--chronicle-text-muted); font-size: var(--type-caption); }
|
|
293
|
+
.effective { margin-top: .75rem; }
|
|
294
|
+
.effective p { margin-top: .25rem; }
|
|
295
|
+
.multiline-value { white-space: pre-wrap; }
|
|
296
|
+
form { margin: 1rem 0; display: grid; gap: .65rem; }
|
|
297
|
+
label { font-weight: 600; }
|
|
298
|
+
input:not([type="checkbox"]), select, textarea { width: 100%; min-width: 0; border: 1px solid var(--chronicle-border-strong); border-radius: var(--radius-sm); padding: .7rem; background: var(--chronicle-panel-surface); color: var(--chronicle-text); font: inherit; }
|
|
299
|
+
textarea { resize: vertical; }
|
|
300
|
+
.combined { padding: .8rem; background: var(--chronicle-panel-muted); border-radius: var(--radius-sm); }
|
|
301
|
+
button { min-height: 44px; padding: .5rem .85rem; border: 1px solid var(--chronicle-border-strong); border-radius: var(--radius-sm); background: var(--chronicle-panel-surface); color: var(--chronicle-text); font: inherit; cursor: pointer; }
|
|
302
|
+
button:hover:not(:disabled) { background: var(--chronicle-panel-muted); }
|
|
303
|
+
button:disabled { opacity: .6; cursor: default; }
|
|
304
|
+
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--chronicle-accent); outline-offset: 3px; }
|
|
305
|
+
.save { background: var(--chronicle-accent); color: var(--chronicle-text-on-accent); border-color: var(--chronicle-accent); }
|
|
306
|
+
.save:hover:not(:disabled) { background: color-mix(in srgb, var(--chronicle-accent) 85%, black); }
|
|
307
|
+
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
|
|
308
|
+
.choices { max-height: 20rem; overflow-y: auto; border-block: 1px solid var(--chronicle-border); }
|
|
309
|
+
.choice { display: flex; align-items: center; gap: .75rem; min-height: 44px; padding: .6rem .2rem; font-weight: 400; cursor: pointer; }
|
|
310
|
+
.choice span { min-width: 0; overflow-wrap: anywhere; }
|
|
311
|
+
.choice input { flex: 0 0 auto; accent-color: var(--chronicle-accent); }
|
|
312
|
+
.choice:hover { background: var(--chronicle-panel-muted); }
|
|
313
|
+
.inherit { margin-top: .5rem; }
|
|
314
|
+
.error { color: var(--chronicle-danger); }
|
|
315
|
+
.notice { color: var(--chronicle-success); }
|
|
316
|
+
@media (max-width: 600px) { .field-heading { flex-direction: column; gap: .5rem; } }
|
|
317
|
+
</style>
|