Skip to content

feat: add marg docs-assistant frontend#4

Open
jacksonyzj wants to merge 2 commits into
botpress:mainfrom
jacksonyzj:feat/marg-frontend
Open

feat: add marg docs-assistant frontend#4
jacksonyzj wants to merge 2 commits into
botpress:mainfrom
jacksonyzj:feat/marg-frontend

Conversation

@jacksonyzj
Copy link
Copy Markdown
Contributor

@jacksonyzj jacksonyzj commented Jun 3, 2026

Adds marg-frontend — the custom React/Vite webchat UI for the marg docs assistant, embedded as an iframe by the docs site's assistant.js. Connected to the deployed bot via its webchat client ID.

  • Chat UI: streaming answers, "Consulted N pages" sources, clarification choices, page-context wiring, light/dark.
  • Builds to a static site for GitHub Pages at /docs-bot/marg-frontend/ (matches vite base).
  • CI: GitHub Actions workflow publishes the build to GitHub Pages on push to main (and via manual dispatch).
  • node_modules/dist gitignored; bun run build passes.

Copy link
Copy Markdown

@janelletam janelletam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: put in env var in case ID is rotated in the future

Comment thread marg-frontend/src/App.tsx

// 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 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): remove since you added the usePageContext hook


const postParent = (type: string) => {
try {
window.parent.postMessage({ type }, '*')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants