Skip to content

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

refactor([issue-721]): migrate GoalDetailPanel badges to shared <Pill>

[._.]/ Adam Eivye06c64e9a000
diff --git a/client/src/components/goals/GoalDetailPanel.jsx b/client/src/components/goals/GoalDetailPanel.jsx
index a4f9455213..f4da6a67cd 100644
--- a/client/src/components/goals/GoalDetailPanel.jsx
+++ b/client/src/components/goals/GoalDetailPanel.jsx
@@ -7,6 +7,7 @@ import {
CalendarX, RefreshCw, ChevronDown, ChevronRight, ClipboardCheck
} from 'lucide-react';
import * as api from '../../services/api';
+import Pill from '../ui/Pill';
const CATEGORY_CONFIG = {
creative: { label: 'Creative', icon: Lightbulb, color: 'text-purple-400', bg: 'bg-purple-500/20', hex: '#a855f7' },
@@ -381,6 +382,8 @@ export default function GoalDetailPanel({ goal, allGoals, onClose, onRefresh })
</div>
<span className="text-sm font-medium text-white truncate">{goal.title}</span>
{goal.goalType && goal.goalType !== 'standard' && (
+ // Not <Pill>: text-xs + px-1.5 is a size combo Pill doesn't carry, and
+ // its sm/xs padding would override the className, shifting this badge.
<span className={`shrink-0 text-xs px-1.5 py-0.5 rounded ${GOAL_TYPE_CONFIG[goal.goalType]?.bg} ${GOAL_TYPE_CONFIG[goal.goalType]?.color}`}>
{GOAL_TYPE_CONFIG[goal.goalType]?.label}
</span>
@@ -525,12 +528,12 @@ export default function GoalDetailPanel({ goal, allGoals, onClose, onRefresh })
<label className="text-xs text-gray-500">Tags</label>
<div className="flex flex-wrap gap-1 mt-1 mb-2">
{form.tags.map(tag => (
- <span key={tag} className="flex items-center gap-1 px-2 py-0.5 rounded bg-port-accent/20 text-port-accent text-xs">
+ <Pill key={tag} tone="bare" bordered={false} className="bg-port-accent/20 text-port-accent">
{tag}
<button onClick={() => removeTag(tag)} className="hover:text-white">
<X className="w-3 h-3" />
</button>
- </span>
+ </Pill>
))}
</div>
<div className="flex gap-1">
@@ -568,19 +571,18 @@ export default function GoalDetailPanel({ goal, allGoals, onClose, onRefresh })
)}
<div className="flex flex-wrap gap-2 text-xs">
- <span className={`px-2 py-0.5 rounded ${cat.bg} ${cat.color}`}>{cat.label}</span>
- <span className="px-2 py-0.5 rounded bg-gray-700 text-gray-300">
+ <Pill tone="bare" bordered={false} className={`${cat.bg} ${cat.color}`}>{cat.label}</Pill>
+ <Pill tone="bare" bordered={false} className="bg-gray-700 text-gray-300">
{HORIZON_OPTIONS.find(h => h.value === goal.horizon)?.label}
- </span>
+ </Pill>
{goal.urgency != null && (
- <span className={`flex items-center gap-1 px-2 py-0.5 rounded bg-gray-700 ${urgencyColor(goal.urgency)}`}>
- {goal.urgency >= 0.7 && <AlertTriangle className="w-3 h-3" />}
+ <Pill tone="bare" bordered={false} icon={goal.urgency >= 0.7 ? AlertTriangle : undefined} className={`bg-gray-700 ${urgencyColor(goal.urgency)}`}>
{Math.round(goal.urgency * 100)}% urgency
- </span>
+ </Pill>
)}
- <span className="px-2 py-0.5 rounded bg-gray-700 text-gray-400">
+ <Pill tone="bare" bordered={false} className="bg-gray-700 text-gray-400">
{goal.status}
- </span>
+ </Pill>
</div>
{/* Progress Bar */}
@@ -614,6 +616,7 @@ export default function GoalDetailPanel({ goal, allGoals, onClose, onRefresh })
<span className={`flex-1 ${todo.status === 'done' ? 'text-gray-500 line-through' : 'text-gray-300'}`}>
{todo.title}
</span>
+ {/* Not <Pill>: px-1 is tighter than Pill's xs (px-1.5) and would be overridden. */}
<span className={`shrink-0 px-1 py-0.5 rounded text-[10px] ${
todo.priority === 'high' ? 'bg-red-500/20 text-red-400' :
todo.priority === 'low' ? 'bg-gray-700 text-gray-500' :
@@ -704,10 +707,9 @@ export default function GoalDetailPanel({ goal, allGoals, onClose, onRefresh })
{goal.tags?.length > 0 && (
<div className="flex flex-wrap gap-1">
{goal.tags.map(tag => (
- <span key={tag} className="flex items-center gap-1 px-2 py-0.5 rounded bg-port-accent/20 text-port-accent text-xs">
- <Tag className="w-3 h-3" />
+ <Pill key={tag} tone="bare" bordered={false} icon={Tag} className="bg-port-accent/20 text-port-accent">
{tag}
- </span>
+ </Pill>
))}
</div>
)}
@@ -990,7 +992,7 @@ export default function GoalDetailPanel({ goal, allGoals, onClose, onRefresh })
<div key={ci.id} className="p-2 rounded bg-port-bg border border-port-border space-y-1">
<div className="flex items-center justify-between">
<span className="text-[10px] text-gray-500">{new Date(ci.date + 'T00:00:00').toLocaleDateString()}</span>
- <span className={`px-1.5 py-0.5 rounded text-[10px] ${sc.bg} ${sc.color}`}>{sc.label}</span>
+ <Pill tone="bare" size="xs" bordered={false} className={`${sc.bg} ${sc.color}`}>{sc.label}</Pill>
</div>
<div className="text-[10px] text-gray-500">
Progress: {ci.actualProgress}%{ci.expectedProgress != null && ` / ${ci.expectedProgress}% expected`}
diff --git a/client/src/components/goals/GoalDetailPanel.test.jsx b/client/src/components/goals/GoalDetailPanel.test.jsx
new file mode 100644
index 0000000000..1f92a1c405
--- /dev/null
+++ b/client/src/components/goals/GoalDetailPanel.test.jsx
@@ -0,0 +1,98 @@
+import { describe, it, expect, vi, beforeEach } from 'vitest';
+import { render, screen } from '@testing-library/react';
+
+// The panel fires getActivities()/getCalendarAccounts() on mount; stub them so the
+// read view renders without network. The badge assertions below only care about
+// the static read-mode markup.
+vi.mock('../../services/api', () => ({
+ getActivities: vi.fn(() => Promise.resolve([])),
+ getCalendarAccounts: vi.fn(() => Promise.resolve([])),
+}));
+
+import GoalDetailPanel from './GoalDetailPanel';
+
+const baseGoal = {
+ id: 'g-1',
+ title: 'Master the craft',
+ description: 'A description',
+ category: 'mastery',
+ horizon: '5-year',
+ status: 'active',
+ goalType: 'standard',
+ progress: 40,
+ urgency: 0.8,
+ tags: ['focus'],
+ todos: [],
+ milestones: [],
+ checkIns: [
+ { id: 'ci-1', date: '2026-05-01', status: 'on-track', actualProgress: 40 },
+ ],
+};
+
+const renderPanel = (goal = baseGoal) =>
+ render(
+ <GoalDetailPanel goal={goal} allGoals={[goal]} onClose={() => {}} onRefresh={() => {}} />
+ );
+
+beforeEach(() => {
+ vi.clearAllMocks();
+});
+
+describe('GoalDetailPanel badge migration to <Pill>', () => {
+ it('renders the category/horizon/status badges with the shared Pill structural shape', () => {
+ renderPanel();
+ // Pill emits `inline-flex items-center gap-1 rounded` + the sm size's `text-xs px-2 py-0.5`.
+ const category = screen.getByText('Mastery');
+ expect(category.className).toContain('inline-flex');
+ expect(category.className).toContain('rounded');
+ expect(category.className).toContain('px-2');
+ expect(category.className).toContain('py-0.5');
+ expect(category.className).toContain('text-xs');
+ // Data-driven colors are still supplied via className (tone="bare").
+ expect(category.className).toContain('text-blue-400');
+ expect(category.className).toContain('bg-blue-500/20');
+
+ const horizon = screen.getByText('5 Years');
+ expect(horizon.className).toContain('inline-flex');
+ expect(horizon.className).toContain('bg-gray-700');
+
+ const status = screen.getByText('active');
+ expect(status.className).toContain('inline-flex');
+ expect(status.className).toContain('text-gray-400');
+ });
+
+ it('renders the urgency badge as a Pill with its computed color and warning icon', () => {
+ renderPanel();
+ const urgency = screen.getByText('80% urgency');
+ expect(urgency.className).toContain('inline-flex');
+ expect(urgency.className).toContain('bg-gray-700');
+ // urgency >= 0.7 → red text + an AlertTriangle icon rendered inside the Pill.
+ expect(urgency.className).toContain('text-red-400');
+ expect(urgency.querySelector('svg')).not.toBeNull();
+ });
+
+ it('renders read-only tag chips as Pills with a leading Tag icon', () => {
+ renderPanel();
+ const tag = screen.getByText('focus');
+ expect(tag.className).toContain('inline-flex');
+ expect(tag.className).toContain('text-port-accent');
+ expect(tag.querySelector('svg')).not.toBeNull();
+ });
+
+ it('does not emit a stray border-color utility for bordered={false} bare Pills', () => {
+ renderPanel();
+ const category = screen.getByText('Mastery');
+ // bordered={false} strips both the `border` width and any tone border-color.
+ expect(category.className).not.toMatch(/\bborder\b/);
+ });
+
+ it('keeps the goal-type badge as its own non-standard-size span (not a Pill)', () => {
+ // sub-apex exercises the goalType !== 'standard' branch; its text-xs+px-1.5 size
+ // is intentionally left un-migrated so Pill's padding can't shift it.
+ renderPanel({ ...baseGoal, goalType: 'sub-apex' });
+ const typeBadge = screen.getByText('Sub-Apex');
+ expect(typeBadge.tagName).toBe('SPAN');
+ expect(typeBadge.className).toContain('px-1.5');
+ expect(typeBadge.className).not.toContain('inline-flex');
+ });
+});