Skip to content

fix: preserve user's browser tabs on connect and newChat - #6

Open
itsbrex wants to merge 1 commit into
hanzili:mainfrom
itsbrex:preserve-tabs-reuse
Open

fix: preserve user's browser tabs on connect and newChat#6
itsbrex wants to merge 1 commit into
hanzili:mainfrom
itsbrex:preserve-tabs-reuse

Conversation

@itsbrex

@itsbrex itsbrex commented Jun 4, 2026

Copy link
Copy Markdown

Problem

comet_connect and comet_ask (with newChat: true) call a "close all tabs except one" cleanup on every startup/reset:

// Close extra tabs, keep only one
if (pageTabs.length > 1) {
  for (let i = 1; i < pageTabs.length; i++) {
    try { await cometClient.closeTab(pageTabs[i].id); } catch {}
  }
}

For anyone who keeps Comet open as their normal browser, this silently destroys their session — in my case Connected to Perplexity (cleaned 105 old tabs) on first connect. Losing 100+ tabs to an MCP connect is a nasty surprise.

Fix

Stop closing tabs. Instead:

  • comet_connect — reuse the existing Perplexity tab via listTabsCategorized() (tabs.main). If there isn't one, open a single new tab. Other tabs are never touched.
  • comet_ask (newChat) — same reuse-or-open logic, no cleanup loop.

This also avoids hijacking an arbitrary tab: rather than connecting to "the first page tab" and navigating it to Perplexity, it targets the actual Perplexity tab (tabs.main) and only creates a new tab when none exists.

Notes

  • No new dependencies, no API changes. Connect message now reports tabs preserved instead of tabs cleaned.
  • Related: Stop closing user's existing browser tabs on connect #2 takes a similar "don't close tabs" direction; this PR additionally reuses the existing Perplexity tab (via listTabsCategorized) instead of navigating the first available tab, so an unrelated foreground tab isn't repurposed.
  • tsc compiles clean.

comet_connect and comet_ask(newChat) closed all browser tabs except one
on every startup/reset, destroying the user's open tabs (commonly 100+).

Instead, reuse the existing Perplexity tab via listTabsCategorized() — or
open a single new tab if none exists — and never close or navigate the
user's other tabs.

- comet_connect: reuse Perplexity tab, else open new; report tabs preserved
- comet_ask newChat: same reuse/open logic, no tab cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant