Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): show graph tooltip titles and URLs as plain text (#6513)

Dimitri POSTOLOVcdec5abe2ada
diff --git a/.changeset/graph-tooltip-plain-text.md b/.changeset/graph-tooltip-plain-text.md
new file mode 100644
index 000000000..ea0cf7d5d
--- /dev/null
+++ b/.changeset/graph-tooltip-plain-text.md
@@ -0,0 +1,5 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+Graph view tooltips now show document titles and link URLs as plain text, even when they contain HTML tags.
diff --git a/packages/app/src/components/graph-view-utils.ts b/packages/app/src/components/graph-view-utils.ts
index 1c39fd81b..46717eed6 100644
--- a/packages/app/src/components/graph-view-utils.ts
+++ b/packages/app/src/components/graph-view-utils.ts
@@ -201,12 +201,12 @@ export function getGraphNodeTooltipLabel(
displayState?: GraphDocDisplayState;
} = {},
): string {
- if (node.kind === 'external') return node.url;
+ if (node.kind === 'external') return escapeHtml(node.url);
const title = node.label ?? node.id;
const displayState = options.displayState ?? 'doc';
const hasMetadata = node.cluster || node.category || (node.tags && node.tags.length > 0);
- if (displayState === 'doc' && !hasMetadata) return title;
+ if (displayState === 'doc' && !hasMetadata) return escapeHtml(title);
const lines: string[] = [
...getGraphNodeTooltipStatusLines(displayState),
diff --git a/packages/app/tests/stress/graph-panel-surfaces.e2e.ts b/packages/app/tests/stress/graph-panel-surfaces.e2e.ts
index 49b59c39e..bfe72f575 100644
--- a/packages/app/tests/stress/graph-panel-surfaces.e2e.ts
+++ b/packages/app/tests/stress/graph-panel-surfaces.e2e.ts
@@ -542,3 +542,66 @@ test('docked graph clicks still navigate immediately with anchor-preserving hash
expect(await clickGraphDoc(page, fixtures.beta)).toBe(true);
await expect(page).toHaveURL(new RegExp(`#/${escapeRegExp(fixtures.beta)}#deep-link$`));
});
+
+async function fetchLinkGraphNodes(baseURL: string) {
+ const response = await fetch(`${baseURL}/api/link-graph`);
+ const data: {
+ nodes?: Array<{ kind?: string; docName?: string; url?: string; label?: string }>;
+ } = await response.json();
+ return data.nodes ?? [];
+}
+
+async function expectGraphNodeTooltipText(page: Page, nodeKey: string, text: string) {
+ const tooltip = page.locator('.float-tooltip-kap');
+ await expect(async () => {
+ const point = await getGraphNodeClickPoint(page, nodeKey);
+ if (!point) {
+ throw new Error(`Expected a hover point for graph node ${nodeKey}`);
+ }
+ await page.mouse.move(0, 0);
+ await getGraphSurface(page).hover({ position: point, force: true });
+ await expect(tooltip).toHaveText(text, { timeout: 1_000 });
+ }).toPass({ timeout: 15_000 });
+ await expect(tooltip.locator('*')).toHaveCount(0);
+}
+
+test('graph node tooltips show a markup document title as text', async ({ page, api, baseURL }) => {
+ const fixtures = await seedGraphFixtures(api, baseURL);
+ const title = `<i>Zeta ${fixtures.suffix}</i>`;
+ await api.replaceDoc(fixtures.zeta, `# ${title}\n\n[[${fixtures.beta}]]`);
+ await expect
+ .poll(
+ async () =>
+ (await fetchLinkGraphNodes(baseURL)).find((node) => node.docName === fixtures.zeta)?.label,
+ { timeout: 10_000, intervals: [200, 500, 1000] },
+ )
+ .toBe(title);
+
+ await openGraph(page, { docName: fixtures.alpha, fullscreen: true });
+ await waitForGraphNode(page, fixtures.zeta);
+ await waitForGraphSimulationSettled(page);
+
+ await expectGraphNodeTooltipText(page, fixtures.zeta, title);
+});
+
+test('graph external node tooltips show a markup URL as text', async ({ page, api, baseURL }) => {
+ const fixtures = await seedGraphFixtures(api, baseURL);
+ const url = `https://example.com/${fixtures.suffix}<i>docs</i>`;
+ await api.replaceDoc(fixtures.alpha, `# Alpha\n\n[[${fixtures.beta}]]\n\n[Example](${url})`);
+ await expect
+ .poll(
+ async () =>
+ (await fetchLinkGraphNodes(baseURL)).some(
+ (node) => node.kind === 'external' && node.url === url,
+ ),
+ { timeout: 10_000, intervals: [200, 500, 1000] },
+ )
+ .toBe(true);
+
+ await openGraph(page, { docName: fixtures.alpha, fullscreen: true });
+ await page.getByLabel('Show external URL nodes').click();
+ await waitForGraphNodeClickPoint(page, url);
+ await waitForGraphSimulationSettled(page);
+
+ await expectGraphNodeTooltipText(page, url, url);
+});