Commit graph

274 commits

Author SHA1 Message Date
af7019f91b fix: make all code examples visible by default
- Add 'open' attribute to all <details> sections
- Ensure code examples are immediately visible to users
- No need to click to expand - documentation should be accessible
2025-07-04 14:36:30 -04:00
1bf4d26a8a feat: comprehensive demo page documentation improvement
- Add TTS modal button example with openTTSModal() function
- Add translation modal button example with openTranslateModal() function
- Add standalone read page button example with readPageWithHermes() function
- Reorganize all sections to show live examples first, then code examples
- Improve documentation flow: demo first, then implementation details
- Add detailed feature lists and best-use-case descriptions
- Provide multiple implementation options for each feature (widget vs modal vs API)
- Update table of contents to reflect new organization
- Make it easy for people to add widgets to any webpage with clear examples
2025-07-04 14:32:13 -04:00
c57d86c27f fix: properly load all widget functions for demo page
- Restore translate modal demo - it works fine on main app
- Add manual imports for openTranslateModal, openTTSModal, readPageWithHermes
- Ensure all widget functions are available globally for demo widgets
- Fix module loading issues that were causing "is not a function" errors
- Make translation modal work as isolated tool in demo
2025-07-04 14:24:52 -04:00
9148d26496 fix: completely remove smart translate dropdown from demo
- Comment out entire smart dropdown section - no point advertising broken features
- Simplify translation section to only show working translation modal
- Update section title from "Translation Options" to "Translation Modal"
- Change "Live Examples" to "Live Example" (singular)
- Clean up code examples to only show working translate feature
- Remove confusing "two ways to translate" messaging
2025-07-04 14:17:52 -04:00
61b4cb0d5c fix: disable non-working features in demo.html
- Remove file upload references from system message
- Comment out smart-translate feature examples (not working yet)
- Disable smart translate demo with "Under Development" styling
- Keep traditional translate modal working
- Style disabled features with greyed-out appearance
- Fix demo page to only show working functionality
2025-07-04 12:49:53 -04:00
ce7014e83a fix: resolve handleFileUpload ReferenceError while preserving upload code for future
- Restore handleFileUpload import in widget-library.js to fix ReferenceError
- Keep all upload functionality code intact for future development
- Disable upload features in demo.html with "Under Development" messaging
- Remove upload from feature button examples but preserve the code
- Style disabled upload demo with greyed-out appearance
- Fix demo page functionality while maintaining upload code for future fixes
2025-07-04 12:43:04 -04:00
38fdedb6a6 docs: enhance language support documentation and remove auto-detection claims
- Expand README language section with complete list of 19 supported languages
- Add native language names and language codes for each supported language
- Detail language features: manual selection, complete coverage, AI responses
- List comprehensive translation coverage areas (modals, buttons, messages, etc.)
- Update project structure to show language files with descriptions
- Remove auto-detection claims since feature is not working properly
- Change to accurate "manual selection" and "AI-powered translation"
- Fix demo.html to remove false auto-detection advertising

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-04 12:31:53 -04:00
8c99a0316e fix: correct demo.html issues and update language count to 19
- Fix demo.html language count from 18 to 19 (verified by counting files)
- Remove "omni-directional" translation claims and use standard "Translation"
- Fix custom TTS example to use speakTextDirect instead of speakText (no Hermes preprocessing)
- Fix all demo functions to properly import modules dynamically
- Add missing imports for sendMessage, uploadFile, speakTextDirect, translateText
- Fix broken custom chat, TTS, file upload, page analysis, and translation examples
- Update README.rst and index.html language counts to accurate 19 languages
- Fix typo "transation" to "translation" in index.html

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-04 12:28:15 -04:00
d7cc5531b8 feat: improve streaming completion detection and add syntax highlighting with copy buttons
- Detect when model streaming is complete in all streaming locations
- Add syntax highlighting (hljs) to code blocks after streaming finishes
- Add copy buttons to code blocks after highlighting is applied
- Prevent duplicate copy buttons with CSS class detection
- Optimize performance by doing syntax highlighting and copy buttons only once per message
- Apply improvements to both modal streaming and standalone chat
- Add copy buttons to intro message generation as well

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-04 12:22:18 -04:00
41818a202b docs: add comprehensive README.rst and documentation sections to index.html and demo.html
- Created extensive README.rst with full project documentation
- Added brief documentation sections to index.html and demo.html
- Emphasized public domain licensing and open web philosophy
- Fixed branding to use lowercase uncloseai. and unturf.
- Points users to git repository for complete technical details

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-04 12:13:15 -04:00
91f446f5ed Revert "fix: explicitly set white color for uncloseai logo text in PicoCSS light mode"
This reverts commit f50ccabcd1.
2025-07-04 12:03:57 -04:00
f50ccabcd1 fix: explicitly set white color for uncloseai logo text in PicoCSS light mode 2025-07-04 11:59:32 -04:00
b49e52678b Revert "fix: use original page content for title generation instead of processed TTS content"
This reverts commit b178e039b2.
2025-07-03 22:40:55 -04:00
b178e039b2 fix: use original page content for title generation instead of processed TTS content 2025-07-03 22:39:55 -04:00
7bb43c7613 fix: make dropdown text color conditional for PicoCSS and fix download button positioning to be next to play buttons 2025-07-03 22:32:44 -04:00
2e655a206b fix: make tab styling conditional - only apply custom CSS for blog version, let PicoCSS handle native styling 2025-07-03 22:20:55 -04:00
f4c39823b1 fix: add proper tab styling to replace bullet points with visual tab design 2025-07-03 22:17:40 -04:00
d8642675df update translate modal title from 'Translate Page' to 'Translate' across all 19 languages 2025-07-03 22:17:01 -04:00
375471e81a feat: replace button-based tabs with PicoCSS tab navigation in translate modal 2025-07-03 22:11:20 -04:00
d24b6fa1bb fix: use correct variable name targetLanguage instead of targetLanguageCode 2025-07-03 22:04:43 -04:00
28d0b516f1 fix: use exact tokenization in translate modal UI instead of rough estimate 2025-07-03 22:01:01 -04:00
e300a93545 fix: replace tokenInfo reference with roughTokenEstimate in translate modal 2025-07-03 21:49:44 -04:00
f53742a9d5 fix: tokenize actual prompt sent to AI instead of raw HTML and remove duplicate tokenization from modal 2025-07-03 21:46:22 -04:00
cda3455a22 fix: remove enforceModalTextColors function and set black text directly on textarea and dropdowns 2025-07-03 21:36:13 -04:00
a8de98a56a fix: improve tokenizer response parsing and force black text on all modal elements 2025-07-03 21:30:41 -04:00
04b062f3f8 fix: strip v1 from tokenize endpoint since it uses base URL not v1 API 2025-07-03 21:24:37 -04:00
5364b6c446 fix: revert v1 prefix from API endpoints to restore Read Page functionality 2025-07-03 21:20:14 -04:00
c2aa8f1fbd fix: ensure form elements have black text on white backgrounds 2025-07-03 21:18:58 -04:00
969dcbc31e fix: simplify modal text colors and add v1 prefix to API endpoints 2025-07-03 21:16:05 -04:00
29a6a82fa1 fix: enforce modal text colors to prevent white-on-white text issues
- Add enforceModalTextColors() function with high CSS specificity
- Use !important declarations to override blog CSS
- Force dark text (#212529) on inputs, buttons, and general content
- Keep white text on user messages for proper contrast
- Add user-message class to user messages for targeted styling
- Prevents unreadable white text on white backgrounds on blog
2025-07-03 21:11:05 -04:00
401d245fe4 CRITICAL FIX: trash buttons now properly update localStorage
- All delete buttons now call loadConversationHistory/saveConversationHistory
- Update both localStorage and chat.js module for consistency
- User message delete: filters by content match
- AI message delete: removes both user and AI messages in pair
- Historical message delete: removes by array index
- Intro message delete: filters by assistant role and content
- No more localStorage sync issues with deleted messages
2025-07-03 21:02:12 -04:00
933ad570ac feat: major TTS improvements for chat messages and Read Page
- Chat TTS now uses speakTextDirect (no Hermes preprocessing, faster)
- Add download buttons (💾) next to all TTS buttons after processing
- Download buttons use generateTitleForTTS for smart filenames
- Read Page download now uses title generator instead of document.title
- Download buttons appear for user messages, AI responses, and historical messages
- Fallback filenames if title generation fails
- All TTS processing is now direct without Hermes delay
2025-07-03 20:58:40 -04:00
cb88b2da38 debug: add error logging to sendMessage wrapper
- Add try/catch with detailed error logging
- Check if sendMessage exists in imported module
- Log module contents if function not found
- Helps diagnose 'sendMessage(...) is not iterable' error
2025-07-03 20:51:50 -04:00
0213a7e632 fix: improve TTS filename generation with strict prompt and fallback
- Enhanced system prompt: MUST generate title, NEVER refuse
- Clear instructions for edge cases (empty, inappropriate, nonsensical text)
- Added fallback logic if Hermes returns empty or refusal messages
- Fallback uses first 30 chars of text or 'audio-file' as last resort
- Ensures downloads always have a valid filename
2025-07-03 20:48:47 -04:00
46f74eab59 CRITICAL FIX: restore chat functionality - sendMessage must be generator
- Change sendMessage to async generator function with yield*
- Fixes 'Error: sendMessage(...) is not iterable' error
- Restores chat functionality in Hermes modal
2025-07-03 20:45:28 -04:00
20ed410ff0 fix: multiple improvements to TTS modal and language switching
- 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
2025-07-03 20:42:11 -04:00
beab5d01a8 feat: reuse markdown extraction logic for TTS spoken tokens
- 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
2025-07-03 20:28:18 -04:00
4dc9568079 feat: improve extractSpokenTokens with JavaScript pre and post-processing
- Pre-clean HTML before sending to Hermes (remove scripts, styles, ads, iframes)
- Decode HTML entities (&nbsp; &amp; 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
2025-07-03 20:23:52 -04:00
17925537a6 feat: optimize TTS with direct processing for modal and Hermes for Read Page
- 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
2025-07-03 20:20:59 -04:00
78ab413e8e fix: remove manual positioning from TTS modal for proper centering
- 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
2025-07-03 20:14:35 -04:00
6cd16664f7 modified: src/tts-modal.js 2025-07-03 20:03:12 -04:00
67408f0b1a feat: improve TTS filename generation with better system prompt
- 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'
2025-07-03 19:33:49 -04:00
da4ff80655 feat: improve TTS filename generation with better system prompt
- 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'
2025-07-03 19:32:53 -04:00
76bd27bea8 feat: generate smart filenames for TTS downloads using Hermes
- 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
2025-07-03 19:31:52 -04:00
69fd142004 fix: TTS modal audio playback and download functionality
- 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
2025-07-03 19:08:21 -04:00
f42ea86c7b fix: reduce console spam and improve audio error handling
- 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
2025-07-03 19:05:51 -04:00
ade7f4a35e feat: replace TTS modal audio embed with custom player controls
## Enhanced TTS Audio Experience:
- **Remove browser default audio controls** (was showing embed instead of custom player)
- **Add custom play/pause button** with emoji icons (⏸️ Pause / ▶️ Play / ▶️ Replay)
- **Add interactive progress bar** with click-to-seek functionality
- **Add time display** showing current time / total duration (e.g., "1:23 / 3:45")
- **Prominent download button** (💾 Download) for saving MP3 files
- **Auto-play with fallback** - attempts auto-play, gracefully handles browser restrictions

## UI Improvements:
- **Clean layout** with flexbox controls container
- **Visual progress indicator** with smooth transitions
- **Responsive design** supporting both custom and default styling modes
- **Proper spacing and styling** for professional appearance

## Functionality:
- **Click progress bar to seek** to any position in audio
- **Real-time progress updates** during playback
- **Proper state management** (play/pause/ended states)
- **Error handling** for audio playback issues
- **Accessibility** with proper button labels and time displays

## Technical Details:
- Hidden audio element (no browser controls)
- Custom event listeners for timeupdate, ended, error events
- Proper time formatting (MM:SS format)
- Progress calculation with percentage-based width updates
- Browser auto-play policy compliance with user interaction fallback

**Result: Professional audio player experience instead of basic browser embed\!** 🎵
2025-07-03 19:01:37 -04:00
03e402fdf9 feat: add comprehensive Jest test suite for all 3 modals with complete coverage
## 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.
2025-07-03 18:55:49 -04:00
c721b88473 fix: add fallback handling for window modal functions in embed modal
- 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.
2025-07-03 18:51:48 -04:00
f3531d1591 fix: resolve localStorage Promise handling in modal dynamic import wrappers
- Fix loadConversationHistory() calls missing await (was returning Promise instead of data)
- Fix saveConversationHistory() calls missing await in 4 locations
- Fix clearConversationHistory() calls missing await
- Fix getChatHistory() calls missing await in 6 locations
- Fix updateChatHistory() calls missing await in 5 locations

All dynamic import wrapper functions are now properly awaited, resolving:
- "History length: undefined" error (Promise.length was undefined)
- "Raw history from localStorage: Promise { <state>: "pending" }" console output
- localStorage operations not completing before UI updates

This fixes the localStorage breakage caused by async wrapper functions not being awaited.
2025-07-03 18:44:59 -04:00