Skip to content

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

fix: the dashboard Profiles page ignores the quarantined and temporary flags the API sends (PIN-066)

Luigi Agostib4e1a0054e00
diff --git a/dashboard/src/pages/ProfilesPage.test.tsx b/dashboard/src/pages/ProfilesPage.test.tsx
index 0a3a3aa1..fe27372a 100644
--- a/dashboard/src/pages/ProfilesPage.test.tsx
+++ b/dashboard/src/pages/ProfilesPage.test.tsx
@@ -173,3 +173,140 @@ describe("ProfilesPage", () => {
expect(saveButton).toBeEnabled();
});
});
+
+describe("ProfilesPage classification groups", () => {
+ const mixedProfiles: Profile[] = [
+ {
+ id: "prof_user",
+ name: "default",
+ created: "2026-03-01T10:00:00Z",
+ lastUsed: "2026-03-05T10:00:00Z",
+ diskUsage: 4096,
+ sizeMB: 0,
+ running: false,
+ },
+ {
+ // The flag decides, not the string: a profile the user named after the word is
+ // still theirs, and it must not be grouped with the debris.
+ id: "prof_notes",
+ name: "my.quarantine-notes",
+ created: "2026-03-01T10:00:00Z",
+ lastUsed: "2026-03-05T10:00:00Z",
+ diskUsage: 1024,
+ sizeMB: 0,
+ running: false,
+ },
+ {
+ id: "prof_q1",
+ name: "default.quarantine-1700000001",
+ created: "2026-03-01T10:00:00Z",
+ lastUsed: "2026-03-05T10:00:00Z",
+ diskUsage: 1024 * 1024,
+ sizeMB: 1,
+ running: false,
+ quarantined: true,
+ },
+ {
+ id: "prof_q2",
+ name: "default.quarantine-1700000002",
+ created: "2026-03-01T10:00:00Z",
+ lastUsed: "2026-03-05T10:00:00Z",
+ diskUsage: 3 * 1024 * 1024,
+ sizeMB: 3,
+ running: false,
+ quarantined: true,
+ },
+ {
+ id: "prof_tmp",
+ name: "instance-9868",
+ created: "2026-03-01T10:00:00Z",
+ lastUsed: "2026-03-05T10:00:00Z",
+ diskUsage: 512 * 1024,
+ sizeMB: 0,
+ running: false,
+ temporary: true,
+ },
+ ];
+
+ beforeEach(() => {
+ vi.clearAllMocks();
+ useAppStore.setState({
+ profiles: mixedProfiles,
+ profilesLoading: false,
+ instances: [],
+ });
+ });
+
+ function sidebarRowNames() {
+ const sidebar = document.querySelector(
+ ".bg-bg-surface\\/50",
+ ) as HTMLElement;
+ return within(sidebar)
+ .getAllByRole("button")
+ .filter((b) => b.classList.contains("border-b"))
+ .map((b) => b.querySelector(".text-sm.font-semibold")?.textContent ?? "");
+ }
+
+ it("keeps the user's own profiles above the quarantined and temporary groups", () => {
+ renderProfilesPage();
+
+ const names = sidebarRowNames();
+ expect(names.slice(0, 2)).toEqual(["default", "my.quarantine-notes"]);
+ expect(names.indexOf("instance-9868")).toBeGreaterThan(
+ names.indexOf("my.quarantine-notes"),
+ );
+ expect(names.indexOf("default.quarantine-1700000001")).toBeGreaterThan(
+ names.indexOf("instance-9868"),
+ );
+ });
+
+ it("heads each classification group with its count and combined size", () => {
+ renderProfilesPage();
+
+ const quarantined = screen.getByTestId("profile-group-quarantined");
+ expect(quarantined).toHaveTextContent("Quarantined (2)");
+ expect(quarantined).toHaveTextContent("4.0 MB total");
+
+ const temporary = screen.getByTestId("profile-group-temporary");
+ expect(temporary).toHaveTextContent("Temporary (1)");
+ expect(temporary).toHaveTextContent("512.0 KB total");
+ });
+
+ it("marks quarantined and temporary rows and leaves user rows unmarked", () => {
+ renderProfilesPage();
+
+ const rowFor = (name: string) => {
+ const label = screen.getByText(name, {
+ selector: ".text-sm.font-semibold",
+ });
+ return label.closest("button") as HTMLElement;
+ };
+
+ expect(rowFor("default.quarantine-1700000001")).toHaveTextContent(
+ "quarantined",
+ );
+ expect(rowFor("instance-9868")).toHaveTextContent("temporary");
+
+ // The name contains the word and the flag does not: no badge, and no group header
+ // above it either.
+ expect(rowFor("my.quarantine-notes")).not.toHaveTextContent("quarantined");
+ expect(rowFor("default")).not.toHaveTextContent("quarantined");
+ expect(rowFor("default")).not.toHaveTextContent("temporary");
+ });
+
+ it("adds no bulk-delete or cleanup affordance", () => {
+ renderProfilesPage();
+
+ const sidebar = document.querySelector(
+ ".bg-bg-surface\\/50",
+ ) as HTMLElement;
+ for (const label of [
+ /delete all/i,
+ /clean ?up/i,
+ /prune/i,
+ /safe to delete/i,
+ ]) {
+ expect(within(sidebar).queryByText(label)).toBeNull();
+ }
+ });
+});
diff --git a/dashboard/src/pages/ProfilesPage.tsx b/dashboard/src/pages/ProfilesPage.tsx
index e4218cd4..ea2a16cc 100644
--- a/dashboard/src/pages/ProfilesPage.tsx
+++ b/dashboard/src/pages/ProfilesPage.tsx
@@ -1,5 +1,13 @@
import { useState } from "react";
import { EmptyState, Button, Badge } from "../components/atoms";
+import type { Instance, Profile } from "../generated/types";
+import {
+ formatProfileBytes,
+ groupBytes,
+ groupOrder,
+ groupProfiles,
+ type ProfileGroupKind,
+} from "./profileGroups";
import {
CreateProfileModal,
StartInstanceModal,
@@ -7,6 +15,70 @@ import {
import ProfileDetailsPanel from "../profiles/ProfileDetailsPanel";
import { useProfilesController, getProfileKey } from "./useProfilesController";
+const kindBadge: Partial<Record<ProfileGroupKind, string>> = {
+ temporary: "temporary",
+ quarantined: "quarantined",
+};
+
+function ProfileRow({
+ profile,
+ kind,
+ instance,
+ selected,
+ onSelect,
+}: {
+ profile: Profile;
+ kind: ProfileGroupKind;
+ instance?: Instance;
+ selected: boolean;
+ onSelect: () => void;
+}) {
+ const accountText =
+ profile.accountEmail || profile.accountName || "No account";
+ const statusVariant =
+ instance?.status === "running"
+ ? "success"
+ : instance?.status === "error"
+ ? "danger"
+ : "default";
+ const statusLabel =
+ instance?.status === "running"
+ ? `:${instance.port}`
+ : instance?.status === "error"
+ ? "error"
+ : "stopped";
+ const badge = kindBadge[kind];
+
+ return (
+ <button
+ type="button"
+ onClick={onSelect}
+ className={`w-full 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"
+ }`}
+ >
+ <div className="flex items-start justify-between gap-3">
+ <div className="min-w-0">
+ <div className="truncate text-sm font-semibold text-text-primary">
+ {profile.name}
+ </div>
+ <div className="mt-1 text-xs text-text-muted">{accountText}</div>
+ </div>
+ <div className="flex shrink-0 items-center gap-1.5">
+ {badge && <Badge variant="warning">{badge}</Badge>}
+ <Badge variant={statusVariant}>{statusLabel}</Badge>
+ </div>
+ </div>
+
+ {profile.useWhen && (
+ <div className="mt-3 line-clamp-2 text-xs leading-5 text-text-secondary">
+ {profile.useWhen}
+ </div>
+ )}
+ </button>
+ );
+}
+
export default function ProfilesPage() {
const {
profiles,
@@ -24,6 +96,7 @@ export default function ProfilesPage() {
handleSave,
} = useProfilesController();
const [showCreate, setShowCreate] = useState(false);
+ const groups = groupProfiles(orderedProfiles);
return (
<div className="flex h-full flex-col">
@@ -60,62 +133,43 @@ export default function ProfilesPage() {
</div>
<div className="flex-1 overflow-auto">
- <div>
- {orderedProfiles.map((profile) => {
- const instance = instanceByProfile.get(profile.name);
- const isSelected =
- getProfileKey(profile) === selectedProfileKey;
- const accountText =
- profile.accountEmail ||
- profile.accountName ||
- "No account";
- const statusVariant =
- instance?.status === "running"
- ? "success"
- : instance?.status === "error"
- ? "danger"
- : "default";
- const statusLabel =
- instance?.status === "running"
- ? `:${instance.port}`
- : instance?.status === "error"
- ? "error"
- : "stopped";
-
- return (
- <button
- key={getProfileKey(profile)}
- type="button"
- onClick={() =>
- setSelectedProfileKey(getProfileKey(profile))
- }
- className={`w-full border-b border-border-subtle px-3 py-2.5 text-left transition-colors ${
- isSelected
- ? "bg-bg-hover text-text-primary"
- : "hover:bg-bg-hover/50"
- }`}
- >
- <div className="flex items-start justify-between gap-3">
- <div className="min-w-0">
- <div className="truncate text-sm font-semibold text-text-primary">
- {profile.name}
- </div>
- <div className="mt-1 text-xs text-text-muted">
- {accountText}
- </div>
- </div>
- <Badge variant={statusVariant}>{statusLabel}</Badge>
+ {groupOrder.map(({ kind, label }) => {
+ const rows = groups[kind];
+ if (rows.length === 0) {
+ return null;
+ }
+ return (
+ <div key={kind}>
+ {kind !== "user" && (
+ <div
+ className="flex items-baseline justify-between border-b border-border-subtle bg-bg-surface px-3 py-1.5 text-xs text-text-muted"
+ data-testid={`profile-group-${kind}`}
+ >
+ <span className="font-medium uppercase tracking-[0.08em]">
+ {label} ({rows.length})
+ </span>
+ <span>
+ {formatProfileBytes(groupBytes(rows))} total
+ </span>
</div>
-
- {profile.useWhen && (
- <div className="mt-3 line-clamp-2 text-xs leading-5 text-text-secondary">
- {profile.useWhen}
- </div>
- )}
- </button>
- );
- })}
- </div>
+ )}
+ {rows.map((profile) => (
+ <ProfileRow
+ key={getProfileKey(profile)}
+ profile={profile}
+ kind={kind}
+ instance={instanceByProfile.get(profile.name)}
+ selected={
+ getProfileKey(profile) === selectedProfileKey
+ }
+ onSelect={() =>
+ setSelectedProfileKey(getProfileKey(profile))
+ }
+ />
+ ))}
+ </div>
+ );
+ })}
</div>
</div>
diff --git a/dashboard/src/pages/profileGroups.test.ts b/dashboard/src/pages/profileGroups.test.ts
new file mode 100644
index 00000000..cd57f79c
--- /dev/null
+++ b/dashboard/src/pages/profileGroups.test.ts
@@ -0,0 +1,40 @@
+import { describe, expect, it } from "vitest";
+import type { Profile } from "../generated/types";
+import { formatProfileBytes, groupBytes, groupProfiles } from "./profileGroups";
+
+describe("profile grouping helpers", () => {
+ it("groups on the flags rather than the name", () => {
+ const groups = groupProfiles([
+ { name: "default", running: false } as Profile,
+ { name: "looks.quarantine-1700000000", running: false } as Profile,
+ { name: "real", running: false, quarantined: true } as Profile,
+ { name: "inst", running: false, temporary: true } as Profile,
+ ]);
+
+ expect(groups.user.map((p) => p.name)).toEqual([
+ "default",
+ "looks.quarantine-1700000000",
+ ]);
+ expect(groups.quarantined.map((p) => p.name)).toEqual(["real"]);
+ expect(groups.temporary.map((p) => p.name)).toEqual(["inst"]);
+ });
+
+ it("formats bytes the way the CLI does", () => {
+ expect(formatProfileBytes(512)).toBe("512 B");
+ expect(formatProfileBytes(1024)).toBe("1.0 KB");
+ expect(formatProfileBytes(4 * 1024 * 1024)).toBe("4.0 MB");
+ expect(formatProfileBytes(2 * 1024 * 1024 * 1024)).toBe("2.0 GB");
+ });
+});
+
+describe("groupBytes", () => {
+ it("sums diskUsage, the field the CLI totals", () => {
+ expect(
+ groupBytes([
+ { name: "a", running: false, diskUsage: 1024, sizeMB: 99 } as Profile,
+ { name: "b", running: false, diskUsage: 2048, sizeMB: 99 } as Profile,
+ { name: "c", running: false } as Profile,
+ ]),
+ ).toBe(3072);
+ });
+});
diff --git a/dashboard/src/pages/profileGroups.ts b/dashboard/src/pages/profileGroups.ts
new file mode 100644
index 00000000..da283f30
--- /dev/null
+++ b/dashboard/src/pages/profileGroups.ts
@@ -0,0 +1,62 @@
+import type { Profile } from "../generated/types";
+
+export type ProfileGroupKind = "user" | "temporary" | "quarantined";
+
+// groupOrder puts the operator's own profiles first, so quarantine debris and ephemeral
+// instance directories can never push them out of view — the rows someone made are at the
+// top whether there are ten quarantined siblings or none.
+export const groupOrder: { kind: ProfileGroupKind; label: string }[] = [
+ { kind: "user", label: "Profiles" },
+ { kind: "temporary", label: "Temporary" },
+ { kind: "quarantined", label: "Quarantined" },
+];
+
+// groupProfiles splits the listing on the FLAGS the API sends, never on the name. A profile
+// a user called "my.quarantine-notes" is theirs; a directory quarantine renamed aside is
+// not, and only the server can tell them apart.
+export function groupProfiles(
+ profiles: Profile[],
+): Record<ProfileGroupKind, Profile[]> {
+ const groups: Record<ProfileGroupKind, Profile[]> = {
+ user: [],
+ temporary: [],
+ quarantined: [],
+ };
+ profiles.forEach((profile) => {
+ if (profile.quarantined) {
+ groups.quarantined.push(profile);
+ return;
+ }
+ if (profile.temporary) {
+ groups.temporary.push(profile);
+ return;
+ }
+ groups.user.push(profile);
+ });
+ return groups;
+}
+
+// groupBytes sums diskUsage, the same field `pinchtab profiles` totals, so the two surfaces
+// cannot report different sizes for one set of directories.
+export function groupBytes(profiles: Profile[]): number {
+ return profiles.reduce(
+ (total, profile) => total + (profile.diskUsage ?? 0),
+ 0,
+ );
+}
+
+// formatProfileBytes mirrors the CLI's own byte formatting: 1024 units, one decimal above a
+// kilobyte, so the same directory reads the same way in both places.
+export function formatProfileBytes(bytes: number): string {
+ if (bytes < 1024) {
+ return `${bytes} B`;
+ }
+ const units = ["KB", "MB", "GB", "TB", "PB"];
+ let value = bytes / 1024;
+ let unit = 0;
+ while (value >= 1024 && unit < units.length - 1) {
+ value /= 1024;
+ unit += 1;
+ }
+ return `${value.toFixed(1)} ${units[unit]}`;
+}
diff --git a/internal/profiles/handlers.go b/internal/profiles/handlers.go
index 7e83e6f3..ef810182 100644
--- a/internal/profiles/handlers.go
+++ b/internal/profiles/handlers.go
@@ -23,6 +23,7 @@ type profileResponse struct {
SizeMB float64 `json:"sizeMB"`
Running bool `json:"running"`
Quarantined bool `json:"quarantined"`
+ Temporary bool `json:"temporary"`
Source string `json:"source"`
ChromeProfileName string `json:"chromeProfileName"`
AccountEmail string `json:"accountEmail"`
@@ -44,6 +45,7 @@ func newProfileResponse(p bridge.ProfileInfo) profileResponse {
SizeMB: float64(p.DiskUsage) / (1024 * 1024),
Running: p.Running,
Quarantined: p.Quarantined,
+ Temporary: p.Temporary,
Source: p.Source,
ChromeProfileName: p.ChromeProfileName,
AccountEmail: p.AccountEmail,
@@ -89,19 +91,20 @@ func (pm *ProfileManager) handleList(w http.ResponseWriter, r *http.Request) {
return
}
+ // One shape for both branches. all=true used to serve bridge.ProfileInfo directly, so
+ // the only listing that CAN contain a temporary profile was also the only one missing
+ // the fields the response type declares (sizeMB among them) — which is how a client
+ // reading `temporary` could never see it: absent from the filtered branch by design,
+ // and absent from the response shape in the other.
showAll := r.URL.Query().Get("all") == "true"
- if !showAll {
- filtered := []profileResponse{}
- for _, p := range profiles {
- if !p.Temporary {
- filtered = append(filtered, newProfileResponse(p))
- }
+ out := []profileResponse{}
+ for _, p := range profiles {
+ if !showAll && p.Temporary {
+ continue
}
- httpx.JSON(w, 200, filtered)
- return
+ out = append(out, newProfileResponse(p))
}
-
- httpx.JSON(w, 200, profiles)
+ httpx.JSON(w, 200, out)
}
func (pm *ProfileManager) handleCreate(w http.ResponseWriter, r *http.Request) {
diff --git a/internal/profiles/handlers_list_test.go b/internal/profiles/handlers_list_test.go
new file mode 100644
index 00000000..409cedc9
--- /dev/null
+++ b/internal/profiles/handlers_list_test.go
@@ -0,0 +1,117 @@
+package profiles
+
+import (
+ "encoding/json"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "path/filepath"
+ "testing"
+
+ "github.com/pinchtab/pinchtab/internal/bridge"
+)
+
+func writeListedProfile(t *testing.T, baseDir, name string) {
+ t.Helper()
+
+ if err := os.MkdirAll(filepath.Join(baseDir, name, "Default"), 0o700); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func listProfiles(t *testing.T, pm *ProfileManager, query string) []map[string]any {
+ t.Helper()
+
+ mux := http.NewServeMux()
+ pm.RegisterHandlers(mux)
+
+ rec := httptest.NewRecorder()
+ mux.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/profiles"+query, nil))
+ if rec.Code != http.StatusOK {
+ t.Fatalf("GET /profiles%s = %d, want 200: %s", query, rec.Code, rec.Body.String())
+ }
+
+ var listed []map[string]any
+ if err := json.Unmarshal(rec.Body.Bytes(), &listed); err != nil {
+ t.Fatalf("response is not a JSON array (%v): %s", err, rec.Body.String())
+ }
+ return listed
+}
+
+func findListed(listed []map[string]any, name string) map[string]any {
+ for _, entry := range listed {
+ if entry["name"] == name {
+ return entry
+ }
+ }
+ return nil
+}
+
+// The classifications the API computes have to reach the wire, or a client reading them
+// gets undefined for ever. quarantined already did; temporary did not — the response type
+// had no such field, and the only listing that can contain a temporary profile served a
+// different struct entirely.
+func TestProfileListingServesBothClassificationFlags(t *testing.T) {
+ baseDir := t.TempDir()
+ writeListedProfile(t, baseDir, "default")
+ writeListedProfile(t, baseDir, "instance-9868")
+ writeListedProfile(t, baseDir, "default.quarantine-1700000001")
+ pm := NewProfileManager(baseDir)
+
+ all := listProfiles(t, pm, "?all=true")
+
+ temporary := findListed(all, "instance-9868")
+ if temporary == nil {
+ t.Fatalf("all=true listing omitted the instance profile: %v", all)
+ }
+ if temporary["temporary"] != true {
+ t.Errorf("instance profile temporary = %v, want true", temporary["temporary"])
+ }
+ if _, ok := temporary["sizeMB"]; !ok {
+ t.Errorf("instance profile is served in a different shape from the rest: %v", temporary)
+ }
+
+ quarantined := findListed(all, "default.quarantine-1700000001")
+ if quarantined == nil {
+ t.Fatalf("all=true listing omitted the quarantined profile: %v", all)
+ }
+ if quarantined["quarantined"] != true {
+ t.Errorf("quarantined profile quarantined = %v, want true", quarantined["quarantined"])
+ }
+ if !bridge.IsQuarantinedProfileDir("default.quarantine-1700000001") {
+ t.Error("the fixture name is not one the quarantine predicate recognises, so this row proves nothing")
+ }
+
+ user := findListed(all, "default")
+ if user == nil {
+ t.Fatalf("all=true listing omitted the user profile: %v", all)
+ }
+ if user["temporary"] != false || user["quarantined"] != false {
+ t.Errorf("user profile flags = temporary %v / quarantined %v, want both false", user["temporary"], user["quarantined"])
+ }
+}
+
+// The default listing still hides temporary profiles, which is why the flag is dormant for
+// the dashboard until a caller asks for all=true. Stated as a test so the filter is a
+// recorded decision rather than a surprise to the next reader of the UI code.
+func TestDefaultProfileListingStillHidesTemporaryProfilesButKeepsQuarantined(t *testing.T) {
+ baseDir := t.TempDir()
+ writeListedProfile(t, baseDir, "default")
+ writeListedProfile(t, baseDir, "instance-9868")
+ writeListedProfile(t, baseDir, "default.quarantine-1700000001")
+ pm := NewProfileManager(baseDir)
+
+ listed := listProfiles(t, pm, "")
+
+ if findListed(listed, "instance-9868") != nil {
+ t.Errorf("the default listing now includes a temporary profile: %v", listed)
+ }
+ if findListed(listed, "default.quarantine-1700000001") == nil {
+ t.Errorf("the default listing dropped the quarantined profile, which an operator needs to see: %v", listed)
+ }
+ for _, entry := range listed {
+ if _, ok := entry["temporary"]; !ok {
+ t.Errorf("%v is served without the temporary field; the shape must not depend on the query", entry)
+ }
+ }
+}