feat(settings): open Assistenten on Kunskap with the konteringskarta first (#1044)

The Assistenten settings hub used to open on Minne, with the
konteringskarta buried two clicks away (Kunskap tab, below a second
nested tab row). Now /settings/assistant opens on Kunskap and the
LedgerGraph hero is the first thing on screen.

- Kunskap is the default view and first tab; Minne moves to ?view=memory
  (old ?view=knowledge links still resolve to the default)
- Drop the nested Kompetens/Minne/Regler & profil tab row inside the
  Kunskap view: Kompetens and Minne duplicated the top-level tabs one
  row above; Regler & profil now renders inline under the graph with a
  section header (KnowledgeTabs.tsx deleted)
- Restore vertical rhythm (space-y-8) between the hero, detail section
  and footer, lost when the view moved into the settings tabs
- Update redirects and memory deep links (/settings/agent-memory,
  AgentChat memory chips, FactsCard manage link) to ?view=memory
- Match the loading skeleton to the new layout

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Jakob Wennberg
2026-07-17 13:43:57 +02:00
committed by GitHub
co-authored by Claude Fable 5
parent fd1c266cb0
commit bfd5b42eb1
12 changed files with 48 additions and 77 deletions
@@ -111,7 +111,7 @@ export function FactsCard({ competence }: { competence: AgentCompetence }) {
<span className="tabular-nums">
{factsActiveTotal > facts.length ? t('facts_more', { n: factsActiveTotal - facts.length }) : ''}
</span>
<ManageLink href="/settings/assistant" label={t('facts_manage')} />
<ManageLink href="/settings/assistant?view=memory" label={t('facts_manage')} />
</div>
</>
)}
@@ -60,11 +60,17 @@ export function AgentKnowledgePanel() {
}
if (!payload) {
// Mirrors the loaded layout: graph hero, section header, two profile cards.
return (
<div className="space-y-6">
<Skeleton className="h-64 w-full rounded-xl" />
<Skeleton className="h-9 w-64" />
<Skeleton className="h-48 w-full rounded-xl" />
<div className="space-y-8">
<Skeleton className="h-96 w-full rounded-xl" />
<div className="space-y-4">
<Skeleton className="h-4 w-40" />
<div className="grid gap-4 md:grid-cols-2">
<Skeleton className="h-48 w-full rounded-lg" />
<Skeleton className="h-48 w-full rounded-lg" />
</div>
</div>
</div>
)
}
@@ -26,7 +26,6 @@ import type { DeepLedgerContext } from '@/lib/agent-context/ledger-deep'
import type { AgentCompetence } from '@/lib/agent-context/agent-competence'
import { LedgerGraph } from './LedgerGraph'
import { CompetenceCard, FactsCard } from './AgentCompetenceSections'
import { KnowledgeTabs } from './KnowledgeTabs'
// Swedish VAT (moms) treatment codes stay Swedish in both locales, like BAS
// account names and momsdeklaration labels (.claude/rules/i18n.md).
@@ -74,7 +73,7 @@ export function AgentKnowledgeView({
// No bookings yet, but the agent still ships with competence and may
// already remember facts: show those rather than a dead end.
return (
<>
<div className="space-y-8">
<Card>
<CardContent className="p-0">
<EmptyState
@@ -90,7 +89,7 @@ export function AgentKnowledgeView({
<CompetenceCard competence={competence} />
<FactsCard competence={competence} />
</div>
</>
</div>
)
}
@@ -110,7 +109,9 @@ export function AgentKnowledgeView({
? t('period_yearly')
: (vat_profile.moms_period ?? t('unknown'))
// "Regler & profil" tab: user-authored rules + observed VAT + conventions.
// "Regler & profil": user-authored rules + observed VAT + conventions.
// Rendered inline below the graph; Minne and Kompetens have their own
// top-level tabs, so nesting a second tab row here would just duplicate them.
const configContent = (
<>
{explicit_rules.length > 0 && (
@@ -218,24 +219,22 @@ export function AgentKnowledgeView({
</>
)
const tabs = [
{ value: 'competence', label: t('tab_competence'), content: <CompetenceCard competence={competence} /> },
{ value: 'memory', label: t('tab_memory'), content: <FactsCard competence={competence} /> },
{ value: 'config', label: t('tab_config'), content: configContent },
]
return (
<>
<div className="space-y-8">
{/* The cinematic hero: a self-contained dark panel with its own header */}
<LedgerGraph deep={deep} companyName={companyName} />
{/* Supporting detail, tabbed so it doesn't stack into a long scroll */}
<KnowledgeTabs tabs={tabs} />
<section className="space-y-4">
<h2 className="text-sm font-medium uppercase tracking-wider text-muted-foreground">
{t('tab_config')}
</h2>
{configContent}
</section>
<p className="text-right text-xs text-muted-foreground">
{t('footer_basis', { entries: meta.coverage.posted_entries_window, date: formatDateLong(meta.computed_at) })}
</p>
</>
</div>
)
}
@@ -1,33 +0,0 @@
'use client'
import type { ReactNode } from 'react'
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs'
/**
* Client wrapper that organizes the page's supporting detail into tabs so the
* booking map stays the hero and the rest doesn't stack into a long scroll.
* Content is server-rendered upstream and handed in as ReactNode slots.
*/
export function KnowledgeTabs({
tabs,
}: {
tabs: { value: string; label: string; content: ReactNode }[]
}) {
if (tabs.length === 0) return null
return (
<Tabs defaultValue={tabs[0].value} className="space-y-6">
<TabsList>
{tabs.map((t) => (
<TabsTrigger key={t.value} value={t.value}>
{t.label}
</TabsTrigger>
))}
</TabsList>
{tabs.map((t) => (
<TabsContent key={t.value} value={t.value} className="space-y-8 focus-visible:outline-none">
{t.content}
</TabsContent>
))}
</Tabs>
)
}
+1 -1
View File
@@ -842,7 +842,7 @@ function MemoryChip({ event }: { event: MemoryEvent }) {
: null
return (
<Link
href="/settings/assistant"
href="/settings/assistant?view=memory"
className="group inline-flex items-start gap-2 rounded-lg border border-border bg-card px-3 py-2 text-xs text-muted-foreground transition-colors hover:border-foreground/30 hover:text-foreground"
title="Visa i Assistentens minne"
>
+2 -2
View File
@@ -189,8 +189,8 @@ const navItems: NavItem[] = [
// Rapporter surface (nav_ia_redesign §F) is built.
{ href: '/kpi', labelKey: 'kpi', icon: TrendingUp, group: 'analys' },
{ href: '/reports', labelKey: 'reports', icon: BarChart3, group: 'analys' },
// "Vad din agent vet" now lives inside Settings (Assistenten -> Kunskap),
// reachable via /settings/assistant?view=knowledge, not the top nav.
// "Vad din agent vet" now lives inside Settings (Assistenten -> Kunskap,
// the default view), reachable via /settings/assistant, not the top nav.
// Data: master-data registers + data plumbing. Anställda is a register
// (you edit an employee rarely, you run payroll monthly), so it lives here
// while the Löner flow stays in Arbeta.
@@ -6,48 +6,49 @@ import { AgentMemoryPanel } from '@/components/settings/AgentMemoryPanel'
import { AgentSkillsPanel } from '@/components/settings/AgentSkillsPanel'
import { AgentKnowledgePanel } from '@/components/agent-knowledge/AgentKnowledgePanel'
// "Assistenten": what the assistant remembers about this company (Minne,
// editable), the domain knowledge it ships with (Kompetens, read-only), and
// the ledger profile it reads before booking (Kunskap = "Vad din agent vet",
// read-only). Tabs keep all three one click away instead of stacked.
type View = 'memory' | 'skills' | 'knowledge'
// "Assistenten": the ledger profile the agent reads before booking (Kunskap =
// "Vad din agent vet", opens on the konteringskarta and is the default view),
// what the assistant remembers about this company (Minne, editable), and the
// domain knowledge it ships with (Kompetens, read-only). Tabs keep all three
// one click away instead of stacked.
type View = 'knowledge' | 'memory' | 'skills'
const VIEW_ROUTE: Record<View, string> = {
memory: '/settings/assistant',
knowledge: '/settings/assistant',
memory: '/settings/assistant?view=memory',
skills: '/settings/assistant?view=skills',
knowledge: '/settings/assistant?view=knowledge',
}
export function AssistantSettingsContent() {
const searchParams = useSearchParams()
const router = useRouter()
const raw = searchParams.get('view')
const view: View = raw === 'skills' ? 'skills' : raw === 'knowledge' ? 'knowledge' : 'memory'
const view: View = raw === 'skills' ? 'skills' : raw === 'memory' ? 'memory' : 'knowledge'
function setView(next: string) {
// 'memory' is the default: keep its URL clean (no query string).
router.replace(VIEW_ROUTE[next as View] ?? VIEW_ROUTE.memory, { scroll: false })
// 'knowledge' is the default: keep its URL clean (no query string).
router.replace(VIEW_ROUTE[next as View] ?? VIEW_ROUTE.knowledge, { scroll: false })
}
return (
<Tabs value={view} onValueChange={setView} className="space-y-6">
<TabsList>
<TabsTrigger value="knowledge">Kunskap</TabsTrigger>
<TabsTrigger value="memory">Minne</TabsTrigger>
<TabsTrigger value="skills">Kompetens</TabsTrigger>
<TabsTrigger value="knowledge">Kunskap</TabsTrigger>
</TabsList>
{/* Radix unmounts the inactive panel, so each panel's data is fetched
lazily the first time its tab is opened. */}
<TabsContent value="knowledge">
<AgentKnowledgePanel />
</TabsContent>
<TabsContent value="memory">
<AgentMemoryPanel />
</TabsContent>
<TabsContent value="skills">
<AgentSkillsPanel />
</TabsContent>
<TabsContent value="knowledge">
<AgentKnowledgePanel />
</TabsContent>
</Tabs>
)
}