How ggprompts/tabzchrome works
1. The runtime is split into three cooperating parts: a Chrome Extension UI, a local Node.js backend on port 8129, and a local MCP server for Claude Code/browser automation. The key architectural boundary is that terminal processes live on the host via tmux, while the browser extension is mostly the presentation and browser-control layer.
2. Chrome Extension is the main user-facing shell. It is a Manifest V3 extension with multiple surfaces: the side panel for active terminals, a dashboard for management pages, a new tab launcher, a popup, devtools panels, and a content script for page-level actions. The background service worker is the hub for extension messaging, Chrome API calls, and relaying events.
3. The side panel is the terminal cockpit. It renders xterm.js terminals, session tabs, profile selectors, working-directory controls, and status indicators. User actions such as spawn, detach, reattach, kill, paste, and tab switching are sent through the background layer to the backend.
4. The backend is the system of record for terminal lifecycle coordination. Under backend/modules, the main responsibilities are PTY handling, tmux session management, terminal registry, spawn orchestration, file watching, git helpers, logging, and optional audio generation. The backend exposes REST routes and a WebSocket channel, and also serves the local dashboard assets.
5. tmux is the durable persistence layer for terminal sessions. New terminals are spawned through the backend into tmux sessions, and the terminal UI attaches to those sessions over PTY/WebSocket plumbing. This is why sessions survive sidebar closure, browser restarts, and backend restarts; tmux is effectively the source of truth, not browser state.
6. The terminal data flow is: profile/config → backend spawn → tmux/PTY → websocket stream → xterm.js UI. Profiles define working directory, startup command, fonts, and theme. The backend uses that config to start or reconnect a session, and terminal output/status is streamed back to the extension and dashboard.
7. Profiles and working-directory state are shared, but not centralized in one database. Profile definitions live in extension-side storage/files, while the backend also exposes working-directory settings and session state. The UI synchronizes these settings so profiles can inherit a global project directory and so detached sessions can be rediscovered by the “ghost badge”/orphan-session flow.
8. Browser automation is handled inside the extension, not by remote debugging. The background/browserMcp modules wrap Chrome extension APIs for tabs, windows, screenshots, downloads, history, bookmarks, cookies, tab groups, scripting, emulation, and interaction. The content script and context menus add page-level affordances like “Send to Tabz,” “Paste to Terminal,” and data-terminal-command buttons.
9. The dashboard is the operational admin console. It provides pages for terminals, profiles, files, git, API testing, MCP settings, audio, notifications, and a catalog of backend-served pages. The Files and Git sections depend on backend file and repo data; the Audio and MCP settings pages control runtime features that affect both the extension and backend behavior.
10. Claude Code integration is a separate automation plane. The tabz-mcp-server package exposes a large toolset for browser control and terminal-related operations, and is launched as a local process configured with BACKEND_URL. It is designed so Claude Code can drive Tabz without loading all tool schemas up front, making it a companion process rather than part of the Chrome extension runtime.
11. Audio and notifications are cross-cutting features. The backend can generate speech via edge-tts, then broadcast playback events to connected clients over WebSocket. The extension also manages desktop/audio notifications and per-event voice/sound settings, so alerts can be triggered by terminal status, Claude activity, downloads, or browser events.
12. Builds and tests are split by runtime boundary. The repository contains separate TypeScript/Vite/Vitest setups for the extension, backend, and MCP server. The extension source in extension/ builds to dist-extension/, while the backend and MCP server each have their own package/configuration, reflecting the fact that this is a multi-process local system rather than a single app.
Main entry points: background/index.ts Background hub · server.js Backend server · unified-spawn.js Spawn core · src/index.ts MCP server
Components 19
Chrome Extension
Manifest V3 UI shell and browser-control runtime
- Background hub · Central message router, Chrome API gateway, websocket client, and state coordinator
extension/background/index.ts - Side panel · Main terminal UI with tabs, profiles, working dir controls, and session actions
extension/sidepanel/sidepanel.tsx - Dashboard · Operational pages for terminals, files, git, API testing, audio, notifications, profiles, and MCP settings
extension/dashboard/App.tsx - New tab · Quick launch surface for profiles, recent dirs, shortcuts, and status
extension/newtab/NewTab.tsx - Popup · Compact extension entry point for fast access to controls
extension/popup/popup.tsx - Devtools panel · Developer-facing panel surface integrated into Chrome devtools
extension/devtools/panel.tsx - Content script · Page-level affordances, commands, and context actions injected into web pages
extension/content/content.ts - Browser MCP · Extension-side wrappers for tabs, windows, screenshots, downloads, history, bookmarks, cookies, scripting, and interaction
extension/background/browserMcp/index.ts
Local Backend
Node.js terminal orchestration and dashboard server
- Backend server · Local server on port 8129 exposing REST, websocket, and static dashboard assets
backend/server.js - Spawn core · Unified spawn orchestration over PTY and tmux session creation
backend/modules/unified-spawn.js - tmux manager · Session persistence and attachment layer for terminal state
backend/modules/tmux-session-manager.js - PTY handler · Pseudo-terminal plumbing between spawned processes and websocket clients
backend/modules/pty-handler.js - Terminal registry · Tracks terminals, ghost/orphan recovery, and session metadata
backend/modules/terminal-registry.js - API routes · REST endpoints for api, browser, files, and git operations
backend/routes/api.js - Files & git · Backend helpers for file watching, filesystem access, and git state/actions
backend/modules/file-watcher.js - Audio engine · Speech generation and sound-event broadcasting for notifications
backend/modules/audio-generator.js
MCP Server
Companion automation server for Claude Code
- MCP server · Local Claude Code automation server configured through BACKEND_URL
plugins/tabz/tabz-mcp-server/src/index.ts - MCP tools · Tool modules for browser control, terminals, screenshots, downloads, page actions, and notifications
plugins/tabz/tabz-mcp-server/src/tools/terminals.ts
Docs & Plans
Repository guidance, audits, and operational notes
- Docs & plans · Architecture notes, audits, plans, and usage guides that document the multi-process system
docs/README.md
Connections 22
- Side panel → Background hub: terminal actions · Spawn, attach, detach, kill, paste, and tab changes are routed through the background hub
- New tab → Background hub: launch state · New tab launcher reads shared profile and working-directory state via extension messaging
- Popup → Background hub: commands · Popup actions are relayed to the hub for execution and state updates
- Devtools panel → Background hub: inspect events · Devtools surfaces exchange messages through the background service worker
- Content script → Browser MCP: page actions · Injected page affordances trigger browser automation and context-menu workflows
- Background hub → Backend server: ws + http · Extension connects to the local backend for terminal state, dashboard data, and event streams
- Background hub → Browser MCP: chrome apis · Background layer centralizes browser automation wrappers for extension-controlled features
- Backend server → API routes: serves api · HTTP entrypoint dispatches REST endpoints and static assets
- Backend server → Spawn core: orchestrates · Server delegates terminal lifecycle requests into unified spawn logic
- Spawn core → tmux manager: persist sessions · New terminals are launched into tmux sessions for durability across restarts
- Spawn core → PTY handler: pty stream · Spawned processes connect through PTY plumbing for interactive terminal I/O
- Spawn core → Terminal registry: register sessions · Spawn orchestration records session metadata and recovery state
- PTY handler → Side panel: terminal output · Terminal bytes and status updates flow back to the xterm-based UI over websocket
- Terminal registry → Dashboard: session state · Dashboard surfaces active terminals, orphan sessions, and ghost badge recovery
- API routes → Files & git: file repo ops · Files and git pages consume backend-side filesystem and repository helpers
- Audio engine → Background hub: alerts · Audio and voice events are broadcast to connected clients for notifications
- MCP server → Browser MCP: automation plane · Claude-facing tools drive the same browser-control capabilities exposed by the extension
- MCP server → Backend server: backend url · Companion process is configured to talk to the local backend service
- MCP server → MCP tools: loads tools · Server composes its large toolset from modular domain-specific tool implementations
- Docs & plans → Dashboard: guidance · Documentation describes dashboard sections, settings, and operational workflows
- Docs & plans → Backend server: guidance · Docs capture backend API, terminal lifecycle, and deployment behavior
- Docs & plans → MCP server: guidance · Docs explain Claude Code integration and MCP tool usage