Problem:
- Buttons were being inserted as children of <pre> element
- This caused buttons to appear inside code blocks with wrong styling
- Template caching made changes appear to require "two commits"
Solution:
- Change insertion point from block.parentNode to preElement.parentNode
- This places buttons as siblings of <pre>, not children
- Add TEMPLATES_AUTO_RELOAD=True to prevent Flask template caching
Technical Details:
- block is the <code> element
- block.parentNode is the <pre> element
- preElement.parentNode.insertBefore puts buttons after <pre>
- Previous code put buttons inside <pre> after <code>
DOM Structure Before:
<pre>
<code>...</code>
<buttons> <!-- Wrong: inside pre -->
</pre>
DOM Structure After:
<pre>
<code>...</code>
</pre>
<buttons> <!-- Correct: after pre -->
Co-authored-by: Claude <noreply@anthropic.com>
When MODEL_X references (MODEL_0, MODEL_1, etc.) are used, the code now
properly looks up actual model names from the dynamic registry (MODEL_CLIENT_MAP)
instead of hardcoding "model" or requiring MODEL_NAME_X environment variables.
Changes:
- app.py: Look up models from MODEL_CLIENT_MAP for the specified endpoint
- guarded_ai.py: Query endpoints for actual model names at initialization
- guarded_ai.py: Use dynamic registry for MODEL_X lookups
This fixes the "model not found" error when using activities with MODEL_X
references like activity37.
Critical fix for activity model configuration:
- Handle MODEL_1, MODEL_2, MODEL_3 references in get_openai_client_and_model()
- Look up MODEL_ENDPOINT_{n}, MODEL_API_KEY_{n}, MODEL_NAME_{n} from environment
- Fall back gracefully to default model if MODEL_{n} not configured
- Matches implementation in research/guarded_ai.py
Fixes error: 'NoneType' object has no attribute 'chat'
This error occurred when activities tried to use classifier_model="MODEL_1"
but the app didn't know how to resolve the MODEL_X reference.
Now activity37 (programming languages) will work correctly with:
- classifier_model: "MODEL_1" (Hermes for classification)
- feedback_model: "MODEL_3" (Qwen3-Coder for code generation)
Moved all activity-related functions from app.py to a new activity.py
module to improve code organization and maintainability. This reduces
app.py from 2852 lines to 1552 lines.
Changes:
- Created activity.py with 16 activity-related functions
- Updated app.py to import and initialize activity module
- Updated test_app.py to import activity module
- All 34 unit tests pass successfully
Pass the selected model parameter through the entire activity workflow
to ensure all AI operations (categorization, translation, feedback
generation, and grading) use the user's chosen model instead of
defaulting to the system default. Falls back to default when no model
is selected.
- Remove STFU check from app.py feedback filtering logic
- Update tests to remove STFU-specific test cases
- Simplify empty content filtering to just check for actual content
Add skip_condition logic to feedback prompts to prevent AI from generating
false ship destruction messages when no ships were actually destroyed.
Changes:
- Add skip_condition parameter support in provide_feedback_prompts()
- Support all_null, all_false, and all_true condition types
- Apply skip_condition to battleship Ship Status and Game Over prompts
- Add comprehensive unit tests covering all skip condition scenarios
- Test real battleship scenario that was causing hallucinations
This prevents the AI from creating false positive ship destruction messages
when metadata indicates no ships were actually sunk (all null values).
- Add username field to right sidebar and mobile modal with 'guest' default
- Implement real-time username sync with URL query string updates
- Add opencompletion.com button and new room creation in left sidebar
- Implement room name slugification (e.g. "a whole new world" → "a-whole-new-world")
- Create shared utils.js for common functions like slugify
- Add single search result auto-redirect functionality
- Remove redundant UI elements ("Create New Room" header, docs link)
- Preserve user settings (username, model, voice) across redirects and room creation
Technical improvements:
- Consolidated duplicate code into shared utility functions
- Enhanced search logic with parameter preservation
- Improved mobile/desktop sync for all input fields
- Better URL handling and query string management
- Created test_streaming_protocol_simple.py with 3 passing tests
- Created test_streaming_protocol.py with comprehensive test suite
- Tests verify new protocol format with separate username/model fields
- Tests confirm content separation from metadata for clean TTS processing
- Added debug logging for Game Over feedback prompt
- All tests validate the streaming refactoring works correctly
Backend changes:
- Send username, model_name, and is_first_chunk as separate fields
- Keep actual content separate from header formatting
- Cleaner separation of concerns in streaming protocol
Frontend changes:
- Build display content with header only for visual rendering
- Keep messageBuffers clean (content only) for TTS processing
- TTS now processes pure content without username headers
This fixes the issue where TTS was reading 'fxhp (model):' prefix
- Added activity_status emit with active: false when activity ends
- Now matches behavior of activity cancellation
- Users will automatically see activity chooser when activity finishes
Major improvements to battleship game feedback accuracy and user experience:
## New Multi-Prompt Feedback System
- Replaced single feedback with 3 specialized prompts: Shot Report, Ship Status, Game Over
- Each prompt has individual metadata filtering to see only relevant data
- Shot Report only sees hit/miss data, Ship Status only sees ship destruction data
- Added STFU token system to suppress empty messages (filtered out automatically)
## Technical Implementation
- Added per-prompt metadata_filter support in YAML structure
- Updated app.py and guarded_ai.py to handle prompt-specific filtering
- Legacy single-prompt system still works with transition-level filtering
- Added comprehensive test suite for feedback system validation
## User Experience Fixes
- Fixed TTS queue blocking JavaScript execution (async promises instead of await)
- Ship Status now correctly reports who destroyed which ship (role confusion fixed)
- Game Over only appears when game actually ends (no more random messages)
- Maintained dramatic storytelling while ensuring factual accuracy
## Battleship-Specific Improvements
- Ship destruction messages only appear when ships actually sink
- Clear separation of concerns: hits/misses vs ship destruction vs game over
- Eliminated false positive ship destruction reports
- Fixed role reversal where wrong player got credit for destruction
The battleship narrator now provides accurate, contextual feedback while preserving the dramatic naval warfare atmosphere.
- Fix battleship feedback perspective confusion with better Hermes prompting
- Add auto-play TTS button with localStorage persistence and queueing system
- Move activity controls below model/voice selectors in sidebar
- Add activity controls to mobile hamburger menu
- Fix model/activity dropdowns to stay within container bounds
- Filter activities API to only show .yaml/.yml files
- Clean up system message labels by moving to usernames (System (Feedback), System (Question))
- Apply black formatting to app.py
Major improvements:
- app.py coverage: 15% → 25% (+10 percentage points)
- research/guarded_ai.py coverage: 68% → 81% (+13 percentage points)
- Overall project coverage: 68% → 72% (+4 percentage points)
Key changes:
- Add comprehensive Flask integration tests for app.py activity functions
- Test real database operations with in-memory SQLite
- Add extensive guarded_ai.py error handling and client management tests
- Enhanced Makefile with comprehensive test targets
- Updated requirements-test.txt with flake8
- All 135 tests now passing with proper test coverage
The integration tests use real Flask environment, actual YAML processing,
and genuine database operations instead of mocks for accurate coverage.
- Add matplotlib.use("Agg") backend configuration to prevent runtime errors in headless environments
- Add error handling guards for script results that might return None
- Fix AI targeting logic to exclude already-fired cells in super hunter and hunter modes
- Update CLAUDE.md with matplotlib best practices
- Add user_response to pre-script metadata for better game state management
- Implement metadata_feedback_filter to control feedback data exposure
- Improve ship destruction announcements and game over messaging
- Add debug logging for ship sinking events
- Include test ship configuration file
- Add new Hermes Reasoner AI mode that combines probability analysis with LLM reasoning
- Implement pre-script and post-script architecture in app.py for flexible YAML processing
- Fix game ending detection by adding transition override mechanism
- Add probability matrix visualization and strategic move analysis
- Support both legacy processing_script and new pre_script/post_script naming
- Restore full ship complement for complete battleship gameplay
- Prevent SQL injection in search functionality with input sanitization
- Add path traversal protection for local file operations
- Replace hardcoded secret key with environment variable
- Escape HTML output to prevent XSS attacks in image generation
- Restrict file access to research/ directory with .yaml extension only
- Add comprehensive input validation and error handling
Security improvements maintain full application functionality while
protecting against common web application vulnerabilities.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>