* fix(agent): hide Anthropic-only assistant surfaces where the provider cannot run them Self-hosted deployments on an OpenAI-compatible provider (or with no AI configured) still showed every entry point into the tool-loop runtime behind /api/agent/invoke, which answers 503 there. The capability lived server-side only (getAiStatus().assistantAvailable); no UI could read it. Hand the flag to the client through CompanyContext (useAssistantAvailable, beside the paid-capability gate) and gate each entry point that opens AgentChat: the bookkeeping page's "Skapa med assistent" and "Med assistenten", the inbox workspace's "Fråga assistenten" doors, /chat/intake and /chat/new?intent=. The floating trigger falls back to general help (the single-call console runs on any provider) instead of hiding, and AgentChat itself never fires an invoke without the runtime, so a resumed thread or a forgotten entry point shows a notice instead of a 503. The Hem checklist's "Anslut till Claude" step renders only where the assistant runs on Claude and the mcp-server extension is on. Provider-agnostic AI (ask console, categorization, extraction) and the server-side 503 are unchanged; on hosted the flag is true and nothing changes. Closes #2204 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019SaJfqNi4VmsG8FMKq99G6 * test(ai): use a placeholder that cannot match an Anthropic key shape The new direct-Anthropic status test assigned a string in the exact format of a live API key, which trips secret scanners on every run. The config only reads presence, so any non-empty string exercises the path. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
44 lines
2.0 KiB
TypeScript
44 lines
2.0 KiB
TypeScript
import { redirect } from 'next/navigation'
|
|
import ChatNewStarter from '@/components/agent/ChatNewStarter'
|
|
import { getIntent } from '@/lib/agent/intents/registry'
|
|
import { CHAT_INTENT_ID } from '@/lib/agent/ask/persist'
|
|
import { getAiStatus } from '@/lib/ai'
|
|
import { getDashboardAuthContext, getDashboardCompanyId } from '../../request-context'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
interface PageProps {
|
|
searchParams: Promise<{ intent?: string; prompt?: string }>
|
|
}
|
|
|
|
// /chat/new: generic conversation bootstrap. Reads ?intent= and ?prompt=
|
|
// from the URL and mounts AgentChat in fresh mode; AgentChat creates the
|
|
// conversation server-side on first invoke and the client swaps the URL
|
|
// to /chat/[id] when the id streams back. Mirrors /chat/intake but with
|
|
// caller-chosen intent/seed, so suggestion chips and ⌘K can route here
|
|
// inline instead of opening the slide-in sheet.
|
|
export default async function ChatNewPage({ searchParams }: PageProps) {
|
|
const [{ user }, companyId] = await Promise.all([
|
|
getDashboardAuthContext(),
|
|
getDashboardCompanyId(),
|
|
])
|
|
if (!user) redirect('/login')
|
|
if (!companyId) redirect('/onboarding')
|
|
|
|
const sp = await searchParams
|
|
const requested = typeof sp.intent === 'string' && sp.intent.trim() ? sp.intent.trim() : 'general.help'
|
|
// Validate against the registry: a bogus ?intent= would otherwise render the
|
|
// chat shell and then fail at invoke with a 400, which reads as "Anna is broken"
|
|
// rather than "bad link". Fall back to general help instead.
|
|
// Specialized intents run on the tool-loop runtime; where the deployment
|
|
// cannot run it (#2204) the single-call console takes the same prompt as
|
|
// general help instead of a chat that fails at invoke.
|
|
const intent =
|
|
getIntent(requested) && (requested === CHAT_INTENT_ID || getAiStatus().assistantAvailable)
|
|
? requested
|
|
: CHAT_INTENT_ID
|
|
const prompt = typeof sp.prompt === 'string' ? sp.prompt : ''
|
|
|
|
return <ChatNewStarter intentId={intent} seedUserMessage={prompt} />
|
|
}
|