An intelligent writing assistant that uses AI to continue your text seamlessly. Built with React, XState, ProseMirror, and Radix UI.
- ✍️ AI-Powered Writing: Continue your text with AI-generated content
- ⌨️ Keyboard Shortcuts: Quick access with Ctrl+Space (or Cmd+Space on Mac)
- 🎨 Rich Text Editor: Powered by ProseMirror with formatting support
- 🔄 State Management: Robust state handling with XState
- 🎯 Content Control: Accept, clear, or discard AI suggestions
- 📱 Responsive Design: Works on desktop and mobile
- ♿ Accessible: Built with Radix UI for WCAG compliance
- React 18: Modern UI library with hooks
- XState v5: State machine for predictable state management
- ProseMirror: Powerful rich text editor framework
- Radix UI: Accessible, unstyled UI primitives
- OpenAI API: GPT-4 for content generation
- Vite: Fast build tool and dev server
- Node.js 16+ and npm
- OpenAI API key (Get one here)
-
Clone the repository
git clone <repository-url> cd chronicle_assignment_sheetal_singh
-
Install dependencies
npm install
-
Configure API Key
Create a
.envfile in the project root:cp .env.example .env
Edit
.envand add your OpenAI API key:VITE_OPENAI_API_KEY=your_openai_api_key_here -
Start the development server
npm run dev
-
Open in browser
Navigate to
http://localhost:5173
- Start typing in the editor
- Click "Continue Writing" or press
Ctrl+Space(Windows/Linux) orCmd+Space(Mac) - Wait for AI to generate content
- Review the highlighted AI-generated text
- Choose an action:
- Accept All: Keep the AI content
- Clear All: Remove the AI content
- Discard Session: Revert to before AI generation
Ctrl+Space/Cmd+Space: Trigger AI generationCtrl+Z/Cmd+Z: UndoCtrl+Y/Cmd+Y: Redo
src/
├── components/
│ ├── Editor.jsx # ProseMirror editor component
│ ├── Editor.css # Editor styles
│ ├── Toolbar.jsx # Main toolbar with Continue button
│ ├── StatusBar.jsx # Status indicator at bottom
│ └── AIToolbar.jsx # Floating toolbar for AI actions
├── machines/
│ └── editorMachine.js # XState state machine
├── services/
│ └── aiService.js # OpenAI API integration
├── App.jsx # Main application component
└── App.css # Global styles
The application uses XState to manage states:
idle → generating → review → idle
↓ ↓
error ←──────────────┘
- idle: Ready for user input
- generating: AI is creating content
- review: AI content ready for user action
- error: Something went wrong
All code files include extensive comments explaining:
- What each function does
- Why certain approaches were chosen
- How different parts interact
- React and JavaScript concepts for beginners
npm run buildnpm run previewnpm run lint- Never expose API keys in frontend code
- Use a backend server to make API calls
- Implement proper authentication
- Add rate limiting
- Local AI fallback with transformers.js
- Multiple AI model selection
- Customizable AI parameters (temperature, max tokens)
- Export to Markdown/PDF
- Dark mode support
- Collaborative editing
- Version history with branching
MIT
Sheetal Singh