High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: lint errors in store_test and remove unused tokenFromAuthorizationHeader
Bosch2c3c79a41a3a
diff --git a/cmd/pinchtab/cmd_cli_runtime.go b/cmd/pinchtab/cmd_cli_runtime.goindex b2150f48..426b2d48 100644--- a/cmd/pinchtab/cmd_cli_runtime.go+++ b/cmd/pinchtab/cmd_cli_runtime.go@@ -68,7 +68,6 @@ func resolveCLIToken(cfg *config.RuntimeConfig) string {return token}-func resolveCLIAgentID() string {if trimmed := strings.TrimSpace(cliAgentID); trimmed != "" {return trimmeddiff --git a/dashboard/src/activities/ActiveFilterBar.tsx b/dashboard/src/activities/ActiveFilterBar.tsxindex 14a02607..398b6e04 100644--- a/dashboard/src/activities/ActiveFilterBar.tsx+++ b/dashboard/src/activities/ActiveFilterBar.tsx@@ -19,7 +19,9 @@ export default function ActiveFilterBar({filters.instanceId ? `instance:${filters.instanceId}` : "",filters.tabId ? `tab:${filters.tabId}` : "",filters.action ? `action:${filters.action}` : "",- !hideSessionFilter && filters.sessionId ? `session:${filters.sessionId}` : "",+ !hideSessionFilter && filters.sessionId+ ? `session:${filters.sessionId}`+ : "",filters.pathPrefix ? `path:${filters.pathPrefix}` : "",].filter(Boolean);diff --git a/dashboard/src/activities/AgentActivityWorkspace.tsx b/dashboard/src/activities/AgentActivityWorkspace.tsxindex 17e76420..3085b534 100644--- a/dashboard/src/activities/AgentActivityWorkspace.tsx+++ b/dashboard/src/activities/AgentActivityWorkspace.tsx@@ -347,12 +347,15 @@ export default function AgentActivityWorkspace({: visibleEvents;const derivedSessions = useMemo<api.AgentSession[]>(() => {- const bySession = new Map<string, {- agentId: string;- label?: string;- earliest: string;- latest: string;- }>();+ const bySession = new Map<+ string,+ {+ agentId: string;+ label?: string;+ earliest: string;+ latest: string;+ }+ >();for (const s of agentSessions) {bySession.set(s.id, {@@ -363,9 +366,10 @@ export default function AgentActivityWorkspace({});}- const sourceEvents = usesAgentThreadView && filters.agentId- ? (agentEventsById[filters.agentId] ?? []).map(toDashboardActivityEvent)- : visibleEvents;+ const sourceEvents =+ usesAgentThreadView && filters.agentId+ ? (agentEventsById[filters.agentId] ?? []).map(toDashboardActivityEvent)+ : visibleEvents;for (const event of sourceEvents) {const sid = event.sessionId?.trim();@@ -382,8 +386,10 @@ export default function AgentActivityWorkspace({}const ts = new Date(event.timestamp).getTime();- if (ts < new Date(existing.earliest).getTime()) existing.earliest = event.timestamp;- if (ts > new Date(existing.latest).getTime()) existing.latest = event.timestamp;+ if (ts < new Date(existing.earliest).getTime())+ existing.earliest = event.timestamp;+ if (ts > new Date(existing.latest).getTime())+ existing.latest = event.timestamp;}return [...bySession.entries()]@@ -400,7 +406,13 @@ export default function AgentActivityWorkspace({(a, b) =>new Date(b.lastSeenAt).getTime() - new Date(a.lastSeenAt).getTime(),);- }, [usesAgentThreadView, filters.agentId, agentEventsById, visibleEvents, agentSessions]);+ }, [+ usesAgentThreadView,+ filters.agentId,+ agentEventsById,+ visibleEvents,+ agentSessions,+ ]);const unlabeledPtsKey = useMemo(() => {const apiIds = new Set(agentSessions.map((s) => s.id));@@ -507,13 +519,15 @@ export default function AgentActivityWorkspace({return;}- const hasAgent = visibleAgents.some((agent) => agent.id === filters.agentId);- const targetAgent = hasAgent- ? filters.agentId- : visibleAgents[0].id;- const agentSessionList = derivedSessions- .filter((s) => s.agentId === targetAgent);- const latestSession = agentSessionList.length > 0 ? agentSessionList[0].id : "";+ const hasAgent = visibleAgents.some(+ (agent) => agent.id === filters.agentId,+ );+ const targetAgent = hasAgent ? filters.agentId : visibleAgents[0].id;+ const agentSessionList = derivedSessions.filter(+ (s) => s.agentId === targetAgent,+ );+ const latestSession =+ agentSessionList.length > 0 ? agentSessionList[0].id : "";if (!hasAgent || (!filters.sessionId && latestSession)) {setFilters((current) => ({@@ -522,7 +536,13 @@ export default function AgentActivityWorkspace({sessionId: latestSession,}));}- }, [filters.agentId, filters.sessionId, requireSelectedAgent, visibleAgents, derivedSessions]);+ }, [+ filters.agentId,+ filters.sessionId,+ requireSelectedAgent,+ visibleAgents,+ derivedSessions,+ ]);const updateFilter = (key: keyof ActivityFilters, value: string) => {setFilters((current) => ({ ...current, [key]: value }));diff --git a/dashboard/src/activities/AgentStreamPanel.tsx b/dashboard/src/activities/AgentStreamPanel.tsxindex fd186392..56914366 100644--- a/dashboard/src/activities/AgentStreamPanel.tsx+++ b/dashboard/src/activities/AgentStreamPanel.tsx@@ -116,8 +116,7 @@ export default function AgentStreamPanel({const prevSessionId =index > 0 ? events[index - 1].sessionId : undefined;const showDivider =- event.sessionId &&- event.sessionId !== prevSessionId;+ event.sessionId && event.sessionId !== prevSessionId;return (<div key={`${event.requestId || event.timestamp}-${index}`}>{showDivider && (diff --git a/dashboard/src/activities/AgentWorkspaceSidebar.tsx b/dashboard/src/activities/AgentWorkspaceSidebar.tsxindex 98287d42..ac17876f 100644--- a/dashboard/src/activities/AgentWorkspaceSidebar.tsx+++ b/dashboard/src/activities/AgentWorkspaceSidebar.tsx@@ -120,7 +120,9 @@ export default function AgentWorkspaceSidebar({selected={activeAgentId === agent.id}sessions={sessionsByAgent.get(agent.id) || []}activeSessionId={filters.sessionId}- onClick={(autoSessionId) => onSelectAgent(agent.id, autoSessionId)}+ onClick={(autoSessionId) =>+ onSelectAgent(agent.id, autoSessionId)+ }onSelectSession={onSelectSession}/>))}diff --git a/dashboard/src/activities/StreamRow.tsx b/dashboard/src/activities/StreamRow.tsxindex acfb2679..da66aa39 100644--- a/dashboard/src/activities/StreamRow.tsx+++ b/dashboard/src/activities/StreamRow.tsx@@ -36,8 +36,6 @@ function isDefaultProfile(name: string | undefined): boolean {return lower === "default" || lower === "chrome-profile";}--function quoted(value: string): string {return `"${value}"`;}diff --git a/internal/agentsession/store.go b/internal/agentsession/store.goindex 22a59d05..b88824a3 100644--- a/internal/agentsession/store.go+++ b/internal/agentsession/store.go@@ -43,10 +43,10 @@ type Config struct {// Store manages agent sessions with persistence.type Store struct {- mu sync.Mutex- sessions map[string]*Session // keyed by session ID- cfg Config- now func() time.Time+ mu sync.Mutex+ sessions map[string]*Session // keyed by session ID+ cfg Config+ now func() time.Time}const (@@ -281,20 +281,20 @@ func (s *Store) pruneExpiredLocked() {// persistence typestype persistedStore struct {- SavedAt time.Time `json:"savedAt"`+ SavedAt time.Time `json:"savedAt"`Sessions []persistedAgentSession `json:"sessions"`}type persistedAgentSession struct {- ID string `json:"id"`- AgentID string `json:"agentId"`- Label string `json:"label,omitempty"`- TokenHash string `json:"tokenHash"`- CreatedAt time.Time `json:"createdAt"`- LastSeenAt time.Time `json:"lastSeenAt"`- ExpiresAt time.Time `json:"expiresAt,omitempty"`- Status string `json:"status"`- Grants []string `json:"grants,omitempty"`+ ID string `json:"id"`+ AgentID string `json:"agentId"`+ Label string `json:"label,omitempty"`+ TokenHash string `json:"tokenHash"`+ CreatedAt time.Time `json:"createdAt"`+ LastSeenAt time.Time `json:"lastSeenAt"`+ ExpiresAt time.Time `json:"expiresAt,omitempty"`+ Status string `json:"status"`+ Grants []string `json:"grants,omitempty"`}func (s *Store) loadPersisted() {diff --git a/internal/agentsession/store_test.go b/internal/agentsession/store_test.goindex a8a49567..7c0e136e 100644--- a/internal/agentsession/store_test.go+++ b/internal/agentsession/store_test.go@@ -182,8 +182,8 @@ func TestGet(t *testing.T) {func TestList(t *testing.T) {s := NewStore(Config{Enabled: true})- s.Create("agent-1", "")- s.Create("agent-2", "")+ _, _, _ = s.Create("agent-1", "")+ _, _, _ = s.Create("agent-2", "")list := s.List()if len(list) != 2 {@@ -217,7 +217,7 @@ func TestPrunedOnLoad(t *testing.T) {s1 := NewStore(Config{Enabled: true, PersistPath: path, MaxLifetime: 1 * time.Hour, IdleTimeout: 30 * time.Minute})now := time.Now()s1.now = func() time.Time { return now }- s1.Create("agent-1", "will expire")+ _, _, _ = s1.Create("agent-1", "will expire")// Load with time advanced past expiry — set now before NewStore calls loadPersistedfutureTime := now.Add(2 * time.Hour)@@ -238,7 +238,7 @@ func TestAtomicWrite(t *testing.T) {path := filepath.Join(dir, "sessions.json")s := NewStore(Config{Enabled: true, PersistPath: path})- s.Create("agent-1", "")+ _, _, _ = s.Create("agent-1", "")// Verify file exists and is valid JSONdata, err := os.ReadFile(path)diff --git a/internal/authn/request.go b/internal/authn/request.goindex 00c6179c..bc11d880 100644--- a/internal/authn/request.go+++ b/internal/authn/request.go@@ -75,20 +75,6 @@ func ClientIP(r *http.Request) string {return strings.TrimSpace(r.RemoteAddr)}-func tokenFromAuthorizationHeader(auth string) string {- auth = strings.TrimSpace(auth)- if auth == "" {- return ""- }- if strings.HasPrefix(strings.ToLower(auth), "bearer ") {- return strings.TrimSpace(auth[7:])- }- if strings.HasPrefix(strings.ToLower(auth), "session ") {- return ""- }- return auth-}-func parseAuthorizationHeader(auth string) (bearer, session string) {auth = strings.TrimSpace(auth)if auth == "" {diff --git a/internal/server/bridge_test.go b/internal/server/bridge_test.goindex 298ed5d2..b6be80cb 100644--- a/internal/server/bridge_test.go+++ b/internal/server/bridge_test.go@@ -50,7 +50,7 @@ func TestBridgeHandlerChainAppliesRateLimit(t *testing.T) {),)- for i := 0; i < 120; i++ {+ for i := 0; i < 300; i++ {req := httptest.NewRequest(http.MethodGet, "/protected", nil)req.RemoteAddr = "198.51.100.10:41000"req.Header.Set("Authorization", "Bearer secret")diff --git a/internal/server/server.go b/internal/server/server.goindex ae822ec0..3e089f66 100644--- a/internal/server/server.go+++ b/internal/server/server.go@@ -6,8 +6,8 @@ import ("log/slog""net/http""os"- "path/filepath""os/signal"+ "path/filepath""sync""syscall""time"diff --git a/internal/server/timeouts_test.go b/internal/server/timeouts_test.goindex d71ffd91..eaede094 100644--- a/internal/server/timeouts_test.go+++ b/internal/server/timeouts_test.go@@ -45,7 +45,7 @@ func TestDashboardHandlerChainAppliesRateLimit(t *testing.T) {),)- for i := 0; i < 120; i++ {+ for i := 0; i < 300; i++ {req := httptest.NewRequest(http.MethodGet, "/protected", nil)req.RemoteAddr = "198.51.100.11:41001"req.Header.Set("Authorization", "Bearer secret")diff --git a/internal/strategy/autorestart/autorestart.go b/internal/strategy/autorestart/autorestart.goindex 4ae75224..836fc060 100644--- a/internal/strategy/autorestart/autorestart.go+++ b/internal/strategy/autorestart/autorestart.go@@ -16,11 +16,11 @@ import ("sync""time"+ "github.com/pinchtab/pinchtab/internal/activity""github.com/pinchtab/pinchtab/internal/bridge""github.com/pinchtab/pinchtab/internal/config""github.com/pinchtab/pinchtab/internal/httpx""github.com/pinchtab/pinchtab/internal/orchestrator"- "github.com/pinchtab/pinchtab/internal/activity""github.com/pinchtab/pinchtab/internal/strategy")diff --git a/internal/strategy/explicit/explicit.go b/internal/strategy/explicit/explicit.goindex 82639cbd..1d773cc5 100644--- a/internal/strategy/explicit/explicit.go+++ b/internal/strategy/explicit/explicit.go@@ -9,9 +9,9 @@ import ("fmt""net/http"+ "github.com/pinchtab/pinchtab/internal/activity""github.com/pinchtab/pinchtab/internal/httpx""github.com/pinchtab/pinchtab/internal/orchestrator"- "github.com/pinchtab/pinchtab/internal/activity""github.com/pinchtab/pinchtab/internal/strategy")diff --git a/internal/strategy/noinstance/noinstance.go b/internal/strategy/noinstance/noinstance.goindex 2defdade..01c35b76 100644--- a/internal/strategy/noinstance/noinstance.go+++ b/internal/strategy/noinstance/noinstance.go@@ -8,9 +8,9 @@ import ("fmt""net/http"+ "github.com/pinchtab/pinchtab/internal/activity""github.com/pinchtab/pinchtab/internal/httpx""github.com/pinchtab/pinchtab/internal/orchestrator"- "github.com/pinchtab/pinchtab/internal/activity""github.com/pinchtab/pinchtab/internal/strategy")diff --git a/internal/strategy/simple/simple.go b/internal/strategy/simple/simple.goindex b81149c9..5f5d2848 100644--- a/internal/strategy/simple/simple.go+++ b/internal/strategy/simple/simple.go@@ -15,9 +15,9 @@ import ("net/http""time"+ "github.com/pinchtab/pinchtab/internal/activity""github.com/pinchtab/pinchtab/internal/httpx""github.com/pinchtab/pinchtab/internal/orchestrator"- "github.com/pinchtab/pinchtab/internal/activity""github.com/pinchtab/pinchtab/internal/strategy")