8 Commits

Author SHA1 Message Date
3e5cb76d1d Major codebase cleanup after .insertr-add functionality overhaul
Consolidates duplicate code and removes technical debt accumulated during rapid development. This cleanup improves maintainability while preserving all functionality.

Backend cleanup:
- Remove unused legacy function findViableChildrenLegacy()
- Consolidate duplicate SQL null string helper functions into shared utils
- Unify text extraction functions across utils, engine, and id_generator
- Consolidate duplicate attribute getter functions into single implementation

Frontend cleanup:
- Remove duplicate authentication methods (authenticateWithOAuth vs performOAuthFlow)
- Remove unused hasPermission() method from auth.js
- Centralize repetitive API endpoint construction in api-client.js
- Reduce excessive console logging while preserving important error logs

Impact: -144 lines of code, improved maintainability, no functionality changes
All tests pass and builds succeed

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 19:00:41 +02:00
eb812fa78a feat: dramatically improve structural differentiation with sibling context
- Add sibling context detection to identify unique heading content
- Include parent container context with enhanced class filtering
- Look for heading siblings (h1-h6) that provide unique container context
- Extract up to 12 chars of sibling heading text for differentiation

Results:
 Collision Elimination: From 8 collisions to 0 collisions
 Unique Base IDs: Each element gets distinct ID (no -1, -2, -3 suffixes)
 Better Context: 'Example 1', 'Example 2' headings provide unique signatures
 Maintained Stability: Same elements still get same IDs across runs

Before: index-p-cad2a8, index-p-cad2a8-1, index-p-cad2a8-2... (8 collisions)
After: index-p-1198e8, index-p-215de9, index-p-604e11... (0 collisions)
2025-09-20 21:49:48 +02:00
b5225c1388 feat: implement structural IDs with database-first existence checking
- Remove content preview from ID generation for stable structural IDs
- Implement database-first approach to check content existence before creation
- Add enhanced DOM path, semantic context, and precise sibling indexing
- Replace HTML attribute checking with reliable database lookups
- Add collision handling with increment counters for similar elements

Fixes:
 UNIQUE constraint errors eliminated (multiple enhancement runs work)
 Structural stability (same element keeps same ID regardless of content changes)
 Database-driven workflow (single source of truth for content existence)
 Enhanced collision resistance with detailed structural differentiation

Results: No more 'Failed to store content' errors, stable enhance workflow.
2025-09-20 21:39:40 +02:00
c7ff63a87d feat: implement enhanced deterministic ID generation system
- Replace random UUID with 6-component deterministic signature
- Use filePath|domPath|tag|classes|contentPreview|siblingIndex for uniqueness
- Enhance sibling positioning with insertr-aware index calculation
- Improve DOM path generation with meaningful class inclusion
- Restore ID consistency across enhancement runs for reliable content injection

Results:
 ID Consistency: Same elements always get same IDs (index-p-639460)
 Collision Resistance: Different elements get different IDs (4c7206, 23df20, 5a975d)
 File Scoping: Same structure in different files gets different IDs
 Enhanced Workflow: API edit → enhance button → content injected successfully

Fixes enhance button by ensuring API content IDs match enhancement-generated IDs.
2025-09-20 18:05:13 +02:00
1b5c673466 fix: implement deterministic ID generation for consistent content injection
- Replace random UUID suffix with deterministic hash-based signature
- Use element DOM path, sibling position, and content preview for uniqueness
- Ensure same elements always get the same content ID across enhancements
- Fix critical bug where content updates weren't being injected into static files

This resolves the enhance button workflow: API content updates → enhance trigger → static file injection.
2025-09-20 17:53:04 +02:00
2177055c76 feat: Complete HTML-first architecture implementation with API integration
- Replace value field with html_content for direct HTML storage
- Add original_template field for style detection preservation
- Remove all markdown processing from injector (delete markdown.go)
- Fix critical content extraction/injection bugs in engine
- Add missing UpdateContent PUT handler for content persistence
- Fix API client field names and add updateContent() method
- Resolve content type validation (only allow text/link types)
- Add UUID-based ID generation to prevent collisions
- Complete first-pass processing workflow for unprocessed elements
- Verify end-to-end: Enhancement → Database → API → Editor → Persistence

All 37 files updated for HTML-first content management system.
Phase 3a implementation complete and production ready.
2025-09-20 16:42:00 +02:00
71561316da Fix demo site auto-enhancement and content persistence
- Restructure demo directory from test-sites/ to demos/ with flattened layout
- Add auto-enhancement on server startup for all sites with auto_enhance: true
- Fix inconsistent content ID generation that prevented dan-eden-portfolio content persistence
- Update server configuration to enhance from source to separate output directories
- Remove manual enhancement from justfile in favor of automatic server enhancement
- Clean up legacy test files and unused restore command
- Update build system to use CDN endpoint instead of file copying
2025-09-17 00:07:40 +02:00
84c90f428d feat: implement unified content engine to eliminate ID generation inconsistencies
- Create internal/engine module as single source of truth for content processing
- Consolidate 4 separate ID generation systems into one unified engine
- Update API handlers to use engine for consistent server-side ID generation
- Remove frontend client-side ID generation, delegate to server engine
- Ensure identical HTML markup + file path produces identical content IDs
- Resolve content persistence failures caused by ID fragmentation between manual editing and enhancement processes
2025-09-16 15:04:27 +02:00