Two weekends into a Chrome side panel: the four state bugs that took longer than the UI
I shipped the first public build of a Chrome extension two weekends ago. The marketing-ready UI took me about six hours. The four state bugs below took me the rest of those two weekends, plus parts of the following week. I am writing this down because every reviewer of "I built an X in Y hours" posts seems to skip the state-model half, and the state-model half is where the actual time goes. The extension A sidebar that lives in Chrome's side panel API. You highlight text or screenshot a region on any page, the sidebar lets you pick a destination AI tab (ChatGPT / Claude / Gemini / a custom one) and forwards the content with a small wrapper prompt. That is the whole product description. The interesting part is what happens when a user does it twice. Bug 1: the destination you "logged into" is not the destination the message lands in First failure I caught: user has two ChatGPT tabs open, one workspace, one personal. The extension forwards to whichever tab was last focused. The user sees the message arrive in the workspace, replies there, then realizes the context they wanted to capture is on the personal tab. Fix: every AI destination registers a stable tab id at extension boot, not at click time. The forwarding logic walks the registry, not the focused window. Took a morning to redesign, an afternoon to migrate existing flows. Lesson: tab identity is not the same as window focus. Chrome's chrome.tabs.query({active: true}) returns the active tab. The active tab is not necessarily the destination the user has in their head. Bug 2: the screenshot is from before the user edited it User takes a screenshot of a code block, opens the sidebar, hits "annotate", drags a red box around lines 12-15, hits send. The annotation worked. But the underlying screenshot bytes were captured at the moment the toolbar first appeared, before the user could draw the box. Fix: the sidebar cannot trust that the screenshot in memory is the screenshot the user is looking at. Either re-capture o