# Roadmap

## Done

- [x] Multi-language UI (NL, AR, EN)
- [x] RTL support
- [x] Real-time name validation
- [x] SSE deployment progress
- [x] Dokploy orchestration
- [x] SSL certificate provisioning wait
- [x] Stack cleanup API
- [x] Auto-rollback on failure
- [x] Persistent storage volumes
- [x] Logging infrastructure (log-ingest → Loki → Grafana)
- [x] AI Stack monitoring dashboard at logs.intra.flexinit.nl
- [x] Repository consolidation (3 repos → flexinit/agent-stack)
- [x] Unified CI/CD pipeline (stack + portal images)

## Next (Priority)

### Automated Cleanup System (HIGH)
**Issue**: Disk space exhaustion on Dokploy server causes CI failures

**Components**:
- [ ] CI workflow cleanup step - prune build cache after each build
- [ ] Server-side cron job - daily Docker system prune
- [ ] Disk monitoring - alert at 80% usage via Grafana
- [ ] Post-deployment cleanup - remove unused resources after stack deploy

**Implementation**:
```yaml
# CI workflows (.gitea/workflows/*.yaml)
- name: Cleanup build artifacts
  if: always()
  run: |
    docker builder prune -f --keep-storage=2GB
    docker image prune -f --filter "until=24h"
```

```bash
# Server cron (/etc/cron.d/docker-cleanup on 10.100.0.20)
0 4 * * * root docker system prune -f --volumes --filter "until=72h"
0 4 * * * root docker exec flexinit-runner docker builder prune -f --keep-storage=5GB
```

### Web-based TUI Support (HIGH) - IN PROGRESS
**Feature**: Full TUI (Terminal User Interface) support inside the web browser

**Goal**: Enable rich terminal UI applications (like htop, lazygit, OpenCode TUI mode) to render correctly in the browser-based terminal.

**Completed** (Terminal Environment):
- [x] TERM=xterm-256color environment variable
- [x] COLORTERM=truecolor for 24-bit color support
- [x] ncurses-base and ncurses-term packages for terminfo database
- [x] Locale configuration (en_US.UTF-8) for Unicode support
- [x] Environment variables passed to deployed stacks

**Remaining** (Direct Web Terminal):
- [ ] Add ttyd for raw terminal access in browser
- [ ] Configure dual-port exposure (OpenCode IDE + ttyd terminal)
- [ ] Update Traefik routing for terminal port
- [ ] Test TUI applications (htop, lazygit, vim)
- [ ] Document TUI capabilities for users

**Architecture** (Dual Interface):
```
https://name.ai.flexinit.nl/      → Port 8080 → OpenCode Web IDE
https://name.ai.flexinit.nl:7681/ → Port 7681 → ttyd Raw Terminal
```

**Implementation Plan**:
```dockerfile
# Add ttyd to Dockerfile
RUN curl -sL https://github.com/tsl0922/ttyd/releases/latest/download/ttyd.x86_64 \
    -o /usr/local/bin/ttyd && chmod +x /usr/local/bin/ttyd

# Startup script runs both services
ttyd -p 7681 -W bash &
opencode serve --hostname 0.0.0.0 --port 8080
```

**Use Cases**:
- OpenCode TUI mode in browser
- lazygit, lazydocker
- htop, btop system monitoring
- vim/neovim with full features
- Any ncurses-based application

### Other Next Items
- [ ] User authentication (protect deployments)
- [ ] Rate limiting (prevent abuse)
- [ ] Stack management UI (list/delete stacks)

## Later

- [ ] Unit tests for validation
- [ ] Integration tests
- [ ] Resource limits configuration
- [ ] Custom domain support
- [ ] Image versioning (semantic versions + rollback)
- [ ] Auto-cleanup of abandoned stacks (inactive > 30 days)

## Technical Notes

### Disk Space Management
Server: 10.100.0.20 (97GB total)
- Docker images: ~10GB
- Containers: ~1.5GB
- Volumes: ~30GB
- Build cache: Up to 6GB between cleanups
- **Safe threshold**: Keep 15GB+ free (85% max usage)

### Key Infrastructure
- Gitea: git.app.flexinit.nl (repo: flexinit/agent-stack)
- Runner: flexinit-runner container on 10.100.0.20
- Registry: git.app.flexinit.nl/flexinit/agent-stack:latest
- Monitoring: logs.intra.flexinit.nl (dashboard: /d/ai-stack-overview)
