# HTML File Rendering — Implementation Plan ## Goal Replace the `
` raw text fallback in the knowledge view with a proper HTML file renderer using ``. ## Scope - Only HTML file rendering for now - No layout changes, no split pane - No other file types in this PR --- ## Phase 1 — IPC: Read HTML file content and pass to renderer ### What Add an IPC handler in the main process that reads a local HTML file and returns its content as a string to the renderer. ### Work 1. Add `knowledge:readHtmlFile` handler in `apps/main/src/ipc.ts` - Accepts a workspace-relative path - Resolves to absolute path, validates it stays inside workspace root (path traversal guard) - Reads file as UTF-8 string - Returns the HTML string to renderer 2. Add the channel type to `packages/shared/src/ipc.ts` ### Test ✅ - Open a `.html` file from the knowledge tree - Console log the returned string in the renderer - Verify: correct HTML content is returned, no errors - Verify: attempting a path like `../../secret.txt` is rejected with an error --- ## Phase 2 — Renderer: Detect `.html` files and render in iframe ### What In `App.tsx`, detect when `selectedPath` is an `.html` file and render it in a sandboxed `` instead of the `` fallback. ### Work 1. In the file loading logic (`App.tsx:1284–1357`), when extension is `.html`: - Call `knowledge:readHtmlFile` via IPC - Store the HTML string in state 2. In the knowledge view render switch (`App.tsx:4522–4527`): - Add a condition: if extension is `.html` → render `` - Otherwise fall through to existing `` fallback 3. Create `apps/renderer/src/components/html-file-viewer.tsx`: - Accepts `html: string` prop - Renders `` with full width/height, no border ### Test ✅ - Open a real `.html` file from the knowledge tree - Verify: file renders visually in the iframe (not raw text) - Verify: a non-html file still shows the `` fallback (no regression) - Verify: an HTML file with a `
` fallback. ### Work 1. In the file loading logic (`App.tsx:1284–1357`), when extension is `.html`: - Call `knowledge:readHtmlFile` via IPC - Store the HTML string in state 2. In the knowledge view render switch (`App.tsx:4522–4527`): - Add a condition: if extension is `.html` → render `` - Otherwise fall through to existing `` fallback 3. Create `apps/renderer/src/components/html-file-viewer.tsx`: - Accepts `html: string` prop - Renders `` with full width/height, no border ### Test ✅ - Open a real `.html` file from the knowledge tree - Verify: file renders visually in the iframe (not raw text) - Verify: a non-html file still shows the `` fallback (no regression) - Verify: an HTML file with a `
` fallback 3. Create `apps/renderer/src/components/html-file-viewer.tsx`: - Accepts `html: string` prop - Renders `` with full width/height, no border ### Test ✅ - Open a real `.html` file from the knowledge tree - Verify: file renders visually in the iframe (not raw text) - Verify: a non-html file still shows the `` fallback (no regression) - Verify: an HTML file with a `
` fallback (no regression) - Verify: an HTML file with a `