@leitwerk-dev/ui 0.1.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/LICENSE +13 -0
- package/dist/assets/ChronicleMarkdown-BLgtHeEE.js +16 -0
- package/dist/assets/ChronicleMarkdown-D6hFzERy.css +1 -0
- package/dist/assets/FutureLaunchDetailPage-KrXSGzHM.js +1 -0
- package/dist/assets/FutureLaunchDetailPage-VPMBtpYc.css +1 -0
- package/dist/assets/GenericLauncher-Cv38FByt.js +1 -0
- package/dist/assets/GenericLauncher-D_GMtsQ5.css +1 -0
- package/dist/assets/HomePage-Cd3lEtwZ.js +1 -0
- package/dist/assets/HomePage-DYh_QHXv.css +1 -0
- package/dist/assets/PageHeader-6PdvYODN.css +1 -0
- package/dist/assets/PageHeader-D6pP4hIh.js +1 -0
- package/dist/assets/ProcessActionsMenu-1QySGNy9.js +1 -0
- package/dist/assets/ProcessActionsMenu-BT2r9vO8.css +1 -0
- package/dist/assets/ProcessDetailPage-BLuc7sjV.js +12 -0
- package/dist/assets/ProcessDetailPage-CSrjzajF.css +1 -0
- package/dist/assets/ProcessFlowDiagram-BAh_M_rb.js +2 -0
- package/dist/assets/ProcessFlowDiagram-Cz8wNicU.css +1 -0
- package/dist/assets/ProcessesPage-BcM38HMs.css +1 -0
- package/dist/assets/ProcessesPage-DtPweRU-.js +1 -0
- package/dist/assets/ScheduleDateTimePicker-CQGvY-Rc.js +1 -0
- package/dist/assets/ScheduleDateTimePicker-CadXN9z7.css +1 -0
- package/dist/assets/SkillsPage-B30FAFia.css +1 -0
- package/dist/assets/SkillsPage-bXuv0kEE.js +2 -0
- package/dist/assets/WatchersPage-DNyUsU1y.js +1 -0
- package/dist/assets/WatchersPage-Dnfi1zUK.css +1 -0
- package/dist/assets/api-CqECFdii.js +1 -0
- package/dist/assets/browser-storage-LbKCyf_w.js +1 -0
- package/dist/assets/dist-B7WNbObw.js +2 -0
- package/dist/assets/index-66T4Gmbl.css +1 -0
- package/dist/assets/index-C8qCggeq.js +7 -0
- package/dist/assets/index-client-BqF3_t3P.js +2 -0
- package/dist/assets/mermaid-render.worker-DAVgiVRG.js +6393 -0
- package/dist/assets/retry-config.svelte-DFKCJtCe.js +1 -0
- package/dist/assets/router.svelte-COr45o9R.js +1 -0
- package/dist/fonts/OFL-Public-Sans.txt +115 -0
- package/dist/fonts/OFL-Spectral.txt +93 -0
- package/dist/fonts/README.md +38 -0
- package/dist/fonts/fonts.css +85 -0
- package/dist/fonts/public-sans-latin-cd00287f.woff2 +0 -0
- package/dist/fonts/public-sans-latin-ext-d025d4ba.woff2 +0 -0
- package/dist/fonts/spectral-latin-89d48951.woff2 +0 -0
- package/dist/fonts/spectral-latin-b7578f14.woff2 +0 -0
- package/dist/fonts/spectral-latin-c4e0a00d.woff2 +0 -0
- package/dist/fonts/spectral-latin-ext-260738f4.woff2 +0 -0
- package/dist/fonts/spectral-latin-ext-ab18ac17.woff2 +0 -0
- package/dist/fonts/spectral-latin-ext-f58c1db3.woff2 +0 -0
- package/dist/index.html +32 -0
- package/package.json +47 -0
- package/src/App.svelte +257 -0
- package/src/chronicle/components/ChronicleActionSection.svelte +1035 -0
- package/src/chronicle/components/ChronicleExpandButton.svelte +70 -0
- package/src/chronicle/components/ChronicleFlow.svelte +289 -0
- package/src/chronicle/components/ChronicleLeafOutcomePlaceholder.svelte +44 -0
- package/src/chronicle/components/ChronicleLeafOutcomeRendererHost.svelte +408 -0
- package/src/chronicle/components/ChronicleLeafOutcomeSection.svelte +253 -0
- package/src/chronicle/components/ChronicleLiveChip.svelte +96 -0
- package/src/chronicle/components/ChronicleLiveTail.svelte +376 -0
- package/src/chronicle/components/ChronicleMarkdown.svelte +168 -0
- package/src/chronicle/components/ChronicleOperatorInputSection.svelte +41 -0
- package/src/chronicle/components/ChronicleProcessErrorSection.svelte +131 -0
- package/src/chronicle/components/ChroniclePromptSection.svelte +54 -0
- package/src/chronicle/components/ChronicleQuestionRequest.svelte +167 -0
- package/src/chronicle/components/ChronicleReasoningDetailsOverlay.svelte +893 -0
- package/src/chronicle/components/ChronicleRecoverySection.svelte +338 -0
- package/src/chronicle/components/ChronicleScheduledActionSection.svelte +192 -0
- package/src/chronicle/components/ChronicleSectionHeader.svelte +135 -0
- package/src/chronicle/components/ChronicleStartupRecoverySection.svelte +138 -0
- package/src/chronicle/components/ChronicleTerminalSummary.svelte +127 -0
- package/src/chronicle/components/ChronicleThinkingSection.svelte +191 -0
- package/src/chronicle/components/ChronicleThinkingText.svelte +46 -0
- package/src/chronicle/components/ChronicleToolCallItem.svelte +477 -0
- package/src/chronicle/components/ChronicleTurnCluster.svelte +325 -0
- package/src/chronicle/components/ChronicleTurnRail.svelte +584 -0
- package/src/chronicle/components/ChronicleUsageStats.svelte +107 -0
- package/src/chronicle/components/CompactActionComposer.svelte +417 -0
- package/src/chronicle/components/ModelProfileOptions.svelte +20 -0
- package/src/chronicle/components/ProviderOptionsEditor.svelte +171 -0
- package/src/chronicle/components/RecoveryModelControl.svelte +95 -0
- package/src/chronicle/lib/action-bindings.ts +90 -0
- package/src/chronicle/lib/action-model-display.ts +133 -0
- package/src/chronicle/lib/action-preview.ts +16 -0
- package/src/chronicle/lib/chronicle-projection.ts +1342 -0
- package/src/chronicle/lib/chronicle-selectable-items.ts +352 -0
- package/src/chronicle/lib/chronicle-view-model.ts +121 -0
- package/src/chronicle/lib/formatting.ts +18 -0
- package/src/chronicle/lib/leaf-outcome-loader.ts +214 -0
- package/src/chronicle/lib/leaf-outcome-runtime.ts +37 -0
- package/src/chronicle/lib/prompt-highlighting.ts +78 -0
- package/src/chronicle/lib/scroll-sync.ts +88 -0
- package/src/chronicle/lib/tool-call-summary.ts +64 -0
- package/src/components/BrowserUiExtensionIndicatorHost.svelte +34 -0
- package/src/components/ConversationTreeDiagram.svelte +393 -0
- package/src/components/FormFieldRenderer.svelte +359 -0
- package/src/components/GenericLauncher.svelte +1970 -0
- package/src/components/KeyboardShortcutsModal.svelte +52 -0
- package/src/components/ModalShell.svelte +105 -0
- package/src/components/PageHeader.svelte +146 -0
- package/src/components/ProcessActionsMenu.svelte +514 -0
- package/src/components/ProcessInfoOverlay.svelte +1229 -0
- package/src/components/ScheduleDateTimePicker.svelte +155 -0
- package/src/components/SkillSelector.svelte +45 -0
- package/src/components/ToastContainer.svelte +192 -0
- package/src/components/launcher-form-copy.ts +172 -0
- package/src/components/launcher-model-config.ts +263 -0
- package/src/components/launcher-schedule.ts +127 -0
- package/src/extension-ui-dev-server.ts +98 -0
- package/src/lib/api.ts +970 -0
- package/src/lib/beautiful-mermaid-elk-instance.ts +54 -0
- package/src/lib/browser-storage.ts +11 -0
- package/src/lib/cost-estimates.ts +41 -0
- package/src/lib/elk-bundled-worker.ts +41 -0
- package/src/lib/flow-layout.ts +326 -0
- package/src/lib/format.ts +96 -0
- package/src/lib/future-executions-logic.ts +12 -0
- package/src/lib/future-launch-detail.ts +145 -0
- package/src/lib/instance-tree-layout.ts +158 -0
- package/src/lib/keyboard-shortcuts-help.ts +20 -0
- package/src/lib/keyboard.ts +40 -0
- package/src/lib/launcher-recent-values.ts +68 -0
- package/src/lib/markdown.ts +94 -0
- package/src/lib/mermaid-render.worker.ts +36 -0
- package/src/lib/pi-stream.ts +3 -0
- package/src/lib/primary-path-detail.ts +337 -0
- package/src/lib/primary-path-replay.ts +27 -0
- package/src/lib/process-browser.ts +179 -0
- package/src/lib/process-initial-prompt.ts +7 -0
- package/src/lib/process-launch-notices.svelte.ts +25 -0
- package/src/lib/process-row-view.ts +60 -0
- package/src/lib/process-terminal-display.ts +17 -0
- package/src/lib/process-toast-focus.svelte.ts +18 -0
- package/src/lib/processes-logic.ts +2 -0
- package/src/lib/processes.svelte.ts +334 -0
- package/src/lib/request-guard.ts +20 -0
- package/src/lib/retry-config.svelte.ts +19 -0
- package/src/lib/rich-markdown-elements.ts +173 -0
- package/src/lib/router-logic.ts +190 -0
- package/src/lib/router.svelte.ts +56 -0
- package/src/lib/runtime-config.ts +96 -0
- package/src/lib/test-fixtures.ts +13 -0
- package/src/lib/toasts.svelte.ts +104 -0
- package/src/lib/tool-call-rendering.ts +66 -0
- package/src/lib/ui-extensions.svelte.ts +381 -0
- package/src/lib/usage-snapshot.ts +9 -0
- package/src/lib/ws-classifier.ts +80 -0
- package/src/lib/ws.svelte.ts +281 -0
- package/src/main.ts +8 -0
- package/src/pages/FutureLaunchDetailPage.svelte +479 -0
- package/src/pages/HomePage.svelte +306 -0
- package/src/pages/ProcessCard.svelte +99 -0
- package/src/pages/ProcessDetailPage.svelte +599 -0
- package/src/pages/ProcessFlowDiagram.svelte +696 -0
- package/src/pages/ProcessGallery.svelte +252 -0
- package/src/pages/ProcessesPage.svelte +994 -0
- package/src/pages/SkillsPage.svelte +665 -0
- package/src/pages/WatchersPage.svelte +330 -0
- package/src/pages/process-detail/OverlayFrame.svelte +58 -0
- package/src/pages/process-detail/ProcessDetailChronicle.svelte +460 -0
- package/src/pages/process-detail/ProcessDetailHeader.svelte +167 -0
- package/src/pages/process-detail/process-detail-action-drafts.svelte.ts +211 -0
- package/src/pages/process-detail/process-detail-actions.svelte.ts +548 -0
- package/src/pages/process-detail/process-detail-chronicle-dom.ts +102 -0
- package/src/pages/process-detail/process-detail-chronicle-scroll.svelte.ts +711 -0
- package/src/pages/process-detail/process-detail-mutations.svelte.ts +91 -0
- package/src/pages/process-detail/process-detail-view-model.ts +149 -0
- package/src/shell/AppShell.svelte +249 -0
- package/src/shell/RouteLoadBoundary.svelte +43 -0
- package/src/shell/Sidebar.svelte +1358 -0
- package/src/shell/test-fixtures/RouteLoadTestComponent.svelte +5 -0
- package/src/vite-env.d.ts +2 -0
- package/src/vite-server-config.ts +27 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { FutureLaunchSummary, UiLauncherSummary } from "./api.js";
|
|
2
|
+
import { formatDefinition } from "./format.js";
|
|
3
|
+
|
|
4
|
+
export interface FutureLaunchDetailItem {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface FutureLaunchDetailSection {
|
|
10
|
+
id: string;
|
|
11
|
+
title: string;
|
|
12
|
+
items: FutureLaunchDetailItem[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function stringifyValue(value: unknown): string | null {
|
|
16
|
+
if (value === null || value === undefined) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (typeof value === "boolean") {
|
|
20
|
+
return value ? "Yes" : "No";
|
|
21
|
+
}
|
|
22
|
+
if (typeof value === "number") {
|
|
23
|
+
return Number.isFinite(value) ? String(value) : null;
|
|
24
|
+
}
|
|
25
|
+
if (typeof value === "string") {
|
|
26
|
+
const trimmed = value.trim();
|
|
27
|
+
return trimmed === "" ? null : trimmed;
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(value)) {
|
|
30
|
+
const values = value.map(stringifyValue).filter((item): item is string => Boolean(item));
|
|
31
|
+
return values.length > 0 ? values.join(", ") : null;
|
|
32
|
+
}
|
|
33
|
+
if (typeof value === "object") {
|
|
34
|
+
return JSON.stringify(value, null, 2);
|
|
35
|
+
}
|
|
36
|
+
return String(value);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function fieldLabel(launcher: UiLauncherSummary | null, fieldId: string): string {
|
|
40
|
+
const configuredLabel = launcher?.launchConfigSchema.fields.find(
|
|
41
|
+
(field) => field.id === fieldId,
|
|
42
|
+
)?.label;
|
|
43
|
+
if (configuredLabel) {
|
|
44
|
+
return configuredLabel;
|
|
45
|
+
}
|
|
46
|
+
return formatDefinition(fieldId.replace(/([a-z0-9])([A-Z])/g, "$1 $2"));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function addSection(
|
|
50
|
+
sections: FutureLaunchDetailSection[],
|
|
51
|
+
id: string,
|
|
52
|
+
title: string,
|
|
53
|
+
items: FutureLaunchDetailItem[],
|
|
54
|
+
) {
|
|
55
|
+
const visibleItems = items.filter((item) => item.value.trim() !== "");
|
|
56
|
+
if (visibleItems.length > 0) {
|
|
57
|
+
sections.push({ id, title, items: visibleItems });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isBranchField(fieldId: string): boolean {
|
|
62
|
+
const normalized = fieldId.toLowerCase();
|
|
63
|
+
return normalized.includes("branch") || normalized.includes("merge") || normalized.includes("mr");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function isProjectField(fieldId: string): boolean {
|
|
67
|
+
const normalized = fieldId.toLowerCase();
|
|
68
|
+
return (
|
|
69
|
+
normalized.includes("repo") ||
|
|
70
|
+
normalized.includes("project") ||
|
|
71
|
+
normalized.includes("component") ||
|
|
72
|
+
normalized.includes("path")
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function isInstructionField(fieldId: string): boolean {
|
|
77
|
+
const normalized = fieldId.toLowerCase();
|
|
78
|
+
return (
|
|
79
|
+
normalized.includes("instruction") ||
|
|
80
|
+
normalized.includes("prompt") ||
|
|
81
|
+
normalized.includes("description") ||
|
|
82
|
+
normalized.includes("summary")
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function buildFutureLaunchDetailSections(
|
|
87
|
+
futureLaunch: FutureLaunchSummary,
|
|
88
|
+
launcher: UiLauncherSummary | null,
|
|
89
|
+
): FutureLaunchDetailSection[] {
|
|
90
|
+
const sections: FutureLaunchDetailSection[] = [];
|
|
91
|
+
addSection(sections, "schedule", "Schedule", [
|
|
92
|
+
{ label: "Launches", value: futureLaunch.nextRunAt },
|
|
93
|
+
{
|
|
94
|
+
label: "Recurrence",
|
|
95
|
+
value:
|
|
96
|
+
futureLaunch.scheduleKind === "cron"
|
|
97
|
+
? (futureLaunch.cronExpression ?? "Cron schedule")
|
|
98
|
+
: "One time",
|
|
99
|
+
},
|
|
100
|
+
]);
|
|
101
|
+
addSection(sections, "process", "Process", [
|
|
102
|
+
{ label: "Process", value: launcher?.displayName ?? futureLaunch.launcherLabel },
|
|
103
|
+
{ label: "Title", value: futureLaunch.launchTitle ?? futureLaunch.title },
|
|
104
|
+
]);
|
|
105
|
+
|
|
106
|
+
const projectItems: FutureLaunchDetailItem[] = [];
|
|
107
|
+
const branchItems: FutureLaunchDetailItem[] = [];
|
|
108
|
+
const instructionItems: FutureLaunchDetailItem[] = [];
|
|
109
|
+
const otherItems: FutureLaunchDetailItem[] = [];
|
|
110
|
+
for (const [fieldId, rawValue] of Object.entries(futureLaunch.launcherInput)) {
|
|
111
|
+
const value = stringifyValue(rawValue);
|
|
112
|
+
if (!value) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const item = { label: fieldLabel(launcher, fieldId), value };
|
|
116
|
+
if (isBranchField(fieldId)) {
|
|
117
|
+
branchItems.push(item);
|
|
118
|
+
} else if (isProjectField(fieldId)) {
|
|
119
|
+
projectItems.push(item);
|
|
120
|
+
} else if (isInstructionField(fieldId)) {
|
|
121
|
+
instructionItems.push(item);
|
|
122
|
+
} else {
|
|
123
|
+
otherItems.push(item);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
addSection(sections, "projects", "Projects / repositories", projectItems);
|
|
127
|
+
addSection(sections, "branches", "Branches / MR settings", branchItems);
|
|
128
|
+
addSection(sections, "instructions", "Instructions", instructionItems);
|
|
129
|
+
addSection(sections, "details", "Selected fields", otherItems);
|
|
130
|
+
|
|
131
|
+
const modelItems: FutureLaunchDetailItem[] = [];
|
|
132
|
+
if (typeof futureLaunch.modelConfig.defaultModelProfileId === "string") {
|
|
133
|
+
modelItems.push({
|
|
134
|
+
label: "Default model",
|
|
135
|
+
value: futureLaunch.modelConfig.defaultModelProfileId,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
for (const [turnId, config] of Object.entries(futureLaunch.modelConfig.turnConfigs ?? {})) {
|
|
139
|
+
if (typeof config?.modelProfileId === "string" && config.modelProfileId.trim() !== "") {
|
|
140
|
+
modelItems.push({ label: formatDefinition(turnId), value: config.modelProfileId });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
addSection(sections, "runtime", "Runtime / model settings", modelItems);
|
|
144
|
+
return sections;
|
|
145
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
InstanceTreeEdgeSummary,
|
|
3
|
+
InstanceTreeNodeSummary,
|
|
4
|
+
} from "@leitwerk-dev/protocol/http-contracts";
|
|
5
|
+
|
|
6
|
+
const NODE_WIDTH = 196;
|
|
7
|
+
const NODE_HEIGHT = 68;
|
|
8
|
+
const LANE_LABEL_WIDTH = 126;
|
|
9
|
+
export const INSTANCE_TREE_COLUMN_GAP = 160;
|
|
10
|
+
const LANE_GAP = 72;
|
|
11
|
+
const HORIZONTAL_MARGIN = 24;
|
|
12
|
+
const VERTICAL_MARGIN = 60;
|
|
13
|
+
|
|
14
|
+
export interface InstanceTreeLayoutNode extends InstanceTreeNodeSummary {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
lane: number;
|
|
20
|
+
startsLane: boolean;
|
|
21
|
+
contextOrigin: "fresh" | "previous" | null;
|
|
22
|
+
childCount: number;
|
|
23
|
+
isCurrent: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface InstanceTreeLayoutEdge extends InstanceTreeEdgeSummary {
|
|
27
|
+
points: { x: number; y: number }[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface InstanceTreeLayout {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
laneCount: number;
|
|
34
|
+
nodes: InstanceTreeLayoutNode[];
|
|
35
|
+
edges: InstanceTreeLayoutEdge[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function edgePathPoints(
|
|
39
|
+
edge: InstanceTreeLayoutEdge,
|
|
40
|
+
source: InstanceTreeLayoutNode,
|
|
41
|
+
target: InstanceTreeLayoutNode,
|
|
42
|
+
): { x: number; y: number }[] {
|
|
43
|
+
if (edge.productLabels.length) {
|
|
44
|
+
const start = { x: source.x + source.width / 2, y: source.y };
|
|
45
|
+
const departureX = start.x + 24;
|
|
46
|
+
const end = { x: target.x, y: target.y - target.height / 2 };
|
|
47
|
+
const approachY = end.y - 24;
|
|
48
|
+
return [
|
|
49
|
+
start,
|
|
50
|
+
{ x: departureX, y: start.y },
|
|
51
|
+
{ x: departureX, y: approachY },
|
|
52
|
+
{ x: end.x, y: approachY },
|
|
53
|
+
end,
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
const end = { x: target.x - target.width / 2, y: target.y };
|
|
57
|
+
if (source.lane !== target.lane && target.x <= source.x) {
|
|
58
|
+
const start = { x: source.x, y: source.y + source.height / 2 };
|
|
59
|
+
const transitY = start.y + Math.max(24, (target.y - start.y) * 0.45);
|
|
60
|
+
const turnX = end.x - 40;
|
|
61
|
+
return [
|
|
62
|
+
start,
|
|
63
|
+
{ x: start.x, y: transitY },
|
|
64
|
+
{ x: turnX, y: transitY },
|
|
65
|
+
{ x: turnX, y: end.y },
|
|
66
|
+
end,
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
const start = { x: source.x + source.width / 2, y: source.y };
|
|
70
|
+
if (source.lane === target.lane) return [start, end];
|
|
71
|
+
const bendX = Math.min(end.x - 24, start.x + Math.max(24, (end.x - start.x) * 0.45));
|
|
72
|
+
return [start, { x: bendX, y: start.y }, { x: bendX, y: end.y }, end];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function layoutInstanceTree(
|
|
76
|
+
nodes: readonly InstanceTreeNodeSummary[],
|
|
77
|
+
currentLeafId: string | null,
|
|
78
|
+
edgeSummaries: readonly InstanceTreeEdgeSummary[] = [],
|
|
79
|
+
): InstanceTreeLayout | null {
|
|
80
|
+
if (!nodes.length) return null;
|
|
81
|
+
const sorted = [...nodes].sort(
|
|
82
|
+
(left, right) =>
|
|
83
|
+
left.timestamp.localeCompare(right.timestamp) || left.id.localeCompare(right.id),
|
|
84
|
+
);
|
|
85
|
+
const byId = new Map(sorted.map((node) => [node.id, node]));
|
|
86
|
+
const childrenByParent = new Map<string, InstanceTreeNodeSummary[]>();
|
|
87
|
+
for (const node of sorted) {
|
|
88
|
+
if (!node.parentId || !byId.has(node.parentId)) continue;
|
|
89
|
+
const children = childrenByParent.get(node.parentId) ?? [];
|
|
90
|
+
children.push(node);
|
|
91
|
+
childrenByParent.set(node.parentId, children);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const positioned = new Map<string, InstanceTreeLayoutNode>();
|
|
95
|
+
const ranks = new Map<string, number>();
|
|
96
|
+
let nextLane = 0;
|
|
97
|
+
function position(node: InstanceTreeNodeSummary): InstanceTreeLayoutNode {
|
|
98
|
+
const existing = positioned.get(node.id);
|
|
99
|
+
if (existing) return existing;
|
|
100
|
+
const parentNode = node.parentId ? byId.get(node.parentId) : undefined;
|
|
101
|
+
const parent = parentNode ? position(parentNode) : undefined;
|
|
102
|
+
const siblings = node.parentId ? (childrenByParent.get(node.parentId) ?? []) : [];
|
|
103
|
+
const startsLane = !parent || node.pathType === "leaf_branch" || siblings[0]?.id !== node.id;
|
|
104
|
+
const lane = startsLane ? nextLane++ : parent.lane;
|
|
105
|
+
const rank = parent ? (ranks.get(parent.id) ?? 0) + 1 : 0;
|
|
106
|
+
ranks.set(node.id, rank);
|
|
107
|
+
const result: InstanceTreeLayoutNode = {
|
|
108
|
+
...node,
|
|
109
|
+
x:
|
|
110
|
+
HORIZONTAL_MARGIN +
|
|
111
|
+
LANE_LABEL_WIDTH +
|
|
112
|
+
NODE_WIDTH / 2 +
|
|
113
|
+
rank * (NODE_WIDTH + INSTANCE_TREE_COLUMN_GAP),
|
|
114
|
+
y: VERTICAL_MARGIN + NODE_HEIGHT / 2 + lane * (NODE_HEIGHT + LANE_GAP),
|
|
115
|
+
width: NODE_WIDTH,
|
|
116
|
+
height: NODE_HEIGHT,
|
|
117
|
+
lane,
|
|
118
|
+
startsLane,
|
|
119
|
+
contextOrigin: startsLane ? (parent ? "previous" : "fresh") : null,
|
|
120
|
+
childCount: childrenByParent.get(node.id)?.length ?? 0,
|
|
121
|
+
isCurrent: node.id === currentLeafId,
|
|
122
|
+
};
|
|
123
|
+
positioned.set(node.id, result);
|
|
124
|
+
return result;
|
|
125
|
+
}
|
|
126
|
+
const layoutNodes = sorted.map(position);
|
|
127
|
+
const edges = edgeSummaries
|
|
128
|
+
.map((edge) => {
|
|
129
|
+
const source = positioned.get(edge.sourceNodeId);
|
|
130
|
+
const target = edge.targetNodeId ? positioned.get(edge.targetNodeId) : null;
|
|
131
|
+
if (!source || (edge.targetNodeId && !target)) return null;
|
|
132
|
+
if (edge.endState) {
|
|
133
|
+
return {
|
|
134
|
+
...edge,
|
|
135
|
+
points: [
|
|
136
|
+
{ x: source.x + source.width / 2, y: source.y },
|
|
137
|
+
{ x: source.x + source.width / 2 + 42, y: source.y },
|
|
138
|
+
{ x: source.x + source.width / 2 + 82, y: source.y + 38 },
|
|
139
|
+
],
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return target ? { ...edge, points: edgePathPoints(edge, source, target) } : null;
|
|
143
|
+
})
|
|
144
|
+
.filter((edge): edge is InstanceTreeLayoutEdge => Boolean(edge));
|
|
145
|
+
const maxRank = Math.max(...ranks.values());
|
|
146
|
+
return {
|
|
147
|
+
width:
|
|
148
|
+
HORIZONTAL_MARGIN * 2 +
|
|
149
|
+
LANE_LABEL_WIDTH +
|
|
150
|
+
(maxRank + 1) * NODE_WIDTH +
|
|
151
|
+
maxRank * INSTANCE_TREE_COLUMN_GAP +
|
|
152
|
+
(edges.some((edge) => edge.endState) ? 100 : 0),
|
|
153
|
+
height: VERTICAL_MARGIN * 2 + nextLane * NODE_HEIGHT + Math.max(0, nextLane - 1) * LANE_GAP,
|
|
154
|
+
laneCount: nextLane,
|
|
155
|
+
nodes: layoutNodes,
|
|
156
|
+
edges,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { writable } from "svelte/store";
|
|
2
|
+
|
|
3
|
+
export interface KeyboardShortcutItem {
|
|
4
|
+
keys: readonly string[];
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const keyboardShortcutHelpOpen = writable(false);
|
|
9
|
+
|
|
10
|
+
export function openKeyboardShortcutHelp(): void {
|
|
11
|
+
keyboardShortcutHelpOpen.set(true);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function closeKeyboardShortcutHelp(): void {
|
|
15
|
+
keyboardShortcutHelpOpen.set(false);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function toggleKeyboardShortcutHelp(): void {
|
|
19
|
+
keyboardShortcutHelpOpen.update((open) => !open);
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { get } from "svelte/store";
|
|
2
|
+
import { keyboardShortcutHelpOpen } from "./keyboard-shortcuts-help.js";
|
|
3
|
+
|
|
4
|
+
export function isTextEntryTarget(target: EventTarget | null): boolean {
|
|
5
|
+
if (!(target instanceof HTMLElement)) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (target.isContentEditable) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const tagName = target.tagName.toLowerCase();
|
|
14
|
+
return tagName === "input" || tagName === "textarea" || tagName === "select";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isPlainShortcut(event: KeyboardEvent): boolean {
|
|
18
|
+
return !event.metaKey && !event.ctrlKey && !event.altKey;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function shouldIgnorePlainShortcut(event: KeyboardEvent): boolean {
|
|
22
|
+
return (
|
|
23
|
+
event.defaultPrevented ||
|
|
24
|
+
get(keyboardShortcutHelpOpen) ||
|
|
25
|
+
isTextEntryTarget(event.target) ||
|
|
26
|
+
!isPlainShortcut(event)
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* True when the event target is an interactive control that has its own native
|
|
32
|
+
* activation (button, link, summary, or an explicit button role). Window-level
|
|
33
|
+
* key shortcuts must not steal keys like Enter/Space from these elements.
|
|
34
|
+
*/
|
|
35
|
+
export function isInteractiveTarget(target: EventTarget | null): boolean {
|
|
36
|
+
if (!(target instanceof HTMLElement)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return target.closest('button, a[href], summary, [role="button"]') !== null;
|
|
40
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import {
|
|
2
|
+
addLauncherRecentValue,
|
|
3
|
+
DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT,
|
|
4
|
+
normalizeLauncherRecentValue,
|
|
5
|
+
normalizeLauncherRecentValues,
|
|
6
|
+
} from "@leitwerk-dev/domain";
|
|
7
|
+
import type { StorageLike } from "./browser-storage.js";
|
|
8
|
+
|
|
9
|
+
export type { StorageLike } from "./browser-storage.js";
|
|
10
|
+
|
|
11
|
+
const STORAGE_KEY_PREFIX = "leitwerk.launcher-recents:";
|
|
12
|
+
const DEFAULT_RECENT_VALUE_LIMIT = DEFAULT_LAUNCHER_RECENT_VALUE_LIMIT;
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
addLauncherRecentValue,
|
|
16
|
+
DEFAULT_RECENT_VALUE_LIMIT,
|
|
17
|
+
normalizeLauncherRecentValue,
|
|
18
|
+
normalizeLauncherRecentValues,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function buildLauncherRecentValuesStorageKey(launcherId: string, fieldId: string): string {
|
|
22
|
+
return `${STORAGE_KEY_PREFIX}${launcherId}:${fieldId}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function readLauncherRecentValues(
|
|
26
|
+
storage: StorageLike,
|
|
27
|
+
launcherId: string,
|
|
28
|
+
fieldId: string,
|
|
29
|
+
limit = DEFAULT_RECENT_VALUE_LIMIT,
|
|
30
|
+
): string[] {
|
|
31
|
+
let rawValue: string | null;
|
|
32
|
+
try {
|
|
33
|
+
rawValue = storage.getItem(buildLauncherRecentValuesStorageKey(launcherId, fieldId));
|
|
34
|
+
} catch {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
if (!rawValue) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const parsed = JSON.parse(rawValue);
|
|
42
|
+
return Array.isArray(parsed) ? normalizeLauncherRecentValues(parsed, limit) : [];
|
|
43
|
+
} catch {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function writeLauncherRecentValue(
|
|
49
|
+
storage: StorageLike,
|
|
50
|
+
launcherId: string,
|
|
51
|
+
fieldId: string,
|
|
52
|
+
value: string,
|
|
53
|
+
limit = DEFAULT_RECENT_VALUE_LIMIT,
|
|
54
|
+
): string[] {
|
|
55
|
+
const existingValues = readLauncherRecentValues(storage, launcherId, fieldId, limit);
|
|
56
|
+
const nextValues = addLauncherRecentValue(existingValues, value, limit);
|
|
57
|
+
const key = buildLauncherRecentValuesStorageKey(launcherId, fieldId);
|
|
58
|
+
try {
|
|
59
|
+
if (nextValues.length === 0) {
|
|
60
|
+
storage.removeItem?.(key);
|
|
61
|
+
return nextValues;
|
|
62
|
+
}
|
|
63
|
+
storage.setItem(key, JSON.stringify(nextValues));
|
|
64
|
+
return nextValues;
|
|
65
|
+
} catch {
|
|
66
|
+
return existingValues;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { normalizeMarkdownLineEndings } from "@leitwerk-dev/domain";
|
|
2
|
+
import { parseManagedResultImagePath } from "@leitwerk-dev/worker-protocol/worker-result-image";
|
|
3
|
+
import createDOMPurify from "dompurify";
|
|
4
|
+
import MarkdownIt from "markdown-it";
|
|
5
|
+
|
|
6
|
+
function createMarkdownRenderer(options: { rich: boolean }): MarkdownIt {
|
|
7
|
+
const renderer = new MarkdownIt({
|
|
8
|
+
html: true,
|
|
9
|
+
linkify: false,
|
|
10
|
+
breaks: false,
|
|
11
|
+
xhtmlOut: true,
|
|
12
|
+
});
|
|
13
|
+
if (!options.rich) return renderer;
|
|
14
|
+
|
|
15
|
+
const escapeHtml = renderer.utils.escapeHtml;
|
|
16
|
+
renderer.renderer.rules.image = (tokens, index) => {
|
|
17
|
+
const token = tokens[index];
|
|
18
|
+
const src = token?.attrGet("src") ?? "";
|
|
19
|
+
if (!parseManagedResultImagePath(src)) return escapeHtml(token?.content ?? "");
|
|
20
|
+
return `<span data-result-image="${escapeHtml(src)}" data-alt="${escapeHtml(token?.content ?? "")}"></span>`;
|
|
21
|
+
};
|
|
22
|
+
const defaultFence = renderer.renderer.rules.fence;
|
|
23
|
+
renderer.renderer.rules.fence = (tokens, index, options, env, self) => {
|
|
24
|
+
const token = tokens[index];
|
|
25
|
+
if (token?.info.trim().split(/\s+/, 1)[0]?.toLowerCase() === "mermaid") {
|
|
26
|
+
return `<div data-mermaid-source><pre><code>${escapeHtml(token.content)}</code></pre></div>`;
|
|
27
|
+
}
|
|
28
|
+
return defaultFence
|
|
29
|
+
? defaultFence(tokens, index, options, env, self)
|
|
30
|
+
: self.renderToken(tokens, index, options);
|
|
31
|
+
};
|
|
32
|
+
return renderer;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const markdownRenderer = createMarkdownRenderer({ rich: false });
|
|
36
|
+
const richMarkdownRenderer = createMarkdownRenderer({ rich: true });
|
|
37
|
+
|
|
38
|
+
function sanitizeRenderedHtml(renderedHtml: string): string {
|
|
39
|
+
const htmlSanitizer = createDOMPurify(globalThis.window);
|
|
40
|
+
if (!htmlSanitizer.isSupported || typeof htmlSanitizer.sanitize !== "function") {
|
|
41
|
+
throw new Error("renderMarkdownToHtml requires a DOM-capable environment for DOMPurify");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return htmlSanitizer.sanitize(renderedHtml, {
|
|
45
|
+
FORBID_TAGS: [
|
|
46
|
+
"audio",
|
|
47
|
+
"embed",
|
|
48
|
+
"iframe",
|
|
49
|
+
"img",
|
|
50
|
+
"object",
|
|
51
|
+
"picture",
|
|
52
|
+
"source",
|
|
53
|
+
"track",
|
|
54
|
+
"video",
|
|
55
|
+
],
|
|
56
|
+
FORBID_ATTR: ["poster", "srcset"],
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function renderMarkdownToHtml(markdown: string): string {
|
|
61
|
+
return sanitizeRenderedHtml(markdownRenderer.render(normalizeMarkdownLineEndings(markdown), {}));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function renderRichMarkdownToHtml(markdown: string): string {
|
|
65
|
+
return sanitizeRenderedHtml(
|
|
66
|
+
richMarkdownRenderer.render(normalizeMarkdownLineEndings(markdown), {}),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function markdownToPlainText(markdown: string): string {
|
|
71
|
+
return normalizeMarkdownLineEndings(markdown)
|
|
72
|
+
.replace(/<br\s*\/?>/gi, " ")
|
|
73
|
+
.replace(/<\/?[^>]+>/g, " ")
|
|
74
|
+
.replace(/```([\s\S]*?)```/g, (_match, code: string) => code.trim())
|
|
75
|
+
.replace(/^#{1,6}\s+/gm, "")
|
|
76
|
+
.replace(/^\s*[-*+]\s+/gm, "")
|
|
77
|
+
.replace(/^\s*\d+\.\s+/gm, "")
|
|
78
|
+
.replace(/^\s*>\s?/gm, "")
|
|
79
|
+
.replace(/\[([^\]]+)\]\(([^)]+)\)/g, "$1")
|
|
80
|
+
.replace(/`([^`]+)`/g, "$1")
|
|
81
|
+
.replace(/\*\*([^*]+)\*\*/g, "$1")
|
|
82
|
+
.replace(/__([^_]+)__/g, "$1")
|
|
83
|
+
.replace(/\*([^*]+)\*/g, "$1")
|
|
84
|
+
.replace(/_([^_]+)_/g, "$1")
|
|
85
|
+
.replace(/\s+/g, " ")
|
|
86
|
+
.trim();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function truncateText(value: string, maxLength: number): string {
|
|
90
|
+
if (value.length <= maxLength) {
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
return `${value.slice(0, maxLength).trimEnd()}…`;
|
|
94
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface MermaidRenderRequest {
|
|
2
|
+
id: number;
|
|
3
|
+
source: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export type MermaidRenderResponse =
|
|
7
|
+
| { id: number; ok: true; svg: string }
|
|
8
|
+
| { id: number; ok: false; error: string };
|
|
9
|
+
|
|
10
|
+
const rendererPromise = import("beautiful-mermaid");
|
|
11
|
+
const workerScope = globalThis as unknown as {
|
|
12
|
+
addEventListener(
|
|
13
|
+
type: "message",
|
|
14
|
+
listener: (event: MessageEvent<MermaidRenderRequest>) => void,
|
|
15
|
+
): void;
|
|
16
|
+
postMessage(message: MermaidRenderResponse): void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
workerScope.addEventListener("message", (event) => {
|
|
20
|
+
const { id, source } = event.data;
|
|
21
|
+
void rendererPromise
|
|
22
|
+
.then(({ renderMermaidSVG, THEMES }) => {
|
|
23
|
+
workerScope.postMessage({
|
|
24
|
+
id,
|
|
25
|
+
ok: true,
|
|
26
|
+
svg: renderMermaidSVG(source, THEMES["zinc-light"]),
|
|
27
|
+
});
|
|
28
|
+
})
|
|
29
|
+
.catch((error) => {
|
|
30
|
+
workerScope.postMessage({
|
|
31
|
+
id,
|
|
32
|
+
ok: false,
|
|
33
|
+
error: error instanceof Error ? error.message : "Mermaid rendering failed",
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|