Skip to content

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

feat: improving profile page in the dashboard

Luigi Agosti716594c71f7e
diff --git a/dashboard/src/components/molecules/ProfileDetailsModal.tsx b/dashboard/src/components/molecules/ProfileDetailsModal.tsx
index 9ae95de6..8a9cf1d7 100644
--- a/dashboard/src/components/molecules/ProfileDetailsModal.tsx
+++ b/dashboard/src/components/molecules/ProfileDetailsModal.tsx
@@ -35,7 +35,7 @@ export default function ProfileDetailsModal({
const [name, setName] = useState("");
const [useWhen, setUseWhen] = useState("");
const [tabs, setTabs] = useState<InstanceTab[]>([]);
- const [logs] = useState(""); // TODO: fetch from /instances/{id}/logs
+ const [logs, setLogs] = useState("");
const [copyFeedback, setCopyFeedback] = useState("");
const isRunning = instance?.status === "running";
@@ -59,6 +59,10 @@ export default function ProfileDetailsModal({
? allTabs.filter((t) => t.instanceId === instance.id)
: [];
setTabs(instanceTabs);
+ const instanceLogs = await api.fetchInstanceLogs(instance.id).catch(
+ () => "",
+ );
+ setLogs(instanceLogs);
} catch (e) {
console.error("Failed to load live data", e);
}
diff --git a/dashboard/src/components/molecules/ProfileDetailsPanel.tsx b/dashboard/src/components/molecules/ProfileDetailsPanel.tsx
new file mode 100644
index 00000000..e5a451f1
--- /dev/null
+++ b/dashboard/src/components/molecules/ProfileDetailsPanel.tsx
@@ -0,0 +1,415 @@
+import { useState, useEffect, useCallback } from "react";
+import { Button, Input, Badge } from "../atoms";
+import ScreencastTile from "./ScreencastTile";
+import TabItem from "./TabItem";
+import type { Profile, Instance, InstanceTab } from "../../generated/types";
+import * as api from "../../services/api";
+
+interface Props {
+ profile: Profile | null;
+ instance?: Instance;
+ onLaunch: () => void;
+ onStop?: () => void;
+ onSave?: (name: string, useWhen: string) => void;
+ onDelete?: () => void;
+}
+
+type TabId = "profile" | "live" | "tabs" | "agents" | "logs";
+
+function MetaBlock({
+ label,
+ children,
+}: {
+ label: string;
+ children: React.ReactNode;
+}) {
+ return (
+ <div className="rounded-xl border border-border-subtle bg-black/10 p-4">
+ <div className="dashboard-section-title mb-2 text-[0.68rem]">{label}</div>
+ {children}
+ </div>
+ );
+}
+
+export default function ProfileDetailsPanel({
+ profile,
+ instance,
+ onLaunch,
+ onStop,
+ onSave,
+ onDelete,
+}: Props) {
+ const [activeTab, setActiveTab] = useState<TabId>("profile");
+ const [name, setName] = useState("");
+ const [useWhen, setUseWhen] = useState("");
+ const [tabs, setTabs] = useState<InstanceTab[]>([]);
+ const [logs, setLogs] = useState("");
+ const [copyFeedback, setCopyFeedback] = useState("");
+
+ const isRunning = instance?.status === "running";
+
+ useEffect(() => {
+ if (profile) {
+ setName(profile.name);
+ setUseWhen(profile.useWhen || "");
+ setCopyFeedback("");
+ } else {
+ setName("");
+ setUseWhen("");
+ setTabs([]);
+ setLogs("");
+ }
+ }, [profile]);
+
+ const loadLiveData = useCallback(async () => {
+ if (!instance?.id) {
+ setTabs([]);
+ setLogs("");
+ return;
+ }
+
+ try {
+ const [instanceTabs, instanceLogs] = await Promise.all([
+ api.fetchInstanceTabs(instance.id).catch(() => []),
+ api.fetchInstanceLogs(instance.id).catch(() => ""),
+ ]);
+ setTabs(instanceTabs);
+ setLogs(instanceLogs);
+ } catch (e) {
+ console.error("Failed to load live data", e);
+ }
+ }, [instance]);
+
+ useEffect(() => {
+ if (activeTab === "live" || activeTab === "tabs" || activeTab === "logs") {
+ loadLiveData();
+ }
+ }, [activeTab, loadLiveData]);
+
+ useEffect(() => {
+ if (activeTab !== "logs" || !instance?.id) {
+ return;
+ }
+
+ return api.subscribeToInstanceLogs(instance.id, {
+ onLogs: (nextLogs) => setLogs(nextLogs),
+ });
+ }, [activeTab, instance?.id]);
+
+ const handleCopyId = async () => {
+ if (!profile?.id) return;
+ try {
+ await navigator.clipboard.writeText(profile.id);
+ setCopyFeedback("Copied");
+ setTimeout(() => setCopyFeedback(""), 2000);
+ } catch {
+ setCopyFeedback("Failed");
+ setTimeout(() => setCopyFeedback(""), 2000);
+ }
+ };
+
+ const handleSave = () => {
+ onSave?.(name, useWhen);
+ };
+
+ const tabClasses = (id: TabId) =>
+ `rounded-sm px-3 py-2 text-sm font-medium transition-colors ${
+ activeTab === id
+ ? "bg-bg-hover text-text-primary"
+ : "text-text-muted hover:bg-bg-hover hover:text-text-secondary"
+ }`;
+
+ if (!profile) {
+ return (
+ <div className="dashboard-panel flex h-full min-h-[28rem] items-center justify-center p-6 text-center text-sm text-text-muted">
+ Select a profile to inspect its instance, live tabs, and logs.
+ </div>
+ );
+ }
+
+ const statusVariant =
+ instance?.status === "running"
+ ? "success"
+ : instance?.status === "error"
+ ? "danger"
+ : "default";
+ const statusLabel =
+ instance?.status === "running"
+ ? `Running on :${instance.port}`
+ : instance?.status === "error"
+ ? "Error"
+ : "Stopped";
+ const accountText = profile.accountEmail || profile.accountName || "";
+ const sizeText = profile.sizeMB ? `${profile.sizeMB.toFixed(0)} MB` : "—";
+ const browserType = instance?.attached
+ ? "Attached via CDP"
+ : instance?.headless
+ ? "Headless"
+ : "Headed";
+ const headerMeta = [
+ profile.chromeProfileName ? `Chrome ${profile.chromeProfileName}` : null,
+ instance?.attached ? "CDP attached" : null,
+ ].filter(Boolean);
+ const hasChanges =
+ name.trim() !== profile.name || useWhen !== (profile.useWhen || "");
+
+ return (
+ <div className="dashboard-panel flex h-full min-h-[28rem] flex-col overflow-hidden">
+ <div className="border-b border-border-subtle px-4 py-3 lg:px-5">
+ <div className="flex flex-col gap-3 xl:flex-row xl:items-center xl:justify-between">
+ <div className="min-w-0">
+ <div className="flex flex-wrap items-center gap-3">
+ <h2 className="truncate text-lg font-semibold text-text-primary">
+ {profile.name}
+ </h2>
+ <Badge variant={statusVariant}>{statusLabel}</Badge>
+ {headerMeta.length > 0 && (
+ <div className="text-sm text-text-muted">
+ {headerMeta.join(" · ")}
+ </div>
+ )}
+ </div>
+ {profile.useWhen?.trim() && (
+ <p className="mt-1 text-sm text-text-muted">{profile.useWhen}</p>
+ )}
+ </div>
+ <div className="flex shrink-0 flex-wrap gap-2">
+ {profile.id && (
+ <Button size="sm" variant="secondary" onClick={handleCopyId}>
+ {copyFeedback || "Copy ID"}
+ </Button>
+ )}
+ <Button size="sm" variant="secondary" onClick={onDelete}>
+ Delete
+ </Button>
+ <Button
+ size="sm"
+ variant="primary"
+ onClick={handleSave}
+ disabled={!name.trim() || !hasChanges}
+ >
+ Save
+ </Button>
+ {isRunning ? (
+ <Button size="sm" variant="danger" onClick={onStop}>
+ Stop
+ </Button>
+ ) : (
+ <Button size="sm" variant="primary" onClick={onLaunch}>
+ Start
+ </Button>
+ )}
+ </div>
+ </div>
+ </div>
+
+ <div className="border-b border-border-subtle px-4 py-3 lg:px-5">
+ <div className="flex flex-wrap gap-2">
+ <button
+ type="button"
+ className={tabClasses("profile")}
+ onClick={() => setActiveTab("profile")}
+ >
+ Profile
+ </button>
+ <button
+ type="button"
+ className={tabClasses("live")}
+ onClick={() => setActiveTab("live")}
+ >
+ Live
+ </button>
+ <button
+ type="button"
+ className={tabClasses("tabs")}
+ onClick={() => setActiveTab("tabs")}
+ >
+ Tabs ({tabs.length})
+ </button>
+ <button
+ type="button"
+ className={tabClasses("logs")}
+ onClick={() => setActiveTab("logs")}
+ >
+ Logs
+ </button>
+ </div>
+ </div>
+
+ <div className="min-h-0 flex-1 overflow-hidden px-4 py-4 lg:px-5">
+ {activeTab === "profile" && (
+ <div className="h-full overflow-auto">
+ <div className="grid gap-4 xl:grid-cols-2">
+ <div className="space-y-4">
+ <Input
+ label="Name"
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ />
+
+ <div>
+ <label className="dashboard-section-title mb-1 block text-[0.68rem]">
+ Use this profile when
+ </label>
+ <textarea
+ value={useWhen}
+ onChange={(e) => setUseWhen(e.target.value)}
+ className="min-h-[180px] w-full resize-y rounded border border-border-subtle bg-bg-elevated px-3 py-2 text-sm text-text-primary"
+ />
+ </div>
+ </div>
+
+ <MetaBlock label="Profile panel">
+ <div className="space-y-3 text-sm text-text-secondary">
+ <div className="flex items-center justify-between gap-3">
+ <span className="dashboard-section-title text-[0.68rem]">
+ Status
+ </span>
+ <span className="text-right">{instance?.status || "stopped"}</span>
+ </div>
+ {instance?.port && (
+ <div className="flex items-center justify-between gap-3">
+ <span className="dashboard-section-title text-[0.68rem]">
+ Port
+ </span>
+ <span className="text-right">{instance.port}</span>
+ </div>
+ )}
+ <div className="flex items-center justify-between gap-3">
+ <span className="dashboard-section-title text-[0.68rem]">
+ Browser
+ </span>
+ <span className="text-right">{browserType}</span>
+ </div>
+ <div className="flex items-center justify-between gap-3">
+ <span className="dashboard-section-title text-[0.68rem]">
+ Size
+ </span>
+ <span className="text-right">{sizeText}</span>
+ </div>
+ {accountText && (
+ <div className="flex items-center justify-between gap-3">
+ <span className="dashboard-section-title text-[0.68rem]">
+ Account
+ </span>
+ <span className="text-right">{accountText}</span>
+ </div>
+ )}
+ {profile.chromeProfileName && (
+ <div className="flex items-center justify-between gap-3">
+ <span className="dashboard-section-title text-[0.68rem]">
+ Identity
+ </span>
+ <span className="text-right">
+ {profile.chromeProfileName}
+ </span>
+ </div>
+ )}
+ {instance?.attached && (
+ <div className="flex items-center justify-between gap-3">
+ <span className="dashboard-section-title text-[0.68rem]">
+ Connection
+ </span>
+ <span className="text-right">CDP attached</span>
+ </div>
+ )}
+ {instance?.cdpUrl && (
+ <div>
+ <div className="dashboard-section-title mb-1 text-[0.68rem]">
+ CDP URL
+ </div>
+ <code className="dashboard-mono block break-all text-xs text-text-secondary">
+ {instance.cdpUrl}
+ </code>
+ </div>
+ )}
+ {profile.path && (
+ <div>
+ <div className="dashboard-section-title mb-1 text-[0.68rem]">
+ Path
+ </div>
+ <code
+ className={`dashboard-mono block break-all text-xs ${
+ profile.pathExists
+ ? "text-text-secondary"
+ : "text-destructive"
+ }`}
+ >
+ {profile.path}
+ {!profile.pathExists && " (not found)"}
+ </code>
+ </div>
+ )}
+ </div>
+ </MetaBlock>
+ </div>
+ </div>
+ )}
+
+ {activeTab === "live" && (
+ <div className="flex h-full min-h-0 flex-col">
+ {isRunning && instance ? (
+ tabs.length === 0 ? (
+ <div className="flex flex-1 items-center justify-center rounded-xl border border-border-subtle bg-black/10 text-sm text-text-muted">
+ No tabs open
+ </div>
+ ) : (
+ <div className="min-h-0 flex-1 overflow-auto">
+ <div className="flex min-h-full items-center justify-center">
+ <div className="grid w-full max-w-6xl gap-3 xl:grid-cols-2">
+ {tabs.map((tab) => (
+ <ScreencastTile
+ key={tab.id}
+ instancePort={instance.port}
+ tabId={tab.id}
+ label={tab.title?.slice(0, 20) || tab.id.slice(0, 8)}
+ url={tab.url}
+ />
+ ))}
+ </div>
+ </div>
+ </div>
+ )
+ ) : (
+ <div className="flex flex-1 items-center justify-center rounded-xl border border-border-subtle bg-black/10 text-sm text-text-muted">
+ Instance not running. Start the profile to see live view.
+ </div>
+ )}
+ </div>
+ )}
+
+ {activeTab === "tabs" && (
+ <div className="flex h-full min-h-0 flex-col">
+ {tabs.length === 0 ? (
+ <div className="flex h-full items-center justify-center rounded-xl border border-border-subtle bg-black/10 px-4 py-6 text-sm text-text-muted">
+ {isRunning ? "No tabs open." : "Instance not running."}
+ </div>
+ ) : (
+ <div className="h-full overflow-auto">
+ <div className="space-y-1">
+ {tabs.map((tab) => (
+ <TabItem key={tab.id} tab={tab} compact />
+ ))}
+ </div>
+ </div>
+ )}
+ </div>
+ )}
+
+ {activeTab === "logs" && (
+ <div className="flex h-full min-h-0 flex-col">
+ {logs ? (
+ <pre className="h-full overflow-auto rounded-xl border border-border-subtle bg-black/10 p-3 font-mono text-[10px] leading-4 text-text-secondary">
+ {logs}
+ </pre>
+ ) : (
+ <div className="flex h-full items-center justify-center rounded-xl border border-border-subtle bg-black/10 px-4 py-6 text-sm text-text-muted">
+ No instance logs available.
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/dashboard/src/components/molecules/index.ts b/dashboard/src/components/molecules/index.ts
index d0a012d4..3edcb099 100644
--- a/dashboard/src/components/molecules/index.ts
+++ b/dashboard/src/components/molecules/index.ts
@@ -1,6 +1,7 @@
export { default as NavBar } from "./NavBar";
export { default as ProfileCard } from "./ProfileCard";
export { default as ProfileDetailsModal } from "./ProfileDetailsModal";
+export { default as ProfileDetailsPanel } from "./ProfileDetailsPanel";
export { default as ScreencastTile } from "./ScreencastTile";
export { default as InstanceCard } from "./InstanceCard";
export { default as InstanceListItem } from "./InstanceListItem";
diff --git a/dashboard/src/pages/ProfilesPage.test.tsx b/dashboard/src/pages/ProfilesPage.test.tsx
new file mode 100644
index 00000000..35359434
--- /dev/null
+++ b/dashboard/src/pages/ProfilesPage.test.tsx
@@ -0,0 +1,138 @@
+import { render, screen, waitFor, within } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { beforeEach, describe, expect, it, vi } from "vitest";
+import ProfilesPage from "./ProfilesPage";
+import { useAppStore } from "../stores/useAppStore";
+import type { Instance, Profile } from "../generated/types";
+
+vi.mock("../services/api", () => ({
+ fetchProfiles: vi.fn(),
+ createProfile: vi.fn(),
+ deleteProfile: vi.fn(),
+ updateProfile: vi.fn(),
+ fetchInstances: vi.fn(),
+ launchInstance: vi.fn(),
+ stopInstance: vi.fn(),
+ fetchInstanceTabs: vi.fn(),
+ fetchInstanceLogs: vi.fn(),
+}));
+
+const profiles: Profile[] = [
+ {
+ id: "prof_alpha",
+ name: "alpha",
+ created: "2026-03-01T10:00:00Z",
+ lastUsed: "2026-03-05T10:00:00Z",
+ diskUsage: 1024,
+ sizeMB: 12,
+ running: false,
+ useWhen: "Use for personal logins",
+ },
+ {
+ id: "prof_beta",
+ name: "beta",
+ created: "2026-03-02T10:00:00Z",
+ lastUsed: "2026-03-06T10:00:00Z",
+ diskUsage: 2048,
+ sizeMB: 24,
+ running: true,
+ accountEmail: "[email protected]",
+ },
+];
+
+const instances: Instance[] = [
+ {
+ id: "inst_beta",
+ profileId: "prof_beta",
+ profileName: "beta",
+ port: "9988",
+ headless: false,
+ status: "running",
+ startTime: "2026-03-06T10:00:00Z",
+ attached: false,
+ },
+];
+
+describe("ProfilesPage", () => {
+ beforeEach(() => {
+ vi.clearAllMocks();
+ useAppStore.setState({
+ profiles,
+ profilesLoading: false,
+ instances,
+ });
+ });
+
+ it("auto-selects the first profile and renders its details", async () => {
+ render(<ProfilesPage />);
+
+ let detailPanel: HTMLElement;
+ await waitFor(() => {
+ detailPanel = screen
+ .getByRole("heading", { name: "alpha" })
+ .closest(".dashboard-panel") as HTMLElement;
+ expect(detailPanel).toBeInTheDocument();
+ });
+
+ detailPanel = screen
+ .getByRole("heading", { name: "alpha" })
+ .closest(".dashboard-panel") as HTMLElement;
+
+ expect(
+ within(detailPanel).getAllByText("Use for personal logins").length,
+ ).toBeGreaterThan(0);
+ expect(
+ within(detailPanel).getByRole("button", { name: "Start" }),
+ ).toBeInTheDocument();
+ });
+
+ it("switches the right detail pane when selecting another profile", async () => {
+ render(<ProfilesPage />);
+
+ await waitFor(() => {
+ expect(
+ screen.getByRole("heading", { name: "alpha" }),
+ ).toBeInTheDocument();
+ });
+
+ await userEvent.click(screen.getByRole("button", { name: /beta/i }));
+
+ const detailPanel = screen
+ .getByRole("heading", { name: "beta" })
+ .closest(".dashboard-panel") as HTMLElement;
+
+ expect(detailPanel).toBeInTheDocument();
+ expect(
+ within(detailPanel).getAllByText("[email protected]").length,
+ ).toBeGreaterThan(0);
+ expect(
+ within(detailPanel).getByText("Running on :9988"),
+ ).toBeInTheDocument();
+ expect(
+ within(detailPanel).getByRole("button", { name: "Stop" }),
+ ).toBeInTheDocument();
+ });
+
+ it("enables save only after profile fields change", async () => {
+ render(<ProfilesPage />);
+
+ await waitFor(() => {
+ expect(
+ screen.getByRole("heading", { name: "alpha" }),
+ ).toBeInTheDocument();
+ });
+
+ const detailPanel = screen
+ .getByRole("heading", { name: "alpha" })
+ .closest(".dashboard-panel") as HTMLElement;
+ const saveButton = within(detailPanel).getByRole("button", { name: "Save" });
+ const nameInput = within(detailPanel).getByDisplayValue("alpha");
+
+ expect(saveButton).toBeDisabled();
+
+ await userEvent.clear(nameInput);
+ await userEvent.type(nameInput, "alpha-updated");
+
+ expect(saveButton).toBeEnabled();
+ });
+});
diff --git a/dashboard/src/pages/ProfilesPage.tsx b/dashboard/src/pages/ProfilesPage.tsx
index d1615708..dbee3bba 100644
--- a/dashboard/src/pages/ProfilesPage.tsx
+++ b/dashboard/src/pages/ProfilesPage.tsx
@@ -1,10 +1,21 @@
import { useEffect, useState, useMemo } from "react";
import { useAppStore } from "../stores/useAppStore";
-import { Toolbar, EmptyState, Button, Modal, Input } from "../components/atoms";
-import { ProfileCard, ProfileDetailsModal } from "../components/molecules";
+import {
+ Toolbar,
+ EmptyState,
+ Button,
+ Modal,
+ Input,
+ Badge,
+} from "../components/atoms";
+import { ProfileDetailsPanel } from "../components/molecules";
import * as api from "../services/api";
import type { LaunchInstanceRequest, Profile } from "../generated/types";
+function getProfileKey(profile: Profile) {
+ return profile.id || profile.name;
+}
+
export default function ProfilesPage() {
const {
profiles,
@@ -16,7 +27,9 @@ export default function ProfilesPage() {
} = useAppStore();
const [showCreate, setShowCreate] = useState(false);
const [showLaunch, setShowLaunch] = useState<string | null>(null);
- const [showDetails, setShowDetails] = useState<Profile | null>(null);
+ const [selectedProfileKey, setSelectedProfileKey] = useState<string | null>(
+ null,
+ );
// Create form
const [createName, setCreateName] = useState("");
@@ -30,11 +43,21 @@ export default function ProfilesPage() {
const [launchLoading, setLaunchLoading] = useState(false);
const [copyFeedback, setCopyFeedback] = useState("");
- const loadProfiles = async () => {
+ const loadProfiles = async (preferredProfileKey?: string) => {
setProfilesLoading(true);
try {
const data = await api.fetchProfiles();
setProfiles(data);
+ if (preferredProfileKey) {
+ const preferred = data.find(
+ (profile) =>
+ getProfileKey(profile) === preferredProfileKey ||
+ profile.name === preferredProfileKey,
+ );
+ if (preferred) {
+ setSelectedProfileKey(getProfileKey(preferred));
+ }
+ }
} catch (e) {
console.error("Failed to load profiles", e);
} finally {
@@ -53,7 +76,7 @@ export default function ProfilesPage() {
const handleCreate = async () => {
if (!createName.trim()) return;
try {
- await api.createProfile({
+ const created = await api.createProfile({
name: createName.trim(),
useWhen: createUseWhen.trim() || undefined,
});
@@ -61,7 +84,7 @@ export default function ProfilesPage() {
setCreateName("");
setCreateUseWhen("");
setCreateSource("");
- loadProfiles();
+ loadProfiles(created.id || created.name);
} catch (e) {
console.error("Failed to create profile", e);
}
@@ -108,10 +131,10 @@ export default function ProfilesPage() {
};
const handleDelete = async () => {
- if (!showDetails?.id) return;
+ if (!selectedProfile?.id) return;
try {
- await api.deleteProfile(showDetails.id);
- setShowDetails(null);
+ await api.deleteProfile(selectedProfile.id);
+ setSelectedProfileKey(null);
loadProfiles();
} catch (e) {
console.error("Failed to delete profile", e);
@@ -119,14 +142,13 @@ export default function ProfilesPage() {
};
const handleSave = async (name: string, useWhen: string) => {
- if (!showDetails?.id) return;
+ if (!selectedProfile?.id) return;
try {
- await api.updateProfile(showDetails.id, {
- name: name !== showDetails.name ? name : undefined,
- useWhen: useWhen !== showDetails.useWhen ? useWhen : undefined,
+ const updated = await api.updateProfile(selectedProfile.id, {
+ name: name !== selectedProfile.name ? name : undefined,
+ useWhen: useWhen !== selectedProfile.useWhen ? useWhen : undefined,
});
- setShowDetails(null);
- loadProfiles();
+ loadProfiles(updated.id || selectedProfile.id);
} catch (e) {
console.error("Failed to update profile", e);
}
@@ -158,6 +180,26 @@ export default function ProfilesPage() {
};
const instanceByProfile = new Map(instances.map((i) => [i.profileName, i]));
+ const selectedProfile =
+ profiles.find((profile) => getProfileKey(profile) === selectedProfileKey) ||
+ null;
+ const runningProfiles = instances.filter(
+ (instance) => instance.status === "running",
+ ).length;
+
+ useEffect(() => {
+ if (profiles.length === 0) {
+ setSelectedProfileKey(null);
+ return;
+ }
+
+ if (
+ !selectedProfileKey ||
+ !profiles.some((profile) => getProfileKey(profile) === selectedProfileKey)
+ ) {
+ setSelectedProfileKey(getProfileKey(profiles[0]));
+ }
+ }, [profiles, selectedProfileKey]);
return (
<div className="flex h-full flex-col">
@@ -173,8 +215,8 @@ export default function ProfilesPage() {
]}
/>
- <div className="flex-1 overflow-auto p-4">
- <div className="mx-auto max-w-2xl">
+ <div className="flex flex-1 flex-col overflow-hidden p-4 lg:p-6">
+ <div className="h-full">
{profilesLoading && profiles.length === 0 ? (
<div className="flex items-center justify-center py-16 text-text-muted">
Loading profiles...
@@ -190,17 +232,96 @@ export default function ProfilesPage() {
}
/>
) : (
- <div className="grid gap-4 grid-cols-1 sm:grid-cols-2">
- {profiles.map((p) => (
- <ProfileCard
- key={p.name}
- profile={p}
- instance={instanceByProfile.get(p.name)}
- onLaunch={() => setShowLaunch(p.name)}
- onStop={() => handleStop(p.name)}
- onDetails={() => setShowDetails(p)}
+ <div className="flex h-full min-h-0 flex-col gap-4 lg:flex-row">
+ <div className="dashboard-panel flex max-h-[22rem] w-full shrink-0 flex-col overflow-hidden lg:max-h-none lg:w-80">
+ <div className="border-b border-border-subtle px-4 py-3">
+ <div className="dashboard-section-label mb-1">Profiles</div>
+ <div className="flex items-center justify-between gap-3">
+ <h3 className="text-sm font-semibold text-text-secondary">
+ Profiles ({profiles.length})
+ </h3>
+ <Badge variant={runningProfiles > 0 ? "success" : "default"}>
+ {runningProfiles} running
+ </Badge>
+ </div>
+ </div>
+
+ <div className="flex-1 overflow-auto p-2">
+ <div className="space-y-2">
+ {profiles.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 rounded-2xl border px-4 py-3 text-left transition ${
+ isSelected
+ ? "dashboard-panel-selected border-primary"
+ : "dashboard-panel-hover border-border-subtle bg-black/10"
+ }`}
+ >
+ <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>
+ </div>
+
+ {profile.useWhen && (
+ <div className="mt-3 line-clamp-2 text-xs leading-5 text-text-secondary">
+ {profile.useWhen}
+ </div>
+ )}
+ </button>
+ );
+ })}
+ </div>
+ </div>
+ </div>
+
+ <div className="min-h-0 min-w-0 flex-1">
+ <ProfileDetailsPanel
+ profile={selectedProfile}
+ instance={
+ selectedProfile
+ ? instanceByProfile.get(selectedProfile.name)
+ : undefined
+ }
+ onLaunch={() =>
+ selectedProfile && setShowLaunch(selectedProfile.name)
+ }
+ onStop={() =>
+ selectedProfile && handleStop(selectedProfile.name)
+ }
+ onSave={handleSave}
+ onDelete={handleDelete}
/>
- ))}
+ </div>
</div>
)}
</div>
@@ -327,16 +448,6 @@ export default function ProfilesPage() {
</div>
</Modal>
- {/* Profile Details Modal */}
- <ProfileDetailsModal
- profile={showDetails}
- instance={
- showDetails ? instanceByProfile.get(showDetails.name) : undefined
- }
- onClose={() => setShowDetails(null)}
- onSave={handleSave}
- onDelete={handleDelete}
- />
</div>
);
}
diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.ts
index de29a23b..a78f7a8b 100644
--- a/dashboard/src/services/api.ts
+++ b/dashboard/src/services/api.ts
@@ -63,6 +63,36 @@ async function request<T>(
return res.json();
}
+async function requestText(
+ url: string,
+ options?: RequestInit,
+ meta?: RequestMeta,
+): Promise<string> {
+ const headers = new Headers(options?.headers ?? {});
+ const token = meta?.authToken?.trim() || getStoredAuthToken();
+ if (token) {
+ headers.set("Authorization", `Bearer ${token}`);
+ }
+
+ const res = await fetch(BASE + url, {
+ ...options,
+ headers,
+ });
+ if (!res.ok) {
+ const err = await res.json().catch(() => ({ error: res.statusText }));
+ if (
+ res.status === 401 &&
+ !meta?.suppressAuthRedirect &&
+ typeof window !== "undefined"
+ ) {
+ window.localStorage.removeItem("pinchtab.auth.token");
+ dispatchAuthRequired(err.code || "unauthorized");
+ }
+ throw new Error(err.error || "Request failed");
+ }
+ return res.text();
+}
+
// Profiles — endpoint is /profiles (no /api prefix)
export async function fetchProfiles(): Promise<Profile[]> {
return request<Profile[]>("/profiles");
@@ -132,6 +162,41 @@ export async function fetchInstanceTabs(id: string): Promise<InstanceTab[]> {
return request<InstanceTab[]>(`/instances/${encodeURIComponent(id)}/tabs`);
}
+export async function fetchInstanceLogs(id: string): Promise<string> {
+ return requestText(`/instances/${encodeURIComponent(id)}/logs`);
+}
+
+export function subscribeToInstanceLogs(
+ id: string,
+ handlers: { onLogs?: (logs: string) => void },
+): () => void {
+ const url = addTokenToUrl(`/instances/${encodeURIComponent(id)}/logs/stream`);
+ const es = new EventSource(url);
+
+ es.addEventListener("log", (e) => {
+ try {
+ const payload = JSON.parse(e.data) as { logs?: string };
+ handlers.onLogs?.(payload.logs || "");
+ } catch {
+ // ignore malformed events
+ }
+ });
+
+ es.onerror = () => {
+ if (!getStoredAuthToken()) {
+ dispatchAuthRequired("missing_token");
+ }
+ };
+
+ const cleanup = () => es.close();
+ window.addEventListener("beforeunload", cleanup);
+
+ return () => {
+ window.removeEventListener("beforeunload", cleanup);
+ es.close();
+ };
+}
+
export async function fetchAllTabs(): Promise<InstanceTab[]> {
return request<InstanceTab[]>("/instances/tabs");
}
diff --git a/internal/orchestrator/orchestrator.go b/internal/orchestrator/orchestrator.go
index cc4c0b79..882c2ce3 100644
--- a/internal/orchestrator/orchestrator.go
+++ b/internal/orchestrator/orchestrator.go
@@ -314,7 +314,7 @@ func (o *Orchestrator) Launch(name, port string, headless bool, extensionPaths [
}
env := mergeEnvWithOverrides(filterEnvWithPrefixes(os.Environ(), "BRIDGE_", "PINCHTAB_"), envOverrides)
- logBuf := newRingBuffer(64 * 1024)
+ logBuf := newRingBuffer(256 * 1024)
slog.Info("starting instance process", "id", instanceID, "profile", name, "port", port)
cmd, err := o.runner.Run(context.Background(), o.binary, []string{"bridge"}, env, logBuf, logBuf)