Skip to content

Feature/prompt ai enhancer#346

Open
AlanAAG wants to merge 4 commits into
V1.4.0from
feature/prompt_ai_enhancer
Open

Feature/prompt ai enhancer#346
AlanAAG wants to merge 4 commits into
V1.4.0from
feature/prompt_ai_enhancer

Conversation

@AlanAAG

@AlanAAG AlanAAG commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

What changed

Backend (browser_adapter.py)

  • New enhance_prompt WebSocket message handler: receives the user's draft, calls the LLM one-shot, returns prompt_enhanced over the same WS connection
  • Full 7-rule enhancement system prompt: preserves intent, names targets explicitly, adds done-conditions, signals task complexity, honours scheduling language, eliminates pronoun ambiguity, enforces one action frame

Frontend

  • Chat.tsx: Sparkles/Loader2 icon button added between the paperclip and mic; enhancing state drives disabled + spinner; useEffect consumes the enhanced prompt and replaces textarea content
  • WebSocketContext.tsx: enhancedPrompt state, enhancePrompt / clearEnhancedPrompt callbacks, case 'prompt_enhanced': handler
  • types/index.ts: 'prompt_enhanced' added to WSMessageType union
  • Chat.module.css: reuses existing .uploadingSpinner animation (no new keyframes)

Behaviour

  1. User types a prompt → clicks ✨ → button spins and disables
  2. Backend calls LLM (~2–4s) → returns enhanced prose
  3. Textarea content is replaced → focus returned → user reviews and sends normally
  4. On WS disconnect mid-request: spinner auto-resets, no stuck UI
  5. On LLM error: original content returned as fallback, no silent failure

AlanAAG and others added 4 commits June 25, 2026 20:31
Add new message handler for enhance_prompt type that optimizes user prompts
using LLM before submission. Includes _handle_enhance_prompt method that calls
generate_response_async with a prompt optimization system message, sends the
enhanced content back via WebSocket, and falls back to original content on error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wire WebSocketContext to handle prompt_enhanced WS roundtrip and expose
enhancePrompt/clearEnhancedPrompt; add Sparkles IconButton with Loader2
spin state to Chat input area.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…onnect

- Split _handle_enhance_prompt into two try/except blocks so a closed
  socket on fallback send is swallowed rather than raising unhandled
- Reset enhancing state in Chat.tsx when WebSocket disconnects
- Remove duplicate .spinIcon CSS class; reuse .uploadingSpinner instead

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…geType

- Replace minimal system prompt with full 7-rule enhancement protocol
- Add done-condition, task complexity, scheduling, and pronoun rules
- Fix tooltip text to 'AI Enhance'
- Add 'prompt_enhanced' to WSMessageType union in types/index.ts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AlanAAG AlanAAG requested a review from ahmad-ajmal June 26, 2026 04:14
@zfoong

zfoong commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Do not merge this yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants