mirror of
https://github.com/bitbaum/botsmann.git
synced 2026-12-03 19:37:08 +01:00
#144 put the bot pages on the brand. This does the other 60 files, so the whole product reads as one thing, and adds the guard that keeps it that way. ~410 raw palette classes became semantic tokens across the public marketing surface (/try, /enterprise, /about, /knowledge, /personal, /professionals, /bots, blog, navigation) and the app internals (dashboard, documents, chat, conversations, onboarding, auth, settings, profile). Gradient text is gone. Fifteen headings were `bg-gradient-to-r from-X to-Y bg-clip-text text-transparent`; they are now solid text-ink or text-action. globals.css says the identity is carried by typography, and a serif display does not need a gradient to do that. The 'B' mark was still a blue/purple gradient in BotNavigation's MOBILE menu. #144 only fixed the desktop header. Both now render the shared <Logo>. Three defects introduced mid-sweep and corrected, all caught by reading the diff rather than trusting the regex: - degenerate gradients (`from-action-tint to-action-tint`) collapsed to solid - dead hovers (tint on tint) rebased to bg-surface + hover:bg-action-tint - `to-action\b` matched the prefix of `to-action-hover`, so a collapse left a stray `bg-action-hover` as a BASE background in 11 places -- those are the primary, not the hover shade Deliberately NOT changed: - components/knowledge/Callout.tsx -- its blue is the `info` half of an info/warning/error triad. Semantic status colour is a separate scale from the brand accent, and warning is amber, so ochre-ing info would make the two nearly indistinguishable. - the custom-bot surfaces -- custom_bots.accent_color is a real column with a CHECK constraint and the owner picks it. User data, not a design token. Never-twice: tests/__tests__/lib/design-tokens.test.ts refuses any raw brand-palette class, and any bg-clip-text, outside those two documented exceptions. Mutation-verified -- swap one token back to bg-blue-600 and it fails and names the file. No allowlist debt: every other file was swept rather than excused. verify: format, lint, typecheck, 256 tests, build -- all green. Twelve pages smoke-tested and checked visually against a local production build. Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
201 lines
6.5 KiB
TypeScript
201 lines
6.5 KiB
TypeScript
'use client';
|
|
|
|
import { useState, useEffect } from 'react';
|
|
import Link from 'next/link';
|
|
import { documentToasts } from '@/lib/toast';
|
|
import { LoadingSpinner } from '@/components/shared/LoadingSpinner';
|
|
|
|
interface Bot {
|
|
id: string;
|
|
title: string;
|
|
emoji: string;
|
|
slug: string;
|
|
knowledge_count?: number;
|
|
}
|
|
|
|
interface AddToBotModalProps {
|
|
isOpen: boolean;
|
|
onClose: () => void;
|
|
documentId: string;
|
|
documentName: string;
|
|
}
|
|
|
|
export const AddToBotModal = ({
|
|
isOpen,
|
|
onClose,
|
|
documentId,
|
|
documentName,
|
|
}: AddToBotModalProps) => {
|
|
const [bots, setBots] = useState<Bot[]>([]);
|
|
const [loading, setLoading] = useState(true);
|
|
const [importing, setImporting] = useState<string | null>(null);
|
|
const [error, setError] = useState<string | null>(null);
|
|
|
|
// Load user's bots
|
|
useEffect(() => {
|
|
if (!isOpen) return;
|
|
|
|
const loadBots = async () => {
|
|
setLoading(true);
|
|
setError(null);
|
|
try {
|
|
const response = await fetch('/api/custom-bots');
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
setBots(data.data?.bots || []);
|
|
} else {
|
|
setError('Failed to load bots');
|
|
}
|
|
} catch {
|
|
setError('Failed to load bots');
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
loadBots();
|
|
}, [isOpen]);
|
|
|
|
const handleImport = async (botId: string) => {
|
|
setImporting(botId);
|
|
setError(null);
|
|
|
|
try {
|
|
const response = await fetch(`/api/custom-bots/${botId}/import-document`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ document_id: documentId }),
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
documentToasts.addToBotSuccess(data.data.bot_title, data.data.imported_chunks);
|
|
onClose();
|
|
} else {
|
|
setError(data.error || 'Failed to import document');
|
|
}
|
|
} catch {
|
|
setError('Failed to import document');
|
|
} finally {
|
|
setImporting(null);
|
|
}
|
|
};
|
|
|
|
if (!isOpen) return null;
|
|
|
|
return (
|
|
<div className="fixed inset-0 z-50 flex items-center justify-center">
|
|
{/* Backdrop */}
|
|
<div className="absolute inset-0 bg-black/50" onClick={onClose} />
|
|
|
|
{/* Modal */}
|
|
<div className="relative bg-white rounded-xl shadow-xl max-w-md w-full mx-4 overflow-hidden">
|
|
{/* Header */}
|
|
<div className="flex items-center justify-between p-4 border-b border-gray-200">
|
|
<div>
|
|
<h2 className="text-lg font-semibold text-gray-900">Add to Bot</h2>
|
|
<p className="text-sm text-gray-500 mt-0.5 truncate max-w-[280px]">{documentName}</p>
|
|
</div>
|
|
<button
|
|
onClick={onClose}
|
|
className="p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-lg transition-colors"
|
|
>
|
|
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
strokeWidth={2}
|
|
d="M6 18L18 6M6 6l12 12"
|
|
/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
{/* Content */}
|
|
<div className="p-4 max-h-80 overflow-y-auto">
|
|
{error && (
|
|
<div className="mb-4 p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm">
|
|
{error}
|
|
</div>
|
|
)}
|
|
|
|
{loading ? (
|
|
<div className="flex items-center justify-center py-8">
|
|
<LoadingSpinner size="lg" />
|
|
</div>
|
|
) : bots.length === 0 ? (
|
|
<div className="text-center py-8">
|
|
<span className="text-4xl mb-3 block">🤖</span>
|
|
<p className="text-gray-600 mb-4">No bots yet</p>
|
|
<Link
|
|
href="/bots/create"
|
|
className="inline-flex items-center px-4 py-2 bg-action text-white rounded-lg font-medium hover:bg-action-hover transition-colors text-sm"
|
|
>
|
|
Create your first bot
|
|
</Link>
|
|
</div>
|
|
) : (
|
|
<div className="space-y-2">
|
|
<p className="text-sm text-gray-600 mb-3">
|
|
Select a bot to import this document's knowledge:
|
|
</p>
|
|
{bots.map((bot) => (
|
|
<button
|
|
key={bot.id}
|
|
onClick={() => handleImport(bot.id)}
|
|
disabled={importing !== null}
|
|
className={`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors text-left ${
|
|
importing === bot.id
|
|
? 'bg-action-tint border-edge'
|
|
: 'bg-gray-50 border-gray-200 hover:bg-gray-100 hover:border-gray-300'
|
|
} disabled:opacity-60 disabled:cursor-not-allowed`}
|
|
>
|
|
<span className="text-2xl flex-shrink-0">{bot.emoji}</span>
|
|
<div className="flex-1 min-w-0">
|
|
<p className="font-medium text-gray-900 truncate">{bot.title}</p>
|
|
<p className="text-xs text-gray-500">
|
|
{bot.knowledge_count || 0} knowledge chunks • /{bot.slug}
|
|
</p>
|
|
</div>
|
|
{importing === bot.id ? (
|
|
<div className="w-5 h-5 border-2 border-edge border-t-transparent rounded-full animate-spin flex-shrink-0" />
|
|
) : (
|
|
<svg
|
|
className="w-5 h-5 text-gray-400 flex-shrink-0"
|
|
fill="none"
|
|
stroke="currentColor"
|
|
viewBox="0 0 24 24"
|
|
>
|
|
<path
|
|
strokeLinecap="round"
|
|
strokeLinejoin="round"
|
|
strokeWidth={2}
|
|
d="M12 4v16m8-8H4"
|
|
/>
|
|
</svg>
|
|
)}
|
|
</button>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
|
|
{/* Footer */}
|
|
<div className="flex items-center justify-between p-4 border-t border-gray-200 bg-gray-50">
|
|
<Link href="/bots/create" className="text-sm text-action hover:text-action font-medium">
|
|
+ Create new bot
|
|
</Link>
|
|
<button
|
|
onClick={onClose}
|
|
className="px-4 py-2 text-gray-700 hover:bg-gray-200 rounded-lg transition-colors text-sm font-medium"
|
|
>
|
|
Cancel
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|