# notcorwin/surfwax architecture

> Architecture diagram of the GitHub repository notcorwin/surfwax, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/notcorwin/surfwax
- Repository: https://github.com/notcorwin/surfwax

## Overview

Surf Wax is a Chrome Side Panel browser agent: users configure a model, describe a browser task, and review streamed responses and recorded tool results. The runtime coordinates model requests, conversation context and browser execution; users can also manage conversations and persistent user scripts. README capabilities are included, but some subsystem links are documented rather than visible in the sampled code, so those use README evidence.

Main entry points: [`src/sidepanel/useSidePanelRuntime.ts`](https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/useSidePanelRuntime.ts) (Conversation runtime), [`src/logging.ts`](https://github.com/notcorwin/surfwax/blob/master/src/logging.ts) (Canonical event log), [`src/chrome/executor.ts`](https://github.com/notcorwin/surfwax/blob/master/src/chrome/executor.ts) (Browser executor), [`src/sidepanel/App.tsx`](https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/App.tsx) (Side Panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Side Panel experience"]
  node_sidepanel["Side Panel<br/>[App.tsx]"]
  node_chat["Chat and threads<br/>[thread.tsx]"]
  node_threadlist["Conversation search<br/>[thread-list.tsx]"]
  node_options["Model settings<br/>[OptionsApp.tsx]"]
  node_scriptsui["User script manager<br/>[ScriptsApp.tsx]"]
end

subgraph group_runtime["Session runtime"]
  node_session["Session configuration"]
  node_runtimeview["Conversation runtime"]
  node_coordinator["Run coordination<br/>[coordinator.ts]"]
  node_conversationstore["Conversation store"]
end

subgraph group_agent["Agent and models"]
  node_agent["Agent runner<br/>[runner.ts]"]
  node_transport["Chat transport<br/>[transport.ts]"]
  node_model["Model routing<br/>[model.ts]"]
  node_catalog["Model catalog and limits<br/>[model-limits.ts]"]
  node_context["Context compaction<br/>[compaction.ts]"]
end

subgraph group_browser["Browser automation"]
  node_executor["Browser executor<br/>[executor.ts]"]
  node_automation["Page inspection and actions<br/>[automation.ts]"]
  node_jobs["Background jobs<br/>[jobs.ts]"]
  node_guard["Interaction guard"]
end

subgraph group_local["Local data and settings"]
  node_eventlog[("Canonical event log<br/>[logging.ts]")]
  node_conversations["Conversation projections<br/>[conversations.ts]"]
  node_config["Model configuration<br/>[config.ts]"]
  node_userpersistence["User script persistence<br/>[persistence.ts]"]
end

node_user(("User"))
node_provider(("Configured model service"))

node_user -->|"opens and prompts"| node_sidepanel
node_user -->|"configures model"| node_options
node_user -->|"manages scripts"| node_scriptsui
node_sidepanel -->|"renders"| node_chat
node_sidepanel -->|"renders"| node_threadlist
node_chat -.->|"submits turns"| node_runtimeview
node_threadlist -.->|"selects threads"| node_conversationstore
node_options -->|"saves settings"| node_config
node_session -->|"loads settings"| node_config
node_runtimeview -->|"creates transport"| node_conversationstore
node_runtimeview -->|"creates agent"| node_agent
node_runtimeview -->|"creates model"| node_model
node_runtimeview -->|"summarizes context"| node_context
node_runtimeview -->|"runs browser work"| node_executor
node_runtimeview -->|"coordinates runs"| node_coordinator
node_agent -.->|"streams turns"| node_transport
node_model -->|"resolves limits"| node_catalog
node_model -->|"sends model requests"| node_provider
node_context -->|"reads and appends"| node_eventlog
node_conversationstore -.->|"records events"| node_eventlog
node_conversations -->|"reads events"| node_eventlog
node_executor -.->|"dispatches actions"| node_automation
node_executor -.->|"manages jobs"| node_jobs
node_executor -.->|"protects interaction"| node_guard
node_scriptsui -->|"manages scripts"| node_userpersistence
node_userpersistence -->|"records changes"| node_eventlog
node_eventlog -->|"projects history"| node_conversations

click node_sidepanel "https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/App.tsx"
click node_chat "https://github.com/notcorwin/surfwax/blob/master/src/components/chat/thread.tsx"
click node_threadlist "https://github.com/notcorwin/surfwax/blob/master/src/components/chat/thread-list.tsx"
click node_options "https://github.com/notcorwin/surfwax/blob/master/src/options/OptionsApp.tsx"
click node_scriptsui "https://github.com/notcorwin/surfwax/blob/master/src/userscripts/ScriptsApp.tsx"
click node_session "https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/useSidePanelSession.ts"
click node_runtimeview "https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/useSidePanelRuntime.ts"
click node_coordinator "https://github.com/notcorwin/surfwax/blob/master/src/agent/coordinator.ts"
click node_conversationstore "https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/conversation-store.ts"
click node_agent "https://github.com/notcorwin/surfwax/blob/master/src/agent/runner.ts"
click node_transport "https://github.com/notcorwin/surfwax/blob/master/src/agent/transport.ts"
click node_model "https://github.com/notcorwin/surfwax/blob/master/src/agent/model.ts"
click node_catalog "https://github.com/notcorwin/surfwax/blob/master/src/agent/model-limits.ts"
click node_context "https://github.com/notcorwin/surfwax/blob/master/src/agent/compaction.ts"
click node_executor "https://github.com/notcorwin/surfwax/blob/master/src/chrome/executor.ts"
click node_automation "https://github.com/notcorwin/surfwax/blob/master/src/chrome/automation.ts"
click node_jobs "https://github.com/notcorwin/surfwax/blob/master/src/chrome/jobs.ts"
click node_guard "https://github.com/notcorwin/surfwax/blob/master/src/chrome/interaction-guard.ts"
click node_eventlog "https://github.com/notcorwin/surfwax/blob/master/src/logging.ts"
click node_conversations "https://github.com/notcorwin/surfwax/blob/master/src/conversations.ts"
click node_config "https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/config.ts"
click node_userpersistence "https://github.com/notcorwin/surfwax/blob/master/src/userscripts/persistence.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sidepanel,node_chat,node_threadlist,node_options,node_scriptsui,node_user toneBlue
class node_session,node_runtimeview,node_coordinator,node_conversationstore toneAmber
class node_agent,node_transport,node_model,node_catalog,node_context toneMint
class node_executor,node_automation,node_jobs,node_guard toneRose
class node_eventlog,node_conversations,node_config,node_userpersistence,node_provider toneIndigo
```

## Components

### Side Panel experience

- [Side Panel](https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/App.tsx): `src/sidepanel/App.tsx`
- [Chat and threads](https://github.com/notcorwin/surfwax/blob/master/src/components/chat/thread.tsx): `src/components/chat/thread.tsx`
- [Conversation search](https://github.com/notcorwin/surfwax/blob/master/src/components/chat/thread-list.tsx): `src/components/chat/thread-list.tsx`
- [Model settings](https://github.com/notcorwin/surfwax/blob/master/src/options/OptionsApp.tsx): `src/options/OptionsApp.tsx`
- [User script manager](https://github.com/notcorwin/surfwax/blob/master/src/userscripts/ScriptsApp.tsx): `src/userscripts/ScriptsApp.tsx`

### Session runtime

- [Session configuration](https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/useSidePanelSession.ts): `src/sidepanel/useSidePanelSession.ts`
- [Conversation runtime](https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/useSidePanelRuntime.ts): `src/sidepanel/useSidePanelRuntime.ts`
- [Run coordination](https://github.com/notcorwin/surfwax/blob/master/src/agent/coordinator.ts): `src/agent/coordinator.ts`
- [Conversation store](https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/conversation-store.ts): `src/sidepanel/conversation-store.ts`

### Agent and models

- [Agent runner](https://github.com/notcorwin/surfwax/blob/master/src/agent/runner.ts): `src/agent/runner.ts`
- [Chat transport](https://github.com/notcorwin/surfwax/blob/master/src/agent/transport.ts): `src/agent/transport.ts`
- [Model routing](https://github.com/notcorwin/surfwax/blob/master/src/agent/model.ts): `src/agent/model.ts`
- [Model catalog and limits](https://github.com/notcorwin/surfwax/blob/master/src/agent/model-limits.ts): `src/agent/model-limits.ts`
- [Context compaction](https://github.com/notcorwin/surfwax/blob/master/src/agent/compaction.ts): `src/agent/compaction.ts`

### Browser automation

- [Browser executor](https://github.com/notcorwin/surfwax/blob/master/src/chrome/executor.ts): `src/chrome/executor.ts`
- [Page inspection and actions](https://github.com/notcorwin/surfwax/blob/master/src/chrome/automation.ts): `src/chrome/automation.ts`
- [Background jobs](https://github.com/notcorwin/surfwax/blob/master/src/chrome/jobs.ts): `src/chrome/jobs.ts`
- [Interaction guard](https://github.com/notcorwin/surfwax/blob/master/src/chrome/interaction-guard.ts): `src/chrome/interaction-guard.ts`

### Local data and settings

- [Canonical event log](https://github.com/notcorwin/surfwax/blob/master/src/logging.ts): `src/logging.ts`
- [Conversation projections](https://github.com/notcorwin/surfwax/blob/master/src/conversations.ts): `src/conversations.ts`
- [Model configuration](https://github.com/notcorwin/surfwax/blob/master/src/sidepanel/config.ts): `src/sidepanel/config.ts`
- [User script persistence](https://github.com/notcorwin/surfwax/blob/master/src/userscripts/persistence.ts): `src/userscripts/persistence.ts`

### Other components

- **User**
- **Configured model service**

## Connections

- User → Side Panel: opens and prompts (evidence: `README.md`)
- User → Model settings: configures model (evidence: `README.md`)
- User → User script manager: manages scripts (evidence: `README.md`)
- Side Panel → Chat and threads: renders (evidence: `src/sidepanel/App.tsx`)
- Side Panel → Conversation search: renders (evidence: `src/sidepanel/App.tsx`)
- Chat and threads → Conversation runtime: submits turns
- Conversation search → Conversation store: selects threads
- Model settings → Model configuration: saves settings (evidence: `src/options/OptionsApp.tsx`)
- Session configuration → Model configuration: loads settings (evidence: `src/sidepanel/useSidePanelSession.ts`)
- Conversation runtime → Conversation store: creates transport (evidence: `src/sidepanel/useSidePanelRuntime.ts`)
- Conversation runtime → Agent runner: creates agent (evidence: `src/sidepanel/useSidePanelRuntime.ts`)
- Conversation runtime → Model routing: creates model (evidence: `src/sidepanel/useSidePanelRuntime.ts`)
- Conversation runtime → Context compaction: summarizes context (evidence: `src/sidepanel/useSidePanelRuntime.ts`)
- Conversation runtime → Browser executor: runs browser work (evidence: `src/sidepanel/useSidePanelRuntime.ts`)
- Conversation runtime → Run coordination: coordinates runs (evidence: `src/sidepanel/useSidePanelRuntime.ts`)
- Agent runner → Chat transport: streams turns
- Model routing → Model catalog and limits: resolves limits (evidence: `src/agent/model-limits.ts`)
- Model routing → Configured model service: sends model requests (evidence: `README.md`)
- Context compaction → Canonical event log: reads and appends (evidence: `src/agent/compaction.ts`)
- Conversation store → Canonical event log: records events
- Conversation projections → Canonical event log: reads events (evidence: `src/conversations.ts`)
- Browser executor → Page inspection and actions: dispatches actions
- Browser executor → Background jobs: manages jobs
- Browser executor → Interaction guard: protects interaction
- User script manager → User script persistence: manages scripts (evidence: `src/userscripts/ScriptsApp.tsx`)
- User script persistence → Canonical event log: records changes (evidence: `src/userscripts/persistence.ts`)
- Canonical event log → Conversation projections: projects history (evidence: `src/conversations.ts`)
