AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.
HTML ai-agentcloudflarecloudflare-d1cloudflare-r2cloudflare-workersdockerelectronevernoteevernote-alternativeknowledge-basemcpnote-takingobsidian-alternativeoffline-firstpersonal-knowledge-basepwaself-hostedsqlitetiptapweb-clipper
refactor AI settings layout
tianma-ifb18cc61fc921
diff --git a/apps/web/src/components/SettingsPane.tsx b/apps/web/src/components/SettingsPane.tsxindex 12febac9..d5607cf8 100644--- a/apps/web/src/components/SettingsPane.tsx+++ b/apps/web/src/components/SettingsPane.tsx@@ -33,7 +33,6 @@ import { UserManagementCard } from "./settings/UserManagementCard";import { ObjectStorageCard } from "./settings/ObjectStorageCard";import { AiModelCard } from "./settings/AiModelCard";import { AiPromptsCard } from "./settings/AiPromptsCard";-import { AiGenerationPreferenceCard } from "./settings/AiGenerationPreferenceCard";import { AiTagSuggestionPromptCard } from "./settings/AiTagSuggestionPromptCard";import { ThemeToggle } from "./ThemeToggle";import type { AuthUser } from "@edgeever/shared";@@ -242,15 +241,14 @@ export const SettingsPane = ({return (<SettingsGroup><AiModelCard />- <AiPromptsCard onOpenLibrary={onOpenAiPrompts} /><McpConfigCard />+ <AiPromptsCard onOpenLibrary={onOpenAiPrompts} /><AdvancedPlayCard /></SettingsGroup>);case "advanced":return (<SettingsGroup>- <AiGenerationPreferenceCard /><AiTagSuggestionPromptCard />{isOwner ? <ObjectStorageCard demoMode={demoMode} /> : null}{canClearLocalData ? <DesktopLocalDataCard /> : null}diff --git a/apps/web/src/components/settings/AiGenerationPreferenceCard.tsx b/apps/web/src/components/settings/AiGenerationPreferenceCard.tsxdeleted file mode 100644index 4f379f83..00000000--- a/apps/web/src/components/settings/AiGenerationPreferenceCard.tsx+++ /dev/null@@ -1,43 +0,0 @@-import { RadioTower } from "lucide-react";-import { useState } from "react";-import { useTranslation } from "react-i18next";-import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";-import { Switch } from "@/components/ui/switch";-import {- readAiStreamingPreference,- writeAiStreamingPreference,-} from "@/lib/ai-generation-preference";--export const AiGenerationPreferenceCard = () => {- const { t } = useTranslation();- const [streamingEnabled, setStreamingEnabled] = useState(readAiStreamingPreference);-- return (- <Card className="w-full min-w-0 overflow-hidden shadow-none">- <CardHeader className="p-4">- <CardTitle className="flex items-center gap-2 text-sm">- <RadioTower className="h-4 w-4 text-emerald-700" />- {t("settings.aiGenerationTitle")}- </CardTitle>- </CardHeader>- <CardContent className="p-0">- <div className="flex min-h-16 flex-col items-start gap-3 px-4 py-3 sm:flex-row sm:items-center sm:justify-between sm:gap-4">- <div className="min-w-0">- <div className="text-sm font-semibold text-slate-900">{t("settings.aiStreamingTitle")}</div>- <div className="mt-0.5 text-xs leading-5 text-slate-500">{t("settings.aiStreamingDescription")}</div>- </div>- <div className="flex w-full shrink-0 justify-start sm:w-44 sm:justify-end">- <Switch- checked={streamingEnabled}- onCheckedChange={(enabled) => {- writeAiStreamingPreference(enabled);- setStreamingEnabled(enabled);- }}- aria-label={t("settings.aiStreamingAria")}- />- </div>- </div>- </CardContent>- </Card>- );-};diff --git a/apps/web/src/components/settings/AiModelCard.tsx b/apps/web/src/components/settings/AiModelCard.tsxindex 28c80961..aa53f81c 100644--- a/apps/web/src/components/settings/AiModelCard.tsx+++ b/apps/web/src/components/settings/AiModelCard.tsx@@ -23,7 +23,12 @@ import {} from "@/components/ui/dialog";import { Input } from "@/components/ui/input";import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";+import { Switch } from "@/components/ui/switch";import { api } from "@/lib/api";+import {+ readAiStreamingPreference,+ writeAiStreamingPreference,+} from "@/lib/ai-generation-preference";import { cn } from "@/lib/utils";export const AiModelCard = () => {@@ -41,6 +46,7 @@ export const AiModelCard = () => {const [baseUrl, setBaseUrl] = useState(providerDefaults["openai-compatible"].baseUrl);const [apiKey, setApiKey] = useState("");const [initialModelId, setInitialModelId] = useState(providerDefaults["openai-compatible"].modelId);+ const [streamingEnabled, setStreamingEnabled] = useState(readAiStreamingPreference);const refresh = () => queryClient.invalidateQueries({ queryKey: ["ai-settings"] });const resetAddForm = (nextDisplayName = "") => {@@ -107,8 +113,8 @@ export const AiModelCard = () => {<CollapsibleTrigger asChild><button className="flex w-full min-w-0 items-start justify-between gap-3 text-left" type="button"><span className="min-w-0">- <CardTitle className="flex items-center gap-2 text-sm">- <Sparkles className="h-4 w-4 text-emerald-700" />+ <CardTitle className="flex items-center gap-2 text-base font-semibold">+ <Sparkles className="h-4.5 w-4.5 text-emerald-700" />{t("aiModel.title")}</CardTitle><CardDescription className="mt-1 text-xs text-slate-500">{t("aiModel.description")}</CardDescription>@@ -129,26 +135,51 @@ export const AiModelCard = () => {</p>) : null}- <div className="flex items-center justify-between gap-3 rounded-lg border border-slate-200/70 bg-slate-50/50 px-3.5 py-2">- <span className="text-xs font-medium text-slate-700">{t("aiModel.defaultModel")}</span>- <div className="w-56 max-w-[60%] shrink-0 sm:w-72">- <Select- value={settings?.defaultModelId ?? "none"}- onValueChange={(value) => defaultMutation.mutate(value === "none" ? null : value)}- disabled={readOnly || defaultMutation.isPending}- >- <SelectTrigger className="h-8 bg-white text-xs"><SelectValue /></SelectTrigger>- <SelectContent>- <SelectItem value="none">{t("aiModel.noDefaultModel")}</SelectItem>- {allModels.map((model) => (- <SelectItem key={model.id} value={model.id} disabled={!model.providerEnabled}>- {model.displayName} · {model.providerName}- </SelectItem>- ))}- </SelectContent>- </Select>+ <section className="grid gap-2">+ <span className="text-sm font-semibold text-slate-600">+ {t("aiModel.defaultSettingsTitle")}+ </span>+ <div className="overflow-hidden rounded-lg border border-slate-200/70 bg-slate-50/50 divide-y divide-slate-200/70">+ <div className="flex items-center justify-between gap-3 px-3.5 py-2.5">+ <div className="min-w-0">+ <div className="text-sm font-semibold text-slate-800">{t("aiModel.defaultModel")}</div>+ <div className="mt-0.5 text-xs leading-5 text-slate-500">{t("aiModel.defaultModelHint")}</div>+ </div>+ <div className="w-56 max-w-[60%] shrink-0 sm:w-72">+ <Select+ value={settings?.defaultModelId ?? "none"}+ onValueChange={(value) => defaultMutation.mutate(value === "none" ? null : value)}+ disabled={readOnly || defaultMutation.isPending}+ >+ <SelectTrigger className="h-8 bg-white text-xs"><SelectValue /></SelectTrigger>+ <SelectContent>+ <SelectItem value="none">{t("aiModel.noDefaultModel")}</SelectItem>+ {allModels.map((model) => (+ <SelectItem key={model.id} value={model.id} disabled={!model.providerEnabled}>+ {model.displayName} · {model.providerName}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>+ </div>+ <div className="flex items-center justify-between gap-3 px-3.5 py-2.5">+ <div className="min-w-0">+ <div className="text-sm font-semibold text-slate-800">{t("settings.aiStreamingTitle")}</div>+ <div className="mt-0.5 text-xs leading-5 text-slate-500">{t("settings.aiStreamingDescription")}</div>+ </div>+ <Switch+ className="shrink-0"+ checked={streamingEnabled}+ onCheckedChange={(enabled) => {+ writeAiStreamingPreference(enabled);+ setStreamingEnabled(enabled);+ }}+ aria-label={t("settings.aiStreamingAria")}+ />+ </div></div>- </div>+ </section>{!defaultModelAvailable ? (<p className="flex items-center gap-1.5 text-xs text-amber-700"><TriangleAlert className="h-3.5 w-3.5 shrink-0" />@@ -159,7 +190,7 @@ export const AiModelCard = () => {<section className="grid gap-3"><div className="flex items-center justify-between gap-3"><div className="flex items-center gap-2">- <span className="text-xs font-semibold uppercase tracking-wider text-slate-500">+ <span className="text-sm font-semibold text-slate-600">{t("aiModel.servicesTitle")}</span><span className="rounded-full bg-slate-100 px-2 py-0.5 text-[11px] font-medium text-slate-600">diff --git a/apps/web/src/components/settings/AiProviderCard.tsx b/apps/web/src/components/settings/AiProviderCard.tsxindex 0f9be4d5..bc62938c 100644--- a/apps/web/src/components/settings/AiProviderCard.tsx+++ b/apps/web/src/components/settings/AiProviderCard.tsx@@ -163,16 +163,16 @@ export const AiProviderCard = ({ provider: saved, defaultDisplayName, defaultMod<div className="flex flex-col gap-2.5 p-3.5 sm:p-4"><div className="flex items-center justify-between gap-3"><div className="flex min-w-0 flex-wrap items-center gap-2">- <span className="truncate text-xs font-semibold text-slate-900">{effectiveDisplayName}</span>- <span className="rounded-md bg-slate-100 px-2 py-0.5 text-xs font-normal text-slate-600">+ <span className="truncate text-sm font-semibold text-slate-900">{effectiveDisplayName}</span>+ <span className="rounded-md bg-slate-100 px-2 py-0.5 text-[11px] font-medium text-slate-600">{providerLabel}</span>- <span className="max-w-full truncate font-mono text-xs text-slate-400">+ <span className="max-w-full truncate font-mono text-[11px] text-slate-400">{formatBaseUrl(saved.baseUrl)}</span></div><div className="flex shrink-0 items-center gap-1.5">- <span className="hidden text-xs text-slate-400 sm:inline">+ <span className="hidden text-[11px] text-slate-400 sm:inline">{saved.isEnabled ? t("aiModel.serviceEnabledStatus") : t("aiModel.serviceDisabledStatus")}</span><Switchdiff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.tsindex cea8a531..397d33b1 100644--- a/packages/shared/src/i18n/en-US.ts+++ b/packages/shared/src/i18n/en-US.ts@@ -182,9 +182,8 @@ export const enUS = {imageCompressionTitle: "Compress note images",imageCompressionDescription: "Compress large images locally before upload to reduce storage use.",imageCompressionAria: "Compress note images",- aiGenerationTitle: "AI generation",aiStreamingTitle: "Stream AI responses",- aiStreamingDescription: "Show generated content progressively for faster feedback. Streaming processes many response chunks and can make long generations fail on Cloudflare Workers Free because of its strict CPU limit. Keep this off for better reliability.",+ aiStreamingDescription: "Turn on to watch AI content generation in real time; turn off for greater stability.",aiStreamingAria: "Stream AI responses",aiTagPromptTitle: "AI tag suggestion instruction",aiTagPromptDescription: "Customize how AI derives tags from note content. This workspace setting is shared by every client.",diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.tsindex 2985ed66..e2a4368a 100644--- a/packages/shared/src/i18n/zh-CN.ts+++ b/packages/shared/src/i18n/zh-CN.ts@@ -182,9 +182,8 @@ export const zhCN = {imageCompressionTitle: "压缩笔记内图片",imageCompressionDescription: "上传大图时在本地压缩,节省资源占用。",imageCompressionAria: "是否压缩笔记内图片",- aiGenerationTitle: "AI 生成",aiStreamingTitle: "流式返回 AI 结果",- aiStreamingDescription: "开启后可逐步看到生成内容,反馈更及时;但流式处理会解析大量响应分片,在 CPU 限制严格的 Cloudflare Workers 免费版上,长内容更容易生成失败。建议优先保持关闭以获得更好的稳定性。",+ aiStreamingDescription: "开启后实时展示 AI 内容生成过程;关闭可获得更高稳定性。",aiStreamingAria: "是否流式返回 AI 结果",aiTagPromptTitle: "AI 标签建议指令",aiTagPromptDescription: "自定义 AI 如何根据笔记内容生成标签。此设置保存在工作区,各端共用。",