Commit Graph

16 Commits

Author SHA1 Message Date
Dwindi Ramadhana
690991c526 refactor: Cleanup git state - commit all staged changes
Major refactoring cleanup:
- Add new controller architecture (class-controller-*.php)
- Add new settings-v2 UI (views/settings-v2/)
- Add new CSS architecture (agentic-sidebar.css, tokens)
- Add esbuild build pipeline (scripts/build.js, package.json)
- Add composer dependencies (vendor/)
- Add frontend src directory (assets/js/src/index.jsx)
- Add documentation files
- Remove old/obsolete files (class-settings.php, old CSS)

This commits all pending changes from previous refactoring efforts.
2026-06-17 05:27:58 +07:00
Dwindi Ramadhana
d3f142222c feat: Add connection test caching and reasoning content support
Backend improvements:
- Add cache auto-clear on settings save (class-settings-v2.php)
  - Hooks updated_option action
  - Clears connection test transients when local backend settings change
- Add reasoning_content streaming support (class-local-backend-provider.php)
  - Handles thinking models like Claude extended thinking
  - Captures chunk['choices'][0]['delta']['reasoning_content']

Documentation:
- Add FRONTEND_AND_CHAT_FIX_SUMMARY.md with all fixes
- Add FRONTEND-REFACTOR-PHASE2.md with modularization plan

Note: Splitting effort deferred - will continue iterating on monolith
Next: Fix session history not appearing bug
2026-06-17 05:26:12 +07:00
Dwindi Ramadhana
f55acd7d26 Add sidebar 1:1 migration docs 2026-06-15 11:47:03 +07:00
Dwindi Ramadhana
619d36d3c8 feat: MEMANTO integration — persistent memory for cross-session context (Phases 1-4)
Phase 1: Core Client
- New class-memanto-client.php: Singleton PHP client for MEMANTO API v2
  - Health check with 5-min transient caching
  - Agent CRUD (ensure, activate, deactivate sessions)
  - Memory operations (remember, batch_remember, recall, recall_recent)
  - Auto re-activation on expired session tokens (401 retry)

Phase 2: Write-Through Memory Hooks
- New class-memanto-context-enhancer.php: Orchestrates remember/recall
  - Fires on: user message, plan generated/approved/rejected,
    section written, block refined, config saved, session start/end
  - All hooks via do_action() — zero coupling to MEMANTO when disabled

Phase 3: Context Enrichment
- Context builder injects recalled memories into AI prompts
  via build_memanto_context() in build_working_context()
- 3-recall strategy: recent post memories, semantic search, user preferences
- Deduplication by content hash

Phase 4: Cross-Session Restore
- New REST endpoints: /memanto/restore, /memanto/preferences
- restore_session() recalls 15 recent memories + user preferences on editor load
- build_session_restore_message() creates AI-ready system message
- get_user_preferences_for_new_post() extracts tone/audience/length/language
- Frontend: 🧠 Restored badge in status bar with memory count tooltip
- Preference carry-over: auto-fills post config from stored user preferences
- deactivate_session() called on session end (triggers MEMANTO summary)
- Badge clears on new conversation start

Settings UI:
- MEMANTO Context Keeper section with enable toggle, URL, API key, test connection
- Settings registered via class-settings-v2.php + tab-memanto.php view

Graceful degradation: all MEMANTO calls guarded by is_active(),
frontend catches silently, plugin works identically when disabled.
2026-06-08 12:42:04 +07:00
Dwindi Ramadhana
379a72e52d fix: writing stuck - handle empty model response + no-divider fallback + timeline cleanup
Root causes of writing getting stuck:
1. Model returns empty response for a section → now detected early with
   actionable error message including model name
2. Model responds but without ~~~ARTICLE~~~ divider (happens with fallback
   models like Gemini) → now treats entire response as markdown content
3. Stream ends without 'complete' event (error/exit in PHP) → JS timeline
   entries lingered as 'active' forever. Now deactivated on stream close.
4. Error messages in execution flow now use structured formatAiErrorMessage
   with retry button instead of raw text

Also: deactivateActiveTimelineEntries called in catch block so errors
properly clear the 'Writing section X' status indicator.
2026-06-06 05:30:12 +07:00
Dwindi Ramadhana
23a34b3035 fix: session history not loading + new session showing stale messages
Bug 1 - Session opens with empty messages:
- loadChatHistory effect was re-running on every currentSessionId change,
  racing with openSessionById and overwriting loaded messages
