[PR #3239] [MERGED] feat: in-app documentation viewer + FAQ entry + homepage button (#3238) #5856

Closed
opened 2026-10-22 04:20:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3239
Author: @kolacheee
Created: 7/5/2026
Status: ✅ Merged
Merged: 7/5/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/3238-in-app-docs


📝 Commits (10+)

  • 3891df3 chore: start in-app documentation viewer (#3238)
  • eb27820 feat: in-app documentation viewer with FAQ entry and home footer button (#3238)
  • 2966633 fix: render docs with engine markdown styles, ship docs/ in Docker images, harden viewer edge cases (#3238)
  • a5b62c8 feat: docs viewer search, last-updated dates, larger layout, and reading-place memory (#3238)
  • 03efe61 fix: docs viewer polish from review: safe-area height, saved-place edge cases, search count and snippets (#3238)
  • 51a7c66 fix: docs viewer scroll restore raced the modal mount; widen to max-w-6xl; add code block copy buttons (#3238)
  • 4188ffc fix: move docs code block copy button to bottom-right, clear of the language tag (#3238)
  • fc17bd9 feat: docs viewer opens as a full-screen window on mobile via new Modal mobileFullscreen prop (#3238)
  • 2889c14 fix: wrap docs code blocks instead of horizontal scroll so the lang tag and Copy button stay corner-anchored (#3238)
  • 9082633 Harden docs content path resolution

📊 Changes

12 files changed (+871 additions, -13 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 Dockerfile (+3 -0)
📝 Dockerfile.lite (+3 -0)
📝 docs/FAQ.md (+17 -0)
📝 packages/client/src/components/chat/ChatArea.tsx (+24 -10)
📝 packages/client/src/components/chat/HomeFaq.tsx (+51 -1)
📝 packages/client/src/components/layout/ModalRenderer.tsx (+8 -0)
➕ packages/client/src/components/modals/DocsViewerModal.tsx (+436 -0)
📝 packages/client/src/components/ui/Modal.tsx (+13 -2)
➕ packages/client/src/hooks/use-docs.ts (+81 -0)
➕ packages/server/src/routes/docs.routes.ts (+232 -0)
📝 packages/server/src/routes/index.ts (+2 -0)

📄 Description

Closes #3238

Summary

Adds an in-app documentation viewer so the guides shipped in docs/ can be read directly inside Marinara, discoverable from a new Documentation button in the home page footer (next to Replay Tutorial) and a new FAQ entry ("Where can I find documentation?") that shows the on-disk docs path and opens the viewer. The viewer supports full-text search across all guides, shows a per-guide "Last updated" date, has one-click Copy buttons on every code block, and remembers the reader's place (guide + scroll position) across close/reopen.

Why

Marinara ships ~28 user guides (installation, configuration, troubleshooting, macros, extensions, Game Mode, and more), but the app never mentioned them — users had to already know the docs folder existed inside the install directory. Discussed and approved beforehand; see #3238. The search, last-updated dates, larger layout, place-memory, and code-block copy buttons were requested during testing: last-updated helps triage "is this documentation outdated?" reports, place-memory supports bouncing in and out of the viewer while referencing macros/CSS guides mid-chat, and copy buttons serve the CSS-theming guide's paste-a-snippet workflow.

Architecture

Layer Change
Server New docs.routes.ts: GET /api/docs (index with titles from each file's first # heading, file-mtime updatedAt, and the absolute on-disk docs path), GET /api/docs/content?path=… (one markdown file), and GET /api/docs/search?q=… (case-insensitive full-text search with per-doc match counts and match-windowed line snippets). Path safety: per-segment validation (no ../\/null bytes), .md-only, case-insensitive exclusion of internal artifact folders (evidence/, pr-evidence/, screenshots/, examples/), assertInsideDir containment, and the MAX_DOC_BYTES size guard applied on both content and search reads.
Client New DocsViewerModal (max-w-6xl, fills the modal shell height on desktop; on mobile it opens as a full-screen window via a new opt-in mobileFullscreen prop on the shared Modal — edge-to-edge, square corners, safe-area padding inside the panel; registered as docs-viewer in ModalRenderer), use-docs.ts React Query hooks (staleTime: Infinity, debounced search), FAQ entry + FaqDocsAccess block in HomeFaq, footer button in ChatArea. Reading place persists via sessionStorage; the reader element is tracked with a state callback ref because the Modal shell renders null on its first frame (plain refs never see the portal DOM when the doc is already cached).
Rendering Reuses the chat markdown renderer (renderMarkdownBlocks) inside the standard mari-message-content styling scope. A prepareDocMarkdown pass converts the structural HTML used by docs/FAQ.md (<details>/<summary> blocks, anchor tags) into headings and rewrites relative cross-doc links to the content endpoint; a click handler follows those inside the modal, so cross-doc navigation works. Opening a search result jumps to the first occurrence of the term in the rendered text. Code blocks get a Copy button via viewer-scoped DOM augmentation (the renderer is shared with chat, so it is not modified globally).
Packaging Dockerfile and Dockerfile.lite production stages now COPY docs/ docs/ — container images previously shipped no docs at all, which would have 404'd the viewer for every Docker/Podman/HF-Spaces user. (Windows installer and Termux installs are full clones and already include docs/.)

What was verified so far (automated)

  • pnpm check green (lint + production build).
  • API smoke-tested against the built server: index returns all 28 guides with correct titles + updatedAt (CRLF files included) and pinned ordering; nested paths work; search returns windowed snippets, correct counts (H1 not double-counted), 400 on sub-2-character queries, and empty results cleanly.
  • Path-traversal probes all rejected (../, encoded/double-encoded, backslash, absolute path, null byte, excluded dirs in any letter case).
  • The markdown preprocessing was run against the real FAQ.md, INSTALLATION.md, installation/ios-pwa.md, and PROFESSOR_MARI.md: zero leftover raw-HTML lines, zero unrewritten relative links, correct ../ resolution from nested docs.
  • Two multi-agent adversarial review passes over the diff; all confirmed findings fixed (inert prose classes → mari-message-content, Docker docs packaging, FAQ.md HTML handling, cross-doc links, safe-area-aware mobile height, saved-place edge cases, search count/snippet windowing, duplicate native search-clear button, scroll-restore racing the modal mount animation).

Manual verification

  • Home page footer shows the Documentation button next to Replay Tutorial; clicking opens the viewer.
  • FAQ entry "Where can I find documentation?" appears (first Setup entry), shows the real on-disk path, and its Open Documentation button opens the viewer — in both the full home FAQ and the compact Professor Mari FAQ.
  • Viewer size feels right on desktop (wide two-pane layout, fills the modal shell).
  • FAQ.md renders with proper headings (no visible <details>/<summary> tags); lists/tables/code blocks styled; paragraphs separated.
  • "Last updated" date shows in the reader header and as a tooltip on sidebar entries.
  • Search: type a term (e.g. "macro"), see ranked results with snippets, click one → doc opens scrolled to the first occurrence; clear search returns to the guide list.
  • Code blocks show a Copy button (top right, next to the language tag); clicking copies the snippet and flashes "Copied!".
  • Close the viewer mid-guide, reopen → same guide at the same scroll position.
  • Cross-doc links navigate inside the modal (e.g. INSTALLATION.md → Windows Installation Guide); external links still open in a new tab.
  • Light mode AND dark mode.
  • Mobile viewport (~400px): the viewer opens as a full-screen window (no floating bubble margins); list ↔ reader switching with the back arrow; nothing overflows.
  • Empty/error states: stop the server mid-open → list shows the error message.

Known limitations

  • In-page #anchor fragments in cross-doc links are dropped (navigates to the top of the target doc); same-page anchor links render as plain text.
  • Relative image references inside docs (e.g. screenshots/*.png) are not served and render as text — no shipped top-level guide currently relies on them for comprehension.
  • updatedAt is the file's on-disk modification time: on fresh installs it reflects install/update time rather than when the guide was authored. It still distinguishes "docs from three versions ago" from "docs updated with this release".
  • Search-result jump targets the rendered text; a term that only appears inside a link URL or stripped HTML opens the doc at the top.

Docs touched

  • docs/FAQ.md — new entry: "How do I read the documentation inside the app?"
  • CHANGELOG.md — Unreleased → Added entry.

UI Evidence

image image image image

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/3239 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 7/5/2026 **Status:** ✅ Merged **Merged:** 7/5/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/3238-in-app-docs` --- ### 📝 Commits (10+) - [`3891df3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3891df341ec47d19c85e98dedd17f803de764c41) chore: start in-app documentation viewer (#3238) - [`eb27820`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eb2782086cde902665b86704b44007335b59731c) feat: in-app documentation viewer with FAQ entry and home footer button (#3238) - [`2966633`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2966633ea27f2891af20cd4725e75deab44da0ce) fix: render docs with engine markdown styles, ship docs/ in Docker images, harden viewer edge cases (#3238) - [`a5b62c8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a5b62c8be2572907572eb7ef89f02699fba4bdc6) feat: docs viewer search, last-updated dates, larger layout, and reading-place memory (#3238) - [`03efe61`](https://github.com/Pasta-Devs/Marinara-Engine/commit/03efe61e34e27f8c8253ef14c33105cb2ed12262) fix: docs viewer polish from review: safe-area height, saved-place edge cases, search count and snippets (#3238) - [`51a7c66`](https://github.com/Pasta-Devs/Marinara-Engine/commit/51a7c668085efcbed4ae881e1df1eea9beab0600) fix: docs viewer scroll restore raced the modal mount; widen to max-w-6xl; add code block copy buttons (#3238) - [`4188ffc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4188ffc0f2b9590938ffb91b3da3ab888057ac86) fix: move docs code block copy button to bottom-right, clear of the language tag (#3238) - [`fc17bd9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fc17bd96a7e6d829c950de93e11056d39286c9a5) feat: docs viewer opens as a full-screen window on mobile via new Modal mobileFullscreen prop (#3238) - [`2889c14`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2889c14d1bd2880b738bdf3aed15b9b9ddcf6dc3) fix: wrap docs code blocks instead of horizontal scroll so the lang tag and Copy button stay corner-anchored (#3238) - [`9082633`](https://github.com/Pasta-Devs/Marinara-Engine/commit/9082633937c2746b63960e3e5191b180af4dde0d) Harden docs content path resolution ### 📊 Changes **12 files changed** (+871 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `Dockerfile` (+3 -0) 📝 `Dockerfile.lite` (+3 -0) 📝 `docs/FAQ.md` (+17 -0) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+24 -10) 📝 `packages/client/src/components/chat/HomeFaq.tsx` (+51 -1) 📝 `packages/client/src/components/layout/ModalRenderer.tsx` (+8 -0) ➕ `packages/client/src/components/modals/DocsViewerModal.tsx` (+436 -0) 📝 `packages/client/src/components/ui/Modal.tsx` (+13 -2) ➕ `packages/client/src/hooks/use-docs.ts` (+81 -0) ➕ `packages/server/src/routes/docs.routes.ts` (+232 -0) 📝 `packages/server/src/routes/index.ts` (+2 -0) </details> ### 📄 Description Closes #3238 ## Summary Adds an in-app documentation viewer so the guides shipped in `docs/` can be read directly inside Marinara, discoverable from a new **Documentation** button in the home page footer (next to **Replay Tutorial**) and a new FAQ entry ("Where can I find documentation?") that shows the on-disk docs path and opens the viewer. The viewer supports full-text search across all guides, shows a per-guide "Last updated" date, has one-click Copy buttons on every code block, and remembers the reader's place (guide + scroll position) across close/reopen. ## Why Marinara ships ~28 user guides (installation, configuration, troubleshooting, macros, extensions, Game Mode, and more), but the app never mentioned them — users had to already know the `docs` folder existed inside the install directory. Discussed and approved beforehand; see #3238. The search, last-updated dates, larger layout, place-memory, and code-block copy buttons were requested during testing: last-updated helps triage "is this documentation outdated?" reports, place-memory supports bouncing in and out of the viewer while referencing macros/CSS guides mid-chat, and copy buttons serve the CSS-theming guide's paste-a-snippet workflow. ## Architecture | Layer | Change | |---|---| | Server | New `docs.routes.ts`: `GET /api/docs` (index with titles from each file's first `#` heading, file-mtime `updatedAt`, and the absolute on-disk docs path), `GET /api/docs/content?path=…` (one markdown file), and `GET /api/docs/search?q=…` (case-insensitive full-text search with per-doc match counts and match-windowed line snippets). Path safety: per-segment validation (no `..`/`\`/null bytes), `.md`-only, case-insensitive exclusion of internal artifact folders (`evidence/`, `pr-evidence/`, `screenshots/`, `examples/`), `assertInsideDir` containment, and the `MAX_DOC_BYTES` size guard applied on both content and search reads. | | Client | New `DocsViewerModal` (`max-w-6xl`, fills the modal shell height on desktop; on mobile it opens as a full-screen window via a new opt-in `mobileFullscreen` prop on the shared `Modal` — edge-to-edge, square corners, safe-area padding inside the panel; registered as `docs-viewer` in `ModalRenderer`), `use-docs.ts` React Query hooks (`staleTime: Infinity`, debounced search), FAQ entry + `FaqDocsAccess` block in `HomeFaq`, footer button in `ChatArea`. Reading place persists via `sessionStorage`; the reader element is tracked with a state callback ref because the `Modal` shell renders `null` on its first frame (plain refs never see the portal DOM when the doc is already cached). | | Rendering | Reuses the chat markdown renderer (`renderMarkdownBlocks`) inside the standard `mari-message-content` styling scope. A `prepareDocMarkdown` pass converts the structural HTML used by `docs/FAQ.md` (`<details>`/`<summary>` blocks, anchor tags) into headings and rewrites relative cross-doc links to the content endpoint; a click handler follows those inside the modal, so cross-doc navigation works. Opening a search result jumps to the first occurrence of the term in the rendered text. Code blocks get a Copy button via viewer-scoped DOM augmentation (the renderer is shared with chat, so it is not modified globally). | | Packaging | `Dockerfile` and `Dockerfile.lite` production stages now `COPY docs/ docs/` — container images previously shipped no docs at all, which would have 404'd the viewer for every Docker/Podman/HF-Spaces user. (Windows installer and Termux installs are full clones and already include `docs/`.) | ## What was verified so far (automated) - `pnpm check` green (lint + production build). - API smoke-tested against the built server: index returns all 28 guides with correct titles + `updatedAt` (CRLF files included) and pinned ordering; nested paths work; search returns windowed snippets, correct counts (H1 not double-counted), 400 on sub-2-character queries, and empty results cleanly. - Path-traversal probes all rejected (`../`, encoded/double-encoded, backslash, absolute path, null byte, excluded dirs in any letter case). - The markdown preprocessing was run against the real `FAQ.md`, `INSTALLATION.md`, `installation/ios-pwa.md`, and `PROFESSOR_MARI.md`: zero leftover raw-HTML lines, zero unrewritten relative links, correct `../` resolution from nested docs. - Two multi-agent adversarial review passes over the diff; all confirmed findings fixed (inert `prose` classes → `mari-message-content`, Docker docs packaging, FAQ.md HTML handling, cross-doc links, safe-area-aware mobile height, saved-place edge cases, search count/snippet windowing, duplicate native search-clear button, scroll-restore racing the modal mount animation). ## Manual verification - [x] Home page footer shows the **Documentation** button next to **Replay Tutorial**; clicking opens the viewer. - [x] FAQ entry "Where can I find documentation?" appears (first Setup entry), shows the real on-disk path, and its **Open Documentation** button opens the viewer — in both the full home FAQ and the compact Professor Mari FAQ. - [x] Viewer size feels right on desktop (wide two-pane layout, fills the modal shell). - [x] FAQ.md renders with proper headings (no visible `<details>`/`<summary>` tags); lists/tables/code blocks styled; paragraphs separated. - [x] "Last updated" date shows in the reader header and as a tooltip on sidebar entries. - [x] Search: type a term (e.g. "macro"), see ranked results with snippets, click one → doc opens scrolled to the first occurrence; clear search returns to the guide list. - [x] Code blocks show a Copy button (top right, next to the language tag); clicking copies the snippet and flashes "Copied!". - [x] Close the viewer mid-guide, reopen → same guide at the same scroll position. - [x] Cross-doc links navigate inside the modal (e.g. INSTALLATION.md → Windows Installation Guide); external links still open in a new tab. - [x] Light mode AND dark mode. - [x] Mobile viewport (~400px): the viewer opens as a full-screen window (no floating bubble margins); list ↔ reader switching with the back arrow; nothing overflows. - [x] Empty/error states: stop the server mid-open → list shows the error message. ## Known limitations - In-page `#anchor` fragments in cross-doc links are dropped (navigates to the top of the target doc); same-page anchor links render as plain text. - Relative image references inside docs (e.g. `screenshots/*.png`) are not served and render as text — no shipped top-level guide currently relies on them for comprehension. - `updatedAt` is the file's on-disk modification time: on fresh installs it reflects install/update time rather than when the guide was authored. It still distinguishes "docs from three versions ago" from "docs updated with this release". - Search-result jump targets the rendered text; a term that only appears inside a link URL or stripped HTML opens the doc at the top. ## Docs touched - `docs/FAQ.md` — new entry: "How do I read the documentation inside the app?" - `CHANGELOG.md` — Unreleased → Added entry. ## UI Evidence <img width="1180" height="873" alt="image" src="https://github.com/user-attachments/assets/0468974a-f9a4-4d0f-b6ef-2b80eaac6dbc" /> <img width="1313" height="831" alt="image" src="https://github.com/user-attachments/assets/7b03b2d6-d3b0-49bc-90b8-3943bcc3e677" /> <img width="386" height="581" alt="image" src="https://github.com/user-attachments/assets/2b8e1bbc-54b6-4654-b352-0a5eea4f7c0e" /> <img width="1298" height="828" alt="image" src="https://github.com/user-attachments/assets/9e14b22f-2b48-4af6-9dcd-fc490f28d238" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:20:14 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5856
No description provided.