Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(avatar): drop the SVG <title>, so the row tooltip shows the bot name

Pepe Neif594b62ff69ce
diff --git a/packages/phone-protocol/src/open-bot-avatar/render.ts b/packages/phone-protocol/src/open-bot-avatar/render.ts
index bf2aa849e2..babddcd2dc 100644
--- a/packages/phone-protocol/src/open-bot-avatar/render.ts
+++ b/packages/phone-protocol/src/open-bot-avatar/render.ts
@@ -670,8 +670,10 @@ export function renderAvatarSvg(definition: AvatarDefinition, options: RenderOpt
const label = esc(frame.name);
return (
+ // A <title> builds a browser tooltip of its own, so hovering a bot's avatar showed the body's
+ // name ("Star", "Mug") instead of the name and title shown beside the row. aria-label already
+ // names the image for assistive tech, so the duplicate title only costs the tooltip.
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"${dims} role="img" aria-label="${label}" overflow="visible">` +
- `<title>${label}</title>` +
`<defs>${defsMarkup}</defs>` +
`<g transform="${mat(frame.root)}" fill="${frame.color}">` +
body +
diff --git a/shared/avatar-tooltip.test.ts b/shared/avatar-tooltip.test.ts
new file mode 100644
index 0000000000..88566f6e9f
--- /dev/null
+++ b/shared/avatar-tooltip.test.ts
@@ -0,0 +1,13 @@
+import { describe, expect, it } from "vitest";
+
+import { renderAvatarSvg } from "../packages/phone-protocol/src/open-bot-avatar/render.ts";
+import { OBJECT_BODIES } from "./object-bodies.ts";
+
+describe("avatar svg", () => {
+ it("names the avatar with aria-label only, so no <title> tooltip hides the row's", () => {
+ const svg = renderAvatarSvg(OBJECT_BODIES["obj-mug"]);
+ expect(svg).toContain('role="img"');
+ expect(svg).toContain('aria-label="Mug"');
+ expect(svg).not.toContain("<title>");
+ });
+});