Skip to content

Add Ask AI chat drawer widget for standalone API docs#380

Merged
JakeSCahill merged 14 commits into
mainfrom
feature/chat-drawer-widget
May 27, 2026
Merged

Add Ask AI chat drawer widget for standalone API docs#380
JakeSCahill merged 14 commits into
mainfrom
feature/chat-drawer-widget

Conversation

@JakeSCahill
Copy link
Copy Markdown
Contributor

@JakeSCahill JakeSCahill commented May 27, 2026

Summary

  • Add chat drawer widget (chat-panel-bump.hbs) for Bump.sh API documentation pages
  • Enable Ask AI button in header for standalone widgets
  • Add compile:widgets gulp task with automatic file watching during preview
  • Document widget testing workflow in CLAUDE.md

Changes

File Description
src/partials/chat-panel-bump.hbs New chat drawer partial with inline JS
context/chat-panel.json Widget compilation context
gulpfile.js Add compile:widgets task and file watchers
src/partials/header-content.hbs Show Ask AI button for standalone widgets
CLAUDE.md Add widget testing documentation

Preview Links

Test the widget on these pages:

Page Link
Widget Test Page https://deploy-preview-380--docs-ui.netlify.app/_/widget-test.html
Home Page https://deploy-preview-380--docs-ui.netlify.app/home

Test Plan

  • Open Widget Test Page and click "Ask AI" - drawer should open (not modal)
  • Verify chat drawer has close button that works
  • Test Cmd+K keyboard shortcut opens drawer
  • Verify theme toggle works in header
  • Check dark mode styling is correct

Enable the Ask AI chat drawer on Bump.sh API documentation pages by:

- Create chat-panel-bump.hbs partial with drawer HTML and inline JS
- Add chat-panel.json context for widget compilation
- Update gulpfile.js with compile:widgets task and file watchers
- Show Ask AI button in header for standalone widgets
- Add widget testing documentation to CLAUDE.md

The chat drawer opens from the right side (not a modal) and supports:
- Click Ask AI button or Cmd+K keyboard shortcut
- State persistence via localStorage
- Auto-recompilation on file changes during gulp preview
@netlify
Copy link
Copy Markdown

netlify Bot commented May 27, 2026

Deploy Preview for docs-ui ready!

Name Link
🔨 Latest commit 391f71b
🔍 Latest deploy log https://app.netlify.com/projects/docs-ui/deploys/6a16ee331e8ed40008c35601
😎 Deploy Preview https://deploy-preview-380--docs-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 31 (🟢 up 1 from production)
Accessibility: 89 (no change from production)
Best Practices: 100 (no change from production)
SEO: 89 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 93fd8248-a7c5-4c7a-834b-dd5fedb2b438

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR introduces a new Bump.sh standalone chat panel widget to the documentation UI. It includes a new context configuration file (context/chat-panel.json) defining the widget mode, a Handlebars partial (src/partials/chat-panel-bump.hbs) implementing a drawer-style chat panel with inline event handling and localStorage state persistence, and updates to the gulp build system to compile widgets as a dedicated task. The header template is updated to always render the "Ask AI" button. Documentation is expanded with widget build and local testing instructions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • redpanda-data/docs-ui#295: Established the initial compileWidgets gulp task logic that this PR extends with widget compilation and integration.

