Files

208 lines
12 KiB
Markdown

# Final Comprehensive Gap Analysis: sovereign_browser Rust Port
This document catalogs every remaining gap between the original C implementation (`/home/user/lt/sovereign_browser`) and the Rust port (`/home/user/lt/sovereign_browser_rust`). The goal is 100% feature parity.
---
## 1. Hamburger Menu Gaps
The C hamburger menu ([`tab_manager.c:2562-2692`](../sovereign_browser/src/tab_manager.c:2562)) has significantly more items than the Rust version ([`src/tab_manager.rs:997`](src/tab_manager.rs:997)).
### Missing Menu Items
| Item | C Action | Rust Status |
|------|----------|-------------|
| **Recents (History submenu)** | Dropdown of last 10 pages + "Clear Recents" | ❌ Missing |
| **Bookmarks submenu** | Tree of bookmarks + "Manage Bookmarks…" | ❌ Missing |
| **Tor-routed transport** | Check menu item (toggle Tor mode) | ❌ Missing |
| **FIPS mesh** | Check menu item (toggle FIPS mode) | ❌ Missing |
| **Security strip** | Check menu item (toggle SOP/CORS/certs) | ❌ Missing |
| **Nostr signing status** | Clickable item showing signer status | ❌ Missing |
| **Lock Session** | Sign out without closing browser | ❌ Missing |
| **Download Website** | Opens site downloader | ❌ Missing |
| **About** | Opens about dialog | ❌ Missing |
| **Avatar button** | Circular profile picture button next to hamburger | ❌ Missing |
### Required files: [`src/tab_manager.rs`](src/tab_manager.rs:997)
---
## 2. Keyboard Shortcuts Gaps
The C version defines 20+ shortcuts ([`shortcuts.c:24-124`](../sovereign_browser/src/shortcuts.c:24)). The Rust version ([`src/shortcuts.rs:21`](src/shortcuts.rs:21)) has 12.
### Missing Shortcuts
| Action | Shortcut | Rust Status |
|--------|----------|-------------|
| `new_window` | Ctrl+N | ❌ Not in shortcut registry |
| `open_file` | Ctrl+O | ❌ Missing |
| `force_reload` | Shift+F5 | ❌ Missing |
| `go_back` | Alt+Left | ❌ Missing |
| `go_forward` | Alt+Right | ❌ Missing |
| `find` | Ctrl+F | ❌ Missing |
| `open_settings` | Ctrl+, | ❌ Missing |
| `open_processes` | Ctrl+Shift+Esc | ❌ Missing |
| `new_identity` | Ctrl+Shift+U | ❌ Missing |
| `toggle_fullscreen` | F11 | ❌ Missing |
| `toggle_sidebar` | Ctrl+Shift+A | ❌ Missing |
| `toggle_toolbars` | Ctrl+Shift+M | ❌ Missing |
| `bookmark_page` | Ctrl+D | ❌ Missing |
| `show_history` | Ctrl+H | ❌ Missing |
| `show_bookmarks` | Ctrl+B | ❌ Missing |
| `show_downloads` | Ctrl+J | ❌ Missing |
| `quit` | Ctrl+Q | ❌ Missing |
| `next_tab_pagedown` | Ctrl+PageDown | ❌ Missing |
| `prev_tab_pageup` | Ctrl+PageUp | ❌ Missing |
### Key handler gaps in [`src/main.rs`](src/main.rs:130)
Missing: Ctrl+O (open_file), Ctrl+Comma (settings), Ctrl+Shift+Esc (processes), Ctrl+Shift+U (identity), Alt+Left/Right (back/forward), F5 (reload), Shift+F5 (force), Ctrl+F (find), Ctrl+D (bookmark), Ctrl+H (history), Ctrl+B (bookmarks), Ctrl+Q (quit), Ctrl+PageDown/Up (tabs), Ctrl+Shift+A (sidebar), Ctrl+Shift+M (toolbars)
### Missing `handle_key_press` bypass for `sovereign://` pages
The C version bypasses shortcut interception when `sovereign://` pages are active so the page's JS can capture key combos.
---
## 3. Settings Page (`sovereign://settings`) Gaps
### `settings/config` JSON gaps ([`src/nostr_bridge.rs:465`](src/nostr_bridge.rs:465))
| Field | Type | C version ([`nostr_bridge.c:2940`](../sovereign_browser/src/nostr_bridge.c:2940)) | Rust Status |
|-------|------|-----------|-------------|
| `agent_server_enabled` | bool | Whether agent server is on | ❌ Missing |
| `agent_login_timeout_ms` | number | Login timeout | ❌ Missing |
| `dev_extras` | bool | From WebKit settings | ❌ Missing |
| `file_access` | bool | From WebKit settings | ❌ Missing |
| `universal_access` | bool | From WebKit settings | ❌ Missing |
| `search_engines` | array | List of {id, name} | ❌ Missing |
| `shortcuts` | array | All shortcuts with id/label/accel | ❌ Missing |
| `tab_bar_position` | string | "top"/"bottom"/"left"/"right" | ❌ Returns number |
### `settings/set` handler gaps ([`src/nostr_bridge.rs:465`](src/nostr_bridge.rs:465))
| Feature/Key | C handler ([`nostr_bridge.c:1037`](../sovereign_browser/src/nostr_bridge.c:1037)) | Rust Status |
|-------------|-----------|-------------|
| `agent_server_enabled` | Toggle agent server on/off | ❌ Missing |
| `dev_extras` | Toggle WebKit developer extras | ❌ Missing |
| `file_access` | Toggle file access from file:// | ❌ Missing |
| `universal_access` | Toggle universal access from file:// | ❌ Missing |
| `shortcut.reset_all` | Reset all shortcuts to defaults | ❌ Missing |
| `shortcut.reset` | Reset a single shortcut | ❌ Missing |
| `shortcut.<action>` | Set a shortcut to a custom binding | ❌ Missing |
| `agent_allowed_origins` | Save allowed origins | ❌ Missing |
| `agent_login_timeout_ms` | Save login timeout | ❌ Missing |
### Settings page HTML
The `www/settings.html` + `settings.js` expects the `settings/config` JSON to include `search_engines`, `shortcuts`, `agent_server_enabled`, `dev_extras`, etc. Without these fields, the page renders incompletely.
---
## 4. Agent System Gaps
| Feature | C Status | Rust Status |
|---------|----------|-------------|
| **Agent chat sidebar** | Lazily created webview in GtkPaned, loads `sovereign://agents/chat` | ✅ Implemented ([`src/tab_manager.rs:1076`](src/tab_manager.rs:1076)) |
| **Agent tools** | `browser_click`, `browser_type`, `browser_screenshot` | ✅ Implemented ([`src/agent_tools.rs:323`](src/agent_tools.rs:323)) |
| **Agent loop** | Async LLM loop with tool calling | ✅ Implemented ([`src/agent_loop.rs`](src/agent_loop.rs)) |
| **Agent LLM providers** | OpenAI/Anthropic/Ollama support | ✅ Implemented ([`src/agent_llm.rs`](src/agent_llm.rs)) |
| **Agent chat store** | Message history, conversation management | ✅ Implemented ([`src/agent_chat_store.rs`](src/agent_chat_store.rs)) |
| **Agent conversations** | Save/load/rename/delete conversations | ✅ Implemented ([`src/agent_conversations.rs`](src/agent_conversations.rs)) |
| **Agent skills** | Kind 31123 skill management | ✅ Implemented ([`src/agent_skills.rs`](src/agent_skills.rs)) |
| **Agent snapshot** | MCP snapshot of tool state | ✅ Implemented ([`src/agent_snapshot.rs`](src/agent_snapshot.rs)) |
| **Agent server** | HTTP server for agent tools | ✅ Implemented ([`src/agent_server.rs`](src/agent_server.rs)) |
| **Agent login** | Extension login state | ✅ Implemented ([`src/agent_login.rs`](src/agent_login.rs)) |
| **Agent MCP** | Model Context Protocol server | ✅ Implemented ([`src/agent_mcp.rs`](src/agent_mcp.rs)) |
| **Agent FS tools** | Filesystem tool definitions | ✅ Implemented ([`src/agent_fs_tools.rs`](src/agent_fs_tools.rs)) |
---
## 5. `sovereign://` Internal Page Gaps
| Page | C Status | Rust Status |
|------|----------|-------------|
| `sovereign://settings` | Full settings with all toggles, relays, search, shortcuts | ✅ HTML served from `www/settings.html`, JSON endpoints need config fields |
| `sovereign://bookmarks` | Tree view with add/delete/create/move/rename | ✅ Implemented ([`src/nostr_bridge.rs:95`](src/nostr_bridge.rs:95)) |
| `sovereign://profile` | Kind 0/3/10002 data from SQLite | ✅ Implemented ([`src/nostr_bridge.rs:386`](src/nostr_bridge.rs:386)) |
| `sovereign://processes` | Layer 1 (OS) + Layer 2 (tabs) | ✅ Implemented ([`src/nostr_bridge.rs:99`](src/nostr_bridge.rs:99)) |
| `sovereign://fips` | Status, peers, network, tree, directory | ✅ Implemented — page from `www/fips.html` + JS, API in [`src/fips_api.rs`](src/fips_api.rs) |
| `sovereign://agents` | Provider config, models, skills | ✅ Served from `www/agents/config.html` + JS |
| `sovereign://agents/chat` | Full chat client with markdown, conversations | ✅ Served from `www/agents/chat.html` + JS |
| `sovereign://qr` | QR code generation | ✅ Implemented ([`src/nostr_bridge.rs:419`](src/nostr_bridge.rs:419)) |
| `sovereign://security` | Redirects to settings | ✅ Implemented |
| `sovereign://nostr/*` | NIP-07 bridge API | ✅ Implemented ([`src/nostr_bridge.rs:89`](src/nostr_bridge.rs:89)) |
---
## 6. Network Services Gaps
| Service | C Status | Rust Status |
|---------|----------|-------------|
| **Tor control** | TCP/Unix socket, cookie/password/null auth, multi-line replies, bootstrap poll, NEWNYM | ✅ Implemented ([`src/tor_control.rs`](src/tor_control.rs)) |
| **FIPS control** | Unix socket JSON-line protocol, socket discovery | ✅ Implemented ([`src/fips_control.rs`](src/fips_control.rs)) |
| **Net services** | Attach to running daemon, else spawn/supervise managed Tor & FIPS; autostart; clean shutdown | ✅ Implemented ([`src/net_services.rs`](src/net_services.rs)) |
| **`fips://` URLs** | Normalize to `http://<host>.fips` (URL bar, links, agent `open`) | ✅ Implemented ([`src/search.rs`](src/search.rs), unit-tested) |
| **`.onion` / `tor://`** | Route via Tor SOCKS, wait for bootstrap, full error text | ✅ Implemented ([`src/tor_scheme.rs`](src/tor_scheme.rs)) |
### Network services: behaviour and known limits
- **Modes** (`tor_mode` / `fips_mode`): `auto` (attach, else manage), `attach`, `manage`.
Settable via `sovereign://settings/set?key=...`; other keys: `*_binary_path`,
`tor_attach_socks`, `tor_attach_control`, `tor_data_dir`, `fips_control_socket`, `fips_config_dir`.
- **Managed Tor** uses a loopback TCP `SocksPort` (so `reqwest` can use it) and a Unix
`ControlPort` with cookie auth. `__OwningControllerProcess` makes Tor exit if the browser is
SIGKILLed; SIGTERM/SIGINT/normal quit stop it gracefully (SIGTERM, then SIGKILL after 5s).
- **Attached Tor on a Unix SOCKS socket** (`unix:/run/tor/socks`) is bridged through a
loopback TCP forwarder because `reqwest` cannot dial Unix sockets.
- **Managed FIPS** needs `CAP_NET_ADMIN` (or root) on the `fips` binary; the browser refuses
to start it otherwise. Attached daemons are never stopped.
- **Tor control on the Debian system Tor**: `/run/tor/control.authcookie` is only readable by
the `debian-tor` group, so the browser attaches for SOCKS only and skips bootstrap polling.
- **Not yet done**: NEWNYM / circuit info in the UI, Tor password auth from settings, a
settings-page UI for the new Tor/FIPS keys.
---
## 7. Performance Probe Gaps
| Feature | C Status | Rust Status |
|---------|----------|-------------|
| **Perf-probe.js injection** | Preamble + probe body injected into every non-internal page | ✅ Implemented ([`src/nostr_inject.rs:135`](src/nostr_inject.rs:135)) |
| **probe-report endpoint** | Receives periodic probe reports | ✅ Implemented ([`src/nostr_bridge.rs:99`](src/nostr_bridge.rs:99)) |
| **tab_probe endpoint** | Drill-down for a single tab | ✅ Implemented |
| **tab_action endpoint** | Reload/suspend/close tabs | ✅ Implemented |
---
## 8. Minor Gaps
| Item | C Status | Rust Status |
|------|----------|-------------|
| **Site downloader** | Headless webview rendering & asset bundling | Stub ([`src/site_downloader.rs`](src/site_downloader.rs)) |
| **Favicon display** | 16x16 pixbufs in tab labels | ❌ Missing (cairo API limitation) |
| **Popup handler** | `target="_blank"` → new tab policy | ❌ WebKit `create` signal not hooked |
| **URL history tracking** | Records visited URLs in SQLite | ❌ Not wired to `load-changed` signal |
| **Avatar button** | Circular profile picture in toolbar | ❌ Missing |
| **About dialog** | GTK dialog with version info | ❌ Missing |
---
## Summary: What Needs to Be Done
### High Priority (Blocks user experience)
1. **Hamburger menu parity** — Add Recents (history), Bookmarks tree, Tor/FIPS toggles, Security strip toggle, Nostr signing status, Lock Session, Download Website, About, Avatar button.
2. **Shortcut parity** — Add all missing 17 shortcuts to registry and key handler.
3. **Settings/config JSON** — Add missing fields: `agent_server_enabled`, `agent_login_timeout_ms`, `dev_extras`, `file_access`, `universal_access`, `search_engines`, `shortcuts`, `tab_bar_position` (string).
4. **Settings/set handler** — Add missing features: `agent_server_enabled`, `dev_extras`, `file_access`, `universal_access`, shortcut reset, shortcut set.
### Medium Priority
5. **Popup handler** — Hook WebKit `create` signal for `target="_blank"`.
6. **URL history** — Wire `load-changed` signal to `db_add_history`.
7. **Site downloader** — Implement headless webview rendering.
### Low Priority
8. **Favicon display** — Research cairo surface conversion.
9. **About dialog** — Simple GTK dialog.
10. **Avatar button** — Circular profile picture.