feat: add marg docs-assistant frontend#4
Conversation
janelletam
left a comment
There was a problem hiding this comment.
LGTM 🫡 left a comment about one issue and a few non-blocking suggestions
| @@ -0,0 +1,16 @@ | |||
| // marg's webchat client ID (from the bot's Webchat integration in the dashboard). | |||
| export const CLIENT_ID = '50e37fd0-1cd7-4522-a925-e44c4d764f94' | |||
There was a problem hiding this comment.
suggestion: put in env var in case ID is rotated in the future
|
|
||
| // A message block can be text/markdown directly or nested inside a container | ||
| // (bubble → block, bloc/column/row → items/blocks). Recursively pull out all text. | ||
| function extractText(block: unknown): string { |
There was a problem hiding this comment.
suggestion (non-blocking): consider refactoring extractText, extractButtons, stripSkillRefs, and parseReferences to a helper file in src/lib for better separation of concerns + to make them easier to unit-test in isolation
| * `assistant.js` — text typed into the page's bottom "Ask a question..." | ||
| * input bubble is forwarded into the chat. Other events the parent emits | ||
| * (`panelOpened`, `pageChanged`, `focusInput`) are intentionally ignored: | ||
| * this bot doesn't use page context yet. |
There was a problem hiding this comment.
suggestion (non-blocking): remove since you added the usePageContext hook
|
|
||
| const postParent = (type: string) => { | ||
| try { | ||
| window.parent.postMessage({ type }, '*') |
There was a problem hiding this comment.
issue: for cases where you call postMessage(in Header.tsx, Markdown.tsx, usePageContext.ts, and useThemeFromParent.ts), track the parent's origin from inbound messages and use it as an explicit target; this way, unauthorized embedders won't receive these messages.
Adds
marg-frontend— the custom React/Vite webchat UI for the marg docs assistant, embedded as an iframe by the docs site'sassistant.js. Connected to the deployed bot via its webchat client ID./docs-bot/marg-frontend/(matches vitebase).main(and via manual dispatch).node_modules/distgitignored;bun run buildpasses.