ClawSide — SPEC.md

ClawSide — SPEC.md

1. Concept & Vision

ClawSide is a Chrome side panel extension that acts as a bridge between your browser and local OpenClaw instance. When you select text or want to summarize a page, instead of copy-pasting to ChatGPT/Monica/sider, you just use the side panel — and OpenClaw handles it, remembers it, and can build on it later.

The feeling: OpenClaw is always there, inside your browser, watching your back without being creepy.

MVP focus: lightweight, fast, works offline except for LLM calls.


2. Design Language

Aesthetic: Dark terminal-inspired, but refined. Think VS Code meets Arc browser.

Colors:

Typography:

Spatial system:

Motion:


3. Architecture

Chrome Extension
  ├─ Content Script (floating bubble + radial menu)
  ├─ Side Panel (full UI)
  └─ Service Worker (background.js)
       ↓ HTTP POST (chrome.runtime.sendMessage)
       ↓ HTTP POST (fetch → 127.0.0.1:18789)
OpenClaw Gateway (/v1/chat/completions)
       ↓
LLM (configured provider)

No bridge server needed — Chrome extensions can access localhost directly with host_permissions declared in manifest.


4. Features & Interactions

4.1 Three Interaction Modes

Floating Bubble (Primary)

Radial Menu

Full Side Panel

4.2 Translation

4.3 Page Summarization

4.4 Ask / Chat Interface

4.5 Ask from Summarize

4.6 Interaction History

4.7 Settings


5. Component Inventory

Side Panel Layout

┌─────────────────────────────────┐
│  [🌐] [📄] [💬]       [⚙️] [📜] │  ← action bar (sticky)
├─────────────────────────────────┤
│  [Context: page info + refresh] │  ← page context
├─────────────────────────────────┤
│                                 │
│  (content area)                 │
│  - Result card                 │
│  - Chat messages               │
│  - Input area                  │
│                                 │
└─────────────────────────────────┘

Result Card (Translate/Summarize)

┌─────────────────────────────────┐
│ 📝 Translate      [📋] [💬]     │  ← copy + ask icons
├─────────────────────────────────┤
│                                 │
│  Result text goes here...       │
│                                 │
└─────────────────────────────────┘

Chat Interface (Ask)

┌─────────────────────────────────┐
│ 👤 User message                 │
│ 🤖 AI response (streaming)      │
├─────────────────────────────────┤
│ [Input...              ] [Send] │
└─────────────────────────────────┘

6. Technical Approach

Chrome Extension (Manifest V3)

Key Components:

Storage Keys

Key Pattern Purpose
clawside_settings User settings (port, token, language, prompts)
clawside_chat_{tabId}_{urlHash} Chat history per tab+URL (max 50)
clawside_summarize_{tabId}_{urlHash} Summarize results per tab+URL
cs_history_ask_{tabId}_{urlHash} Ask history deduplication key
cs_history_translate_{textHash} Translate history deduplication key (includes targetLang prefix)
cs_history_summarize_{tabId}_{urlHash} Summarize history deduplication key
_pendingTab, _pendingAction, _pendingMessages Panel-open flow (temporary)
_tabCtxData, _tabCtxVersion Tab context persistence (internal)

LRU Cache

API Design

Extension → OpenClaw Gateway HTTP

POST /v1/chat/completions
Headers: Authorization: Bearer <token>
Body: { model: "openclaw/main", messages: [{role:"user", content: "<prompt>"}] }
Response: streaming { choices: [{delta: {content: "..."}}] }

Two-Phase Connection Test

1. GET /v1/models → Check gateway availability
2. POST /v1/chat/completions → Actual API call

Scan Logic

Floating Bubble

SVG Icons

Language Resolution

Debug Info (About Tab)

Two-Phase Connection Test

1. GET /v1/models → Check gateway availability and get available models
2. POST /v1/chat/completions → Test API call with determined model

7. MVP Out of Scope (Completed)