refactor(agent): keep the assistant in the nav, FAB and underlag flow only (#1557)
The founder wants the scattered per-page assistant buttons gone: the assistant is reachable from the nav and the floating tab everywhere, so in-page duplicates were noise. Removed the AgentSparkleButton call sites (year-end, verifikat detail, supplier invoice detail, invoice editor) and the now-orphaned component, the soft hand-off link in the Ny verifikat modal (plus its i18n keys), and the transaction-row overflow item. Kept: nav entry, floating tab, the Dokumentinkorg flow, and the sanctioned "Skapa med assistent" split-button mode on /bookkeeping (design.md convention 14). The command palette's hand-off entries hardcoded the agent name "Anna"; they now use the identity from AgentSheetProvider like every other affordance, and hide until agent onboarding is done (same gate as the FAB). Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Jakob Wennberg
Claude Fable 5
parent
5453f11330
commit
1e9f245f7c
@@ -1,62 +0,0 @@
|
||||
'use client'
|
||||
|
||||
import { MessageCircle } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useAgentSheet } from './AgentSheetProvider'
|
||||
|
||||
interface Props {
|
||||
intentId: string
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
intentArgs?: Record<string, any>
|
||||
contextRef?: string
|
||||
// Override the auto-derived "Fråga [namn]" label when the page wants
|
||||
// something more contextual (e.g. "Förklara denna siffra"). Most surfaces
|
||||
// should leave this unset.
|
||||
label?: string
|
||||
size?: 'sm' | 'default' | 'lg'
|
||||
variant?: 'outline' | 'default' | 'ghost' | 'secondary'
|
||||
className?: string
|
||||
}
|
||||
|
||||
// Single source of truth for the in-page "Fråga [namn]" affordance. Every
|
||||
// page-header button across the dashboard (invoice form, supplier invoice,
|
||||
// bookkeeping, year-end, VAT report, KPI, …) routes through this component
|
||||
// so they share the same icon size, label format, spacing, and resolved
|
||||
// agent name. The transaction-row icon button stays separate: it's a
|
||||
// different UX (icon-only, ghost) embedded inside a row's action group.
|
||||
export default function AgentSparkleButton({
|
||||
intentId,
|
||||
intentArgs,
|
||||
contextRef,
|
||||
label,
|
||||
size = 'sm',
|
||||
variant = 'outline',
|
||||
className,
|
||||
}: Props) {
|
||||
const { openAgentSheet, identity } = useAgentSheet()
|
||||
// Same gate as AgentTrigger: hide all "Fråga …" affordances until the
|
||||
// user has finished /onboarding/agent.
|
||||
if (!identity.isVerified) return null
|
||||
const name = identity.displayName?.trim() || 'min assistent'
|
||||
const resolvedLabel = label ?? `Fråga ${name}`
|
||||
|
||||
return (
|
||||
<Button
|
||||
type="button"
|
||||
variant={variant}
|
||||
size={size}
|
||||
className={cn('shrink-0', className)}
|
||||
onClick={() =>
|
||||
openAgentSheet({
|
||||
intentId,
|
||||
intentArgs,
|
||||
contextRef,
|
||||
})
|
||||
}
|
||||
>
|
||||
<MessageCircle className="mr-2 h-4 w-4" />
|
||||
{resolvedLabel}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user