Skip to content

AI-powered virtual executive team — a single coherent executive persona backed by 8 specialist agents (FastAPI + Next.js).

feat(ui): show plain contact lines on a person's page and name them in the breadcrumb (#481)

Rufus8c8da3a937cf
diff --git a/packages/ui/scripts/personReach.test.mjs b/packages/ui/scripts/personReach.test.mjs
new file mode 100644
index 00000000..7169b71c
--- /dev/null
+++ b/packages/ui/scripts/personReach.test.mjs
@@ -0,0 +1,47 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { availableChannels, onLeaveLine, reachLine } from "../src/lib/personReach.ts";
+
+const base = {
+ email: null,
+ slack_user_id: null,
+ discord_user_id: null,
+ telegram_chat_id: null,
+ preferred_channel: "any",
+ response_sla_hours: 24,
+};
+
+test("a preferred channel is named with the reply time", () => {
+ const p = { ...base, preferred_channel: "discord", discord_user_id: "100000000000000001", response_sla_hours: 12 };
+ assert.equal(reachLine(p), "Reaches them on Discord, replies within 12h");
+});
+
+test("any channel lists what they have, email first", () => {
+ const p = { ...base, email: "[email protected]", telegram_chat_id: "123" };
+ assert.deepEqual(availableChannels(p), ["email", "telegram"]);
+ assert.equal(reachLine(p, { self: true }), "Reaches you by email or Telegram, replies within 24h");
+ const three = { ...p, slack_user_id: "U01" };
+ assert.equal(reachLine(three), "Reaches them by email, Slack or Telegram, replies within 24h");
+});
+
+test("a preferred channel with no id falls back to what they have", () => {
+ const p = { ...base, email: "[email protected]", preferred_channel: "slack" };
+ assert.equal(reachLine(p), "Reaches them by email, replies within 24h");
+});
+
+test("a contact has no reply time", () => {
+ const p = { ...base, email: "[email protected]", preferred_channel: "email" };
+ assert.equal(reachLine(p, { contact: true }), "Reaches them by email");
+});
+
+test("nothing set says so", () => {
+ assert.equal(reachLine(base), "No email or chat app set for them yet");
+});
+
+test("on leave shows a future date and drops a past one", () => {
+ const today = new Date(2026, 9, 15);
+ assert.equal(onLeaveLine("2026-10-24", today), "On leave until 24 Oct");
+ assert.equal(onLeaveLine("2027-01-03", today), "On leave until 3 Jan 2027");
+ assert.equal(onLeaveLine("2026-10-01", today), null);
+ assert.equal(onLeaveLine(null, today), null);
+});
diff --git a/packages/ui/src/app/people/[id]/page.tsx b/packages/ui/src/app/people/[id]/page.tsx
index bc29f5cf..57aa017a 100644
--- a/packages/ui/src/app/people/[id]/page.tsx
+++ b/packages/ui/src/app/people/[id]/page.tsx
@@ -3,7 +3,9 @@
import { useParams, useRouter } from "next/navigation";
import { type FormEvent, type ReactNode, useEffect, useId, useState } from "react";
+import Icon from "@/components/Icon";
import { TeamModeOffer } from "@/components/people/TeamModeOffer";
+import { usePageCrumb } from "@/components/shell/PageCrumb";
import Button from "@/components/ui/Button";
import OverflowMenu from "@/components/ui/OverflowMenu";
import SectionTabs, { sectionPanelProps } from "@/components/ui/SectionTabs";
@@ -29,6 +31,7 @@ import {
} from "@/lib/api";
import { assignNoticeLine } from "@/lib/assignNotice";
import { isContact, shouldOfferTeamMode } from "@/lib/peopleKinds";
+import { onLeaveLine, reachLine } from "@/lib/personReach";
// ---------------------------------------------------------------------------
// Constants
@@ -47,7 +50,13 @@ const ALL_SCOPES = [
{ value: "wildcard", label: "All (wildcard)", hint: "Receives anything no one else is scoped for — usually the principal." },
];
-const CHANNELS = ["any", "slack", "discord", "telegram", "email"];
+const CHANNELS = [
+ { value: "any", label: "Any channel" },
+ { value: "email", label: "Email" },
+ { value: "slack", label: "Slack" },
+ { value: "discord", label: "Discord" },
+ { value: "telegram", label: "Telegram" },
+];
const INPUT_CLS =
"w-full h-11 px-3 rounded-xl bg-surface-input/60 border border-line text-[15px] text-fg placeholder-fg-subtle focus:outline-none focus:border-accent";
@@ -538,8 +547,7 @@ export default function PersonDetailPage() {
const [tab, setTab] = useState<PersonTab>("overview");
const tabsId = useId();
- // Edit-mode disclosure panels
- const [showContact, setShowContact] = useState(false);
+ // Edit mode keeps the chat ids and leave date in a closed Advanced fold.
const [showAdvanced, setShowAdvanced] = useState(false);
// Edit form state — mirrors the person fields we allow editing
@@ -566,18 +574,14 @@ export default function PersonDetailPage() {
.then((p) => {
setPerson(p);
resetForm(p);
- // Auto-open sections that already have data so existing values aren't hidden
- if (p.email || (p.email_aliases?.length ?? 0) > 0 || p.slack_user_id || p.discord_user_id || p.telegram_chat_id || p.preferred_channel !== "any" || p.response_sla_hours !== 24) {
- setShowContact(true);
- }
- if (p.on_leave_until) {
- setShowAdvanced(true);
- }
})
.catch((e) => setError(e instanceof Error ? e.message : "Failed to load"))
.finally(() => setLoading(false));
}, [personId]);
+ // The breadcrumb names the person rather than the id in the URL.
+ usePageCrumb(person?.full_name);
+
// Contacts are outside the team: no approvals, no reply SLA, no
// availability windows, no departments — and nothing to chase.
const contact = person ? isContact(person) : false;
@@ -844,77 +848,87 @@ export default function PersonDetailPage() {
</label>
)}
- {/* Contact & routing */}
- <DisclosureSection
- label="Contact & routing"
- open={showContact}
- onToggle={() => setShowContact((v) => !v)}
- >
- <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
- <div>
- <label className={LABEL_CLS}>
- Preferred channel
- <select
- value={form.preferred_channel}
- onChange={(e) => setForm((f) => ({ ...f, preferred_channel: e.target.value }))}
- className={INPUT_CLS}
- >
- {CHANNELS.map((c) => (
- <option key={c} value={c}>{c}</option>
- ))}
- </select>
- </label>
- <p className={HINT_CLS}>
- Proposals routed to this person are sent via {form.preferred_channel === "any" ? "any available channel" : form.preferred_channel}.
- </p>
- </div>
- {!formContact && (
- <div>
- <label className={LABEL_CLS}>
- Expected reply within
- <div className="flex items-center gap-2">
- <input
- type="number"
- min={1}
- value={form.response_sla_hours}
- onChange={(e) => setForm((f) => ({ ...f, response_sla_hours: e.target.value }))}
- className={`${INPUT_CLS} flex-1 min-w-0`}
- />
- <span className="text-sm text-fg-muted flex-shrink-0">hours</span>
- </div>
- </label>
- <p className={HINT_CLS}>
- Items show as overdue on Home after {form.response_sla_hours || 24}h with no reply.
- </p>
- </div>
- )}
+ <label className={LABEL_CLS}>
+ Email
+ <input
+ type="email"
+ value={form.email}
+ onChange={(e) => setForm((f) => ({ ...f, email: e.target.value }))}
+ className={INPUT_CLS}
+ />
+ </label>
+
+ <label className={LABEL_CLS}>
+ Other addresses
+ <textarea
+ value={form.email_aliases}
+ onChange={(e) => setForm((f) => ({ ...f, email_aliases: e.target.value }))}
+ rows={2}
+ placeholder="[email protected]"
+ className={`${INPUT_CLS} h-auto py-2.5`}
+ />
+ <span className={HINT_CLS}>
+ One per line. Mail from these reaches them, and they can be emailed
+ here. Only the address above signs in.
+ </span>
+ </label>
+
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
+ <div>
+ <label className={LABEL_CLS}>
+ Preferred channel
+ <select
+ value={form.preferred_channel}
+ onChange={(e) => setForm((f) => ({ ...f, preferred_channel: e.target.value }))}
+ className={INPUT_CLS}
+ >
+ {CHANNELS.map((c) => (
+ <option key={c.value} value={c.value}>{c.label}</option>
+ ))}
+ </select>
+ </label>
+ <p className={HINT_CLS}>
+ Proposals routed to this person are sent via {form.preferred_channel === "any" ? "any available channel" : (CHANNELS.find((c) => c.value === form.preferred_channel)?.label ?? form.preferred_channel)}.
+ </p>
+ </div>
+ {!formContact && (
+ <div>
+ <label className={LABEL_CLS}>
+ Expected reply within
+ <div className="flex items-center gap-2">
+ <input
+ type="number"
+ min={1}
+ value={form.response_sla_hours}
+ onChange={(e) => setForm((f) => ({ ...f, response_sla_hours: e.target.value }))}
+ className={`${INPUT_CLS} flex-1 min-w-0`}
+ />
+ <span className="text-sm text-fg-muted flex-shrink-0">hours</span>
+ </div>
+ </label>
+ <p className={HINT_CLS}>
+ Items show as overdue on Home after {form.response_sla_hours || 24}h with no reply.
+ </p>
</div>
+ )}
+ </div>
+ {/* Advanced */}
+ <DisclosureSection
+ label="Advanced"
+ open={showAdvanced}
+ onToggle={() => setShowAdvanced((v) => !v)}
+ >
<label className={LABEL_CLS}>
- Email
+ On leave until
<input
- type="email"
- value={form.email}
- onChange={(e) => setForm((f) => ({ ...f, email: e.target.value }))}
+ type="date"
+ value={form.on_leave_until}
+ onChange={(e) => setForm((f) => ({ ...f, on_leave_until: e.target.value }))}
className={INPUT_CLS}
/>
</label>
- <label className={LABEL_CLS}>
- Other addresses
- <textarea
- value={form.email_aliases}
- onChange={(e) => setForm((f) => ({ ...f, email_aliases: e.target.value }))}
- rows={2}
- placeholder="[email protected]"
- className={`${INPUT_CLS} h-auto py-2.5`}
- />
- <span className={HINT_CLS}>
- One per line. Mail from these reaches them, and they can be emailed
- here — but only the address above signs in.
- </span>
- </label>
-
<label className={LABEL_CLS}>
Slack user ID
<input
@@ -948,43 +962,33 @@ export default function PersonDetailPage() {
/>
</label>
</DisclosureSection>
-
- {/* Advanced */}
- <DisclosureSection
- label="Advanced"
- open={showAdvanced}
- onToggle={() => setShowAdvanced((v) => !v)}
- >
- <label className={LABEL_CLS}>
- On leave until
- <input
- type="date"
- value={form.on_leave_until}
- onChange={(e) => setForm((f) => ({ ...f, on_leave_until: e.target.value }))}
- className={INPUT_CLS}
- />
- </label>
- </DisclosureSection>
</div>
) : (
- <dl className="divide-y divide-line">
+ <ul className="divide-y divide-line">
{[
- ["Kind", contact ? "Contact — outside the team" : "Team member"],
- ["Preferred channel", person.preferred_channel],
- ...(contact ? [] : [["Expected reply within", `${person.response_sla_hours} hours`]]),
- ["Email", person.email ?? "—"],
- ["Other addresses", (person.email_aliases ?? []).join(", ") || "—"],
- ["Slack user ID", person.slack_user_id ?? "—"],
- ["Discord user ID", person.discord_user_id ?? "—"],
- ["Telegram chat ID", person.telegram_chat_id ?? "—"],
- ["On leave until", person.on_leave_until ?? "—"],
- ].map(([label, value]) => (
- <div key={label} className="flex flex-col sm:flex-row sm:items-baseline gap-0.5 sm:gap-4 py-3">
- <dt className="sm:w-48 flex-shrink-0 text-sm text-fg-muted">{label}</dt>
- <dd className="text-[15px] text-fg break-words min-w-0">{value}</dd>
- </div>
+ {
+ icon: "mail" as const,
+ text: person.email ?? "No email",
+ sub: (person.email_aliases ?? []).length > 0 ? `Also ${(person.email_aliases ?? []).join(", ")}` : null,
+ },
+ {
+ icon: "chat" as const,
+ text: reachLine(person, { self: viewerPersonId === personId, contact }),
+ sub: null,
+ },
+ ...(onLeaveLine(person.on_leave_until)
+ ? [{ icon: "pause" as const, text: onLeaveLine(person.on_leave_until) ?? "", sub: null }]
+ : []),
+ ].map((row) => (
+ <li key={row.icon} className="flex items-start gap-3 py-3.5">
+ <Icon name={row.icon} size="w-4 h-4" className="mt-1 text-fg-subtle flex-shrink-0" />
+ <div className="min-w-0">
+ <p className="text-[15px] text-fg break-words">{row.text}</p>
+ {row.sub && <p className="text-sm text-fg-muted break-words">{row.sub}</p>}
+ </div>
+ </li>
))}
- </dl>
+ </ul>
)}
</section>
diff --git a/packages/ui/src/components/shell/AppShell.tsx b/packages/ui/src/components/shell/AppShell.tsx
index bf1823da..280578b5 100644
--- a/packages/ui/src/components/shell/AppShell.tsx
+++ b/packages/ui/src/components/shell/AppShell.tsx
@@ -9,6 +9,7 @@ import AskOEPanel from "@/components/askoe/AskOEPanel";
import Icon from "@/components/Icon";
import PausedBanner from "@/components/executive/PausedBanner";
import AppSidebar from "@/components/shell/AppSidebar";
+import { PageCrumbProvider, usePageCrumbLabel } from "@/components/shell/PageCrumb";
import {
buildMobilePrimary,
hubForPath,
@@ -128,6 +129,7 @@ export default function AppShell({ children }: { children: React.ReactNode }) {
return (
<AskOEProvider>
+ <PageCrumbProvider>
<div className="flex h-full bg-surface text-fg">
{/* Mobile backdrop */}
{drawerOpen && (
@@ -169,6 +171,7 @@ export default function AppShell({ children }: { children: React.ReactNode }) {
right sheet below. Renders nothing while closed. */}
<AskOEPanel />
</div>
+ </PageCrumbProvider>
</AskOEProvider>
);
}
@@ -182,6 +185,8 @@ function TopBar({
}) {
const { mode, role } = useWorkspace();
const profileLabel = PROFILE_NAV[profileWording(mode, role.role_kind)].label;
+ // A page showing one record names it in place of the id in the URL.
+ const pageLabel = usePageCrumbLabel("/" + segments.join("/"));
// Breadcrumb chain. Only the top-level section (segment[0]) is a real
// route in this app — intermediate segments like `runs` in
// `/jobs/runs/<id>` or `session` in `/audit/session/<id>` are not
@@ -193,7 +198,12 @@ function TopBar({
const href = linkable ? "/" + segment : null;
return {
href,
- label: idx === 0 && segment === "company-profile" ? profileLabel : labelFor(segment),
+ label:
+ idx === segments.length - 1 && idx > 0 && pageLabel
+ ? pageLabel
+ : idx === 0 && segment === "company-profile"
+ ? profileLabel
+ : labelFor(segment),
};
});
// The Advanced pages (Agent Council, Audit log, ...) live at their own
diff --git a/packages/ui/src/components/shell/PageCrumb.tsx b/packages/ui/src/components/shell/PageCrumb.tsx
new file mode 100644
index 00000000..2dcc1046
--- /dev/null
+++ b/packages/ui/src/components/shell/PageCrumb.tsx
@@ -0,0 +1,36 @@
+"use client";
+
+import { usePathname } from "next/navigation";
+import { createContext, useContext, useEffect, useState } from "react";
+
+// A page that shows one record (a person, a department) names it in the
+// breadcrumb instead of the raw id from the URL.
+
+type Crumb = { path: string; label: string } | null;
+
+const PageCrumbContext = createContext<{
+ crumb: Crumb;
+ setCrumb: (c: Crumb) => void;
+}>({ crumb: null, setCrumb: () => undefined });
+
+export function PageCrumbProvider({ children }: { children: React.ReactNode }) {
+ const [crumb, setCrumb] = useState<Crumb>(null);
+ return <PageCrumbContext.Provider value={{ crumb, setCrumb }}>{children}</PageCrumbContext.Provider>;
+}
+
+/** The label set for this path, if a page set one. */
+export function usePageCrumbLabel(pathname: string): string | null {
+ const { crumb } = useContext(PageCrumbContext);
+ return crumb && crumb.path === pathname ? crumb.label : null;
+}
+
+/** Names the last breadcrumb for the current page while it is mounted. */
+export function usePageCrumb(label: string | null | undefined): void {
+ const pathname = usePathname() ?? "";
+ const { setCrumb } = useContext(PageCrumbContext);
+ useEffect(() => {
+ if (!label) return;
+ setCrumb({ path: pathname, label });
+ return () => setCrumb(null);
+ }, [label, pathname, setCrumb]);
+}
diff --git a/packages/ui/src/lib/personReach.ts b/packages/ui/src/lib/personReach.ts
new file mode 100644
index 00000000..3f12a6bc
--- /dev/null
+++ b/packages/ui/src/lib/personReach.ts
@@ -0,0 +1,74 @@
+// The plain lines on a person's Overview: how the Executive reaches them and
+// whether they are away. The ids behind them are edited under Advanced.
+//
+// Type-only imports, so `npm test` can exercise this under
+// `node --experimental-strip-types` (see scripts/personReach.test.mjs).
+
+import type { Person } from "@/lib/api";
+
+type ReachFields = Pick<
+ Person,
+ "email" | "slack_user_id" | "discord_user_id" | "telegram_chat_id" | "preferred_channel" | "response_sla_hours"
+>;
+
+const CHANNEL_NAMES: Record<string, string> = {
+ email: "email",
+ slack: "Slack",
+ discord: "Discord",
+ telegram: "Telegram",
+};
+
+function channelPhrase(channel: string): string {
+ return channel === "email" ? "by email" : `on ${CHANNEL_NAMES[channel] ?? channel}`;
+}
+
+function joinOr(items: string[]): string {
+ if (items.length <= 1) return items.join("");
+ return `${items.slice(0, -1).join(", ")} or ${items[items.length - 1]}`;
+}
+
+/** The channels this person has an address or id for, in a fixed order. */
+export function availableChannels(p: ReachFields): string[] {
+ return [
+ p.email ? "email" : null,
+ p.slack_user_id ? "slack" : null,
+ p.discord_user_id ? "discord" : null,
+ p.telegram_chat_id ? "telegram" : null,
+ ].filter((c): c is string => c !== null);
+}
+
+/**
+ * "Reaches them on Discord, replies within 12h". `self` says "you" on your
+ * own card; a contact has no reply time.
+ */
+export function reachLine(p: ReachFields, opts: { self?: boolean; contact?: boolean } = {}): string {
+ const who = opts.self ? "you" : "them";
+ const have = availableChannels(p);
+ let how: string;
+ // Delivery tries the preferred channel first among those with an address
+ // or id, so a preferred channel with nothing set reads like "any".
+ if (p.preferred_channel && p.preferred_channel !== "any" && have.includes(p.preferred_channel)) {
+ how = `Reaches ${who} ${channelPhrase(p.preferred_channel)}`;
+ } else {
+ if (have.length === 0) return opts.self ? "No email or chat app set for you yet" : "No email or chat app set for them yet";
+ // "by email or Telegram", "on Slack or Discord"
+ const [first, ...rest] = have;
+ how = `Reaches ${who} ${joinOr([channelPhrase(first), ...rest.map((c) => CHANNEL_NAMES[c] ?? c)])}`;
+ }
+ return opts.contact ? how : `${how}, replies within ${p.response_sla_hours}h`;
+}
+
+const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
+
+/** "On leave until 24 Oct" for a YYYY-MM-DD date, with the year when it isn't this year. */
+export function onLeaveLine(date: string | null | undefined, today: Date = new Date()): string | null {
+ const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(date ?? "");
+ if (!m) return null;
+ const [year, month, day] = [Number(m[1]), Number(m[2]), Number(m[3])];
+ const ymd = `${m[1]}-${m[2]}-${m[3]}`;
+ const todayYmd = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, "0")}-${String(today.getDate()).padStart(2, "0")}`;
+ // A date that has passed means they are back.
+ if (ymd < todayYmd) return null;
+ const yearPart = year === today.getFullYear() ? "" : ` ${year}`;
+ return `On leave until ${day} ${MONTHS[month - 1]}${yearPart}`;
+}