@runwisp/ui 0.8.0 → 0.9.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/package.json +4 -4
- package/src/lib/components/dashboard/RunDetailPanel.svelte +10 -1
- package/src/lib/components/dashboard/run-helpers.test.ts +25 -1
- package/src/lib/components/dashboard/run-helpers.ts +15 -0
- package/src/lib/components/dashboard/status-config.ts +22 -0
- package/src/lib/index.ts +1 -1
- package/src/lib/utils/error.test.ts +34 -0
- package/src/lib/utils/id.test.ts +23 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runwisp/ui",
|
|
3
3
|
"description": "Svelte 5 UI component library for RunWisp dashboards and admin interfaces.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@chromatic-com/storybook": "^4.1.3",
|
|
51
51
|
"@eslint/compat": "^1.4.0",
|
|
52
52
|
"@eslint/js": "^9.39.1",
|
|
53
|
-
"@runwisp/eslint-config": "0.
|
|
54
|
-
"@runwisp/typescript-config": "0.
|
|
53
|
+
"@runwisp/eslint-config": "0.9.0",
|
|
54
|
+
"@runwisp/typescript-config": "0.9.0",
|
|
55
55
|
"@storybook/addon-a11y": "^10.1.9",
|
|
56
56
|
"@storybook/addon-docs": "^10.1.9",
|
|
57
57
|
"@storybook/addon-svelte-csf": "^5.0.10",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@floating-ui/dom": "^1.7.4",
|
|
100
100
|
"@fontsource/tasa-orbiter": "^5.2.2",
|
|
101
101
|
"@lucide/svelte": "^0.561.0",
|
|
102
|
-
"@runwisp/common": "0.
|
|
102
|
+
"@runwisp/common": "0.9.0",
|
|
103
103
|
"@tanstack/svelte-virtual": "^3.13.25",
|
|
104
104
|
"ansi-to-html": "^0.7.2",
|
|
105
105
|
"cron-parser": "^5.4.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import { formatDateTime } from "../../utils/format.js";
|
|
22
22
|
import { formatShortId } from "../../utils/id.js";
|
|
23
23
|
import { getRunStatusConfig, runDisplayStatus } from "./status-config.js";
|
|
24
|
-
import { runDuration } from "./run-helpers.js";
|
|
24
|
+
import { runDuration, runStartDelay } from "./run-helpers.js";
|
|
25
25
|
|
|
26
26
|
let {
|
|
27
27
|
run,
|
|
@@ -94,6 +94,7 @@
|
|
|
94
94
|
{@const config = getRunStatusConfig(runDisplayStatus(run))}
|
|
95
95
|
{@const DetailIcon = config.icon}
|
|
96
96
|
{@const duration = runDuration(run)}
|
|
97
|
+
{@const startDelay = runStartDelay(run)}
|
|
97
98
|
<!-- Detailed Header -->
|
|
98
99
|
<div class="@container shrink-0 border-b border-outline-faint bg-surface-raised p-6">
|
|
99
100
|
<div class="flex flex-col justify-between gap-6 @4xl:flex-row @4xl:items-start">
|
|
@@ -200,6 +201,14 @@
|
|
|
200
201
|
<span class="font-mono text-sm font-medium whitespace-nowrap text-on-surface">
|
|
201
202
|
{run.start_at ? formatDateTime(run.start_at) : "--:--"}
|
|
202
203
|
</span>
|
|
204
|
+
{#if startDelay}
|
|
205
|
+
<span
|
|
206
|
+
class="font-mono text-xs whitespace-nowrap text-on-surface-faint"
|
|
207
|
+
title="Scheduled at {formatDateTime(run.created_at)}"
|
|
208
|
+
>
|
|
209
|
+
+{startDelay} after scheduled
|
|
210
|
+
</span>
|
|
211
|
+
{/if}
|
|
203
212
|
</div>
|
|
204
213
|
|
|
205
214
|
<div
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import { runDuration } from "./run-helpers.js";
|
|
5
|
+
import { runDuration, runStartDelay } from "./run-helpers.js";
|
|
6
6
|
|
|
7
7
|
describe("runDuration", () => {
|
|
8
8
|
it("returns undefined when start_at is not set", () => {
|
|
@@ -35,3 +35,27 @@ describe("runDuration", () => {
|
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
|
+
|
|
39
|
+
describe("runStartDelay", () => {
|
|
40
|
+
it("returns undefined when start_at is not set", () => {
|
|
41
|
+
expect(runStartDelay({ created_at: "2024-06-15T12:00:00.000Z" })).toBeUndefined();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("returns undefined when the run started within a second of its tick", () => {
|
|
45
|
+
expect(
|
|
46
|
+
runStartDelay({
|
|
47
|
+
created_at: "2024-06-15T12:00:00.000Z",
|
|
48
|
+
start_at: "2024-06-15T12:00:00.300Z",
|
|
49
|
+
}),
|
|
50
|
+
).toBeUndefined();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("formats the jitter/queue gap when the run started meaningfully later", () => {
|
|
54
|
+
expect(
|
|
55
|
+
runStartDelay({
|
|
56
|
+
created_at: "2024-06-15T03:00:00.000Z",
|
|
57
|
+
start_at: "2024-06-15T03:07:12.000Z",
|
|
58
|
+
}),
|
|
59
|
+
).toBe("7m 12s");
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -11,6 +11,21 @@ export function runDuration(run: Pick<Run, "start_at" | "end_at">): string | und
|
|
|
11
11
|
return formatDuration(end - start);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Gap between when a run was scheduled (`created_at`, the cron tick) and when
|
|
16
|
+
* it actually started (`start_at`), formatted — or undefined when the two are
|
|
17
|
+
* within a second of each other. This is the visible face of `jitter`: a
|
|
18
|
+
* jittered run is created at its tick but starts later inside the window, and
|
|
19
|
+
* this is by how much. It also surfaces queue-wait, since a queued run is
|
|
20
|
+
* created when it joins the line and started when the line clears.
|
|
21
|
+
*/
|
|
22
|
+
export function runStartDelay(run: Pick<Run, "created_at" | "start_at">): string | undefined {
|
|
23
|
+
if (!run.start_at) return undefined;
|
|
24
|
+
const delay = new Date(run.start_at).getTime() - new Date(run.created_at).getTime();
|
|
25
|
+
if (delay < 1000) return undefined;
|
|
26
|
+
return formatDuration(delay);
|
|
27
|
+
}
|
|
28
|
+
|
|
14
29
|
/**
|
|
15
30
|
* Monotonic position of a run's status in its lifecycle. Used to reject stale
|
|
16
31
|
* updates (e.g. a `pending` HTTP response arriving after an SSE already
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
CircleDashed,
|
|
12
12
|
SkipForward,
|
|
13
13
|
FileExclamationPoint,
|
|
14
|
+
CalendarX,
|
|
15
|
+
OctagonX,
|
|
14
16
|
} from "@lucide/svelte";
|
|
15
17
|
import type { Component } from "svelte";
|
|
16
18
|
import { displayStatus, type RunStatus, type Run } from "@runwisp/common";
|
|
@@ -130,6 +132,26 @@ export const RUN_STATUS_CONFIG: Record<RunStatus, RunStatusConfig> = {
|
|
|
130
132
|
description:
|
|
131
133
|
"The daemon shut down while this run was in flight and it exceeded shutdown_timeout; it was not resumed.",
|
|
132
134
|
},
|
|
135
|
+
missed: {
|
|
136
|
+
icon: CalendarX,
|
|
137
|
+
color: "text-danger-surface",
|
|
138
|
+
bg: "bg-danger-soft",
|
|
139
|
+
border: "border-danger-soft",
|
|
140
|
+
dot: "bg-danger-surface",
|
|
141
|
+
badge: "bg-danger-soft text-danger-soft-text",
|
|
142
|
+
description:
|
|
143
|
+
"A scheduled run never happened because the daemon was down. Detected and recorded on restart.",
|
|
144
|
+
},
|
|
145
|
+
start_failed: {
|
|
146
|
+
icon: OctagonX,
|
|
147
|
+
color: "text-danger-surface",
|
|
148
|
+
bg: "bg-danger-soft",
|
|
149
|
+
border: "border-danger-soft",
|
|
150
|
+
dot: "bg-danger-surface",
|
|
151
|
+
badge: "bg-danger-soft text-danger-soft-text",
|
|
152
|
+
description:
|
|
153
|
+
"The service kept failing to stay up for healthy_after; after start_retries the supervisor gave up (FATAL) and stopped restarting it.",
|
|
154
|
+
},
|
|
133
155
|
pending: {
|
|
134
156
|
icon: Clock,
|
|
135
157
|
color: "text-on-surface-muted",
|
package/src/lib/index.ts
CHANGED
|
@@ -90,7 +90,7 @@ export {
|
|
|
90
90
|
RUN_STATUS_CONFIG,
|
|
91
91
|
type RunStatusConfig,
|
|
92
92
|
} from "./components/dashboard/status-config.js";
|
|
93
|
-
export { runDuration, runPhaseOrder } from "./components/dashboard/run-helpers.js";
|
|
93
|
+
export { runDuration, runStartDelay, runPhaseOrder } from "./components/dashboard/run-helpers.js";
|
|
94
94
|
export { humanizeCron, type HumanizedCron } from "./components/dashboard/cron-format.js";
|
|
95
95
|
export type { DaemonState, DaemonStats } from "./components/dashboard/types.js";
|
|
96
96
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: PoppyCake, s.r.o.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { extractErrorMessage } from "./error.js";
|
|
6
|
+
|
|
7
|
+
describe("extractErrorMessage", () => {
|
|
8
|
+
it("returns Error.message when given an Error", () => {
|
|
9
|
+
expect(extractErrorMessage(new Error("boom"))).toBe("boom");
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("returns the fallback when an Error has an empty message", () => {
|
|
13
|
+
expect(extractErrorMessage(new Error(""))).toBe("An unexpected error occurred");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("returns a string error as-is", () => {
|
|
17
|
+
expect(extractErrorMessage("plain text error")).toBe("plain text error");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("returns the fallback for an empty string", () => {
|
|
21
|
+
expect(extractErrorMessage("")).toBe("An unexpected error occurred");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("honours a custom fallback", () => {
|
|
25
|
+
expect(extractErrorMessage(undefined, "custom fallback")).toBe("custom fallback");
|
|
26
|
+
expect(extractErrorMessage({ unrelated: 1 }, "custom fallback")).toBe("custom fallback");
|
|
27
|
+
expect(extractErrorMessage(null, "custom fallback")).toBe("custom fallback");
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("returns the default fallback for non-Error non-string values", () => {
|
|
31
|
+
expect(extractErrorMessage(42)).toBe("An unexpected error occurred");
|
|
32
|
+
expect(extractErrorMessage({ code: 500 })).toBe("An unexpected error occurred");
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: PoppyCake, s.r.o.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import { formatShortId } from "./id.js";
|
|
6
|
+
|
|
7
|
+
describe("formatShortId", () => {
|
|
8
|
+
it("returns the last 8 characters by default", () => {
|
|
9
|
+
expect(formatShortId("01HVZ4XYZ123456ABCDEF")).toBe("56ABCDEF");
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it("honours a custom length", () => {
|
|
13
|
+
expect(formatShortId("01HVZ4XYZ123456ABCDEF", 4)).toBe("CDEF");
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("returns the whole string when shorter than the requested length", () => {
|
|
17
|
+
expect(formatShortId("abc", 8)).toBe("abc");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("returns an empty string for an empty input", () => {
|
|
21
|
+
expect(formatShortId("")).toBe("");
|
|
22
|
+
});
|
|
23
|
+
});
|