High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
fix: test and lint
Luigi Agosti5f1dd7e9a754
diff --git a/dashboard/src/components/molecules/InstanceStats.tsx b/dashboard/src/components/molecules/InstanceStats.tsxindex bc6258d2..0bfc7e2f 100644--- a/dashboard/src/components/molecules/InstanceStats.tsx+++ b/dashboard/src/components/molecules/InstanceStats.tsx@@ -1,4 +1,8 @@-import type { Instance, InstanceMetrics, InstanceTab } from "../../generated/types";+import type {+ Instance,+ InstanceMetrics,+ InstanceTab,+} from "../../generated/types";interface Props {instance?: Instance | null;diff --git a/dashboard/src/components/molecules/NavBar.tsx b/dashboard/src/components/molecules/NavBar.tsxindex ec36e995..c95f51d7 100644--- a/dashboard/src/components/molecules/NavBar.tsx+++ b/dashboard/src/components/molecules/NavBar.tsx@@ -39,7 +39,9 @@ export default function NavBar({ onRefresh, showLogout = false }: NavBarProps) {const location = useLocation();const navigate = useNavigate();- const isMonitoringPage = location.pathname.startsWith("/dashboard/monitoring");+ const isMonitoringPage = location.pathname.startsWith(+ "/dashboard/monitoring",+ );const selectedInstance =instances.find((i) => i.id === selectedMonitoringInstanceId) ?? null;@@ -118,7 +120,7 @@ export default function NavBar({ onRefresh, showLogout = false }: NavBarProps) {sidebarCollapsed={monitoringSidebarCollapsed}tabCount={selectedInstance- ? currentTabs[selectedInstance.id]?.length ?? 0+ ? (currentTabs[selectedInstance.id]?.length ?? 0): 0}onToggleSidebar={() =>diff --git a/dashboard/src/components/molecules/ServerStatusBadge.tsx b/dashboard/src/components/molecules/ServerStatusBadge.tsxindex 945e6856..8663e2f6 100644--- a/dashboard/src/components/molecules/ServerStatusBadge.tsx+++ b/dashboard/src/components/molecules/ServerStatusBadge.tsx@@ -33,9 +33,7 @@ export default function ServerStatusBadge({title={`${instance.profileName} · ${instance.status} · ${instance.port}`}><div className={`h-1.5 w-1.5 shrink-0 rounded-full ${statusColor}`} />- <span className="text-[10px] tracking-wider">- {instance.port}- </span>+ <span className="text-[10px] tracking-wider">{instance.port}</span></div>);}@@ -45,7 +43,9 @@ export default function ServerStatusBadge({type="button"onClick={onToggleSidebar}className="mr-2 flex items-center gap-1.5 px-2 py-1 text-text-muted transition-colors hover:text-text-primary"- title={sidebarCollapsed ? "Expand instance list" : "Collapse instance list"}+ title={+ sidebarCollapsed ? "Expand instance list" : "Collapse instance list"+ }><svgviewBox="0 0 24 24"@@ -67,9 +67,7 @@ export default function ServerStatusBadge({{instance.status} · {tabCount} tab{tabCount !== 1 ? "s" : ""} ·{" "}</span>- <span className="text-[10px] tracking-wider">- {instance.port}- </span>+ <span className="text-[10px] tracking-wider">{instance.port}</span></button>);}@@ -91,9 +89,7 @@ export default function ServerStatusBadge({><divclassName={`h-1.5 w-1.5 rounded-full ${- serverInfo.restartRequired- ? "bg-warning"- : "bg-success animate-pulse"+ serverInfo.restartRequired ? "bg-warning" : "bg-success animate-pulse"}`}/><spandiff --git a/dashboard/src/instances/InstanceListItem.tsx b/dashboard/src/instances/InstanceListItem.tsxindex a6a44487..6263b14c 100644--- a/dashboard/src/instances/InstanceListItem.tsx+++ b/dashboard/src/instances/InstanceListItem.tsx@@ -37,9 +37,7 @@ export default function InstanceListItem({<buttononClick={onClick}className={`flex w-full flex-col gap-1 border-b border-border-subtle px-3 py-2.5 text-left transition-colors ${- selected- ? "bg-bg-hover text-text-primary"- : "hover:bg-bg-hover/50"+ selected ? "bg-bg-hover text-text-primary" : "hover:bg-bg-hover/50"}`}><div className="flex w-full items-center gap-2">diff --git a/dashboard/src/pages/MonitoringPage.test.tsx b/dashboard/src/pages/MonitoringPage.test.tsxindex 0cc6ae24..cef45b45 100644--- a/dashboard/src/pages/MonitoringPage.test.tsx+++ b/dashboard/src/pages/MonitoringPage.test.tsx@@ -8,24 +8,13 @@ import type { Instance } from "../generated/types";vi.mock("../services/api", () => ({stopInstance: vi.fn(),+ fetchBackendConfig: vi.fn().mockResolvedValue({+ config: { multiInstance: { strategy: "always-on" } },+ }),fetchActivity: vi.fn(),fetchAllTabs: vi.fn(),}));-vi.mock("../components/molecules", () => ({- TabsChart: () => <div>Tabs Chart</div>,- InstanceListItem: ({- instance,- onClick,- }: {- instance: Instance;- onClick: () => void;- }) => <button onClick={onClick}>{instance.profileName}</button>,- InstanceTabsPanel: ({ tabs }: { tabs: { title: string }[] }) => (- <div>Tabs Panel ({tabs.length})</div>- ),-}));-const instances: Instance[] = [{id: "inst_beta",@@ -63,6 +52,10 @@ describe("MonitoringPage", () => {inst_beta: [],},currentMemory: {},+ currentMetrics: {},+ monitoringSidebarCollapsed: false,+ selectedMonitoringInstanceId: null,+ monitoringShowTelemetry: false,settings: {...useAppStore.getState().settings,monitoring: {@@ -84,7 +77,9 @@ describe("MonitoringPage", () => {);await waitFor(() => {- expect(screen.getByRole("heading", { name: "beta" })).toBeInTheDocument();+ expect(+ screen.getByRole("heading", { name: "beta" }),+ ).toBeInTheDocument();});await userEvent.click(screen.getByRole("button", { name: "Open Profile" }));diff --git a/dashboard/src/pages/ProfilesPage.test.tsx b/dashboard/src/pages/ProfilesPage.test.tsxindex 64323523..1a21b6f9 100644--- a/dashboard/src/pages/ProfilesPage.test.tsx+++ b/dashboard/src/pages/ProfilesPage.test.tsx@@ -64,6 +64,18 @@ function renderProfilesPage() {);}+function clickSidebarProfile(name: string) {+ const profileNameEl = screen.getByText(name, {+ selector: ".text-sm.font-semibold",+ });+ const button = profileNameEl.closest("button") as HTMLElement;+ return userEvent.click(button);+}++function getDetailPanel() {+ return document.querySelector(".dashboard-panel .min-w-0.flex-1") as HTMLElement;+}+describe("ProfilesPage", () => {beforeEach(() => {vi.clearAllMocks();@@ -77,25 +89,21 @@ describe("ProfilesPage", () => {it("moves the running profile to the top and auto-selects it", async () => {renderProfilesPage();- let detailPanel: HTMLElement;await waitFor(() => {- detailPanel = screen- .getByRole("heading", { name: "beta" })- .closest(".dashboard-panel") as HTMLElement;- expect(detailPanel).toBeInTheDocument();+ expect(+ screen.getByRole("button", { name: /Profile: beta/i }),+ ).toBeInTheDocument();});- const [firstProfileButton, secondProfileButton] = screen.getAllByRole(- "button",- { name: /alpha|beta/i },+ const sidebar = document.querySelector(".bg-bg-surface\\/50") as HTMLElement;+ const sidebarButtons = within(sidebar).getAllByRole("button");+ const profileButtons = sidebarButtons.filter((b) =>+ b.classList.contains("border-b"),);- expect(firstProfileButton).toHaveTextContent("beta");- expect(secondProfileButton).toHaveTextContent("alpha");-- detailPanel = screen- .getByRole("heading", { name: "beta" })- .closest(".dashboard-panel") as HTMLElement;+ expect(profileButtons[0]).toHaveTextContent("beta");+ expect(profileButtons[1]).toHaveTextContent("alpha");+ const detailPanel = getDetailPanel()!;expect(within(detailPanel).getAllByText("[email protected]").length,).toBeGreaterThan(0);@@ -107,16 +115,20 @@ describe("ProfilesPage", () => {renderProfilesPage();await waitFor(() => {- expect(screen.getByRole("heading", { name: "beta" })).toBeInTheDocument();+ expect(+ screen.getByRole("button", { name: /Profile: beta/i }),+ ).toBeInTheDocument();});- await userEvent.click(screen.getByRole("button", { name: /alpha/i }));+ await clickSidebarProfile("alpha");- const detailPanel = screen- .getByRole("heading", { name: "alpha" })- .closest(".dashboard-panel") as HTMLElement;+ await waitFor(() => {+ expect(+ screen.getByRole("button", { name: /Profile: alpha/i }),+ ).toBeInTheDocument();+ });- expect(detailPanel).toBeInTheDocument();+ const detailPanel = getDetailPanel()!;expect(within(detailPanel).getAllByText("Use for personal logins").length,).toBeGreaterThan(0);@@ -129,14 +141,20 @@ describe("ProfilesPage", () => {renderProfilesPage();await waitFor(() => {- expect(screen.getByRole("heading", { name: "beta" })).toBeInTheDocument();+ expect(+ screen.getByRole("button", { name: /Profile: beta/i }),+ ).toBeInTheDocument();});- await userEvent.click(screen.getByRole("button", { name: /alpha/i }));+ await clickSidebarProfile("alpha");++ await waitFor(() => {+ expect(+ screen.getByRole("button", { name: /Profile: alpha/i }),+ ).toBeInTheDocument();+ });- const detailPanel = screen- .getByRole("heading", { name: "alpha" })- .closest(".dashboard-panel") as HTMLElement;+ const detailPanel = getDetailPanel()!;const saveButton = within(detailPanel).getByRole("button", {name: "Save",});diff --git a/dashboard/src/profiles/InstanceLogsPanel.test.tsx b/dashboard/src/profiles/InstanceLogsPanel.test.tsxindex c54845cc..51586bb7 100644--- a/dashboard/src/profiles/InstanceLogsPanel.test.tsx+++ b/dashboard/src/profiles/InstanceLogsPanel.test.tsx@@ -12,6 +12,10 @@ vi.mock("../services/api", () => ({subscribeToInstanceLogs,}));+beforeEach(() => {+ Element.prototype.scrollIntoView = vi.fn();+});+describe("InstanceLogsPanel", () => {beforeEach(() => {vi.clearAllMocks();@@ -30,9 +34,8 @@ describe("InstanceLogsPanel", () => {expect(screen.getByText("Loading logs...")).toBeInTheDocument();await waitFor(() => {- expect(document.querySelector("pre")).toHaveTextContent(- "first line second line",- );+ expect(screen.getByText("first line")).toBeInTheDocument();+ expect(screen.getByText("second line")).toBeInTheDocument();});expect(fetchInstanceLogs).toHaveBeenCalledWith("inst_123");expect(subscribeToInstanceLogs).toHaveBeenCalledWith("inst_123", {@@ -59,7 +62,7 @@ describe("InstanceLogsPanel", () => {onLogs?.("streamed logs");});- expect(document.querySelector("pre")).toHaveTextContent("streamed logs");+ expect(screen.getByText("streamed logs")).toBeInTheDocument();});it("shows the empty state when no instance is available", () => {diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.tsindex 174baddc..068a32e6 100644--- a/dashboard/src/services/api.ts+++ b/dashboard/src/services/api.ts@@ -252,9 +252,7 @@ export async function fetchConsoleLogs(return res.console || [];}-export async function fetchErrorLogs(- tabId: string,-): Promise<ErrorLogEntry[]> {+export async function fetchErrorLogs(tabId: string): Promise<ErrorLogEntry[]> {const res = await request<{ errors: ErrorLogEntry[] }>(`/errors?tabId=${encodeURIComponent(tabId)}`,);diff --git a/dashboard/src/tabs/InstanceTabsPanel.test.tsx b/dashboard/src/tabs/InstanceTabsPanel.test.tsxindex c8c59970..ea2d3016 100644--- a/dashboard/src/tabs/InstanceTabsPanel.test.tsx+++ b/dashboard/src/tabs/InstanceTabsPanel.test.tsx@@ -1,9 +1,22 @@import { render, screen, within } from "@testing-library/react";import userEvent from "@testing-library/user-event";-import { describe, expect, it } from "vitest";+import { describe, expect, it, vi } from "vitest";import type { InstanceTab } from "../generated/types";import InstanceTabsPanel from "./InstanceTabsPanel";+vi.mock("../stores/useAppStore", () => ({+ useAppStore: () => ({+ instances: [],+ tabsChartData: [],+ memoryChartData: [],+ serverChartData: [],+ currentMetrics: {},+ settings: {},+ monitoringShowTelemetry: false,+ setMonitoringShowTelemetry: vi.fn(),+ }),+}));+const tabs: InstanceTab[] = [{id: "tab_alpha",@@ -23,7 +36,6 @@ describe("InstanceTabsPanel", () => {it("auto-selects the first tab and shows its details", () => {render(<InstanceTabsPanel tabs={tabs} />);- // Find heading for first tab titleconst titleHeading = screen.getByRole("heading", { name: "Alpha Tab" });const detailPanel = titleHeading.closest(".rounded-xl") as HTMLElement;@@ -31,7 +43,6 @@ describe("InstanceTabsPanel", () => {within(detailPanel).getByText("https://example.com/alpha"),).toBeInTheDocument();- // IdBadge will show "ID" instead of "alpha" (shortened tab_alpha)expect(within(detailPanel).getByText("ID")).toBeInTheDocument();});@@ -39,11 +50,9 @@ describe("InstanceTabsPanel", () => {const user = userEvent.setup();render(<InstanceTabsPanel tabs={tabs} />);- // Select Beta tab from listconst betaTabItem = screen.getByRole("button", { name: /^Beta Tab$/ });await user.click(betaTabItem);- // Find heading for beta tab titleconst titleHeading = screen.getByRole("heading", { name: "Beta Tab" });const detailPanel = titleHeading.closest(".rounded-xl") as HTMLElement;diff --git a/dashboard/src/tabs/SelectedTabPanel.tsx b/dashboard/src/tabs/SelectedTabPanel.tsxindex 35c26362..c2cc1a47 100644--- a/dashboard/src/tabs/SelectedTabPanel.tsx+++ b/dashboard/src/tabs/SelectedTabPanel.tsx@@ -81,9 +81,7 @@ export default function SelectedTabPanel({ selectedTab, instanceId }: Props) {{activeSubTab === "console" && (<ConsolePanel tabId={selectedTab.id} />)}- {activeSubTab === "errors" && (- <ErrorsPanel tabId={selectedTab.id} />- )}+ {activeSubTab === "errors" && <ErrorsPanel tabId={selectedTab.id} />}</TabsLayout></div></div>diff --git a/dashboard/src/tabs/TabBar.tsx b/dashboard/src/tabs/TabBar.tsxindex 7ebe2b33..10b8b94c 100644--- a/dashboard/src/tabs/TabBar.tsx+++ b/dashboard/src/tabs/TabBar.tsx@@ -115,7 +115,9 @@ export default function TabBar({<div className="ml-auto mb-0.5 flex shrink-0 items-center gap-0.5 self-center"><buttontype="button"- onClick={() => (onSetTelemetry ? onSetTelemetry(false) : onToggleTelemetry?.())}+ onClick={() =>+ onSetTelemetry ? onSetTelemetry(false) : onToggleTelemetry?.()+ }title="Tabs"className={`shrink-0 rounded p-1.5 transition-colors ${!telemetryActive@@ -140,7 +142,9 @@ export default function TabBar({</button><buttontype="button"- onClick={() => (onSetTelemetry ? onSetTelemetry(true) : onToggleTelemetry?.())}+ onClick={() =>+ onSetTelemetry ? onSetTelemetry(true) : onToggleTelemetry?.()+ }title="Monitoring"className={`mr-1 shrink-0 rounded p-1.5 transition-colors ${telemetryActivediff --git a/internal/activity/activity.go b/internal/activity/activity.goindex 3c555512..8a119b2a 100644--- a/internal/activity/activity.go+++ b/internal/activity/activity.go@@ -415,14 +415,6 @@ func isActivityLogFile(name string) bool {return name != "events.jsonl" && strings.HasPrefix(name, "events-") && strings.HasSuffix(name, ".jsonl")}-func isPrimaryDailyActivityLog(name string) bool {- if !isActivityLogFile(name) {- return false- }- middle := strings.TrimSuffix(strings.TrimPrefix(name, "events-"), ".jsonl")- return len(middle) == len(time.DateOnly)-}-func isSourceLogFile(name, source string) bool {prefix := "events-" + source + "-"return strings.HasPrefix(name, prefix)diff --git a/internal/config/config_types.go b/internal/config/config_types.goindex 8983a484..3782aa46 100644--- a/internal/config/config_types.go+++ b/internal/config/config_types.go@@ -4,7 +4,6 @@ import "time"const defaultPort = "9867"-// RuntimeConfig holds all runtime settings used throughout the application.// This is the single source of truth for configuration at runtime.type RuntimeConfig struct {