How takagi/rofi-chrome-tab works
What this project is (type + purpose)
This repo is a hybrid system made of:
• a Chrome Extension (JS: background.js, manifest.json)
• a native companion app written in Go (go/cmd/rofi-chrome-tab/main.go + go/internal/**)
• a Linux user workflow entrypoint via rofi (scripts/rofi-chrome-tab) and config (rofi_chrome_tab.sample.json)
Purpose (from README + structure): select/switch Chrome tabs from a rofi window. That implies a bridge between Chrome (tab state + activation) and rofi (user selection UI).
The architecture strongly suggests Chrome Native Messaging:
• Chrome Extension ⇄ Native Host (Go) via stdin/stdout JSON messages
• rofi script ⇄ Go binary to display choices and execute the user’s selection
Chrome Extension side
• manifest.json: extension entrypoints + permissions (tabs, nativeMessaging, etc.)
• background.js: main extension runtime logic (listens to tab events, handles commands, talks to native host)
Go native host side
• go/cmd/rofi-chrome-tab/main.go: the runnable native host executable (the process Chrome spawns)
• go/internal/command_receiver/**: logic handling inbound “commands” (from rofi or from extension depending on protocol)
• go/internal/event_receiver/**: logic handling inbound “events” (tab updates, focus changes, etc.)
• go/internal/protocol/**: message schema (commands/events/actions/types) — this is the contract between extension and native host
• go/internal/logging/**, go/internal/debug/**: cross-cutting concerns (annotate as side concerns, not main containers)
Rofi / shell integration
• scripts/rofi-chrome-tab: user-invoked wrapper; likely runs rofi, calls the Go binary, formats output, etc.
• rofi_chrome_tab.sample.json: runtime configuration (paths, formatting, filters, etc.)
DevOps / QA
Goal: show who uses it and what systems it touches.
Native Host: rofi-chrome-tab (Go binary)
• User → Rofi: “invokes rofi-chrome-tab”
• Rofi → Script (scripts/rofi-chrome-tab): “runs wrapper”
• Script → Go native host: “request tab list / send selection”
• Chrome Extension ↔ Go native host: “Native Messaging JSON protocol”
• Chrome Extension → Chrome Tabs API: “list tabs / activate tab / listen to tab events”
Notes to annotate:
• Boundary: “Chrome extension sandbox” vs “local OS process”
• Communication channel: “Native Messaging (stdin/stdout JSON)”
Goal: show actual running processes and how data flows.
Extension → Chrome Tabs API: activates the selected tab
• Extension → Go host: “tab created/updated/removed/activated events” (stream)
• Go host: maintains in-memory view to serve rofi quickly
Goal: reflect the Go module boundaries from go/internal/**.
• App Orchestrator (internal/app)
• Event Receiver (internal/event_receiver)
• Command Receiver (internal/command_receiver)
• Protocol Model / Codec (internal/protocol)
• Logging / Debug (internal/logging, internal/debug)
• Receivers → Protocol: “decode/encode JSON messages”
• App ↔ Receivers: “register handlers / dispatch messages”
• App → Logging/Debug: “instrumentation”
Inside the Chrome Extension container, optionally break down:
• “Tab Event Listeners” (Chrome tabs events)
• “Native Messaging Client” (connect + send/receive)
• “Command Handler” (activate tab, focus window, etc.)
This gives a principal-engineer-level view grounded directly in directories/files.
Relationships and interactions to emphasize (project-specific)
• The protocol contract (go/internal/protocol/*) as a first-class element
• Two-way messaging (commands vs events)
• Trust boundary + permissions:
• Chrome extension permissions / APIs
• Native host running on OS (filesystem, processes)
• User interaction loop: rofi is the UI, Chrome is the target system
What “very detailed” means for this project (without overthinking)
To maximize accuracy, include:
• Both message directions: Events (Extension → Go) and Commands (Go → Extension)
• The script and rofi as explicit nodes (they’re essential to the user-facing behavior)
• The protocol package as the shared schema node
• A short note: “transport = Chrome Native Messaging over stdin/stdout”