Skip to content

feat: improved chat widget with markdown, health status, and CI/CD - #18

Merged
neuromechanist merged 6 commits into
mainfrom
develop
Jan 9, 2026
Merged

neuromechanist merged 6 commits into
mainfrom
develop

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Summary

  • Improved chat widget with proper markdown/table rendering, health status indicator, resize functionality, and configurable options
  • Added CI/CD workflow for Cloudflare Pages auto-deploy on push to develop
  • Fixed frontend deployment (renamed demo.html to index.html)
  • Updated CORS to allow *.pages.dev origins

Changes

  • frontend/osa-chat-widget.js: Complete rewrite with better markdown parsing (tables, headers, lists, code blocks), health status indicator, resize handle, configurable title/messages/footer
  • frontend/index.html: Renamed from demo.html, updated with feature documentation and configuration examples
  • .github/workflows/deploy-pages.yml: New workflow for Cloudflare Pages deployment
  • workers/osa-worker/index.js: Added *.pages.dev to CORS allowlist
  • CLAUDE.md: Updated workflow documentation for develop branch

Test plan

…, and config options

- Add proper markdown parsing with table support (flushTable)
- Add health status indicator using /health endpoint
- Add resize handle (drag top-left corner)
- Add configurable options: title, placeholder, initialMessage, suggestedQuestions
- Add footer with 'Powered by Open Science Assistant' repo link
- Add experimental badge toggle
- Update demo page with feature list and configuration documentation
Security fixes:
- Add URL protocol validation to prevent javascript: XSS in markdown links
- Validate localStorage message structure before rendering
- Add Turnstile error/expired callbacks for proper error handling

Error handling improvements:
- Handle non-JSON API error responses gracefully
- Show user-friendly error messages for storage failures
- Add null checks for DOM queries to prevent crashes

CORS hardening:
- Restrict pages.dev CORS to specific osa-demo project only
@neuromechanist

Copy link
Copy Markdown
Member Author

PR Review Summary

Issues Found and Addressed

Critical Issues (Fixed):

  1. XSS via javascript: URLs - Added isSafeUrl() validation for markdown links
  2. Unsafe localStorage loading - Added isValidMessage() validation before rendering
  3. No Turnstile error handling - Added error-callback and expired-callback

Important Issues (Fixed):
4. localStorage save errors silent - Added user notification on storage failure
5. localStorage load errors silent - Improved error logging
6. Overly permissive CORS - Restricted to specific osa-demo.pages.dev project only
7. API error assumes JSON - Added try-catch with status-based fallback messages
8. DOM query failures crash widget - Added null checks with optional chaining

Issues Acknowledged (Not Fixed in this PR):

  • No frontend tests - Will address in separate issue
  • GitHub Actions SHA pinning - Will address in separate issue
  • CSP headers - Requires infrastructure changes

Commits Added

  • fd1fed4 - Security and error handling fixes

All critical and important security/error handling issues have been addressed.

- Add copy icon button to code blocks in assistant responses
- Add copy button next to assistant message labels to copy full markdown
- Event listeners copy content to clipboard with visual feedback
- Shows checkmark for 2 seconds after successful copy
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.

1 participant