- Change sendMessage to async generator function with yield*
- Fixes 'Error: sendMessage(...) is not iterable' error
- Restores chat functionality in Hermes modal
- Fix TTS speed control: change default to 0.9, step by 0.05, max 2.0
- Apply playbackRate to audio element so speed actually works
- Add refreshModalUI() function to update UI when language changes
- Re-add upstream tokenizer API with simplified token counting
- Format token counts with commas (e.g., 8,432 tokens)
- Add getTokenCount() for simple integer token counts
- Language switching now refreshes modal UI without hard refresh
- extractSpokenTokens now detects if input is already markdown format
- Updated prompt to handle both markdown and HTML input
- Added markdown to plain text conversion in prompt (bold, links)
- processContentWithHermes now delegates to extractSpokenTokens
- Consistent processing pipeline whether from Batman button or Read Page
- Better reuse of extractWebpageContent markdown format
- Pre-clean HTML before sending to Hermes (remove scripts, styles, ads, iframes)
- Decode HTML entities ( & etc.) before Hermes processing
- Simplified, clearer system prompt focused on extraction tasks
- Post-process Hermes output with cleanTextForTTS() for final cleanup
- Reduces Hermes workload and improves extraction quality
- Three-stage pipeline: JS pre-clean → Hermes extraction → JS post-clean
- TTS modal now uses speakTextDirect() with simple JavaScript text cleaning
- No more Hermes preprocessing for modal text (faster, simpler)
- Read Page button still uses speakText() with Hermes for article extraction
- Reduced textarea height from 240px to 100px with vertical resize
- Added cleanTextForTTS() to remove markdown, HTML, and excess whitespace
- Modal gets instant TTS while Read Page gets intelligent content extraction
- Remove top, left, and transform properties
- Let dialog element use native browser centering
- Fixes positioning issues across different viewports
- Cleaner solution that works better with dialog element
- Enhanced system prompt to generate 5-10 word descriptive filenames
- Added robust text cleaning to remove quotes, special characters
- Limit filename length to 50 chars for filesystem compatibility
- Better dash-separated filename format like 'javascript-array-methods-guide.mp3'
- Enhanced system prompt to generate 3-5 word descriptive filenames
- Added robust text cleaning to remove quotes, special characters
- Limit filename length to 50 chars for filesystem compatibility
- Better dash-separated filename format like 'javascript-tutorial.mp3'
- Use generateTitleForTTS to create dash-separated filenames based on textarea content
- Hermes analyzes the text and generates descriptive filenames like 'hello-world-tts.mp3'
- Fallback to default filename if generation fails
- Add missing blobUrl to speakText return value
- TTS modal now correctly receives blobUrl for audio playback and download
- Fixes missing MP3 download and autoplay functionality
- Limit translation.js console output to 100 chars for long text (was showing 22KB)
- Add content filtering to TTS to prevent inappropriate content processing
- Enhance audio error handling with abort, stalled, and specific error types
- Add user-friendly error messages for audio playback failures
## Jest Configuration & Setup:
- Configure Jest with jsdom environment for DOM testing
- Set up test mocks for external dependencies (marked, hljs)
- Create test setup with localStorage, fetch, and dialog element mocks
- Add npm scripts for testing: test, test:watch, test:coverage, test:modals
- Update Makefile with Jest test targets and CI integration
## TTS Modal Tests (89 test cases):
- Modal creation, display, and structure validation
- Voice selection dropdown with 6+ voice options
- Speed control slider (0.5x-2.0x range)
- Audio generation with API integration testing
- Download functionality with blob handling
- Modal closing and cleanup
- Accessibility (ARIA, keyboard navigation, focus management)
- Error handling (API failures, malformed responses, network issues)
## Translate Modal Tests (85 test cases):
- Modal creation with source/target language selection
- Language detection and auto-population
- Translation API integration with streaming responses
- Copy functionality with clipboard API
- Text editing and retranslation
- Language swap functionality
- Modal state management
- Accessibility compliance
- Comprehensive error handling
## Embed Modal Tests (78 test cases):
- Main chat modal with conversation management
- Model loading and selection from endpoints
- Conversation history persistence with localStorage
- Real-time chat with streaming AI responses
- Message actions (copy, delete, TTS buttons)
- Action buttons with fallback modal opening
- Toggle functionality and state management
- User input handling (Enter key, send button)
- Accessibility and keyboard navigation
- Error handling for chat API, storage, and network issues
## Total: 252 comprehensive test cases covering:
- UI component creation and rendering
- User interaction and event handling
- API integration and streaming responses
- State management and persistence
- Accessibility compliance
- Error boundary testing
- Modal lifecycle management
- Cross-browser compatibility patterns
All tests include proper mocking, async handling, and cleanup for reliable CI execution.
- Add safety checks for window.openTTSModal and window.openTranslateModal availability
- Implement fallback dynamic imports if window functions not available
- Prevents "window.openTTSModal is not a function" and "window.openTranslateModal is not a function" errors
- Provides graceful error handling with user feedback if modal imports fail
- Resolves loading order dependency issues between ui.js and embed modal
This ensures modal buttons work regardless of script loading order.
Add 10 new regression tests in Section 10 targeting specific errors encountered:
🚨 Session Error Prevention:
- Async generator wrapper validation (prevents "not iterable" errors)
- Dynamic import wrapper error handling (prevents undefined function errors)
- Module import path verification (prevents wrong module imports)
- Variable scope isolation (prevents direct chatHistory access)
- Runtime function availability (prevents window.function undefined errors)
- Module export consistency (prevents import/export mismatches)
- Async/await pattern validation (prevents promise handling errors)
- Error boundary patterns (prevents cascading failures)
- Generator function delegation (prevents yield* delegation errors)
- Function signature compatibility (prevents parameter mismatches)
These tests specifically target the JavaScript errors we encountered:
- sendMessageWithCustomHistory(...) is not iterable
- fetchModelsFromEndpoints is not a function
- loadConversationHistory is not a function
- clearConversationHistory is not a function
- saveConversationHistory is not a function
- getSelectedModel is not a function
- chatHistory is not defined
- window.openTTSModal is not a function
- window.openTranslateModal is not a function
All tests validate current fixes and prevent regression of these specific patterns.
- Fix fetchModelsFromEndpoints import path from ./chat.js to ./models.js
- Fix loadConversationHistory and clearConversationHistory imports from ./chat.js to ./storage.js
- Replace direct chatHistory access with proper async getChatHistory/updateChatHistory calls
- Add sendMessageWithCustomHistory function to chat.js for modal integration
- Enhanced validate_exports.js to detect both named exports (export const/function/etc) and destructured exports (export { name1, name2 })
- Fixes validation error that was incorrectly reporting missing exports
- All CI checks now pass successfully
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced broken placeholder modal with complete working version from commit 3e01e9c
- Fixed all import paths to point to correct modules (chat.js instead of storage.js/models.js)
- Added proper export statements for openUncloseaiEmbeddedModal and openUncloseaiEmbeddedModalNew
- Restored full functionality including:
* Settings panel with model/voice/language selection
* TTS functionality for all messages
* Copy buttons (raw markdown and HTML)
* File upload capability
* Complete chat history management
* Theme support and dynamic theme updating
* Intro message generation with page context
* Conversation persistence
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add missing toggleUncloseaiEmbeddedModal function for floating button
- Create comprehensive integration test suite (15 tests)
- Tests verify all imports/exports work correctly
- Tests ensure proper module structure after refactoring
- All tests passing ✅ - refactoring is solid!
- Add toggleUncloseaiEmbeddedModal function that was missing after refactoring
- Function properly toggles modal open/close state
- Export function globally for floating button onclick handler
- This fixes the floating button not appearing/working issue
- Fix CORS error caused by incorrect import in translate-modal.js
- Change import from ./page-content.js to ./content.js
- Resolves module loading issues
- Remove duplicate initializeSystem function that was causing export at wrong level
- Fix syntax error: export declarations may only appear at top level
- Reduce ui.js to 532 lines (from 567)
- Extract massive modal functions to uncloseai-embed-modal.js (399 lines)
- Extract widget creation functions to widget-library.js (447 lines)
- Move addFileUploadButton to file-upload.js for better organization
- Reduce ui.js from 3,595 lines to 567 lines (84% reduction)
- Transform ui.js into clean coordinator as requested
- All functionality preserved with proper imports and exports
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Move openTTSModal to tts-modal.js (335 lines)
- Move openTranslateModal to translate-modal.js (540 lines)
- Reduce ui.js from 4,832 to 4,028 lines
- Add imports and global exports for onclick handlers
- Each modal is now self-contained with its own imports
- No functionality changes, just code organization
- Fix main chat input textarea in openUncloseaiEmbeddedModal (line 3837)
- Fix TTS modal textarea with conditional styling (line 4070)
- Fix translation modal textarea with conditional styling (line 4417)
- All textareas now use rgba glassmorphism when USE_CUSTOM_STYLING=false
- Should resolve white-on-white text issue in blog dark mode
- Add askAnythingPlaceholder, askPagePlaceholder, enterTextToSpeakPlaceholder, processingTokens
- All 18 language files now complete with 67 translation keys each
- Verified with translation completeness script - all languages pass
- Update CLAUDE.md documentation to reflect new key count
- All UI placeholder text now fully internationalized
- Add askPagePlaceholder, askAnythingPlaceholder, enterTextToSpeakPlaceholder keys
- Replace hardcoded 'Ask about this page...', 'Ask anything...', 'Enter text to speak...'
- All input placeholders now use translation system
- Ensures consistent multilingual experience across all UI elements
- Fixed understanding: index.html uses PicoCSS (custom=true), blog uses fallback (custom=false)
- Replace CSS variables with rgba transparency and glassmorphism effects
- Semi-transparent backgrounds adapt to any light/dark theme
- Backdrop-filter blur creates modern glass effect that works universally
- No longer assumes CSS variables exist on blog sites
- Add USE_CUSTOM_STYLING checks to main chat interfaces
- Use PicoCSS variables (--background-color, --color, --border-color) when USE_CUSTOM_STYLING=false
- Fix white-on-white text issue in dark mode for blog embedding
- Chat input, textarea, and buttons now respect PicoCSS dark theme
- Maintains backward compatibility with index.html (custom styling)
- Fix all remaining 'Read Page' hardcoded strings
- Replace 'Processing...' and 'Detecting...' with translation keys
- Update createReadFeature to use proper translation system
- Add processingTokens translation key for token count display
- UI should now properly internationalize all button text
- Fix all hardcoded text in translation modal content
- Add translatePageInfo, translateToLabel, translateButton keys
- Fix dynamic button text for page/text modes
- Fix hardcoded Processing text during translation
- Fix Translation Modal button labels in UI
- Fix TTS Anything and Smart Translate button labels
- Add data-i18n attributes for dynamic refresh
- All modal content now fully localizes on language switch
- Fix TTS modal hardcoded 'Speed:' and 'Play Text' buttons
- Fix translation modal hardcoded tab text
- Fix system prompt to respect user's selected language
- Fix DOM auto-refresh by connecting both refresh functions
- Add TTS and system prompt translation keys to 10 languages
- Translation modal tabs and TTS controls now localize properly
- Language switching works without hard refresh for data-i18n elements
- Create individual language files for all 19 supported languages
- Add complete 46-key translations for Hindi, Spanish, French, Arabic, Bengali, Russian, Portuguese, Urdu, Indonesian, German, Japanese, Swahili, Marathi, Telugu, Turkish, Chinese Traditional, and Korean
- Implement dynamic UI refresh mechanism for real-time language switching
- Add translation verification script for consistency checks
- Update ui-translations.js to use new modular structure
- Document complete workflow for adding new languages in journal.rst
All languages now have 100% translation key coverage with automated verification
- Fix template literal usage (string concatenation to template literals)
- Apply optional chaining for safer property access
- Reduce biome warnings from 36 to 19
- Code is now cleaner and more maintainable
- Create ui-translations.js with UI_TRANSLATIONS object and translation functions
- Create ui-themes.js with theme detection and styling functions
- Create language-detection.js with AI-powered language detection
- Remove duplicate code from ui.js, reducing from 5600+ to 4741 lines
- Fix import assignments and syntax errors
- All functionality preserved while improving code organization
- Update batman toolbelt action buttons to use getUIText()
- Translate all modal headers (AI Assistant, TTS, Translate)
- Convert all input placeholders to use translations
- Update critical alert messages with parameter substitution
- Add comprehensive translation keys for UI elements
- Translate Hermes intro message with proper HTML formatting
- Support both English and Chinese translations for all new keys
- Maintain fallback to English for missing translations
- Fix biome style issues (template literals, optional chains)
- Add complete UI translations for all 19 supported languages
- Add language preference dropdown in modal settings
- Store language preference in localStorage
- Inject language preference into Hermes system prompts
- Add smart translation dropdown with AI-powered language detection
- Keep both original translation modal and new smart dropdown
- Remove non-functional upload button from modal
- Add biome.json config to ignore third-party CSS files