@app-vitals/agent-admin 1.130.0 → 1.131.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.131.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@anthropic-ai/sdk": "0.137.0",
|
|
47
|
-
"@app-vitals/agent-lib": "1.
|
|
47
|
+
"@app-vitals/agent-lib": "1.131.0",
|
|
48
48
|
"@hono/zod-openapi": "^1.0.0",
|
|
49
49
|
"@prisma/adapter-pg": "^7.10.0",
|
|
50
50
|
"@prisma/client": "^7.10.0",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* admin/src/admin-ui-info-tip.ts
|
|
3
|
+
*
|
|
4
|
+
* Shared CSS-only info tooltip: a focusable ⓘ button plus a popover that opens
|
|
5
|
+
* on hover and keyboard focus. Styles live in baseStyles() (admin-ui-styles.ts).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { escapeHtml } from "@app-vitals/agent-lib/web/toolbar.ts";
|
|
9
|
+
|
|
10
|
+
/** Base URL for product docs links shown in info tooltips. */
|
|
11
|
+
export const ADMIN_DOCS_BASE_URL = "https://shipwrightharness.com/docs/";
|
|
12
|
+
|
|
13
|
+
export interface InfoTipOptions {
|
|
14
|
+
/** Unique id; becomes the popover element id (aria-describedby target). */
|
|
15
|
+
id: string;
|
|
16
|
+
/** Short subject name, used in the button's aria-label ("About {label}"). */
|
|
17
|
+
label: string;
|
|
18
|
+
/** Plain-text summary shown in the popover (escaped). */
|
|
19
|
+
summary: string;
|
|
20
|
+
/** Absolute URL for the "Learn more →" link. */
|
|
21
|
+
docsHref: string;
|
|
22
|
+
/** "end" opens the popover leftward (anchored to the right edge). */
|
|
23
|
+
align?: "start" | "end";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Focusable info button + CSS popover with a docs link. */
|
|
27
|
+
export function renderInfoTip(opts: InfoTipOptions): string {
|
|
28
|
+
const id = escapeHtml(opts.id);
|
|
29
|
+
const alignClass = opts.align === "end" ? " info-tip-end" : "";
|
|
30
|
+
return `<span class="info-tip${alignClass}"><button type="button" class="info-tip-btn" onclick="event.preventDefault();event.stopPropagation()" aria-label="About ${escapeHtml(opts.label)}" aria-describedby="${id}">ⓘ</button><span role="tooltip" id="${id}" class="info-tip-pop">${escapeHtml(opts.summary)}<a href="${escapeHtml(opts.docsHref)}" target="_blank" rel="noopener">Learn more →</a></span></span>`;
|
|
31
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { ADMIN_DOCS_BASE_URL, renderInfoTip } from "./admin-ui-info-tip.ts";
|
|
3
|
+
|
|
4
|
+
const base = {
|
|
5
|
+
id: "tip-1",
|
|
6
|
+
label: "Widgets",
|
|
7
|
+
summary: "Explains widgets.",
|
|
8
|
+
docsHref: `${ADMIN_DOCS_BASE_URL}widgets`,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
describe("renderInfoTip", () => {
|
|
12
|
+
test("renders a button with aria wiring and a tooltip popover", () => {
|
|
13
|
+
const html = renderInfoTip(base);
|
|
14
|
+
expect(html).toContain('<button type="button" class="info-tip-btn"');
|
|
15
|
+
expect(html).toContain("ⓘ</button>");
|
|
16
|
+
expect(html).toContain('aria-label="About Widgets"');
|
|
17
|
+
expect(html).toContain('aria-describedby="tip-1"');
|
|
18
|
+
expect(html).toContain('role="tooltip" id="tip-1"');
|
|
19
|
+
expect(html).toContain("Explains widgets.");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test("link opens a new tab safely", () => {
|
|
23
|
+
const html = renderInfoTip(base);
|
|
24
|
+
expect(html).toContain(
|
|
25
|
+
`<a href="https://shipwrightharness.com/docs/widgets" target="_blank" rel="noopener">Learn more →</a>`,
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("activating the button does not trigger its container", () => {
|
|
30
|
+
const html = renderInfoTip(base);
|
|
31
|
+
expect(html).toContain("event.preventDefault()");
|
|
32
|
+
expect(html).toContain("event.stopPropagation()");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("escapes < \" ' in summary, label and id", () => {
|
|
36
|
+
const html = renderInfoTip({
|
|
37
|
+
...base,
|
|
38
|
+
id: `a"b`,
|
|
39
|
+
label: `<b>"x"</b>'`,
|
|
40
|
+
summary: `<script>alert("x")</script>'`,
|
|
41
|
+
});
|
|
42
|
+
expect(html).not.toContain("<script>");
|
|
43
|
+
expect(html).not.toContain("<b>");
|
|
44
|
+
expect(html).toContain("<script>");
|
|
45
|
+
expect(html).toContain(""");
|
|
46
|
+
expect(html).not.toContain(`id="a"b"`);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("align end adds the leftward modifier; default does not", () => {
|
|
50
|
+
expect(renderInfoTip({ ...base, align: "end" })).toContain(
|
|
51
|
+
'class="info-tip info-tip-end"',
|
|
52
|
+
);
|
|
53
|
+
expect(renderInfoTip(base)).not.toContain("info-tip-end");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("docs base constant is the product docs URL", () => {
|
|
57
|
+
expect(ADMIN_DOCS_BASE_URL).toBe("https://shipwrightharness.com/docs/");
|
|
58
|
+
});
|
|
59
|
+
});
|
package/src/admin-ui-styles.ts
CHANGED
|
@@ -397,6 +397,40 @@ export function baseStyles(): string {
|
|
|
397
397
|
pointer-events: none;
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
+
/* ─── Info tip (ⓘ button + CSS popover; hover and focus-within) ─── */
|
|
401
|
+
.info-tip { position: relative; display: inline-block; vertical-align: middle; }
|
|
402
|
+
.info-tip-btn {
|
|
403
|
+
border: 0;
|
|
404
|
+
background: none;
|
|
405
|
+
padding: 0 4px;
|
|
406
|
+
cursor: pointer;
|
|
407
|
+
font-size: 14px;
|
|
408
|
+
line-height: 1;
|
|
409
|
+
color: var(--vos-text-muted);
|
|
410
|
+
}
|
|
411
|
+
.info-tip-pop {
|
|
412
|
+
display: none;
|
|
413
|
+
position: absolute;
|
|
414
|
+
left: 0;
|
|
415
|
+
top: 100%;
|
|
416
|
+
z-index: 10;
|
|
417
|
+
width: 260px;
|
|
418
|
+
padding: 10px 12px;
|
|
419
|
+
border: 1px solid var(--vos-border);
|
|
420
|
+
border-radius: 6px;
|
|
421
|
+
background: var(--vos-surface);
|
|
422
|
+
color: var(--vos-text);
|
|
423
|
+
font-size: 12px;
|
|
424
|
+
font-weight: normal;
|
|
425
|
+
line-height: 1.4;
|
|
426
|
+
text-align: left;
|
|
427
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
428
|
+
}
|
|
429
|
+
.info-tip-end .info-tip-pop { left: auto; right: 0; }
|
|
430
|
+
.info-tip:hover .info-tip-pop,
|
|
431
|
+
.info-tip:focus-within .info-tip-pop { display: block; }
|
|
432
|
+
.info-tip-pop a { display: block; margin-top: 6px; }
|
|
433
|
+
|
|
400
434
|
/* ─── Heartbeat status dots (fresh/aging/stale) ─────── */
|
|
401
435
|
.heartbeat-dot {
|
|
402
436
|
display: inline-block;
|
|
@@ -148,3 +148,19 @@ describe("baseStyles — SGL-1.1 settings layout", () => {
|
|
|
148
148
|
expect(block).toContain("var(--vos-");
|
|
149
149
|
});
|
|
150
150
|
});
|
|
151
|
+
|
|
152
|
+
describe("baseStyles — info tip", () => {
|
|
153
|
+
const css = baseStyles();
|
|
154
|
+
test("contains the info tip rules with hover and focus-within reveal", () => {
|
|
155
|
+
expect(css).toContain(".info-tip-pop");
|
|
156
|
+
expect(css).toContain(".info-tip:hover .info-tip-pop");
|
|
157
|
+
expect(css).toContain(".info-tip:focus-within .info-tip-pop");
|
|
158
|
+
expect(css).toContain(".info-tip-end .info-tip-pop");
|
|
159
|
+
});
|
|
160
|
+
test("uses theme variables, and the old header tooltip is unchanged", () => {
|
|
161
|
+
expect(css).toContain("background: var(--vos-surface)");
|
|
162
|
+
expect(css).toContain("color: var(--vos-text)");
|
|
163
|
+
expect(css).toContain(".header-tooltip[data-tip]:hover::after");
|
|
164
|
+
expect(css).toContain("content: attr(data-tip)");
|
|
165
|
+
});
|
|
166
|
+
});
|