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
+1
View File
@@ -200,3 +200,4 @@ One line per decision: `[YYYY-MM-DD] <decision>: <why>`. Appended by agents and
[2026-07-10] Reopened the no-LLM call for account intelligence (founder directive): dev_docs/data_quality_master.md v2.1 revises D6. AI is scoped to where the deterministic engine has zero signal (supplier cold-start classification, no-hard-key residue, fleet-cluster naming) under D8 guardrails: persist-first (no model calls on booking hot paths), approval-gated suggest-band only (never preselect, never auto-book), AI priors in a sidecar table not categorization_templates, reuse the existing eu-north-1 Bedrock client (BFL residency), self-hosted/no-creds degrades to deterministic. The deterministic floor still ships first in every workstream; the AI-subsystem removal migration stays valid for what it removed (the auto-booking agent), not for AI as such.
[2026-07-12] Issue #988 (transaction stuck on a removed verifikat): root cause was predicate divergence, the re-booking guards treated ANY non-null transactions.journal_entry_id as linked while the UI counts only status='posted'. Fix is a shared hasLiveJournalEntryLink() so stale pointers (reversed/cancelled/missing) are re-linkable, failing CLOSED on read errors, plus optimistic locks on the exact previous pointer instead of always .is(null). Chose guard self-heal over a null-on-reverse DB trigger because a trigger would fight correctEntry's re-point-to-correction behavior and race the correction insert; reverseEntry/correctEntry re-links stay best-effort. match-invoice/match-supplier-invoice untouched (they key on invoice ids; prod had zero dangling there).
[2026-07-15] Issue #735 result-appropriation: did NOT run the mass 2099-to-2098 backfill. Prod audit showed the script read the FROZEN opening-balance 2099, not the CURRENT posted balance: 202 of 360 planned periods already carried their own disposition (mostly via SIE import) and 43 would have double-moved equity (worst case tens of MSEK on a single company), while periods without an OB entry fabricated balances via the cumulative-history fallback. Posted ONE verified entry for the reporting company (unblocking their arsredovisning) and rewrote the script to a current-balance-safe backfill: eligibility decided from current posted 2099, explicit OB entry required, already-disposed and ambiguous periods skipped to a manual-review report. planResultAppropriation/generateResultAppropriation untouched (steady-state year-end path, covered by pg-real tests); the safety lives in the sweep.
[2026-07-17] Assistenten settings opens on Kunskap (konteringskarta) instead of Minne; dropped the nested Kompetens/Minne tab row inside Kunskap: it duplicated the top-level tabs one row above.
+4 -3
View File
@@ -1,7 +1,8 @@
import { redirect } from 'next/navigation'
// "Vad din agent vet" moved into Settings (Assistenten -> Kunskap). This
// route is kept as a permanent redirect so old links/bookmarks still resolve.
// "Vad din agent vet" moved into Settings (Assistenten -> Kunskap, the default
// view). This route is kept as a permanent redirect so old links/bookmarks
// still resolve.
export default function AgentKnowledgeRedirect() {
redirect('/settings/assistant?view=knowledge')
redirect('/settings/assistant')
}
@@ -4,5 +4,5 @@ import { redirect } from 'next/navigation'
// links (e.g. AgentChat's "what I remember" affordance) and old bookmarks land
// in the right place.
export default function AgentMemorySettingsPage() {
redirect('/settings/assistant')
redirect('/settings/assistant?view=memory')
}
@@ -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>
)
}
-2
View File
@@ -192,8 +192,6 @@
"source_user_taught": "You taught me",
"source_agent_learned": "I noted",
"source_derived": "Derived",
"tab_competence": "Competence",
"tab_memory": "Memory",
"tab_config": "Rules & profile",
"footer_basis": "Based on {entries} posted vouchers · updated {date}",
"cp_title": "Booking patterns by counterparty",
-2
View File
@@ -192,8 +192,6 @@
"source_user_taught": "Du lärde mig",
"source_agent_learned": "Jag noterade",
"source_derived": "Härlett",
"tab_competence": "Kompetens",
"tab_memory": "Minne",
"tab_config": "Regler & profil",
"footer_basis": "Baserat på {entries} bokförda verifikat · uppdaterad {date}",
"cp_title": "Konteringsmönster per motpart",