b800dcd403
* style(ui): system-wide UX/UI polish pass — design-system conformance + copy cleanup Multi-agent scan of all 404 UI files against the locked design system, then 141 verified surgical fixes across 109 files (net -32 lines): - Remove forbidden elevation/motion: shadow-* and rounded-xl on cards, active:scale bounce, hover:shadow on list items, transition-all -> transition-colors. - Drop font-medium from single-weight Hedvig display headings/numerals. - Replace raw rainbow Tailwind status colors with Badge variants / brand tokens / neutral surfaces (achromatic chrome, semantic colors stay data-only). - Route raw dates through formatDate(), hand-rolled currency through formatCurrency(), add tabular-nums to financial figures; text-gray-* -> text-foreground tokens. - Swap hand-rolled skeletons for the Skeleton primitive; off-scale spacing -> token scale. - Fix copy: mislabeled "Leverantörsfakturor" -> "Utgifter" on bank-import outflow total, collapse no-op identical-branch ternaries, broken Swedish diacritics (mojibake), correct mismatch-password toast, correct supplier currency-field label. - Remove PII-leaking debug console.log on register, stray console.logs. Verified: tsc clean on all changed files, eslint clean, production build passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * fix(auth): sanitize residual error logs in register flow Follow-up to PR review (compliance swarm V16 / GDPR Art.5(1)(f)): the remaining console.error calls in the register flow passed raw error objects, which Supabase may populate with PII (email) in nested fields. Log only sanitized message strings instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
68 lines
2.8 KiB
TypeScript
68 lines
2.8 KiB
TypeScript
'use client'
|
|
|
|
import { useRouter } from 'next/navigation'
|
|
import { useState } from 'react'
|
|
import AgentChat from './AgentChat'
|
|
import AgentAvatar from './AgentAvatar'
|
|
import SandboxAgentPreview from './SandboxAgentPreview'
|
|
import { useAgentSheet } from './AgentSheetProvider'
|
|
import { useCompanyOptional } from '@/contexts/CompanyContext'
|
|
|
|
// Phase C entry surface. Lands here from ReviewCard's "kör" after Phase B
|
|
// verify succeeds. Renders AgentChat in fresh-start mode — no
|
|
// initialConversationId, no initialMessages — so the auto-fire effect
|
|
// kicks the first invoke. As soon as /api/agent/invoke emits the
|
|
// conversation event, the URL swaps to /chat/[id] so reload / share /
|
|
// browser-back all work like any other conversation.
|
|
//
|
|
// Plan refs: §7 Phase C.
|
|
export default function ChatIntakeStarter() {
|
|
const router = useRouter()
|
|
const { identity } = useAgentSheet()
|
|
const companyCtx = useCompanyOptional()
|
|
const isSandbox = companyCtx?.isSandbox ?? false
|
|
const agentName = identity.displayName?.trim() || 'Din assistent'
|
|
// Lock the swap to the first id we see — defensive guard against the
|
|
// AgentChat callback firing twice during React 19 Strict Mode reruns.
|
|
const [swapped, setSwapped] = useState(false)
|
|
|
|
return (
|
|
<>
|
|
<header className="flex items-center gap-3 border-b border-border px-6 py-4 shrink-0">
|
|
<AgentAvatar avatarId={identity.avatarId} size="sm" alt={agentName} />
|
|
<div className="min-w-0">
|
|
<h1 className="font-display text-lg tracking-tight truncate">{agentName} är redo</h1>
|
|
<p className="text-xs text-muted-foreground">
|
|
{isSandbox
|
|
? 'Förhandsvisning — den verkliga konversationen kräver ett konto.'
|
|
: 'Några frågor för att lära känna din verksamhet — svara i din egen takt, du kan avsluta när du vill.'}
|
|
</p>
|
|
</div>
|
|
</header>
|
|
|
|
<div className="flex-1 min-h-0 flex flex-col">
|
|
{isSandbox ? (
|
|
<SandboxAgentPreview agentName={agentName} />
|
|
) : (
|
|
<AgentChat
|
|
intentId="onboarding.intake"
|
|
initialMessages={[]}
|
|
initialConversationId={null}
|
|
onFirstTurnComplete={(id) => {
|
|
// Wait for the greeting to finish streaming AND persist before
|
|
// swapping the URL. Swapping on the early `conversation` event
|
|
// unmounts AgentChat mid-stream, so the greeting is never saved
|
|
// and /chat/[id] hydrates empty — the bug where the chat lands
|
|
// blank and only shows the intro on a later visit.
|
|
if (swapped) return
|
|
setSwapped(true)
|
|
router.replace(`/chat/${id}`)
|
|
}}
|
|
scrollerClassName="px-6 py-8"
|
|
/>
|
|
)}
|
|
</div>
|
|
</>
|
|
)
|
|
}
|