Rewrite virtual office with pixel-art characters and compact layout
Replaced generic bot icons with CSS pixel-art people — colored head, shirt body, and legs, each agent with a stable color derived from their name. Layout is now compact flex-wrap (42px per agent) instead of one agent per row. Sidebar narrowed to 172px. Tooltip anchored to right edge to prevent clipping. Department floors use the app's panel-2 background for a clean integrated look.
This commit is contained in:
1 parent
7ff8e4becd
commit
e37faf1a2e
3 files changed
+102
-173
No files matched your search
@@ -174,7 +174,7 @@ export function Shell({
|
|||||||
{officeOpen && (
|
{officeOpen && (
|
||||||
<aside className="office-sidebar">
|
<aside className="office-sidebar">
|
||||||
<div className="office-sidebar-header">
|
<div className="office-sidebar-header">
|
||||||
<span style={{ fontSize: 12, fontWeight: 600, color: "var(--text-2)" }}>Office</span>
|
<span style={{ fontSize: 11, fontWeight: 600, color: "var(--text-3)" }}>Office</span>
|
||||||
<IconButton icon="x" label="Close office" onClick={() => setOfficeOpen(false)} />
|
<IconButton icon="x" label="Close office" onClick={() => setOfficeOpen(false)} />
|
||||||
</div>
|
</div>
|
||||||
<VirtualOffice
|
<VirtualOffice
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { useState, type CSSProperties } from "react";
|
import { useState } from "react";
|
||||||
import type { AgentRecord, TaskRecord, TaskRunRecord } from "../../../shared/domain";
|
import type { AgentRecord, TaskRecord, TaskRunRecord } from "../../../shared/domain";
|
||||||
import type { ChatPresenceRecord } from "../../../shared/chat-domain";
|
import type { ChatPresenceRecord } from "../../../shared/chat-domain";
|
||||||
import { Avatar } from "./ui";
|
|
||||||
|
|
||||||
interface VirtualOfficeProps {
|
interface VirtualOfficeProps {
|
||||||
agents: AgentRecord[];
|
agents: AgentRecord[];
|
||||||
@@ -11,237 +10,167 @@ interface VirtualOfficeProps {
|
|||||||
orgId: string;
|
orgId: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type PresenceStatus = "active" | "thinking" | "busy" | "idle";
|
type Status = "active" | "thinking" | "busy" | "idle";
|
||||||
|
|
||||||
interface AgentDesk {
|
interface Desk {
|
||||||
agent: AgentRecord;
|
agent: AgentRecord;
|
||||||
status: PresenceStatus;
|
status: Status;
|
||||||
currentTask: string | null;
|
task: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveDesks(props: VirtualOfficeProps): AgentDesk[] {
|
const SKIN = ["#f4c28b", "#e8b472", "#c68e5b", "#a56c3e", "#8b5232"];
|
||||||
|
const SHIRT = ["#5b8dd9", "#d95b7a", "#5bbf6f", "#d9a65b", "#9b6fd9", "#5bc4c4"];
|
||||||
|
|
||||||
|
function stableColor(palette: string[], name: string): string {
|
||||||
|
let h = 0;
|
||||||
|
for (let i = 0; i < name.length; i++) h = (h * 31 + name.charCodeAt(i)) | 0;
|
||||||
|
return palette[Math.abs(h) % palette.length];
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveDesks(props: VirtualOfficeProps): Desk[] {
|
||||||
const { agents, tasks, taskRuns, presence, orgId } = props;
|
const { agents, tasks, taskRuns, presence, orgId } = props;
|
||||||
return agents.filter((a) => a.orgId === orgId).map((agent) => {
|
return agents.filter((a) => a.orgId === orgId).map((agent) => {
|
||||||
const p = presence.find((r) => r.principalType === "agent" && r.principalId === agent.id);
|
const p = presence.find((r) => r.principalType === "agent" && r.principalId === agent.id);
|
||||||
const activeTask = tasks.find((t) => t.orgId === orgId && t.assigneeAgentId === agent.id && t.status === "in_progress");
|
const activeTask = tasks.find((t) => t.orgId === orgId && t.assigneeAgentId === agent.id && t.status === "in_progress");
|
||||||
const running = taskRuns.some((r) => r.agentId === agent.id && r.state === "running");
|
const running = taskRuns.some((r) => r.agentId === agent.id && r.state === "running");
|
||||||
return { agent, status: deriveStatus(p?.status, running), currentTask: activeTask?.title ?? null };
|
let status: Status = "idle";
|
||||||
|
if (running) status = "active";
|
||||||
|
else if (p?.status === "thinking") status = "thinking";
|
||||||
|
else if (p?.status === "waiting_approval" || p?.status === "busy") status = "busy";
|
||||||
|
else if (p?.status === "active" || p?.status === "online") status = "active";
|
||||||
|
return { agent, status, task: activeTask?.title ?? null };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deriveStatus(raw: string | undefined, running: boolean): PresenceStatus {
|
|
||||||
if (running) return "active";
|
|
||||||
if (raw === "thinking") return "thinking";
|
|
||||||
if (raw === "waiting_approval" || raw === "busy") return "busy";
|
|
||||||
if (raw === "active" || raw === "online") return "active";
|
|
||||||
return "idle";
|
|
||||||
}
|
|
||||||
|
|
||||||
const COLOR: Record<PresenceStatus, string> = {
|
|
||||||
active: "#34d399",
|
|
||||||
thinking: "#818cf8",
|
|
||||||
busy: "#fbbf24",
|
|
||||||
idle: "rgba(120,120,120,0.3)",
|
|
||||||
};
|
|
||||||
|
|
||||||
export function VirtualOffice(props: VirtualOfficeProps) {
|
export function VirtualOffice(props: VirtualOfficeProps) {
|
||||||
const desks = resolveDesks(props);
|
const desks = resolveDesks(props);
|
||||||
const [hoveredId, setHoveredId] = useState<string | null>(null);
|
const [hovered, setHovered] = useState<string | null>(null);
|
||||||
|
|
||||||
const floors = new Map<string, AgentDesk[]>();
|
const floors = new Map<string, Desk[]>();
|
||||||
for (const desk of desks) {
|
for (const d of desks) {
|
||||||
const dept = desk.agent.department;
|
const dept = d.agent.department;
|
||||||
if (!floors.has(dept)) floors.set(dept, []);
|
if (!floors.has(dept)) floors.set(dept, []);
|
||||||
floors.get(dept)!.push(desk);
|
floors.get(dept)!.push(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (desks.length === 0) return null;
|
if (desks.length === 0) return null;
|
||||||
|
|
||||||
const floorEntries = [...floors.entries()];
|
|
||||||
const activeCount = desks.filter((d) => d.status === "active" || d.status === "thinking").length;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ padding: "8px 6px", overflowY: "auto", height: "100%" }}>
|
<div style={{ padding: "6px 4px", overflowY: "auto", overflowX: "hidden", height: "100%" }}>
|
||||||
<BuildingHeader total={desks.length} active={activeCount} />
|
{[...floors.entries()].map(([dept, agents]) => (
|
||||||
<div style={buildingFrame}>
|
<div key={dept} style={{ marginBottom: 8 }}>
|
||||||
{floorEntries.map(([dept, deptDesks], index) => (
|
<div style={{ fontSize: 9, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.08em", color: "var(--text-4)", padding: "0 6px 3px" }}>
|
||||||
<Floor
|
{dept}
|
||||||
key={dept}
|
</div>
|
||||||
label={dept}
|
<div style={{
|
||||||
level={floorEntries.length - index}
|
background: "var(--panel-2)",
|
||||||
desks={deptDesks}
|
borderRadius: 8,
|
||||||
hoveredId={hoveredId}
|
padding: "6px 4px",
|
||||||
onHover={setHoveredId}
|
display: "flex",
|
||||||
/>
|
flexWrap: "wrap",
|
||||||
))}
|
gap: 2,
|
||||||
</div>
|
}}>
|
||||||
|
{agents.map((d) => (
|
||||||
|
<PixelDesk key={d.agent.id} desk={d} isHovered={hovered === d.agent.id} onHover={setHovered} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function BuildingHeader({ total, active }: { total: number; active: number }) {
|
function PixelDesk({ desk, isHovered, onHover }: { desk: Desk; isHovered: boolean; onHover: (id: string | null) => void }) {
|
||||||
return (
|
const skin = stableColor(SKIN, desk.agent.name);
|
||||||
<div style={{ display: "flex", alignItems: "center", gap: 6, padding: "0 4px 8px", justifyContent: "space-between" }}>
|
const shirt = stableColor(SHIRT, desk.agent.name + desk.agent.role);
|
||||||
<div style={{ display: "flex", alignItems: "center", gap: 4 }}>
|
const glow = desk.status === "active" || desk.status === "thinking";
|
||||||
<div style={{ width: 6, height: 6, borderRadius: "50%", background: active > 0 ? "#34d399" : "rgba(120,120,120,0.3)" }} />
|
|
||||||
<span style={{ fontSize: 10, color: "var(--text-3)" }}>{active}/{total}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const buildingFrame: CSSProperties = {
|
|
||||||
border: "1px solid rgba(255,255,255,0.06)",
|
|
||||||
borderRadius: 12,
|
|
||||||
overflow: "hidden",
|
|
||||||
background: "rgba(0,0,0,0.08)",
|
|
||||||
};
|
|
||||||
|
|
||||||
function Floor({ label, level, desks, hoveredId, onHover }: {
|
|
||||||
label: string;
|
|
||||||
level: number;
|
|
||||||
desks: AgentDesk[];
|
|
||||||
hoveredId: string | null;
|
|
||||||
onHover: (id: string | null) => void;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<div style={{ borderBottom: "1px solid rgba(255,255,255,0.04)" }}>
|
|
||||||
<div style={{
|
|
||||||
display: "flex",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: 4,
|
|
||||||
padding: "4px 8px 2px",
|
|
||||||
}}>
|
|
||||||
<span style={{ fontSize: 8, fontWeight: 700, color: "var(--text-4)", fontVariantNumeric: "tabular-nums", width: 12 }}>{level}F</span>
|
|
||||||
<span style={{ fontSize: 9, fontWeight: 600, textTransform: "uppercase", letterSpacing: "0.06em", color: "var(--text-4)" }}>{label}</span>
|
|
||||||
</div>
|
|
||||||
<div style={{
|
|
||||||
padding: "4px 6px 8px",
|
|
||||||
display: "flex",
|
|
||||||
flexWrap: "wrap",
|
|
||||||
gap: 3,
|
|
||||||
}}>
|
|
||||||
{desks.map((desk) => (
|
|
||||||
<Workstation key={desk.agent.id} desk={desk} hovered={hoveredId === desk.agent.id} onHover={onHover} />
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Workstation({ desk, hovered, onHover }: { desk: AgentDesk; hovered: boolean; onHover: (id: string | null) => void }) {
|
|
||||||
const color = COLOR[desk.status];
|
|
||||||
const alive = desk.status === "active" || desk.status === "thinking";
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
width: 56,
|
width: 42,
|
||||||
padding: "5px 3px 4px",
|
|
||||||
borderRadius: 8,
|
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
position: "relative",
|
padding: "4px 0 2px",
|
||||||
|
borderRadius: 6,
|
||||||
cursor: "default",
|
cursor: "default",
|
||||||
transition: "background 0.15s",
|
position: "relative",
|
||||||
background: hovered ? "rgba(255,255,255,0.05)" : "transparent",
|
background: isHovered ? "var(--hover)" : "transparent",
|
||||||
}}
|
}}
|
||||||
onMouseEnter={() => onHover(desk.agent.id)}
|
onMouseEnter={() => onHover(desk.agent.id)}
|
||||||
onMouseLeave={() => onHover(null)}
|
onMouseLeave={() => onHover(null)}
|
||||||
>
|
>
|
||||||
{/* Monitor */}
|
{/* Pixel person */}
|
||||||
<div style={{
|
<div style={{ position: "relative", width: 16, height: 24 }}>
|
||||||
width: 24,
|
{/* Head */}
|
||||||
height: 15,
|
<div style={{ width: 8, height: 8, borderRadius: 2, background: skin, margin: "0 auto" }} />
|
||||||
borderRadius: 2,
|
{/* Body */}
|
||||||
border: `1.5px solid ${alive ? color : "rgba(255,255,255,0.08)"}`,
|
<div style={{ width: 12, height: 8, borderRadius: "2px 2px 0 0", background: shirt, margin: "1px auto 0" }} />
|
||||||
marginBottom: 1,
|
{/* Legs */}
|
||||||
position: "relative",
|
<div style={{ display: "flex", justifyContent: "center", gap: 2 }}>
|
||||||
overflow: "hidden",
|
<div style={{ width: 4, height: 6, background: "#555", borderRadius: "0 0 1px 1px" }} />
|
||||||
transition: "border-color 0.2s",
|
<div style={{ width: 4, height: 6, background: "#555", borderRadius: "0 0 1px 1px" }} />
|
||||||
}}>
|
</div>
|
||||||
{alive && <ScreenGlow color={color} />}
|
{/* Status dot */}
|
||||||
</div>
|
|
||||||
{/* Monitor stand */}
|
|
||||||
<div style={{ width: 4, height: 2, background: "rgba(255,255,255,0.06)" }} />
|
|
||||||
<div style={{ width: 10, height: 1, background: "rgba(255,255,255,0.06)", borderRadius: 1, marginBottom: 3 }} />
|
|
||||||
{/* Agent */}
|
|
||||||
<div style={{ position: "relative" }}>
|
|
||||||
<Avatar name={desk.agent.name} size="sm" bot />
|
|
||||||
<div style={{
|
<div style={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
bottom: -1,
|
top: -1,
|
||||||
right: -2,
|
right: -1,
|
||||||
width: 6,
|
width: 5,
|
||||||
height: 6,
|
height: 5,
|
||||||
borderRadius: "50%",
|
borderRadius: "50%",
|
||||||
background: color,
|
background: statusColor(desk.status),
|
||||||
border: "1.5px solid var(--bg)",
|
boxShadow: glow ? `0 0 4px ${statusColor(desk.status)}` : undefined,
|
||||||
transition: "background 0.2s",
|
|
||||||
}} />
|
}} />
|
||||||
</div>
|
</div>
|
||||||
|
{/* Desk surface */}
|
||||||
|
<div style={{ width: 20, height: 3, background: "var(--border)", borderRadius: 1, marginTop: 1 }} />
|
||||||
|
{/* Name */}
|
||||||
<div style={{
|
<div style={{
|
||||||
fontSize: 8,
|
fontSize: 7,
|
||||||
color: "var(--text-3)",
|
color: "var(--text-3)",
|
||||||
marginTop: 2,
|
marginTop: 2,
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
maxWidth: 52,
|
maxWidth: 40,
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
textOverflow: "ellipsis",
|
textOverflow: "ellipsis",
|
||||||
whiteSpace: "nowrap",
|
whiteSpace: "nowrap",
|
||||||
|
lineHeight: 1,
|
||||||
}}>
|
}}>
|
||||||
{desk.agent.name.split(" ")[0]}
|
{desk.agent.name.split(" ")[0]}
|
||||||
</div>
|
</div>
|
||||||
{hovered && <HoverCard desk={desk} />}
|
{isHovered && <Tip desk={desk} />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ScreenGlow({ color }: { color: string }) {
|
function Tip({ desk }: { desk: Desk }) {
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
inset: 0,
|
bottom: "calc(100% + 2px)",
|
||||||
background: `${color}33`,
|
right: 0,
|
||||||
animation: "office-pulse 2s ease-in-out infinite",
|
|
||||||
}}>
|
|
||||||
<div style={{ width: "60%", height: 2, background: `${color}55`, margin: "3px 2px", borderRadius: 1 }} />
|
|
||||||
<div style={{ width: "40%", height: 2, background: `${color}44`, margin: "1px 2px", borderRadius: 1 }} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function HoverCard({ desk }: { desk: AgentDesk }) {
|
|
||||||
const color = COLOR[desk.status];
|
|
||||||
return (
|
|
||||||
<div style={{
|
|
||||||
position: "absolute",
|
|
||||||
bottom: "calc(100% + 4px)",
|
|
||||||
left: "50%",
|
|
||||||
transform: "translateX(-50%)",
|
|
||||||
background: "var(--panel)",
|
background: "var(--panel)",
|
||||||
border: "1px solid var(--border)",
|
border: "1px solid var(--border)",
|
||||||
borderRadius: 8,
|
borderRadius: 6,
|
||||||
padding: "6px 10px",
|
padding: "4px 8px",
|
||||||
zIndex: 30,
|
zIndex: 50,
|
||||||
boxShadow: "0 4px 20px rgba(0,0,0,0.2)",
|
boxShadow: "0 2px 10px rgba(0,0,0,0.15)",
|
||||||
pointerEvents: "none",
|
pointerEvents: "none",
|
||||||
minWidth: 110,
|
whiteSpace: "nowrap",
|
||||||
maxWidth: 190,
|
maxWidth: 180,
|
||||||
}}>
|
}}>
|
||||||
<div style={{ fontSize: 11, fontWeight: 560, color: "var(--text-1)" }}>{desk.agent.name}</div>
|
<div style={{ fontSize: 11, fontWeight: 560, color: "var(--text-1)" }}>{desk.agent.name}</div>
|
||||||
<div style={{ fontSize: 9, color: "var(--text-3)", marginBottom: desk.currentTask ? 3 : 0 }}>{desk.agent.role}</div>
|
<div style={{ fontSize: 9, color: "var(--text-3)" }}>{desk.agent.role}</div>
|
||||||
{desk.currentTask && (
|
{desk.task && <div style={{ fontSize: 9, color: statusColor(desk.status), overflow: "hidden", textOverflow: "ellipsis", marginTop: 2 }}>{desk.task}</div>}
|
||||||
<div style={{
|
|
||||||
fontSize: 9,
|
|
||||||
color,
|
|
||||||
overflow: "hidden",
|
|
||||||
textOverflow: "ellipsis",
|
|
||||||
whiteSpace: "nowrap",
|
|
||||||
}}>
|
|
||||||
{desk.currentTask}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function statusColor(s: Status): string {
|
||||||
|
if (s === "active") return "#34d399";
|
||||||
|
if (s === "thinking") return "#818cf8";
|
||||||
|
if (s === "busy") return "#fbbf24";
|
||||||
|
return "#ccc";
|
||||||
|
}
|
||||||
@@ -370,7 +370,7 @@ a { color: inherit; }
|
|||||||
}
|
}
|
||||||
|
|
||||||
.office-sidebar {
|
.office-sidebar {
|
||||||
width: 220px;
|
width: 172px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@@ -379,12 +379,12 @@ a { color: inherit; }
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.office-sidebar-header {
|
.office-sidebar-header {
|
||||||
height: 48px;
|
height: 40px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 0 var(--sp-3);
|
padding: 0 var(--sp-2) 0 var(--sp-3);
|
||||||
border-bottom: 1px solid var(--border-soft);
|
border-bottom: 1px solid var(--border-soft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user