Suggested reviewers

  • kbatuigas
  • paulohtb6
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a chat drawer widget for standalone API docs, which aligns with the primary objectives of the PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description clearly relates to the changeset, detailing the addition of a chat drawer widget for Bump.sh, enabling the Ask AI button, adding a compile:widgets task, and documenting the widget testing workflow—all matching the actual changes in the files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/chat-drawer-widget

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@gulpfile.js`:
- Around line 194-208: The widget watcher currently watches its generated
outputs and causes recursive rebuilds; update the widgetSources array used by
watch(...) so it no longer includes
`${srcDir}/static/assets/widgets/css/*-bump.css` (the cssOutDir from
compile-partial.js) and instead watches the real inputs
`${srcDir}/css/*-bump.css` (cssSrcDir that compile-partial.js reads). Keep the
rest of widgetSources (partials and context/*.json) and leave the main preview
watcher as-is; this change prevents compileWidgetsTask from retriggering itself
while still triggering the series(compileWidgetsTask, buildTask) when true
source files change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b1bbc153-2285-4c04-b743-2d60660d62b6

📥 Commits

Reviewing files that changed from the base of the PR and between 02429bb and f4e9434.

📒 Files selected for processing (5)
  • CLAUDE.md
  • context/chat-panel.json
  • gulpfile.js
  • src/partials/chat-panel-bump.hbs
  • src/partials/header-content.hbs

Comment thread gulpfile.js
Use justify-content: space-between on .navbar.topbar to push nav
action buttons (search, Ask AI, theme toggle) to the right side,
with the brand/logo on the left.
- Fix search button visibility: use dark colors on light backgrounds
- Fix navbar layout: add display flex, proper positioning, box-sizing
- Add chat-panel-bump.css to src/css for widget compilation
- Fix widget-test.html CSS paths to use /_/assets/widgets/css/
Since DOMContentLoaded has already fired when widgets load via fetch,
the theme toggle initialization in head-bump.html never runs.

Added initThemeToggle() function that runs after all widgets load to
manually set up the theme toggle click handler.
When loaded via fetch() (e.g., widget test page), DOMContentLoaded has
already fired so the mount never happens.

Now checks document.readyState and mounts immediately if DOM is ready,
or waits for DOMContentLoaded if still loading.

Also added data-mounted attribute to prevent duplicate mounts.
@JakeSCahill JakeSCahill requested a review from a team May 27, 2026 12:27
Changed widgetSources to watch ${srcDir}/css/*-bump.css (source input) instead
of ${srcDir}/static/assets/widgets/css/*-bump.css (compiled output).

This prevents recursive rebuilds when compile-partial.js copies CSS files to
the output directory, which was triggering the watcher again.

Addresses CodeRabbit review comment.
When a page attribute is set to just 'current' (which is not a valid Antora
resource ID), return the current page URL or '#' instead of logging an error.

This gracefully handles misconfigured attributes that use 'current' when they
should use a proper xref like 'ROOT:index.adoc' or similar.
Copy link
Copy Markdown
Contributor

@micheleRP micheleRP left a comment

Choose a reason for hiding this comment

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

Review

Approving — the chat drawer widget is well-scoped, the gulp watch loop is solid, and the preview test page is a nice addition.

A few non-blocking observations for follow-up:

Worth addressing

  1. Hardcoded production URL in src/partials/chat-panel-bump.hbsAskAI.bundle.js is loaded from https://docs.redpanda.com/_/js/AskAI.bundle.js based on a window.location.hostname check. If the docs site ever moves domains, or for testing on production-like hosts, this will break. Consider passing the bundle URL via a data attribute or context variable.
  2. Kapa integration ID (13dd3c3c-…) is committed in chat-panel-bump.hbs. Kapa integration IDs are usually meant to be public, but worth confirming once that we're happy committing it.

Minor

  1. src/static/widget-test.html<div id="embed-head"></div> is inside <head>. Invalid HTML; move below <body>. Low impact since it's a test page.
  2. src/css/chat-panel-bump.css at 1176 lines is on the chunky side. The KAPA SDK OVERRIDES section is a natural seam if you want to split it later.

CodeRabbit finding

The bot flagged a risk of recursive rebuilds in gulpfile.js. Looking at the diff, you already watch ${srcDir}/css/*-bump.css (the source) and explicitly note this in a comment. Appears already addressed — safe to dismiss.

What works well

  • Self-contained drawer with no extra runtime dependencies beyond AskAI.bundle.js.
  • Cmd/Ctrl+K shortcut + localStorage state persistence.
  • New compile:widgets task with file-watching gives a tight test loop.
  • AskAI.jsx now handles late-loaded DOM, which is what fetch-injected widgets need.
  • CLAUDE.md updated for future contributors.

- Move embed-head div from <head> to <body> in widget-test.html (invalid HTML)
- Add comment documenting Kapa integration ID as intentionally public
- Add window.ASKAI_BUNDLE_URL override for production URL configurability

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@JakeSCahill JakeSCahill merged commit 4c84ba9 into main May 27, 2026
6 of 7 checks passed
@JakeSCahill JakeSCahill deleted the feature/chat-drawer-widget branch May 27, 2026 13:24
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