Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: deduplicate and filter transient URLs on tab save

Mario85df0241bc27
diff --git a/internal/bridge/state.go b/internal/bridge/state.go
index 52c73763..41cb0a8b 100644
--- a/internal/bridge/state.go
+++ b/internal/bridge/state.go
@@ -30,6 +30,18 @@ type SessionState struct {
SavedAt string `json:"savedAt"`
}
+func isTransientURL(url string) bool {
+ switch url {
+ case "about:blank", "chrome://newtab/", "chrome://new-tab-page/":
+ return true
+ }
+ return strings.HasPrefix(url, "chrome://") ||
+ strings.HasPrefix(url, "chrome-extension://") ||
+ strings.HasPrefix(url, "devtools://") ||
+ strings.HasPrefix(url, "file://") ||
+ strings.Contains(url, "localhost:")
+}
+
func MarkCleanExit(profileDir string) {
prefsPath := filepath.Join(profileDir, "Default", "Preferences")
data, err := os.ReadFile(prefsPath)
@@ -71,14 +83,20 @@ func (b *Bridge) SaveState() {
}
tabs := make([]TabState, 0, len(targets))
+ seen := make(map[string]bool, len(targets))
for _, t := range targets {
- if t.URL != "" && t.URL != "about:blank" && t.URL != "chrome://newtab/" {
- tabs = append(tabs, TabState{
- ID: string(t.TargetID),
- URL: t.URL,
- Title: t.Title,
- })
+ if t.URL == "" || isTransientURL(t.URL) {
+ continue
+ }
+ if seen[t.URL] {
+ continue
}
+ seen[t.URL] = true
+ tabs = append(tabs, TabState{
+ ID: string(t.TargetID),
+ URL: t.URL,
+ Title: t.Title,
+ })
}
state := SessionState{
diff --git a/internal/bridge/state_test.go b/internal/bridge/state_test.go
index 3174df43..af81d849 100644
--- a/internal/bridge/state_test.go
+++ b/internal/bridge/state_test.go
@@ -126,6 +126,37 @@ func TestWasUncleanExit_Normal(t *testing.T) {
}
}
+func TestIsTransientURL(t *testing.T) {
+ transient := []string{
+ "about:blank",
+ "chrome://newtab/",
+ "chrome://new-tab-page/",
+ "chrome://settings/",
+ "chrome-extension://abc/popup.html",
+ "devtools://devtools/inspector.html",
+ "file:///tmp/test.html",
+ "http://localhost:9867/welcome",
+ "http://localhost:3000/dashboard",
+ }
+ for _, u := range transient {
+ if !isTransientURL(u) {
+ t.Errorf("expected transient: %s", u)
+ }
+ }
+
+ persistent := []string{
+ "https://example.com",
+ "https://github.com/pinchtab/pinchtab",
+ "https://www.google.com/search?q=test",
+ "https://httpbin.org/get",
+ }
+ for _, u := range persistent {
+ if isTransientURL(u) {
+ t.Errorf("expected persistent: %s", u)
+ }
+ }
+}
+
func TestClearChromeSessions(t *testing.T) {
tmp := t.TempDir()
sessionsDir := filepath.Join(tmp, "Default", "Sessions")