feat: dealer flow, mirror portfolio (M21), options convexity, FINRA short interest, alert producers, vendor gate
CI / Test & Type-Check (push) Canceled after 0s

Snapshot of in-progress module work across multiple slices:

- Dealer Flow: dealerExposureEngine, dealerMapService, dealerMapExplain,
  dealerMapIntegrity, dealerMapReplay, dealerStudyEngine, hanStyleLevels
- Mirror Portfolio (M21): fundRepository, captureIngest, mirrorAlertProducers,
  fund holdings strip, live book, position capture ingest
- Options: BSM, NormalizedOptionSurface types, OptionsChainRouter,
  ConvexityGate, option legs panel
- Alert producers: vixLevel, rotation, thesis, unlock, portfolioRisk,
  mirror (fund_capture, fund_13f, mirror_diff)
- FINRA short interest adapter + queue integration
- SEC company tickers adapter + ingest (symbol search index seed)
- Vendor gate (rate-limit-first data plane, ADR-0009)
- CUSIP registry, reverse 13F refresh, stock float service
- LRU cache, portfolio backtest engine
- Frontend: dealer-flow, funds, journal, lab, monitor, plan, portfolio,
  reports, screener, strategies, theses, guided-start, exits, more pages
- Volume profile, workspace profile, visibility-aware poll
- ADRs 0010 (mirror math not advice), 0011 (symbol search index)
- VENDOR_INTEGRATIONS.md, END_USER_TEST.md
- .gitignore: exclude DBs, .DS_Store, local config, agent scratch
This commit is contained in:
Investor Flow Build
2026-08-10 13:36:26 -04:00
parent 04fc11b2fd
commit ac94acf9e3
229 changed files with 32617 additions and 3934 deletions
+162 -94
View File
@@ -4,26 +4,29 @@ import Link from "next/link";
import { usePathname } from "next/navigation";
import {
BarChart3,
Zap,
Briefcase,
Compass,
Microscope,
Shield,
Settings,
ChevronDown,
Search,
type LucideIcon,
} from "lucide-react";
import { api } from "@/lib/trpc";
import { useFeatureAccess, type ModuleKey } from "@/lib/useFeatureAccess";
import { useWorkspaceProfile } from "@/lib/useWorkspaceProfile";
import { useActiveSymbolGuarded } from "@/stores/active-symbol-store";
import type { NavItemId } from "@/lib/workspace-profile";
import { scrollAppMainToTopSoon } from "@/lib/scroll-app-main";
/**
* Left sidebar navigation with collapsible sections.
* Chrome is intentionally dimmed (muted text) so the content area reads as primary;
* the active item gets an accent tint + left bar.
* Left sidebar — management-centered sections, filtered by module access + workspace density.
*/
interface NavItem {
label: string;
href: string;
navId: NavItemId;
}
interface NavSection {
@@ -39,32 +42,48 @@ const SECTIONS: NavSection[] = [
icon: BarChart3,
module: "research",
items: [
{ label: "Overview", href: "/" },
{ label: "Market Outlook", href: "/market-outlook" },
{ label: "Institutional", href: "/institutional" },
{ label: "Charts", href: "/chart-lab" },
{ label: "Symbol", href: "/", navId: "research" },
{ label: "Market Outlook", href: "/market-outlook", navId: "market" },
{ label: "Charts", href: "/chart-lab", navId: "charts" },
{ label: "Screener", href: "/screener", navId: "screener" },
{ label: "Institutional", href: "/institutional", navId: "institutional" },
{ label: "Dealer Flow", href: "/dealer-flow", navId: "dealer-flow" },
],
},
{
title: "Execution",
icon: Zap,
title: "Book",
icon: Briefcase,
module: "execution",
items: [
{ label: "Trade Plan", href: "/trade-plan" },
{ label: "Execution", href: "/execution" },
{ label: "Trade Closure", href: "/trade-closure" },
{ label: "Daily Focus", href: "/daily-focus" },
{ label: "Portfolio", href: "/portfolio", navId: "portfolio" },
{ label: "Risk", href: "/risk", navId: "risk" },
{ label: "Tracked Funds", href: "/funds", navId: "funds" },
],
},
{
title: "Analytics",
title: "Process",
icon: Compass,
module: "execution",
items: [
{ label: "Get Started", href: "/guided-start", navId: "guided-start" },
{ label: "Decision plan", href: "/plan", navId: "plan" },
{ label: "Theses", href: "/theses", navId: "theses" },
{ label: "Journal", href: "/journal", navId: "journal" },
{ label: "Strategies", href: "/strategies", navId: "strategies" },
{ label: "Strategy lab", href: "/lab", navId: "lab" },
{ label: "Position considerations", href: "/exits", navId: "exits" },
{ label: "Goals", href: "/daily-focus", navId: "goals" },
],
},
{
title: "Tools",
icon: Microscope,
module: "analytics",
items: [
{ label: "Risk Posture", href: "/risk" },
{ label: "Filings", href: "/filings" },
{ label: "Options DD", href: "/options-dd" },
{ label: "Alerts", href: "/alerts" },
{ label: "Alerts", href: "/alerts", navId: "alerts" },
{ label: "Reports", href: "/reports", navId: "reports" },
{ label: "Filings", href: "/filings", navId: "filings" },
{ label: "Options DD", href: "/options-dd", navId: "options" },
],
},
{
@@ -72,19 +91,19 @@ const SECTIONS: NavSection[] = [
icon: Shield,
module: "admin",
items: [
{ label: "Overview", href: "/admin" },
{ label: "Users", href: "/admin/users" },
{ label: "Queue", href: "/admin/queue" },
{ label: "Audit Logs", href: "/admin/audit-logs" },
{ label: "X Accounts", href: "/admin/x-accounts" },
{ label: "SMTP", href: "/admin/smtp" },
{ label: "Overview", href: "/admin", navId: "admin" },
{ label: "Users", href: "/admin/users", navId: "admin" },
{ label: "Queue", href: "/admin/queue", navId: "admin" },
{ label: "Audit Logs", href: "/admin/audit-logs", navId: "admin" },
{ label: "X Accounts", href: "/admin/x-accounts", navId: "admin" },
{ label: "SMTP", href: "/admin/smtp", navId: "admin" },
],
},
{
title: "Settings",
icon: Settings,
module: "settings",
items: [{ label: "Profile / Auth", href: "/settings" }],
items: [{ label: "Profile / Auth", href: "/settings", navId: "settings" }],
},
];
@@ -106,20 +125,32 @@ function getInitialCollapsed(pathname: string, visibleSections: NavSection[]): R
return initial;
}
export function SidebarNav() {
export function SidebarNav({ collapsed: panelCollapsed, onToggle }: { collapsed?: boolean; onToggle?: () => void }) {
const pathname = usePathname();
const normalizedPath = (pathname || "/").replace(/\/+$/, "") || "/";
const { modules, loading } = useFeatureAccess();
const { isNavVisible, density } = useWorkspaceProfile();
const activeSymbol = useActiveSymbolGuarded();
const [collapsed, setCollapsed] = useState<Record<string, boolean>>({});
const [initialized, setInitialized] = useState(false);
const [unackedCount, setUnackedCount] = useState(0);
const visibleSections = SECTIONS.filter((s) => modules.includes(s.module));
// Research → "Symbol" shows the focused ticker, e.g. "Symbol: IREN"
const itemLabel = (item: { label: string }) =>
item.label === "Symbol" && activeSymbol ? `Symbol: ${activeSymbol}` : item.label;
const visibleSections = SECTIONS
.filter((s) => modules.includes(s.module))
.map((s) => ({
...s,
items: s.items.filter((item) => isNavVisible(item.navId)),
}))
.filter((s) => s.items.length > 0);
useEffect(() => {
const fetch = () => api.alerts.unackedCount().then((r) => setUnackedCount(r.count)).catch(() => {});
fetch();
const handler = () => fetch();
const fetchCount = () => api.alerts.unackedCount().then((r) => setUnackedCount(r.count)).catch(() => {});
fetchCount();
const handler = () => fetchCount();
window.addEventListener("alert-dismissed", handler);
return () => window.removeEventListener("alert-dismissed", handler);
}, []);
@@ -127,7 +158,8 @@ export function SidebarNav() {
useEffect(() => {
setCollapsed(getInitialCollapsed(pathname, visibleSections));
setInitialized(true);
}, [loading]);
// eslint-disable-next-line react-hooks/exhaustive-deps -- re-init when module/density loading settles
}, [loading, density]);
useEffect(() => {
if (initialized) {
@@ -141,70 +173,106 @@ export function SidebarNav() {
setCollapsed((prev) => ({ ...prev, [sectionTitle]: !prev[sectionTitle] }));
};
const openPalette = () => window.dispatchEvent(new CustomEvent("open-command-palette"));
return (
<aside className="w-52 border-r border-line bg-surface-raised flex-shrink-0 hidden lg:block">
<nav className="flex h-full flex-col p-3">
<div className="space-y-0.5 flex-1">
{visibleSections.map((section) => {
const Icon = section.icon;
return (
<div key={section.title} className="mb-1">
<button
onClick={() => toggleCollapse(section.title)}
className="w-full flex items-center justify-between px-2 py-1.5 text-2xs font-semibold uppercase tracking-wide text-fg-muted hover:text-fg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded"
>
<span className="flex items-center gap-2">
<Icon className="h-3.5 w-3.5" />
<span>{section.title}</span>
</span>
<ChevronDown
className={`h-3 w-3 transition-transform duration-200 ${collapsed[section.title] ? "-rotate-90" : ""}`}
/>
</button>
{!collapsed[section.title] && (
<div className="mt-0.5 space-y-0.5">
{section.items.map((item) => {
const isActive = normalizedPath === item.href;
const showBadge = item.label === "Alerts" && unackedCount > 0;
return (
<Link
key={item.label}
href={item.href}
className={`block px-2 py-1.5 rounded-md text-xs transition-colors border-l-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${
isActive
? "bg-accent-soft text-fg border-accent font-medium"
: "text-fg-muted hover:text-fg hover:bg-surface-overlay border-transparent"
}`}
>
<span className="flex items-center justify-between">
<span>{item.label}</span>
{showBadge && (
<span className="rounded-full bg-accent px-1.5 py-0.5 text-2xs text-white">{unackedCount}</span>
)}
</span>
</Link>
);
})}
<aside className={`border-r border-line bg-surface-raised flex-shrink-0 hidden lg:flex items-stretch transition-all duration-200 ${panelCollapsed ? "w-14" : "w-52"}`}>
<div className="flex-1 min-w-0 overflow-hidden">
<nav className={`h-full ${panelCollapsed ? "p-2" : "p-3"}`}>
{panelCollapsed ? (
<div className="space-y-2">
{visibleSections.map((section) => {
const Icon = section.icon;
return (
<div key={section.title} className="flex justify-center">
<div className="relative group">
<button
onClick={onToggle}
className="p-1.5 rounded text-fg-muted hover:text-fg hover:bg-surface-overlay transition-colors"
title={section.title}
>
<Icon className="h-4 w-4" />
</button>
<div className="absolute left-full ml-1 top-0 z-50 hidden group-hover:block">
<div className="rounded border border-line bg-surface-raised px-2 py-1 text-2xs text-fg whitespace-nowrap shadow-xl">
{section.title}
</div>
</div>
</div>
</div>
)}
</div>
);
})}
</div>
);
})}
</div>
) : (
<div className="space-y-0.5">
{visibleSections.map((section) => {
const Icon = section.icon;
return (
<div key={section.title} className="mb-1">
<button
onClick={() => toggleCollapse(section.title)}
className="w-full flex items-center justify-between px-2 py-1.5 text-2xs font-semibold uppercase tracking-wide text-fg-muted hover:text-fg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent rounded"
>
<span className="flex items-center gap-2">
<Icon className="h-3.5 w-3.5" />
<span>{section.title}</span>
</span>
<ChevronDown
className={`h-3 w-3 transition-transform duration-200 ${collapsed[section.title] ? "-rotate-90" : ""}`}
/>
</button>
{/* Search affordance -- opens the command palette */}
<button
onClick={openPalette}
className="mt-2 flex items-center gap-2 w-full rounded-md border border-line bg-surface-sunken px-2 py-1.5 text-xs text-fg-muted hover:text-fg hover:bg-surface-overlay transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
>
<Search className="h-3.5 w-3.5" />
<span>Search</span>
<kbd className="ml-auto rounded-sm border border-line px-1 py-0.5 text-2xs">⌘K</kbd>
</button>
</nav>
{!collapsed[section.title] && (
<div className="mt-0.5 space-y-0.5">
{section.items.map((item) => {
const itemPath = item.href.split("#")[0] || "/";
const isActive =
itemPath === "/"
? normalizedPath === "/"
: normalizedPath === itemPath;
const showBadge = item.label === "Alerts" && unackedCount > 0;
return (
<Link
key={item.label}
href={item.href}
// Nested <main> is the scroller; Next window restore is a no-op.
// Same-route + cross-page: force main to top after click.
scroll={false}
onClick={() => {
// Mark intent so home page can reassert after its own mount.
try {
sessionStorage.setItem("iflow-nav-scroll-top", "1");
} catch { /* ignore */ }
scrollAppMainToTopSoon();
}}
className={`block px-2 py-1.5 rounded-md text-xs transition-colors border-l-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${
isActive
? "bg-accent-soft text-fg border-accent font-medium"
: "text-fg-muted hover:text-fg hover:bg-surface-overlay border-transparent"
}`}
>
<span className="flex items-center justify-between">
<span>{itemLabel(item)}</span>
{showBadge && (
<span className="rounded-full bg-accent px-1.5 py-0.5 text-2xs text-white">{unackedCount}</span>
)}
</span>
</Link>
);
})}
</div>
)}
</div>
);
})}
</div>
)}
</nav>
</div>
<button
onClick={onToggle}
className="w-3.5 shrink-0 border-l border-line bg-surface-raised hover:bg-surface-overlay cursor-pointer transition-colors self-stretch"
title={panelCollapsed ? "Expand sidebar" : "Collapse sidebar"}
/>
</aside>
);
}