- Removed currentSessionId from effect dependencies (only runs on mount/postId)
- Added recovery: if session has 0 messages but has post_id, try fetching
  from the post-based conversation endpoint as fallback

Bug 2 - Start New Session shows old messages:
- startNewConversation now sets isHydratingSessionRef=true before changing
  session state, preventing the persistence effect from saving stale data
- Fully resets: messages, plan, agentMode, keyword suggestions, providerInfo
- loadPostSessions called AFTER state reset to avoid stale renders

Also fixed:
- Legacy fallback now only fires when no session was resolved at all
  (prevents loading old post_meta data over session data)
2026-06-06 05:14:34 +07:00
Dwindi Ramadhana
b4ea9025b1 fix: session persistence + h3 readability + outline error messages
Session issues fixed:
- Removed auto-draft-only gate for showing unassigned sessions on new posts
  (now shows on any post that has no linked sessions)
- Auto-link unassigned session to current post when user opens it
- Added beforeunload/pagehide flush to persist messages before page close
  (prevents data loss from 700ms debounce not firing)
- Added warning log when session loads with 0 messages for debugging

UI fix:
- Override WP editor h3 shrinkage (11px/uppercase → 15px/normal/white)
- Fix h2/h4-h6 headings in response content for dark theme readability

Outline error messages:
- Separate empty response from parse failure with distinct actionable messages
- Show model name + token count on empty response for debugging
- Reassure user that parse failures are usually one-time issues
2026-06-06 00:58:08 +07:00
Dwindi Ramadhana
f7bf1f5153 fix: UX audit improvements - dark theme, structured errors, heartbeat, health check
Phase 1 - UI Theme Consistency:
- Chat messages now use consistent dark theme (removed jarring white bg)
- Plan cards restyled with rounded borders, fills, colored status badges
- Timeline entries use humanist sans-serif instead of monospace
- Error messages now structured (icon + title + detail + action link)
- Input area unified with dark theme cohesion

Phase 2 - UX Flow:
- Added contextual placeholder text per agent mode in textarea
- Added visual mode indicator badge (Chat/Planning/Writing)
- Simplified welcome screen (single 'Continue' + collapsible history)
- Added slash command/mention discovery hint in empty input
- Added write confirmation when editor has existing content
- Added 30s streaming heartbeat (reassurance when model is slow)

Phase 3 - Error Handling:
- Added DB table health check on sidebar init
- Improved 'no API key' error with settings link
- Shows in-chat warning when provider fallback triggers
- Auto-fallback to registry fallback model on unavailability
- isLoading always resets via try/finally pattern
2026-06-06 00:43:10 +07:00
Dwindi Ramadhana
ae70e4aea9 checkpoint: pre-audit baseline state 2026-06-06 00:29:10 +07:00
Dwindi Ramadhana
579aab1b2b chore: slim docs by removing retrace and planning artifacts 2026-05-28 01:01:29 +07:00
Dwindi Ramadhana
44e06eed88 feat: consolidate docs, backend/session infra, and settings updates 2026-05-28 00:58:20 +07:00
Dwindi Ramadhana
2424acf726 chore: clean up completed markdown docs 2026-05-28 00:57:11 +07:00
Dwindi Ramadhana
2c10e73ca4 Fix session/image UX and align post cost totals 2026-05-28 00:51:34 +07:00
Dwindi Ramadhana
d2c10756ab Add AI writing assistant plugin with local backend, brave search, and image generation support
- Implement local backend AI provider with Ollama integration
- Add Brave Search API integration for real-time search suggestions
- Add image generation manager with multiple AI providers
- Create hybrid provider system with local/cloud fallback
- Add comprehensive settings UI with provider management
- Implement Gutenberg sidebar with writing assistance controls
- Add SEO schema generation for AI-generated content
- Multiple provider support: OpenRouter, local backend, Codex
2026-05-17 10:48:05 +07:00
dwindown
97426d5ab1 first commit all files 2026-01-28 00:26:00 +07:00
dwindown
65dd207a74 first commit 2026-01-28 00:18:14 +07:00