⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.
TypeScript agenticagileai-agentsbug-reportingbug-trackerganttissue-trackerjirajira-alternativekanbanlinearlinear-alternativeopen-sourceproduct-managementproject-managementroadmapself-hostedsprint-planningteam-collaborationtrello-alternative
feat(web): add a section rail to account preferences (#71)
Croff77211845cf26
diff --git a/apps/web/src/components/common/page/FullPageView.tsx b/apps/web/src/components/common/page/FullPageView.tsxindex 513b9f0b..44c4827b 100644--- a/apps/web/src/components/common/page/FullPageView.tsx+++ b/apps/web/src/components/common/page/FullPageView.tsx@@ -2,6 +2,7 @@ import type { ReactNode } from 'react';import Link from 'next/link';import { ArrowLeft } from 'lucide-react';import { Button } from '@/components/ui/button';+import { cn } from '@/lib/utils';import PageHeader from './PageHeader';// The chrome for a standalone full-height page rendered outside the app shell:@@ -12,6 +13,7 @@ export default function FullPageView({title,description,actions,+ nav,children,}: {label: string;@@ -19,6 +21,9 @@ export default function FullPageView({description: ReactNode;// Rendered on the right of the header row, aligned with the title.actions?: ReactNode;+ // A section rail placed left of the content column on wide viewports; the page+ // widens to make room for it.+ nav?: ReactNode;children: ReactNode;}) {return (@@ -31,9 +36,17 @@ export default function FullPageView({</Button><span className="text-sm font-medium">{label}</span></header>- <div className="mx-auto w-full max-w-3xl px-8 py-10">- <PageHeader title={title} description={description} actions={actions} />- {children}+ <div+ className={cn(+ 'mx-auto flex w-full gap-10 px-8 py-10',+ nav ? 'max-w-[1000px]' : 'max-w-3xl',+ )}+ >+ {nav}+ <div className="w-full max-w-3xl min-w-0">+ <PageHeader title={title} description={description} actions={actions} />+ {children}+ </div></div></div>);diff --git a/apps/web/src/components/common/page/SectionNav.tsx b/apps/web/src/components/common/page/SectionNav.tsxnew file mode 100644index 00000000..964aae58--- /dev/null+++ b/apps/web/src/components/common/page/SectionNav.tsx@@ -0,0 +1,71 @@+import type { LucideIcon } from 'lucide-react';+import { cn } from '@/lib/utils';++export interface SectionNavItem {+ id: string;+ label: string;+ icon: LucideIcon;+ // Optional trailing indicator (e.g. the Actions enabled/total count).+ badge?: string;+}++// A sticky rail listing the sections of a long form or settings page. It highlights+// the one currently in view (driven by the caller's scroll spy) and jumps to a+// section on click. Shown only on wide viewports where there is room beside the+// content; the page stays fully usable without it.+export function SectionNav({+ sections,+ activeId,+ label,+ onJump,+ className,+}: {+ sections: SectionNavItem[];+ activeId: string | null;+ label: string;+ onJump: (id: string) => void;+ // Where the rail pins, when the default offset does not suit the page.+ className?: string;+}) {+ return (+ <nav+ className={cn('sticky top-2 hidden w-44 shrink-0 self-start lg:block', className)}+ aria-label={label}+ >+ <ul className="space-y-0.5">+ {sections.map((section) => {+ const active = section.id === activeId;+ const Icon = section.icon;+ return (+ <li key={section.id}>+ <button+ type="button"+ onClick={() => onJump(section.id)}+ aria-current={active ? 'location' : undefined}+ className={cn(+ 'flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-sm transition-colors duration-150 outline-none focus-visible:ring-2 focus-visible:ring-ring/60',+ active+ ? 'bg-secondary font-medium text-secondary-foreground'+ : 'text-foreground/85 hover:bg-accent/60 hover:text-foreground',+ )}+ >+ <Icon+ className={cn(+ 'size-4 shrink-0',+ active ? 'text-foreground' : 'text-muted-foreground',+ )}+ />+ <span className="min-w-0 flex-1 truncate">{section.label}</span>+ {section.badge && (+ <span className="shrink-0 text-xs text-muted-foreground tabular-nums">+ {section.badge}+ </span>+ )}+ </button>+ </li>+ );+ })}+ </ul>+ </nav>+ );+}diff --git a/apps/web/src/features/account/AccountPreferencesPage.tsx b/apps/web/src/features/account/AccountPreferencesPage.tsxindex 41487456..0742da15 100644--- a/apps/web/src/features/account/AccountPreferencesPage.tsx+++ b/apps/web/src/features/account/AccountPreferencesPage.tsx@@ -21,6 +21,7 @@ import AccountPreferenceSelect from './components/preferences/AccountPreferenceSimport AccountPreferencesSection from './components/preferences/AccountPreferencesSection';import AccountPreferencesTimezone from './components/preferences/AccountPreferencesTimezone';import AccountHotkeys from './components/preferences/AccountHotkeys';+import AccountPreferencesNav from './components/preferences/AccountPreferencesNav';import AccountPreferencesSaveState from './components/preferences/AccountPreferencesSaveState';const THEME_OPTIONS: { value: ThemePreference; label: string }[] = [@@ -71,8 +72,9 @@ export default function AccountPreferencesPage() {title="Preferences"description="How the app looks and behaves for you. Every change saves right away and applies wherever you sign in."actions={<AccountPreferencesSaveState saving={update.isPending} />}+ nav={<AccountPreferencesNav />}>- <AccountPreferencesSection title="Appearance">+ <AccountPreferencesSection id="appearance" title="Appearance"><AccountPreferenceRowlabel="Theme"description="Match system follows your operating system setting."@@ -87,6 +89,7 @@ export default function AccountPreferencesPage() {</AccountPreferencesSection><AccountPreferencesSection+ id="date-and-time"title="Date and time"description="Timestamps are stored in UTC and shown in the zone you pick here.">@@ -100,6 +103,7 @@ export default function AccountPreferencesPage() {</AccountPreferencesSection><AccountPreferencesSection+ id="navigation"title="Navigation"description="Where the app takes you, and how issues open.">@@ -128,6 +132,7 @@ export default function AccountPreferencesPage() {</AccountPreferencesSection><AccountPreferencesSection+ id="issue-settings"title="Issue settings"description="How the stats and the activity log of an issue start out. Switching them while an issue is open does not change these.">@@ -165,7 +170,7 @@ export default function AccountPreferencesPage() {</AccountPreferenceRow></AccountPreferencesSection>- <AccountPreferencesSection title="AI chat">+ <AccountPreferencesSection id="ai-chat" title="AI chat"><AccountPreferenceRowlabel="Show chat by default"description="The chat button stays on screen in a project. The chat window opens only when you click it."@@ -179,6 +184,7 @@ export default function AccountPreferencesPage() {</AccountPreferencesSection><AccountPreferencesSection+ id="shortcuts"title="Keyboard shortcuts"description="Press Change, then the keys you want. Reset takes a shortcut back to the one set for this instance.">diff --git a/apps/web/src/features/account/components/preferences/AccountPreferencesNav.tsx b/apps/web/src/features/account/components/preferences/AccountPreferencesNav.tsxnew file mode 100644index 00000000..f62da51a--- /dev/null+++ b/apps/web/src/features/account/components/preferences/AccountPreferencesNav.tsx@@ -0,0 +1,39 @@+'use client';++import { Bot, Clock, Compass, Keyboard, ListChecks, Palette } from 'lucide-react';+import { SectionNav, type SectionNavItem } from '@/components/common/page/SectionNav';+import { useSectionScrollSpy } from '@/hooks/useSectionScrollSpy';++// The blocks of the preferences page, in the order they are rendered. The ids match+// the ones the page gives its sections.+const SECTIONS: SectionNavItem[] = [+ { id: 'appearance', label: 'Appearance', icon: Palette },+ { id: 'date-and-time', label: 'Date and time', icon: Clock },+ { id: 'navigation', label: 'Navigation', icon: Compass },+ { id: 'issue-settings', label: 'Issue settings', icon: ListChecks },+ { id: 'ai-chat', label: 'AI chat', icon: Bot },+ { id: 'shortcuts', label: 'Keyboard shortcuts', icon: Keyboard },+];++// The section rail for the preferences page: it follows the page scroll and jumps+// to a block on click.+export default function AccountPreferencesNav() {+ const { activeId, setActiveId } = useSectionScrollSpy(SECTIONS.map((s) => s.id));++ function jump(id: string) {+ setActiveId(id);+ document.getElementById(id)?.scrollIntoView({ block: 'start', behavior: 'smooth' });+ }++ return (+ <SectionNav+ sections={SECTIONS}+ activeId={activeId}+ label="Preferences"+ onJump={jump}+ // The page scrolls under a static top bar, so the rail keeps a margin of its+ // own once it pins.+ className="top-8"+ />+ );+}diff --git a/apps/web/src/features/account/components/preferences/AccountPreferencesSection.tsx b/apps/web/src/features/account/components/preferences/AccountPreferencesSection.tsxindex 9f4feb6c..373f1cc1 100644--- a/apps/web/src/features/account/components/preferences/AccountPreferencesSection.tsx+++ b/apps/web/src/features/account/components/preferences/AccountPreferencesSection.tsx@@ -5,16 +5,19 @@ import type { ReactNode } from 'react';// page separates its blocks; the rows carry no box of their own, so every control// lines up down the page instead of sitting in stacked cards.export default function AccountPreferencesSection({+ id,title,description,children,}: {+ // The anchor the section rail scrolls to.+ id: string;title: string;description?: string;children: ReactNode;}) {return (- <section className="border-t py-8 first:border-t-0 first:pt-0">+ <section id={id} className="scroll-mt-4 border-t py-8 first:border-t-0 first:pt-0"><div className="mb-1"><h2 className="text-sm font-medium">{title}</h2>{description && <p className="mt-0.5 text-xs text-muted-foreground">{description}</p>}diff --git a/apps/web/src/features/settings/components/ai-agents/AgentExpandedLayout.tsx b/apps/web/src/features/settings/components/ai-agents/AgentExpandedLayout.tsxindex d3c58b74..89be40f5 100644--- a/apps/web/src/features/settings/components/ai-agents/AgentExpandedLayout.tsx+++ b/apps/web/src/features/settings/components/ai-agents/AgentExpandedLayout.tsx@@ -1,7 +1,8 @@'use client';-import { type ReactNode, useEffect, useRef, useState } from 'react';-import { AgentSectionNav, type AgentNavSection } from './AgentSectionNav';+import { type ReactNode, useRef } from 'react';+import { SectionNav, type SectionNavItem } from '@/components/common/page/SectionNav';+import { useSectionScrollSpy } from '@/hooks/useSectionScrollSpy';// Content width of the full-width internal editor. The sheet sizes its footer to// match, so the two must stay in sync.@@ -15,7 +16,7 @@ export default function AgentExpandedLayout({onExpand,children,}: {- navSections: AgentNavSection[];+ navSections: SectionNavItem[];banner?: ReactNode;// Ensure a section is open before scrolling to it (jumping to a collapsed section// would land on just its header).@@ -23,39 +24,10 @@ export default function AgentExpandedLayout({children: ReactNode;}) {const containerRef = useRef<HTMLDivElement>(null);- const [activeId, setActiveId] = useState<string | null>(navSections[0]?.id ?? null);- const ids = navSections.map((s) => s.id).join(',');-- useEffect(() => {- const container = containerRef.current;- if (!container) return;- const order = ids.split(',');- // The active section is the last one whose header has scrolled above a line near- // the top of the container (offset). A position check is used rather than- // IntersectionObserver so a tall section still counts as active while it fills the- // viewport, instead of an earlier section that only just touches the top edge.- const offset = 96;- let frame = 0;- const update = () => {- frame = 0;- const top = container.getBoundingClientRect().top + offset;- let current = order[0];- for (const id of order) {- const el = container.querySelector(`#${CSS.escape(id)}`);- if (el && el.getBoundingClientRect().top <= top) current = id;- }- setActiveId(current);- };- const onScroll = () => {- if (!frame) frame = requestAnimationFrame(update);- };- update();- container.addEventListener('scroll', onScroll, { passive: true });- return () => {- container.removeEventListener('scroll', onScroll);- if (frame) cancelAnimationFrame(frame);- };- }, [ids]);+ const { activeId, setActiveId } = useSectionScrollSpy(+ navSections.map((s) => s.id),+ containerRef,+ );function jump(id: string) {onExpand(id);@@ -72,7 +44,12 @@ export default function AgentExpandedLayout({<div ref={containerRef} className="min-h-0 flex-1 overflow-y-auto px-6 pt-2 pb-10">{banner && <div className={`mx-auto mb-6 w-full ${AGENT_EXPANDED_WIDTH}`}>{banner}</div>}<div className={`mx-auto flex w-full gap-10 ${AGENT_EXPANDED_WIDTH}`}>- <AgentSectionNav sections={navSections} activeId={activeId} onJump={jump} />+ <SectionNav+ sections={navSections}+ activeId={activeId}+ label="Agent settings"+ onJump={jump}+ /><div className="min-w-0 flex-1 space-y-8">{children}</div></div></div>diff --git a/apps/web/src/features/settings/components/ai-agents/AgentSectionNav.tsx b/apps/web/src/features/settings/components/ai-agents/AgentSectionNav.tsxdeleted file mode 100644index cf59f380..00000000--- a/apps/web/src/features/settings/components/ai-agents/AgentSectionNav.tsx+++ /dev/null@@ -1,57 +0,0 @@-import type { LucideIcon } from 'lucide-react';--export interface AgentNavSection {- id: string;- label: string;- icon: LucideIcon;- // Optional trailing indicator (e.g. the Actions enabled/total count).- badge?: string;-}--// The sticky section rail for the full-width agent editor. It lists the form's-// sections, highlights the one currently in view (driven by the parent's scroll-// spy), and jumps to a section on click. Shown only on wide viewports where the-// three-column editor has room; the form stays fully usable without it.-export function AgentSectionNav({- sections,- activeId,- onJump,-}: {- sections: AgentNavSection[];- activeId: string | null;- onJump: (id: string) => void;-}) {- return (- <nav- className="sticky top-2 hidden w-44 shrink-0 self-start lg:block"- aria-label="Agent settings"- >- <ul className="space-y-0.5">- {sections.map((section) => {- const active = section.id === activeId;- const Icon = section.icon;- return (- <li key={section.id}>- <button- type="button"- onClick={() => onJump(section.id)}- aria-current={active ? 'true' : undefined}- className={`flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors ${- active- ? 'bg-secondary font-medium text-foreground'- : 'text-muted-foreground hover:bg-accent/50 hover:text-foreground'- }`}- >- <Icon className="size-4 shrink-0" />- <span className="min-w-0 flex-1 truncate">{section.label}</span>- {section.badge && (- <span className="shrink-0 text-xs tabular-nums opacity-70">{section.badge}</span>- )}- </button>- </li>- );- })}- </ul>- </nav>- );-}diff --git a/apps/web/src/features/settings/components/ai-agents/SettingsAiAgentFields.tsx b/apps/web/src/features/settings/components/ai-agents/SettingsAiAgentFields.tsxindex 8976a2bd..8ae104b9 100644--- a/apps/web/src/features/settings/components/ai-agents/SettingsAiAgentFields.tsx+++ b/apps/web/src/features/settings/components/ai-agents/SettingsAiAgentFields.tsx@@ -26,9 +26,9 @@ import {SelectTrigger,SelectValue,} from '@/components/ui/select';+import { type SectionNavItem } from '@/components/common/page/SectionNav';import { type AgentFormValue, grantedToolCount } from '../../utils/agentForm';import { AgentFormSection } from './AgentFormSection';-import { type AgentNavSection } from './AgentSectionNav';import AgentExpandedLayout from './AgentExpandedLayout';import AgentModelSection from './AgentModelSection';import AgentActionsSection from './AgentActionsSection';@@ -356,7 +356,7 @@ export default function SettingsAiAgentFields({// column of borderless sections on the right, inside this component's own scroll// container so the nav's scroll spy can track which section is in view.if (expanded && value.kind === 'internal') {- const navSections: AgentNavSection[] = [+ const navSections: SectionNavItem[] = [{ id: 'basics', label: 'Basics', icon: IdCard },{ id: 'model', label: 'Model', icon: Cpu },{ id: 'triggers', label: 'Triggers', icon: Zap },diff --git a/apps/web/src/hooks/useSectionScrollSpy.ts b/apps/web/src/hooks/useSectionScrollSpy.tsnew file mode 100644index 00000000..0084db67--- /dev/null+++ b/apps/web/src/hooks/useSectionScrollSpy.ts@@ -0,0 +1,46 @@+'use client';++import { useEffect, useState, type RefObject } from 'react';++// Which section of a page is being read: the last one whose header has scrolled+// above a line near the top of the scroll root (offset). A position check is used+// rather than IntersectionObserver so a tall section still counts as active while+// it fills the viewport, instead of an earlier section that only just touches the+// top edge. Pass `container` when the sections scroll inside an element; without it+// the page itself is the scroll root. The returned setter lets the caller mark a+// section active right away when it jumps to one.+export function useSectionScrollSpy(ids: string[], container?: RefObject<HTMLElement | null>) {+ const [activeId, setActiveId] = useState<string | null>(ids[0] ?? null);+ const key = ids.join(',');++ useEffect(() => {+ const root = container?.current;+ if (container && !root) return;+ const order = key.split(',').filter(Boolean);+ const scope = root ?? document;+ const target = root ?? window;+ const offset = 96;+ let frame = 0;+ const update = () => {+ frame = 0;+ const top = (root?.getBoundingClientRect().top ?? 0) + offset;+ let current = order[0] ?? null;+ for (const id of order) {+ const el = scope.querySelector(`#${CSS.escape(id)}`);+ if (el && el.getBoundingClientRect().top <= top) current = id;+ }+ setActiveId(current);+ };+ const onScroll = () => {+ if (!frame) frame = requestAnimationFrame(update);+ };+ update();+ target.addEventListener('scroll', onScroll, { passive: true });+ return () => {+ target.removeEventListener('scroll', onScroll);+ if (frame) cancelAnimationFrame(frame);+ };+ }, [key, container]);++ return { activeId, setActiveId };+}