Skip to content

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

refactor(orchestrator): one derivation of the closed tab id drives both the tab-cache invalidation and the binding release

Luigi Agosti86aab675ccc7
diff --git a/internal/orchestrator/proxy.go b/internal/orchestrator/proxy.go
index aa879670..526bb9a3 100644
--- a/internal/orchestrator/proxy.go
+++ b/internal/orchestrator/proxy.go
@@ -416,14 +416,9 @@ func (o *Orchestrator) handleProxyResponseHeaders(origReq *http.Request, resp *h
return
}
- if o.instanceMgr != nil {
- if tabID := tabClosePathID(origReq); tabID != "" {
- o.instanceMgr.InvalidateTab(tabID)
- } else if origReq.Method == http.MethodPost && strings.TrimSpace(origReq.URL.Path) == "/close" {
- if tabID := strings.TrimSpace(resp.Header.Get(activity.HeaderPTTabID)); tabID != "" {
- o.instanceMgr.InvalidateTab(tabID)
- }
- }
+ closedTab := closedTabID(origReq, resp)
+ if o.instanceMgr != nil && closedTab != "" {
+ o.instanceMgr.InvalidateTab(closedTab)
}
// Identity → instance binding writes. Bindings are persisted only after
@@ -441,8 +436,8 @@ func (o *Orchestrator) handleProxyResponseHeaders(origReq *http.Request, resp *h
if id := strings.TrimSpace(origReq.Header.Get(activity.HeaderAgentID)); id != "" {
o.bindings.BindAgent(id, targetInstanceID)
}
- if tabID := closedTabID(origReq, resp); tabID != "" {
- o.bindings.ReleaseTab(tabID)
+ if closedTab != "" {
+ o.bindings.ReleaseTab(closedTab)
}
}