Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat([shared-pill-chip-component]): shared <Pill> inline-badge component
Adam Eivy50156d389ccf
diff --git a/client/src/components/ui/Pill.jsx b/client/src/components/ui/Pill.jsxnew file mode 100644index 0000000000..b443db753d--- /dev/null+++ b/client/src/components/ui/Pill.jsx@@ -0,0 +1,66 @@+// Shared inline-label-badge primitive. Replaces the hand-rolled+// `<span className="text-xs … rounded px-2 py-0.5">{label}</span>` spans that+// were copy-pasted across the client (peer relationship/scheme badges, length+// targets, etc.).+//+// Knobs map to real call-site shapes — nothing speculative:+// tone — semantic color trio (text + bg-tint + border). `context` is the+// uppercase no-bg variant; `note` is muted + italic; `bare` emits no+// color so a data-driven badge can supply its own via `className`.+// size — `sm` (text-xs / px-2, default) or `xs` (text-[10px] / px-1.5).+// icon — optional leading lucide glyph (renders inline-flex + gap).+// bordered — default true (the WritersRoom bordered look); pass false for the+// bg-tint-only badges (the border-color utility is stripped so we+// never emit a `border-…` color with no `border` width).+// mono — adds font-mono (host / scheme badges).+// Any extra props (`title`, …) pass through to the span.++const TONES = {+ accent: 'text-port-accent bg-port-accent/10 border-port-accent/20',+ muted: 'text-gray-300 bg-port-bg border-port-border',+ note: 'text-gray-500 bg-port-bg border-port-border italic',+ context: 'text-gray-500 border-port-border uppercase tracking-wide',+ success: 'text-port-success bg-port-success/10 border-port-success/20',+ warning: 'text-port-warning bg-port-warning/10 border-port-warning/20',+ bare: '',+};++const SIZES = {+ sm: { text: 'text-xs', padding: 'px-2 py-0.5', icon: 12 },+ xs: { text: 'text-[10px]', padding: 'px-1.5 py-0.5', icon: 10 },+};++export default function Pill({+ tone = 'muted',+ size = 'sm',+ icon: Icon,+ bordered = true,+ mono = false,+ className = '',+ children,+ ...rest+}) {+ const sz = SIZES[size] || SIZES.sm;+ const toneClass = TONES[tone] ?? TONES.muted;+ // Without a border, drop the border-color utility so we don't ship a color+ // with no width to paint it.+ const color = bordered ? toneClass : toneClass.replace(/\bborder-\S+/g, '');+ const cls = [+ 'inline-flex items-center gap-1 rounded',+ sz.text,+ sz.padding,+ bordered ? 'border' : '',+ mono ? 'font-mono' : '',+ color,+ className,+ ]+ .join(' ')+ .replace(/\s+/g, ' ')+ .trim();+ return (+ <span className={cls} {...rest}>+ {Icon && <Icon size={sz.icon} aria-hidden="true" className="shrink-0" />}+ {children}+ </span>+ );+}diff --git a/client/src/components/ui/Pill.test.jsx b/client/src/components/ui/Pill.test.jsxnew file mode 100644index 0000000000..73208bc5a2--- /dev/null+++ b/client/src/components/ui/Pill.test.jsx@@ -0,0 +1,70 @@+import { describe, it, expect } from 'vitest';+import { render, screen } from '@testing-library/react';+import { Wifi } from 'lucide-react';++import Pill from './Pill';++describe('Pill', () => {+ it('renders children with the default muted tone, sm size, and a border', () => {+ render(<Pill>hello</Pill>);+ const el = screen.getByText('hello');+ expect(el.className).toContain('text-gray-300');+ expect(el.className).toContain('bg-port-bg');+ expect(el.className).toContain('text-xs');+ expect(el.className).toContain('px-2');+ expect(el.className).toContain('border');+ expect(el.className).toContain('border-port-border');+ });++ it('applies the requested tone color trio', () => {+ render(<Pill tone="accent">x</Pill>);+ const el = screen.getByText('x');+ expect(el.className).toContain('text-port-accent');+ expect(el.className).toContain('bg-port-accent/10');+ expect(el.className).toContain('border-port-accent/20');+ });++ it('switches to the compact xs size', () => {+ render(<Pill size="xs">x</Pill>);+ const el = screen.getByText('x');+ expect(el.className).toContain('text-[10px]');+ expect(el.className).toContain('px-1.5');+ });++ it('drops the border AND the border-color utility when bordered is false', () => {+ render(<Pill tone="success" bordered={false}>x</Pill>);+ const el = screen.getByText('x');+ // No standalone `border` class and no leftover border-color.+ expect(el.className.split(/\s+/)).not.toContain('border');+ expect(el.className).not.toContain('border-port-success/20');+ // Text + bg tint survive.+ expect(el.className).toContain('text-port-success');+ expect(el.className).toContain('bg-port-success/10');+ });++ it('renders a leading icon at the size-appropriate dimension', () => {+ const { container } = render(<Pill size="xs" icon={Wifi}>https</Pill>);+ const svg = container.querySelector('svg');+ expect(svg).toBeTruthy();+ expect(svg).toHaveAttribute('width', '10');+ expect(svg).toHaveAttribute('aria-hidden', 'true');+ });++ it('adds font-mono when mono is set', () => {+ render(<Pill mono>code</Pill>);+ expect(screen.getByText('code').className).toContain('font-mono');+ });++ it('emits no color classes for tone="bare" so className can drive colors', () => {+ render(<Pill tone="bare" bordered={false} className="text-green-500 bg-green-900">x</Pill>);+ const el = screen.getByText('x');+ expect(el.className).toContain('text-green-500');+ expect(el.className).toContain('bg-green-900');+ expect(el.className).not.toContain('text-gray-300');+ });++ it('passes through arbitrary props like title', () => {+ render(<Pill title="tooltip">x</Pill>);+ expect(screen.getByText('x')).toHaveAttribute('title', 'tooltip');+ });+});diff --git a/client/src/pages/Instances.jsx b/client/src/pages/Instances.jsxindex fa75e8c9d8..6e1f99ac84 100644--- a/client/src/pages/Instances.jsx+++ b/client/src/pages/Instances.jsx@@ -10,6 +10,7 @@ import {Lock, Globe, Info, Sparkles, Film, Images} from 'lucide-react';import toast from '../components/ui/Toast';+import Pill from '../components/ui/Pill';import socket from '../services/socket';import {getInstances, updateSelfInstance, addPeer, updatePeer,@@ -133,9 +134,9 @@ function TailnetHelpBanner({ tailnetInfo }) {<div className="flex-1 min-w-0"><div className="flex items-center gap-2 flex-wrap"><span className="text-sm font-medium text-white">Tailnet DNS & trusted HTTPS</span>- <span className={`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded ${toneClass} bg-port-bg`}>- <ToneIcon size={10} /> {status.label}- </span>+ <Pill tone="bare" size="xs" bordered={false} icon={ToneIcon} className={`${toneClass} bg-port-bg`}>+ {status.label}+ </Pill></div></div>{collapsed ? <ChevronRight size={14} className="text-gray-500" /> : <ChevronDown size={14} className="text-gray-500" />}@@ -354,23 +355,23 @@ function DirectionBadge({ directions = [] }) {if (hasInbound && hasOutbound) {return (- <span className="inline-flex items-center gap-1 text-[10px] text-port-success bg-port-success/10 rounded px-1.5 py-0.5" title="Bidirectional — we added them and they added us">- <ArrowLeftRight size={10} /> mutual- </span>+ <Pill tone="success" size="xs" bordered={false} icon={ArrowLeftRight} title="Bidirectional — we added them and they added us">+ mutual+ </Pill>);}if (hasOutbound) {return (- <span className="inline-flex items-center gap-1 text-[10px] text-port-accent bg-port-accent/10 rounded px-1.5 py-0.5" title="Outbound — we added this peer">- <ArrowUpRight size={10} /> outbound- </span>+ <Pill tone="accent" size="xs" bordered={false} icon={ArrowUpRight} title="Outbound — we added this peer">+ outbound+ </Pill>);}if (hasInbound) {return (- <span className="inline-flex items-center gap-1 text-[10px] text-port-warning bg-port-warning/10 rounded px-1.5 py-0.5" title="Inbound — this peer added us">- <ArrowDownLeft size={10} /> inbound- </span>+ <Pill tone="warning" size="xs" bordered={false} icon={ArrowDownLeft} title="Inbound — this peer added us">+ inbound+ </Pill>);}return null;@@ -722,13 +723,13 @@ function PeerHostEditor({ peer, onRefresh, tailnetInfo }) {return (<div className="mt-0.5 flex items-center gap-1.5 flex-wrap">{peer.host ? (- <span className="inline-flex items-center gap-1 text-[10px] text-port-success bg-port-success/10 rounded px-1.5 py-0.5 font-mono" title="Requests to this peer use https://<host>">- <Wifi size={10} /> https://{peer.host}- </span>+ <Pill tone="success" size="xs" bordered={false} mono icon={Wifi} title="Requests to this peer use https://<host>">+ https://{peer.host}+ </Pill>) : (- <span className="inline-flex items-center gap-1 text-[10px] text-gray-500 bg-port-bg rounded px-1.5 py-0.5 font-mono" title="Requests use http://<ip> (no DNS set)">+ <Pill tone="bare" size="xs" bordered={false} mono className="text-gray-500 bg-port-bg" title="Requests use http://<ip> (no DNS set)">http only- </span>+ </Pill>)}<buttononClick={startEdit}diff --git a/client/src/pages/WritersRoomGuide.jsx b/client/src/pages/WritersRoomGuide.jsxindex f9bbdd9300..7a3daae7ae 100644--- a/client/src/pages/WritersRoomGuide.jsx+++ b/client/src/pages/WritersRoomGuide.jsx@@ -6,6 +6,7 @@ import {WRITING_PRINCIPLES,PLANNED_ANALYSES,} from '../lib/writingGuide';+import Pill from '../components/ui/Pill';// Writers Room Guide — deep-linkable docs at /writers-room/guide. Renders from// the canonical reference data in lib/writingGuide.js so length targets stay in@@ -13,20 +14,6 @@ import {// <main> is full-width/overflow-hidden (see Layout.jsx isFullWidth), so this// page owns its own vertical scroll.-const PILL_TONES = {- accent: 'text-port-accent bg-port-accent/10 border-port-accent/20',- muted: 'text-gray-300 bg-port-bg border-port-border',- note: 'text-gray-500 bg-port-bg border-port-border italic',-};--function Pill({ tone = 'muted', children }) {- return (- <span className={`text-xs border rounded px-2 py-0.5 ${PILL_TONES[tone]}`}>- {children}- </span>- );-}-function LengthCard({ target }) {// A chapter band with null bounds means the form is read in one sitting; render// it muted/italic to keep it visually distinct from real numeric targets.@@ -38,9 +25,7 @@ function LengthCard({ target }) {<div className="flex items-center justify-between gap-2"><span className="text-sm font-semibold text-white">{target.label}</span>{!target.core && (- <span className="text-[10px] uppercase tracking-wide text-gray-500 border border-port-border rounded px-1.5 py-0.5">- context- </span>+ <Pill tone="context" size="xs">context</Pill>)}</div><div className="flex flex-wrap gap-1.5">