I build TabZipsa, a Chrome extension that sorts every open tab into native Chrome tab groups with one click. This week a developer gave me feedback that I can't stop thinking about:
If one click rearranges 40 tabs and the result is off, you lose trust right away. Show the proposed groups, and give me an undo right after.
Right now my extension applies the AI result immediately and has no undo. If you build anything where AI changes the user's stuff (tabs, bookmarks, files), you probably have the same gap. Here is the approach I'm prototyping, using only chrome.tabs and chrome.tabGroups.
1. Snapshot before you touch anything
Tab groups in Chrome are always contiguous, so a snapshot needs only three things per tab: window, index and group. Store group titles and colors separately.
async function snapshotTabs() { const tabs = await chrome.tabs.query({}); const groups = await chrome.tabGroups.query({}); return { takenAt: Date.now(), tabs: tabs .filter(t => !t.incognito && !t.pinned) .map(t => ({ id: t.id, windowId: t.windowId, index: t.index, groupId: t.groupId })), groups: groups.map(g => ({ id: g.id, title: g.title, color: g.color, collapsed: g.collapsed })) }; } I skip pinned tabs (they can't move into the unpinned area anyway) and incognito tabs (they shouldn't be sent to an AI in the first place).
2. Restore in the right order
The order matters. If you regroup first and then move tabs, a move can pull a tab out of its group. So:
- Ungroup the tabs that still exist.
- Move each tab back to its original window and index, lowest index first.
- Recreate the old groups, then restore title, color and collapsed state.
async function restoreSnapshot(snap) { const alive = new Set((await chrome.tabs.query({})).map(t => t.id)); const tabs = snap.tabs.filter(t => alive.has(t.id)); if (!tabs.length) return; await chrome.tabs.ungroup(tabs.map(t => t.id)); for (const t of [...tabs].sort((a, b) => a.index - b.index)) { await chrome.tabs.move(t.id, { windowId: t.windowId, index: t.index }); } const byGroup = new Map(); for (const t of tabs) { if (t.groupId === chrome.tabGroups.TAB_GROUP_ID_NONE) continue; if (!byGroup.has(t.groupId)) byGroup.set(t.groupId, []); byGroup.get(t.groupId).push(t.id); } for (const [oldId, tabIds] of byGroup) { const meta = snap.groups.find(g => g.id === oldId); const newId = await chrome.tabs.group({ tabIds }); if (meta) { await chrome.tabGroups.update(newId, { title: meta.title, color: meta.color, collapsed: meta.collapsed }); } } } Tabs the user closed in the meantime are simply skipped; new tabs opened after the snapshot are left alone.
3. Keep the undo window honest
A few rules I'm settling on:
- Keep one snapshot, the one taken right before the last AI run. Undo-of-undo isn't worth the complexity.
- Show the undo button until the user does something else in the panel, not on a timer they might miss.
- Store the snapshot in
chrome.storage.session, so it survives the side panel closing but disappears when the browser restarts (tab IDs don't survive a restart anyway).
Preview vs undo
The same developer also asked for a preview. I think undo comes first: it costs one snapshot, it doesn't slow down the "one click" flow that other users told me they like, and it removes most of the risk. A preview can be an option for people who want it.
How do you handle "AI just changed my stuff" moments in your own tools? Preview, undo, or both?
Disclosure: I'm the developer of TabZipsa (https://tabzipsa.com). This post was written with AI assistance; the code is a prototype, so test it with your own edge cases.