co-mono/packages/web-ui/example
Mario Zechner e5cf25a267 Refactor agent architecture and add session storage
Major architectural improvements:
- Renamed AgentSession → Agent (state/ → agent/)
- Removed id field from AgentState
- Fixed transport abstraction to pass messages directly instead of using callbacks
- Eliminated circular dependencies in transport creation

Transport changes:
- Changed signature: run(messages, userMessage, config, signal)
- Removed getMessages callback from ProviderTransport and AppTransport
- Transports now filter attachments internally

Session storage:
- Added SessionRepository with IndexedDB backend
- Auto-save sessions after first exchange
- Auto-generate titles from first user message
- Session list dialog with search and delete
- Persistent storage permission dialog
- Browser extension now auto-loads last session

UI improvements:
- ChatPanel creates single AgentInterface instance in setAgent()
- Added drag & drop file upload to MessageEditor
- Fixed artifacts panel auto-opening on session load
- Added "Drop files here" i18n strings
- Changed "Continue Without Saving" → "Continue Anyway"

Web example:
- Complete rewrite of main.ts with clean architecture
- Added check script to package.json
- Session management with URL state
- Editable session titles

Browser extension:
- Added full session storage support
- History and new session buttons
- Auto-load most recent session on open
- Session titles in header
2025-10-06 12:47:52 +02:00
..
src Refactor agent architecture and add session storage 2025-10-06 12:47:52 +02:00
.gitignore web-ui package 2025-10-05 13:30:08 +02:00
index.html Add Anthropic prompt caching, pluggable storage, and CORS proxy support 2025-10-05 23:00:36 +02:00
package-lock.json web-ui package 2025-10-05 13:30:08 +02:00
package.json Refactor agent architecture and add session storage 2025-10-06 12:47:52 +02:00
README.md web-ui package 2025-10-05 13:30:08 +02:00
tsconfig.json web-ui package 2025-10-05 13:30:08 +02:00
vite.config.ts web-ui package 2025-10-05 13:30:08 +02:00

Pi Web UI - Example

This is a minimal example showing how to use @mariozechner/pi-web-ui in a web application.

Setup

npm install

Development

npm run dev

Open http://localhost:5173 in your browser.

What's Included

This example demonstrates:

  • ChatPanel - The main chat interface component
  • System Prompt - Custom configuration for the AI assistant
  • Tools - JavaScript REPL and artifacts tool

Configuration

API Keys

The example uses Direct Mode by default, which means it calls AI provider APIs directly from the browser.

To use the chat:

  1. Click the settings icon (⚙️) in the chat interface
  2. Click "Manage API Keys"
  3. Add your API key for your preferred provider:

API keys are stored in your browser's localStorage and never sent to any server except the AI provider's API.

Project Structure

example/
├── src/
│   ├── main.ts       # Main application entry point
│   └── app.css       # Tailwind CSS configuration
├── index.html        # HTML entry point
├── package.json      # Dependencies
├── vite.config.ts    # Vite configuration
└── tsconfig.json     # TypeScript configuration

Learn More