Share links: per-device AI limits and an MCP "Share links" switch
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 28s
All checks were successful
Verify and publish V2 container / build-and-push (push) Successful in 28s
- Each MCP server gets a "Share links" switch (off by default). Shared Explain and Ask use only the servers that have it on. - Visitor AI requests are limited per device instead of per IP, so one campus network doesn't share an allowance. Each browser gets a random id in a signed, HTTP-only cookie (20 requests per 10 minutes per link). Forged ids are replaced. A link-wide cap of 500 requests per hour stays as a cost backstop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
031f7bec31
commit
60cf2322f7
7 changed files with 128 additions and 45 deletions
|
|
@ -5,7 +5,7 @@ import { toast } from 'sonner';
|
|||
import { api, errorMessage } from '@/lib/api';
|
||||
import { Badge, Button, Dialog, Field, Input, Section, Switch, Textarea, useConfirm } from '@/ui';
|
||||
|
||||
type McpArea = 'chat' | 'explain' | 'generate' | 'check';
|
||||
type McpArea = 'chat' | 'explain' | 'generate' | 'check' | 'share';
|
||||
type McpAreas = Record<McpArea, boolean>;
|
||||
|
||||
const AREAS: { key: McpArea; label: string; description: string }[] = [
|
||||
|
|
@ -13,8 +13,9 @@ const AREAS: { key: McpArea; label: string; description: string }[] = [
|
|||
{ key: 'explain', label: 'Explain this', description: 'Help on a quiz question, flashcard or passage.' },
|
||||
{ key: 'generate', label: 'Generating material', description: 'Writing quizzes, flashcards and study guides.' },
|
||||
{ key: 'check', label: 'Quiz check', description: 'The answer check after a quiz is generated.' },
|
||||
{ key: 'share', label: 'Share links', description: 'Explain and Ask on links you share, when those are on. Visitors use this server through your account.' },
|
||||
];
|
||||
const DEFAULT_AREAS: McpAreas = { chat: true, explain: true, generate: false, check: false };
|
||||
const DEFAULT_AREAS: McpAreas = { chat: true, explain: true, generate: false, check: false, share: false };
|
||||
|
||||
interface McpServer {
|
||||
id: string;
|
||||
|
|
@ -61,7 +62,7 @@ function ServerDialog({ open, existing, onClose, onSaved }: { open: boolean; exi
|
|||
setUrl(existing?.url ?? '');
|
||||
setHeaders('');
|
||||
setInstructions(existing?.instructions ?? '');
|
||||
setAreas(existing?.areas ?? DEFAULT_AREAS);
|
||||
setAreas({ ...DEFAULT_AREAS, ...existing?.areas });
|
||||
}, [open, existing]);
|
||||
|
||||
const canSave = name.trim() && /^https?:\/\/\S+$/i.test(url.trim());
|
||||
|
|
|
|||
|
|
@ -374,9 +374,9 @@ export function ShareDialog({ target, onClose }: { target: { kind: ShareKind; id
|
|||
checked={Boolean(share.ai?.assistant)}
|
||||
onChange={(v) => act(() => api.patch<{ share: Share }>(`/api/shares/${share.id}`, { ai: { assistant: v } }))}
|
||||
label="Ask about this material"
|
||||
description="A chat that answers from what you shared only. It can't see the rest of your library or your connected tools."
|
||||
description="A chat that answers from what you shared. It can't see the rest of your library."
|
||||
/>
|
||||
<p className="text-xs text-ink-3">Uses your AI models and is billed to your API keys. Requests are rate-limited per visitor.</p>
|
||||
<p className="text-xs text-ink-3">Uses your AI models and is billed to your API keys. MCP servers take part only if you allowed them on share links in Settings → AI. Each device can make 20 requests per 10 minutes, and the link 500 per hour.</p>
|
||||
</fieldset>
|
||||
</>
|
||||
) : (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue