Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
f002923
docs: share test
jayair Aug 11, 2025
7438a36
```
nitishxyz Aug 3, 2025
25f9bcb
Feat: Add react-native-sse package
nitishxyz Aug 3, 2025
d92f8fd
Feat: Add API services for local and remote data
nitishxyz Aug 3, 2025
92a1ec0
Feat: Add basic app navigation with tabs and chat
nitishxyz Aug 3, 2025
146015a
Feat: Implement home page and server connection setup
nitishxyz Aug 3, 2025
7ffb388
Feat: Display and send messages in chat page
nitishxyz Aug 3, 2025
84054c5
Refactor: Integrate streaming service for real-time updates
nitishxyz Aug 3, 2025
004bcba
Refactor: Improve chat streaming and local storage
nitishxyz Aug 3, 2025
6b1c506
Chore: Upgrade bun version in EAS config
nitishxyz Aug 3, 2025
2f63d3b
Refactor: Improve home screen UI/UX with new components
nitishxyz Aug 3, 2025
f14c7a8
Style: Refine chat input styling
nitishxyz Aug 3, 2025
19a0bf1
Feat: Implement floating header and input with blur
nitishxyz Aug 3, 2025
9c9763a
Fix: Prevent keyboard from covering input on Android
nitishxyz Aug 3, 2025
c7cf202
Feat: Implement chat screen with message streaming
nitishxyz Aug 3, 2025
f93c57e
Feat: Improve chat scrolling and keyboard handling
nitishxyz Aug 3, 2025
9478017
Refactor: Use generic BottomSheet component
nitishxyz Aug 3, 2025
71bc8de
Feat: Enhance chat messages with tool outputs
nitishxyz Aug 3, 2025
090c8de
Refactor: Improve message display and session sync
nitishxyz Aug 3, 2025
3724499
Style: Improve chat message rendering styles
nitishxyz Aug 3, 2025
259b0c5
Feat: Add session management and switching
nitishxyz Aug 3, 2025
bc4892c
Refactor: Improve message rendering and structure
nitishxyz Aug 3, 2025
fa8334d
Refactor: Decouple search input from QuickActions
nitishxyz Aug 3, 2025
9ea68f8
Refactor: Remove session dialog and view all button
nitishxyz Aug 3, 2025
2184ccb
Fix: Truncate long filenames in chat renderers
nitishxyz Aug 3, 2025
4c49fb2
Feat: Implement back navigation in chat header
nitishxyz Aug 3, 2025
31d6f9a
Feat: Improve server connection reliability
nitishxyz Aug 3, 2025
4cdf058
Refactor: Simplify chat page with new architecture
nitishxyz Aug 4, 2025
177a249
Refactor: Improve chat page performance and stability
nitishxyz Aug 4, 2025
f853a2f
Refactor: Simplify chat screen and improve input UX
nitishxyz Aug 4, 2025
33c8219
Docs: Initial mobile app documentation and performance improvements
nitishxyz Aug 4, 2025
3c25657
Feat: Track session cost and token usage
nitishxyz Aug 4, 2025
bf3a611
Refactor: Improve chat session synchronization and updates
nitishxyz Aug 4, 2025
aab85e1
Feat: Implement build/plan mode toggle
nitishxyz Aug 4, 2025
e3e8ce2
Feat: Add BottomSheetInput component and enhance connection sheet
nitishxyz Aug 4, 2025
409354b
Perf: Optimize mobile chat rendering and database queries during stre…
nitishxyz Aug 4, 2025
e04e2b2
Feat: Enhance mobile chat UX with smart keyboard dismissal and mode s…
nitishxyz Aug 4, 2025
f191d6e
Refactor: Replace relative db imports with @/db aliases in mobile ser…
nitishxyz Aug 4, 2025
c9f8a13
Refactor: Simplify chat header by removing menu button and updating n…
nitishxyz Aug 4, 2025
db48141
Fix: Correct session ordering after REST API refresh
nitishxyz Aug 5, 2025
2a89fd6
feat: add skeleton loaders for projects and sessions lists
nitishxyz Aug 5, 2025
8c79c19
feat: restore mode switching on pull-to-refresh in chat
nitishxyz Aug 5, 2025
b0a5140
Refactor: Improve chat message sending and UI updates
nitishxyz Aug 5, 2025
6db1378
feat: add settings page and improve project management
nitishxyz Aug 5, 2025
8cc8b66
Refactor: Use render props for Button.Icon component
nitishxyz Aug 5, 2025
1fbb34a
Refactor: Centralize project connection logic
nitishxyz Aug 5, 2025
d699eec
Feat: Sync remote sessions on connection success
nitishxyz Aug 5, 2025
20e3bce
Refactor: Refactor home screen for performance
nitishxyz Aug 5, 2025
7e8dd64
Feat: Improve project connection flow and UI
nitishxyz Aug 5, 2025
e9119d0
Refactor: Stream message parts directly from database
nitishxyz Aug 5, 2025
c085175
Refactor: Format session time to be more readable
nitishxyz Aug 5, 2025
3771149
Refactor: Simplify StreamingMessageList component
nitishxyz Aug 5, 2025
3b2c6dc
Feat: Implement welcome screen for new users
nitishxyz Aug 5, 2025
fe33195
fix: update query invalidation key in chat state
nitishxyz Aug 5, 2025
85dfe66
Feat: Improve message loading and session handling
nitishxyz Aug 5, 2025
2137a2c
Feat: Align mobile app message handling with TUI
nitishxyz Aug 5, 2025
9ed5c7d
Refactor: Store message timestamps as milliseconds
nitishxyz Aug 5, 2025
45577e6
Feat: Enhance chat streaming message rendering
nitishxyz Aug 5, 2025
26bbe80
Feat: Add expandable generic tool output
nitishxyz Aug 5, 2025
59bf52d
fix: remove auto-scroll on response complete
nitishxyz Aug 5, 2025
8b6708c
feat: Add expandable command output in BashRenderer
nitishxyz Aug 5, 2025
374f5f8
Feat: Enhance chat UI with commands and model select
nitishxyz Aug 6, 2025
c9afb8b
Feat: Simplify chat page and streamline components
nitishxyz Aug 7, 2025
336001f
Refactor: Migrate to BottomSheetModal and refine UI
nitishxyz Aug 7, 2025
2e38d8d
Refactor: Refactor chat message rendering and simplify list
nitishxyz Aug 8, 2025
d6be57f
Feat: Add new renderers for tool outputs
nitishxyz Aug 8, 2025
f21d333
Refactor: Rename 'current_mode' to 'current_agent'
nitishxyz Aug 8, 2025
ccb1301
Feat: Add frequently used models to models sheet
nitishxyz Aug 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,241 changes: 2,047 additions & 194 deletions bun.lock

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions packages/mobile/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files

# dependencies
node_modules/

# Expo
.expo/
dist/
web-build/
expo-env.d.ts

# Native
.kotlin/
*.orig.*
*.jks
*.p8
*.p12
*.key
*.mobileprovision

# Metro
.metro-health-check*

# debug
npm-debug.*
yarn-debug.*
yarn-error.*

# macOS
.DS_Store
*.pem

# local env files
.env*.local

# typescript
*.tsbuildinfo

app-example
ios
android
Empty file added packages/mobile/.watchmanconfig
Empty file.
325 changes: 325 additions & 0 deletions packages/mobile/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
# OpenCode Mobile

<p align="center">
<img src="../../packages/web/src/assets/logo-ornate-light.svg" alt="opencode logo" width="200">
</p>

<p align="center">AI coding agent for mobile - Chat with your codebase on the go</p>

---

## 📱 Overview

OpenCode Mobile is a React Native app that provides a mobile interface for the OpenCode AI coding agent. Chat with your codebase, browse files, and manage coding sessions directly from your phone or tablet.

### Key Features

- 💬 **Real-time Chat** with AI assistant
- 📁 **File Browser** with syntax highlighting
- 🔍 **Code Search** (text, files, symbols)
- 📱 **Session Management** (create, share, delete)
- 🌐 **Offline Support** with local caching
- 🎨 **Dark/Light Theme** support
- 🔄 **Real-time Sync** via Server-Sent Events

## 🚀 Quick Start

### Prerequisites

- Node.js 18+ or Bun
- Expo CLI (`npm install -g @expo/cli`)
- iOS Simulator (macOS) or Android Emulator
- OpenCode server running locally

### Installation

```bash
# Install dependencies
bun install

# Start the development server
bun start

# Run on specific platforms
bun run ios # iOS Simulator
bun run android # Android Emulator
bun run web # Web browser
```

### Server Setup

The mobile app connects to your local OpenCode server:

```bash
# In your project directory, start OpenCode server
opencode serve --hostname 0.0.0.0 --port 4096
```

Then configure the mobile app to connect to your machine's IP address (e.g., `192.168.1.100:4096`).

## 🏗️ Architecture

### Tech Stack

- **Framework**: React Native with Expo
- **Navigation**: Expo Router (file-based routing)
- **State Management**: TanStack Query + React Context
- **Database**: SQLite with Drizzle ORM
- **Styling**: React Native Unistyles
- **Real-time**: Server-Sent Events (SSE)

### Project Structure

```
src/
├── components/
│ ├── ui/
│ │ ├── primitives/ # Base design system components
│ │ └── base/ # Layout and navigation components
│ ├── molecules/ # Composed UI components
│ │ ├── chat/ # Chat-related components
│ │ ├── home/ # Home screen components
│ │ └── session/ # Session management components
│ └── pages/ # Screen components
├── db/
│ ├── schema/ # Database schema definitions
│ └── types.ts # Database type definitions
├── hooks/ # Custom React hooks
├── services/
│ ├── api/ # API client and services
│ │ ├── local/ # Local database operations
│ │ └── remote/ # Server API calls
│ └── *.ts # Other services (chat, theme, etc.)
└── providers/ # React context providers

app/ # Expo Router screens
├── (app)/ # Main app screens
│ ├── _layout.tsx # App layout with tabs
│ ├── index.tsx # Home screen
│ ├── sessions.tsx # Sessions list
│ └── chat/ # Chat screens
└── _layout.tsx # Root layout
```

## 🗄️ Database Schema

The app uses SQLite with Drizzle ORM for local data storage and offline support:

### Core Tables

- **`sessions`** - Chat sessions (mirrors server Session.Info)
- **`messages`** - Chat messages (mirrors server MessageV2.Info)
- **`message_parts`** - Message components (mirrors server MessageV2.Part)
- **`providers`** - AI providers (cached from server)
- **`file_cache`** - Cached file contents for offline access
- **`sync_queue`** - Offline operations queue

### Database Commands

```bash
# Generate migrations
bun run db generate

# Push schema changes
bun run db push

# Open Drizzle Studio
bun run db studio
```

## 🔌 API Integration

### Server Endpoints

The mobile app integrates with these OpenCode server endpoints:

- **Sessions**: `GET/POST/DELETE /session`
- **Messages**: `GET/POST /session/:id/message`
- **Files**: `GET /file`, `GET /find`
- **Config**: `GET /config`, `GET /config/providers`
- **Real-time**: `GET /event` (SSE stream)

### Connection Management

```typescript
// Configure server connection
const config = {
serverHostname: "192.168.1.100",
serverPort: 4096,
serverUrl: "http://192.168.1.100:4096",
}

// The app automatically handles:
// - Connection status monitoring
// - Offline queue management
// - Real-time event synchronization
```

## 📱 Screens & Navigation

### Main Screens

1. **Home** - Dashboard with recent sessions and quick actions
2. **Sessions** - List of all chat sessions with search/filter
3. **Chat** - Main chat interface with AI assistant
4. **Search** - Global search across files and code
5. **Settings** - App configuration and preferences

### Navigation Structure

```
TabNavigator (Bottom Tabs)
├── Home
├── Sessions
├── Search
└── Settings

StackNavigator (Modal/Push)
├── Chat Screen
├── File Viewer
├── Session Details
└── Connection Setup
```

## 🎨 Design System

### UI Components

The app uses a custom design system built with React Native Unistyles:

```typescript
// Example usage
<Box flex safeArea background="base">
<Text size="lg" weight="semibold">Welcome</Text>
<Button mode="brand" onPress={handlePress}>
<Button.Text>Get Started</Button.Text>
</Button>
</Box>
```

### Theme Support

- **Light/Dark Mode** - Automatic system detection
- **Color Tokens** - Consistent color palette
- **Typography Scale** - Responsive text sizing
- **Spacing System** - Consistent layout spacing

## 🔄 Offline Support

### Caching Strategy

- **Sessions & Messages** - Fully cached for offline access
- **File Contents** - LRU cache with configurable size limits
- **Search Results** - TTL-based cache (1 hour)

### Sync Process

1. **Online Mode** - Direct API calls with real-time updates
2. **Offline Mode** - Queue operations in `sync_queue`
3. **Reconnection** - Process queued operations with conflict resolution

## 🛠️ Development

### Available Scripts

```bash
# Development
bun start # Start Expo dev server
bun run ios # Run on iOS simulator
bun run android # Run on Android emulator
bun run web # Run in web browser

# Database
bun run db generate # Generate Drizzle migrations
bun run db push # Push schema to database
bun run db studio # Open Drizzle Studio

# Code Quality
bun run lint # Run ESLint
bun run typecheck # Run TypeScript checks

# Builds
eas build --platform ios # Build for iOS
eas build --platform android # Build for Android
```

### Environment Configuration

The app supports multiple environments via `EXPO_PUBLIC_ENV`:

- **dev** - Development builds
- **preview** - Internal testing builds
- **production** - App Store releases

### Build Profiles

```json
{
"dev": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal"
},
"production": {
"autoIncrement": true
}
}
```

## 📚 Documentation

### Additional Docs

- [**Mobile App Plan**](./MOBILE_APP_PLAN.md) - Detailed feature planning
- [**Component Patterns**](./COMPONENT_PATTERNS.md) - UI component guidelines
- [**Database Schema**](./DATABASE_SCHEMA.md) - Complete database documentation
- [**Streaming Optimizations**](./STREAMING_PERFORMANCE_OPTIMIZATIONS.md) - Performance notes
- [**UI Primitives**](./UI_PRIMITIVES.md) - Design system documentation

### API Documentation

The mobile app integrates with the OpenCode server API. See the main project documentation for complete API reference.

## 🤝 Contributing

### Development Setup

1. **Clone the repository**
2. **Install dependencies**: `bun install`
3. **Start OpenCode server**: `opencode serve --hostname 0.0.0.0`
4. **Start mobile app**: `bun start`
5. **Configure connection** in the app settings

### Code Style

- Use TypeScript for all new code
- Follow existing component patterns
- Use the design system components
- Add proper error handling and loading states
- Test on both iOS and Android

### Testing

```bash
# Run on different platforms
bun run ios # Test iOS functionality
bun run android # Test Android functionality
bun run web # Test web compatibility
```

## 📄 License

This project is licensed under the MIT License - see the main project [LICENSE](../../LICENSE) file for details.

## 🔗 Links

- [OpenCode Main Project](https://github.com/sst/opencode)
- [OpenCode Website](https://opencode.ai)
- [Discord Community](https://opencode.ai/discord)
- [Documentation](https://opencode.ai/docs)

---

**Built with ❤️ by the OpenCode team**
Loading
Loading