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

feat([issue-925]): make top-level single nav rows pinnable

Adam Eivy1618ee60c399
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index 46c282dd66..e8057735ab 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -340,6 +340,68 @@ function WorkingSetRow({ entry, pinned, onTogglePin, onNavigate, isActive }) {
);
}
+// A top-level *single* nav row (Dashboard / Review Hub / City / Goals). Unlike a
+// section, it links straight to one destination — and unlike WorkingSetRow it
+// carries the heavier top-level row weight plus the optional badge (Chief of
+// Staff unread count) and the collapsed-rail layout (icon-only, centered, badge
+// overlaid on the icon). When expanded it also exposes the same hover/focus
+// pin/unpin affordance as WorkingSetRow so these destinations can be pinned too;
+// the pin button is omitted in the collapsed rail, mirroring the Pinned/Recent
+// sections which only render when the sidebar is expanded.
+export function SingleNavRow({ item, collapsed, active, badgeCount, pinned, onTogglePin, onNavigate }) {
+ const Icon = item.icon;
+ const showBadge = item.showBadge && badgeCount > 0;
+ const badgeText = badgeCount > 9 ? '9+' : badgeCount;
+ return (
+ <div className={`group flex items-stretch min-w-0 mx-2 ${collapsed ? 'lg:justify-center' : ''}`}>
+ <NavLink
+ to={item.to}
+ end={item.to === '/'}
+ onClick={onNavigate}
+ className={`flex-1 flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors min-w-0 ${
+ collapsed ? 'lg:justify-center lg:px-2' : 'justify-between'
+ } ${
+ active
+ ? 'bg-port-accent/10 text-port-accent'
+ : 'text-gray-400 hover:text-white hover:bg-port-border/50'
+ }`}
+ title={collapsed ? item.label : undefined}
+ >
+ <div className="flex items-center gap-3 min-w-0">
+ <div className="relative">
+ <Icon size={20} className="shrink-0" />
+ {/* Badge for collapsed state */}
+ {showBadge && collapsed && (
+ <span className="absolute -top-1.5 -right-1.5 min-w-[14px] h-[14px] flex items-center justify-center text-[9px] font-bold rounded-full bg-yellow-500 text-black px-0.5">
+ {badgeText}
+ </span>
+ )}
+ </div>
+ <span className={`whitespace-nowrap min-w-0 truncate ${collapsed ? 'lg:hidden' : ''}`}>
+ {item.label}
+ </span>
+ </div>
+ {/* Badge for expanded state */}
+ {showBadge && !collapsed && (
+ <span className="min-w-[18px] h-[18px] flex items-center justify-center text-[10px] font-bold rounded-full bg-yellow-500 text-black px-1">
+ {badgeText}
+ </span>
+ )}
+ </NavLink>
+ {!collapsed && (
+ <button
+ type="button"
+ aria-label={pinned ? `Unpin ${item.label}` : `Pin ${item.label}`}
+ onClick={(e) => { e.preventDefault(); e.stopPropagation(); onTogglePin(); }}
+ className={`px-2 rounded-lg hover:bg-port-border/50 ${pinned ? 'text-port-accent' : 'text-gray-500 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100'}`}
+ >
+ {pinned ? <PinOff size={14} /> : <Pin size={14} />}
+ </button>
+ )}
+ </div>
+ );
+}
+
export default function Layout() {
const location = useLocation();
const navigate = useNavigate();
@@ -682,42 +744,18 @@ export default function Layout() {
}
if (item.single) {
+ const singlePinned = isPinned(item.to);
return (
- <NavLink
+ <SingleNavRow
key={item.to}
- to={item.to}
- end={item.to === '/'}
- onClick={() => setMobileOpen(false)}
- className={`flex items-center gap-3 mx-2 px-3 py-2.5 rounded-lg text-sm font-medium transition-colors min-w-0 ${
- collapsed ? 'lg:justify-center lg:px-2' : 'justify-between'
- } ${
- isActive(item.to)
- ? 'bg-port-accent/10 text-port-accent'
- : 'text-gray-400 hover:text-white hover:bg-port-border/50'
- }`}
- title={collapsed ? item.label : undefined}
- >
- <div className="flex items-center gap-3 min-w-0">
- <div className="relative">
- <Icon size={20} className="shrink-0" />
- {/* Badge for collapsed state */}
- {item.showBadge && unreadCount > 0 && collapsed && (
- <span className="absolute -top-1.5 -right-1.5 min-w-[14px] h-[14px] flex items-center justify-center text-[9px] font-bold rounded-full bg-yellow-500 text-black px-0.5">
- {unreadCount > 9 ? '9+' : unreadCount}
- </span>
- )}
- </div>
- <span className={`whitespace-nowrap min-w-0 truncate ${collapsed ? 'lg:hidden' : ''}`}>
- {item.label}
- </span>
- </div>
- {/* Badge for expanded state */}
- {item.showBadge && unreadCount > 0 && !collapsed && (
- <span className="min-w-[18px] h-[18px] flex items-center justify-center text-[10px] font-bold rounded-full bg-yellow-500 text-black px-1">
- {unreadCount > 9 ? '9+' : unreadCount}
- </span>
- )}
- </NavLink>
+ item={item}
+ collapsed={collapsed}
+ active={isActive(item.to)}
+ badgeCount={unreadCount}
+ pinned={singlePinned}
+ onTogglePin={() => (singlePinned ? unpin(item.to) : pin(item.to))}
+ onNavigate={() => setMobileOpen(false)}
+ />
);
}
diff --git a/client/src/components/SingleNavRow.test.jsx b/client/src/components/SingleNavRow.test.jsx
new file mode 100644
index 0000000000..7256902ac6
--- /dev/null
+++ b/client/src/components/SingleNavRow.test.jsx
@@ -0,0 +1,85 @@
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen, fireEvent } from '@testing-library/react';
+import { MemoryRouter } from 'react-router-dom';
+import { Home, Crown } from 'lucide-react';
+import { SingleNavRow } from './Layout';
+
+const baseItem = { to: '/', label: 'Dashboard', icon: Home, single: true };
+const badgeItem = { to: '/cos', label: 'Chief of Staff', icon: Crown, single: true, showBadge: true };
+
+const renderRow = (props = {}) => render(
+ <MemoryRouter>
+ <SingleNavRow
+ item={baseItem}
+ collapsed={false}
+ active={false}
+ badgeCount={0}
+ pinned={false}
+ onTogglePin={() => {}}
+ onNavigate={() => {}}
+ {...props}
+ />
+ </MemoryRouter>,
+);
+
+describe('SingleNavRow', () => {
+ it('renders the label and links to the destination', () => {
+ renderRow();
+ const link = screen.getByRole('link', { name: /Dashboard/i });
+ expect(link).toHaveAttribute('href', '/');
+ });
+
+ it('exposes a Pin button when expanded and unpinned', () => {
+ const onTogglePin = vi.fn();
+ renderRow({ onTogglePin });
+ const pinBtn = screen.getByRole('button', { name: /^Pin Dashboard$/i });
+ fireEvent.click(pinBtn);
+ expect(onTogglePin).toHaveBeenCalledTimes(1);
+ });
+
+ it('shows an Unpin button when already pinned', () => {
+ renderRow({ pinned: true });
+ expect(screen.getByRole('button', { name: /^Unpin Dashboard$/i })).toBeTruthy();
+ expect(screen.queryByRole('button', { name: /^Pin Dashboard$/i })).toBeNull();
+ });
+
+ it('hides the pin button in the collapsed rail', () => {
+ renderRow({ collapsed: true });
+ expect(screen.queryByRole('button', { name: /Pin Dashboard/i })).toBeNull();
+ });
+
+ it('does not navigate when the pin button is clicked (preventDefault + stopPropagation)', () => {
+ const onNavigate = vi.fn();
+ const onTogglePin = vi.fn();
+ renderRow({ onNavigate, onTogglePin });
+ const pinBtn = screen.getByRole('button', { name: /^Pin Dashboard$/i });
+ fireEvent.click(pinBtn);
+ expect(onTogglePin).toHaveBeenCalledTimes(1);
+ expect(onNavigate).not.toHaveBeenCalled();
+ });
+
+ it('renders the unread badge when showBadge and badgeCount > 0', () => {
+ renderRow({ item: badgeItem, badgeCount: 3 });
+ expect(screen.getByText('3')).toBeTruthy();
+ });
+
+ it('caps the badge at 9+', () => {
+ renderRow({ item: badgeItem, badgeCount: 42 });
+ expect(screen.getByText('9+')).toBeTruthy();
+ });
+
+ it('omits the badge when badgeCount is 0', () => {
+ renderRow({ item: badgeItem, badgeCount: 0 });
+ expect(screen.queryByText(/^\d/)).toBeNull();
+ });
+
+ it('omits the badge for items without showBadge even when badgeCount > 0', () => {
+ renderRow({ badgeCount: 5 });
+ expect(screen.queryByText('5')).toBeNull();
+ });
+
+ it('still shows the badge in the collapsed rail (overlaid on the icon)', () => {
+ renderRow({ item: badgeItem, badgeCount: 2, collapsed: true });
+ expect(screen.getByText('2')).toBeTruthy();
+ });
+});