Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(docs): show search snippets as prose instead of raw Markdown

rubenluetke10-beep6527b576471a
diff --git a/jarvis/ui/web/frontend/src/components/docs/DocsSearchModal.test.tsx b/jarvis/ui/web/frontend/src/components/docs/DocsSearchModal.test.tsx
index 65b3ce1f5f..27bebd085a 100644
--- a/jarvis/ui/web/frontend/src/components/docs/DocsSearchModal.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/docs/DocsSearchModal.test.tsx
@@ -26,6 +26,21 @@ describe("renderSearchSnippet", () => {
expect(container.textContent).toContain("<script>");
});
+ it("shows snippets as prose, without Markdown syntax", () => {
+ const { container } = render(
+ <div>
+ {renderSearchSnippet(
+ "Open **Settings > <mark>Wake</mark> Word** | read [Audio and <mark>Wake</mark>](audio-and-<mark>wake</mark>-word).",
+ )}
+ </div>,
+ );
+
+ expect(container.textContent).toBe(
+ "Open Settings > Wake Word · read Audio and Wake.",
+ );
+ expect(container.querySelectorAll("mark")).toHaveLength(2);
+ });
+
it("distinguishes a failed search from an empty result", async () => {
vi.stubGlobal(
"ResizeObserver",
diff --git a/jarvis/ui/web/frontend/src/components/docs/DocsSearchModal.tsx b/jarvis/ui/web/frontend/src/components/docs/DocsSearchModal.tsx
index c1f8e26404..89d71c3ee8 100644
--- a/jarvis/ui/web/frontend/src/components/docs/DocsSearchModal.tsx
+++ b/jarvis/ui/web/frontend/src/components/docs/DocsSearchModal.tsx
@@ -267,8 +267,24 @@ function SuggestionItem({
);
}
+/**
+ * The index stores raw Markdown, so a snippet arrives with ``**``, link
+ * targets and table pipes in it. Strip that syntax (keeping the ``<mark>``
+ * highlights) so a result reads as prose.
+ */
+export function cleanSnippetMarkdown(value: string): string {
+ return value
+ .replace(/\]\([^)]*\)/g, "]")
+ .replace(/[[\]]/g, "")
+ .replace(/(\*\*|__|`)/g, "")
+ .replace(/(^|\s)#{1,6}\s/g, "$1")
+ .replace(/\s*\|\s*/g, " · ")
+ .replace(/\s{2,}/g, " ")
+ .trim();
+}
+
export function renderSearchSnippet(value: string): React.ReactNode {
- const parts = value.split(/(<mark>|<\/mark>)/gi);
+ const parts = cleanSnippetMarkdown(value).split(/(<mark>|<\/mark>)/gi);
let marked = false;
return parts.map((part, index) => {
if (part.toLowerCase() === "<mark>") {