Reference for every message the extension exchanges between its runtime contexts. Each message is a plain JSON object discriminated by a type field. Payloads are flattened into the same object (e.g. { type, action, targetLanguage }).
| Transport | Between | Notes |
|---|---|---|
chrome.runtime.sendMessage |
popup ⇄ background, content ⇄ background | Use return true; for async sendResponse |
chrome.tabs.sendMessage |
background → content (specific tab) | Fire-and-forget, keyed by sender.tab.id / tab.id |
chrome.runtime.sendMessage |
background → offscreen document | EXTRACT_TEXT is request/response |
background.jsruns ES modules, imports:AISession,StorageCleaner,cdx,wordDiff,parseDiff, etc.- Content script listens in
content/content.jsand delegates tocontent/ui/overlay.js. - Popup sends actions with
PERFORM_ACTION; the background resolves the active tab itself. - Streaming messages are cumulative in the UI:
STREAM_CHUNKappends to a growing string,CHAT_STREAM_CHUNKappends to a per-message bubble.
- Sender: popup → background
- Payload:
{ type: "PERFORM_ACTION", action: "summarize" | "quality" | "compare" | "live-compare" } - Purpose: Trigger any feature from the popup action cards / more-actions menu. The background looks up the active tab and dispatches to
handleAction/handleCompare/handleLiveCompare.
- Payload:
{ type: "STREAM_START", action, targetLanguage } - Purpose: Create the streaming overlay.
action === "summarize"shows insights (showInsights: true);"quality"does not.
- Payload:
{ type: "REQUEST_CONTENT", action } - Purpose: Ask the content script for page data. Routed to
analyzePage()(content/services/pageAnalyzer.js) → forsummarizereturns extracted text; forqualityreturns timings + text. Reply is viasendResponse.
- Sender: background → content
- Payload:
{ type: "STREAM_CHUNK", chunk } - Purpose: Stream raw AI output (from
aiSession.analyzePage'spromptStreaming) into the overlay's Logs/process area.
- Sender: background → content
- Payload:
{ type: "STREAM_END" } - Purpose: Mark the streaming phase finished (sent on cached-summarize fast path).
- Sender: background → content
- Payload:
{ type: "STREAM_ERROR", error } - Purpose: Surface a streaming-phase error into the Logs area and process list.
- Payload:
{ type: "TRANSLATED_RESULT", action, success, summary, originalSummary, timings?, targetLanguage, screenshot? } - Purpose: Final result for summarize/quality. Content script renders
marked.parse(summary)into the summary accordion,appendQualityTimings(timings)for quality, andsetScreenshot(screenshot).
- Payload:
{ type: "STRUCTURED_INSIGHTS", insights: { faqs, famousPeople }, translatedInsights?, targetLanguage } - Purpose: Deliver FAQs + famous personalities (summarize only). Rendered by
appendInsights().
- Payload:
{ type: "SHOW_RESULT", summary } - Purpose: Simple non-streaming result overlay — used for error messages like "Not enough content to analyze".
- Payload:
{ type: "TRANSLATE_TEXT", text, insights?, targetLanguage, action } - Purpose: Request on-demand translation of the summary (and optionally insights) when the user switches language tabs.
- Payload:
{ type: "TRANSLATE_TEXT_RESPONSE", translatedText, translatedInsights?, targetLanguage } - Purpose: Deliver the translated text/insights into the target-language tab.
- Payload:
{ type: "COMPARE_SHOW_INPUT", url, ts } - Purpose: Show the natural-language date input overlay (
showCompareInput).tsis the current snapshot's timestamp.
- Payload:
{ type: "COMPARE_PARSE_INPUT", text, ts, url } - Purpose: The user's query, resolved by the background into two timestamps (keyword fast-path or
aiSession.getTimeStamp).
- Payload:
{ type: "COMPARE_LOADING", error? } - Purpose: Show the loading overlay (live-compare path).
- Payload:
{ type: "COMPARE_PROGRESS", step, status? } - Purpose: Append a step to the progress list ("Fetching both snapshots…", "Computing word-level diff…", "Cache hit!", etc.).
- Payload (success):
{ type: "COMPARE_RESULT", success: true, titleA, titleB, tsA, tsB, diff, stats: { added, removed }, aiSummary, url } - Payload (error):
{ type: "COMPARE_RESULT", success: false, error } - Purpose: Deliver the full comparison or an error. The popup's Compare History also sends this message to the active tab to reopen a cached comparison.
- Payload:
{ type: "CHAT_QUESTION_START", context, question, messageId, chatType } - Purpose: Start streaming an answer.
chatTypeis"summary"or"compare"and selects the session key and init path. For both types the background computessessionKeyfrom the context; if it differs from the active session key it destroys the old session and re-inits (restoring history from storage if present). This is the only cleanup path — no explicit reset message is sent by content scripts.
- Payload:
{ type: "CHAT_STREAM_CHUNK", messageId, chunk } - Purpose: Append a chunk to the assistant bubble for
messageId.
- Payload:
{ type: "CHAT_STREAM_END", messageId, fullText } - Purpose: Final text for the bubble (
fullTextis""when the stream was aborted). Content renders markdown here.
- Payload:
{ type: "CHAT_STREAM_ERROR", messageId, error } - Purpose: Render an inline error for the message.
- Payload:
{ type: "CHAT_STOP", messageId } - Purpose: Abort the in-flight
AbortControllerformessageId; partial text is preserved with a[stopped]marker.
- Payload:
{ type: "EXTRACT_TEXT", html } - Purpose: Offscreen parses
htmland runs Readability, replying with{ type: "EXTRACT_TEXT_RESPONSE", title, textContent }. Used by the compare pipeline so Readability never runs in the visible tab.
Summarize: PERFORM_ACTION / context-menu → STREAM_START → REQUEST_CONTENT (+reply) → STREAM_CHUNK* → TRANSLATED_RESULT + STRUCTURED_INSIGHTS → optional TRANSLATE_TEXT/TRANSLATE_TEXT_RESPONSE.
Quality: same skeleton, but REQUEST_CONTENT returns timings, prompt includes HTTP status + optional screenshot, and result carries timings + screenshot (never cached).
Compare: COMPARE_SHOW_INPUT → COMPARE_PARSE_INPUT → COMPARE_LOADING/COMPARE_PROGRESS* → COMPARE_RESULT → chat via CHAT_QUESTION_START, CHAT_STREAM_CHUNK*, CHAT_STREAM_END/CHAT_STREAM_ERROR, CHAT_STOP.
Live compare: PERFORM_ACTION("live-compare") → COMPARE_LOADING → COMPARE_PROGRESS* → COMPARE_RESULT.
* = repeated zero or more times.