Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

fix(ai): default generation to non-streaming

tianma-ife4d6050462b8
diff --git a/apps/api/src/ai-routes.test.mjs b/apps/api/src/ai-routes.test.mjs
index 17f5dfcf..2070e423 100644
--- a/apps/api/src/ai-routes.test.mjs
+++ b/apps/api/src/ai-routes.test.mjs
@@ -117,6 +117,12 @@ describe("AI route contracts", () => {
}
});
+ test("defaults AI generation to non-streaming and accepts an explicit opt-in", () => {
+ const input = { action: "summarize", title: "Note", contentMarkdown: "Body" };
+ expect(AiGenerateSchema.parse(input).stream).toBe(false);
+ expect(AiGenerateSchema.parse({ ...input, stream: true }).stream).toBe(true);
+ });
+
test("defers prompt-specific action and parameter validation to the saved prompt", () => {
expect(AiGenerateSchema.safeParse({
action: "custom",
diff --git a/apps/api/src/ai-routes.ts b/apps/api/src/ai-routes.ts
index 821465fd..0ea6e7be 100644
--- a/apps/api/src/ai-routes.ts
+++ b/apps/api/src/ai-routes.ts
@@ -16,12 +16,14 @@ import { auditStatement } from "./audit";
import { getAiPromptTemplate, resolveWorkspaceActionInstruction } from "./ai-prompt-service";
import {
createAiGenerationResultBoundary,
+ createAiGenerationStreamNormalizer,
decryptAiCredential,
discoverAiModels,
getAiModelConfig,
getAiProviderConfig,
getAiSettings,
getDefaultAiModelId,
+ generateAiGeneration,
loadDefaultAiModel,
normalizeAiGenerationText,
normalizeAiBaseUrl,
@@ -491,7 +493,7 @@ export const registerAiRoutes = (app: Hono<AppEnv>, dependencies: AiRouteDepende
context.env,
);
const resultBoundary = createAiGenerationResultBoundary();
- const result = streamAiGeneration({
+ const generationInput = {
...input,
action,
instruction: resolvedInstruction,
@@ -500,27 +502,50 @@ export const registerAiRoutes = (app: Hono<AppEnv>, dependencies: AiRouteDepende
model,
resultBoundary,
abortSignal: context.req.raw.signal,
- });
+ };
const encoder = new TextEncoder();
const stream = new ReadableStream<Uint8Array>({
async start(controller) {
const send = (event: unknown) => controller.enqueue(encoder.encode(`data: ${JSON.stringify(event)}\n\n`));
send({ type: "start" });
try {
- let generatedContent = "";
- for await (const part of result.stream) {
- if (part.type === "error") throw part.error;
- if (part.type === "text-delta") generatedContent += part.text;
+ if (input.stream) {
+ const result = streamAiGeneration(generationInput);
+ const normalizer = createAiGenerationStreamNormalizer(resultBoundary);
+ let hasContent = false;
+ for await (const part of result.stream) {
+ if (part.type === "error") throw part.error;
+ if (part.type !== "text-delta") continue;
+ const text = normalizer.push(part.text);
+ if (!text) continue;
+ hasContent ||= Boolean(text.trim());
+ send({ type: "text-delta", text });
+ }
+ const trailingText = normalizer.finish();
+ if (trailingText) {
+ hasContent ||= Boolean(trailingText.trim());
+ send({ type: "text-delta", text: trailingText });
+ }
+ if (!hasContent) throw new Error("The AI did not return a note result.");
+ const [usage, finishReason] = await Promise.all([result.usage, result.finishReason]);
+ send({
+ type: "finish",
+ finishReason,
+ inputTokens: usage.inputTokens,
+ outputTokens: usage.outputTokens,
+ });
+ return;
}
- const contentMarkdown = normalizeAiGenerationText(generatedContent, resultBoundary);
+
+ const result = await generateAiGeneration(generationInput);
+ const contentMarkdown = normalizeAiGenerationText(result.text, resultBoundary);
if (!contentMarkdown) throw new Error("The AI did not return a note result.");
send({ type: "text-delta", text: contentMarkdown });
- const [usage, finishReason] = await Promise.all([result.usage, result.finishReason]);
send({
type: "finish",
- finishReason,
- inputTokens: usage.inputTokens,
- outputTokens: usage.outputTokens,
+ finishReason: result.finishReason,
+ inputTokens: result.usage.inputTokens,
+ outputTokens: result.usage.outputTokens,
});
} catch (error) {
send({ type: "error", code: "ai_generation_failed", message: providerErrorMessage(error) });
diff --git a/apps/api/src/ai-service.test.mjs b/apps/api/src/ai-service.test.mjs
index 922569e9..e38cf078 100644
--- a/apps/api/src/ai-service.test.mjs
+++ b/apps/api/src/ai-service.test.mjs
@@ -6,6 +6,7 @@ import {
aiActionInstructions,
buildAiGenerationPrompt,
createAiGenerationResultBoundary,
+ createAiGenerationStreamNormalizer,
discoverAiModels,
mapAiProviderConfig,
normalizeAiGenerationText,
@@ -127,6 +128,39 @@ describe("AI model service", () => {
expect(await result.finishReason).toBe("stop");
});
+ test("normalizes bounded output incrementally across split markers", () => {
+ const normalizer = createAiGenerationStreamNormalizer(resultBoundary);
+ const chunks = [
+ "Preamble that must not be shown.\n<edgeever-result-",
+ "test123>\n# Result\n\nFirst ",
+ "part.\n</edgeever-result-",
+ "test123>\nPostscript that must not be shown.",
+ ];
+ const emitted = chunks.map((chunk) => normalizer.push(chunk)).filter(Boolean);
+ const trailing = normalizer.finish();
+
+ expect(emitted.join("") + trailing).toBe("# Result\n\nFirst part.");
+ expect(emitted.length).toBeGreaterThan(1);
+ });
+
+ test("falls back to the normalized full response when a model omits result markers", () => {
+ const normalizer = createAiGenerationStreamNormalizer(resultBoundary);
+ expect(normalizer.push("```markdown\n# Result")).toBe("");
+ expect(normalizer.push("\n```")).toBe("");
+ expect(normalizer.finish()).toBe("# Result");
+ });
+
+ test("removes a whole-response Markdown fence while streaming bounded output", () => {
+ const normalizer = createAiGenerationStreamNormalizer(resultBoundary);
+ const chunks = [
+ `${resultBoundary.start}\n\`\`\`mark`,
+ "down\n# Result\n\nBody",
+ `\n\`\`\`\n${resultBoundary.end}`,
+ ];
+ const output = chunks.map((chunk) => normalizer.push(chunk)).join("") + normalizer.finish();
+ expect(output).toBe("# Result\n\nBody");
+ });
+
test("omits tools and tool_choice from the OpenAI-compatible request body", async () => {
const requests = [];
const model = createOpenAICompatible({
diff --git a/apps/api/src/ai-service.ts b/apps/api/src/ai-service.ts
index ae98aca0..71a587f8 100644
--- a/apps/api/src/ai-service.ts
+++ b/apps/api/src/ai-service.ts
@@ -391,6 +391,85 @@ export const normalizeAiGenerationText = (
return fencedMarkdown ? fencedMarkdown[1].trim() : result;
};
+/** Incrementally remove the result boundary while preserving a safe full-response fallback. */
+export const createAiGenerationStreamNormalizer = (resultBoundary: AiGenerationResultBoundary) => {
+ let pending = "";
+ let boundaryStarted = false;
+ let boundaryFinished = false;
+ let openingLineRemoved = false;
+ let wrapperResolved = false;
+ let fencedMarkdown = false;
+
+ const removeOpeningLine = () => {
+ if (openingLineRemoved) return true;
+ const openingLine = /^[ \t]*(?:\r\n|\r|\n)/.exec(pending);
+ if (openingLine) {
+ pending = pending.slice(openingLine[0].length);
+ openingLineRemoved = true;
+ return true;
+ }
+ if (/^[ \t]*\r?$/.test(pending)) return false;
+ openingLineRemoved = true;
+ return true;
+ };
+
+ const resolveMarkdownWrapper = (finishing = false) => {
+ if (wrapperResolved) return true;
+ const wrapper = /^```(?:markdown|md)[ \t]*(?:\r\n|\r|\n)/i.exec(pending);
+ if (wrapper) {
+ pending = pending.slice(wrapper[0].length);
+ fencedMarkdown = true;
+ wrapperResolved = true;
+ return true;
+ }
+ if (!finishing && !/(?:\r\n|\r|\n)/.test(pending)) return false;
+ wrapperResolved = true;
+ return true;
+ };
+
+ const stripClosingWrapper = (value: string) => fencedMarkdown
+ ? value.replace(/(?:\r\n|\r|\n)```[ \t]*(?:\r\n|\r|\n)?$/, "")
+ : value;
+
+ return {
+ push(value: string) {
+ if (boundaryFinished || !value) return "";
+ pending += value;
+
+ if (!boundaryStarted) {
+ const startIndex = pending.indexOf(resultBoundary.start);
+ if (startIndex < 0) return "";
+ pending = pending.slice(startIndex + resultBoundary.start.length);
+ boundaryStarted = true;
+ }
+
+ if (!removeOpeningLine()) return "";
+ if (!resolveMarkdownWrapper()) return "";
+ const endIndex = pending.indexOf(resultBoundary.end);
+ if (endIndex >= 0) {
+ const output = stripClosingWrapper(pending.slice(0, endIndex))
+ .replace(/[ \t]*(?:\r\n|\r|\n)?$/, "");
+ pending = "";
+ boundaryFinished = true;
+ return output;
+ }
+
+ const retainedLength = resultBoundary.end.length;
+ if (pending.length <= retainedLength) return "";
+ const output = pending.slice(0, -retainedLength);
+ pending = pending.slice(-retainedLength);
+ return output;
+ },
+ finish() {
+ if (boundaryFinished) return "";
+ if (!boundaryStarted) return normalizeAiGenerationText(pending, resultBoundary);
+ removeOpeningLine();
+ resolveMarkdownWrapper(true);
+ return stripClosingWrapper(pending.replaceAll(resultBoundary.end, "")).trimEnd();
+ },
+ };
+};
+
export const resolveAiGenerationSystemInstruction = (input: {
action: AiAction;
tone?: AiTone;
@@ -430,7 +509,7 @@ export const buildAiGenerationPrompt = (input: {
`Note content:\n${input.contentMarkdown}`,
].filter(Boolean).join("\n\n");
-export const streamAiGeneration = (input: {
+type AiGenerationRequest = {
model: ReturnType<typeof createAiModel>;
action: AiAction;
title: string;
@@ -440,7 +519,9 @@ export const streamAiGeneration = (input: {
instruction?: string;
resultBoundary: AiGenerationResultBoundary;
abortSignal?: AbortSignal;
-}) => streamText({
+};
+
+const buildAiGenerationRequest = (input: AiGenerationRequest) => ({
model: input.model,
system: resolveAiGenerationSystemInstruction(input),
prompt: buildAiGenerationPrompt({
@@ -452,3 +533,7 @@ export const streamAiGeneration = (input: {
maxOutputTokens: 4096,
abortSignal: input.abortSignal,
});
+
+export const generateAiGeneration = (input: AiGenerationRequest) => generateText(buildAiGenerationRequest(input));
+
+export const streamAiGeneration = (input: AiGenerationRequest) => streamText(buildAiGenerationRequest(input));
diff --git a/apps/web/src/components/SettingsPane.tsx b/apps/web/src/components/SettingsPane.tsx
index a46883d5..cfda53b1 100644
--- a/apps/web/src/components/SettingsPane.tsx
+++ b/apps/web/src/components/SettingsPane.tsx
@@ -34,6 +34,7 @@ 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 { ThemeToggle } from "./ThemeToggle";
import type { AuthUser } from "@edgeever/shared";
import { contentEnterMotion } from "@/lib/motion";
@@ -142,17 +143,15 @@ export const SettingsPane = ({
},
]
: []),
- ...(isOwner || canClearLocalData
- ? [{
- key: "advanced" as const,
- label: t("settings.tabs.advanced"),
- icon: Wrench,
- colorClass: "text-emerald-700",
- bgColorClass: "bg-emerald-50/80",
- hoverColorClass: "hover:bg-emerald-50/40",
- iconColorClass: "text-emerald-600",
- }]
- : []),
+ {
+ key: "advanced",
+ label: t("settings.tabs.advanced"),
+ icon: Wrench,
+ colorClass: "text-emerald-700",
+ bgColorClass: "bg-emerald-50/80",
+ hoverColorClass: "hover:bg-emerald-50/40",
+ iconColorClass: "text-emerald-600",
+ },
{
key: "account",
label: t("settings.tabs.account"),
@@ -235,12 +234,13 @@ export const SettingsPane = ({
</SettingsGroup>
);
case "advanced":
- return isOwner || canClearLocalData ? (
+ return (
<SettingsGroup>
+ <AiGenerationPreferenceCard />
{isOwner ? <ObjectStorageCard demoMode={demoMode} /> : null}
- <DesktopLocalDataCard />
+ {canClearLocalData ? <DesktopLocalDataCard /> : null}
</SettingsGroup>
- ) : null;
+ );
case "account":
return (
<SettingsGroup>
diff --git a/apps/web/src/components/settings/AiGenerationPreferenceCard.tsx b/apps/web/src/components/settings/AiGenerationPreferenceCard.tsx
new file mode 100644
index 00000000..4f379f83
--- /dev/null
+++ b/apps/web/src/components/settings/AiGenerationPreferenceCard.tsx
@@ -0,0 +1,43 @@
+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/lib/ai-generation-preference.test.mjs b/apps/web/src/lib/ai-generation-preference.test.mjs
new file mode 100644
index 00000000..6b36e59b
--- /dev/null
+++ b/apps/web/src/lib/ai-generation-preference.test.mjs
@@ -0,0 +1,49 @@
+import { afterEach, describe, expect, test } from "bun:test";
+import {
+ AI_STREAMING_STORAGE_KEY,
+ readAiStreamingPreference,
+ writeAiStreamingPreference,
+} from "./ai-generation-preference.ts";
+
+const originalWindow = globalThis.window;
+
+afterEach(() => {
+ globalThis.window = originalWindow;
+});
+
+const installLocalStorage = () => {
+ const values = new Map();
+ globalThis.window = {
+ localStorage: {
+ getItem: (key) => values.get(key) ?? null,
+ setItem: (key, value) => values.set(key, String(value)),
+ },
+ };
+ return values;
+};
+
+describe("AI streaming preference", () => {
+ test("defaults to disabled and persists explicit changes", () => {
+ const values = installLocalStorage();
+ expect(readAiStreamingPreference()).toBe(false);
+
+ writeAiStreamingPreference(true);
+ expect(values.get(AI_STREAMING_STORAGE_KEY)).toBe("true");
+ expect(readAiStreamingPreference()).toBe(true);
+
+ writeAiStreamingPreference(false);
+ expect(values.get(AI_STREAMING_STORAGE_KEY)).toBe("false");
+ expect(readAiStreamingPreference()).toBe(false);
+ });
+
+ test("fails closed when local storage is unavailable", () => {
+ globalThis.window = {
+ localStorage: {
+ getItem: () => { throw new Error("blocked"); },
+ setItem: () => { throw new Error("blocked"); },
+ },
+ };
+ expect(readAiStreamingPreference()).toBe(false);
+ expect(() => writeAiStreamingPreference(true)).not.toThrow();
+ });
+});
diff --git a/apps/web/src/lib/ai-generation-preference.ts b/apps/web/src/lib/ai-generation-preference.ts
new file mode 100644
index 00000000..42df7cab
--- /dev/null
+++ b/apps/web/src/lib/ai-generation-preference.ts
@@ -0,0 +1,18 @@
+export const AI_STREAMING_STORAGE_KEY = "edgeever.aiStreamingEnabled";
+
+export const readAiStreamingPreference = () => {
+ try {
+ return typeof window !== "undefined"
+ && window.localStorage.getItem(AI_STREAMING_STORAGE_KEY) === "true";
+ } catch {
+ return false;
+ }
+};
+
+export const writeAiStreamingPreference = (enabled: boolean) => {
+ try {
+ window.localStorage.setItem(AI_STREAMING_STORAGE_KEY, enabled ? "true" : "false");
+ } catch {
+ // Local storage can be unavailable in private or restricted browser contexts.
+ }
+};
diff --git a/apps/web/src/lib/api.test.mjs b/apps/web/src/lib/api.test.mjs
index cddaf614..90788415 100644
--- a/apps/web/src/lib/api.test.mjs
+++ b/apps/web/src/lib/api.test.mjs
@@ -391,4 +391,23 @@ describe("desktop instance setup", () => {
});
}
});
+
+ test("sends the disabled-by-default AI streaming preference and honors opt-in", async () => {
+ const requestBodies = [];
+ globalThis.fetch = async (_url, init) => {
+ requestBodies.push(JSON.parse(String(init?.body)));
+ return new Response('data: {"type":"finish"}\n\n', {
+ headers: { "Content-Type": "text/event-stream" },
+ });
+ };
+ const payload = { action: "summarize", title: "Note", contentMarkdown: "Body" };
+
+ storage.delete("edgeever.aiStreamingEnabled");
+ await api.streamAiGeneration(payload, { onEvent: () => {} });
+ storage.set("edgeever.aiStreamingEnabled", "true");
+ await api.streamAiGeneration(payload, { onEvent: () => {} });
+ await api.streamAiGeneration({ ...payload, stream: false }, { onEvent: () => {} });
+
+ expect(requestBodies.map((body) => body.stream)).toEqual([false, true, false]);
+ });
});
diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts
index a68e13a2..b01c03f9 100644
--- a/apps/web/src/lib/api.ts
+++ b/apps/web/src/lib/api.ts
@@ -37,6 +37,7 @@ import type {
} from "@edgeever/shared";
import { resolveInstanceUrlInput } from "@edgeever/shared";
import type { MemoFilterMode, MemoSortMode } from "./app-helpers";
+import { readAiStreamingPreference } from "./ai-generation-preference";
type ListNotebooksResponse = {
notebooks: Notebook[];
@@ -631,6 +632,7 @@ export const api = {
locale?: string;
title: string;
contentMarkdown: string;
+ stream?: boolean;
targetLanguage?: AiTargetLanguage;
tone?: AiTone;
instruction?: string;
@@ -646,7 +648,10 @@ export const api = {
method: "POST",
credentials: "include",
headers,
- body: JSON.stringify(payload),
+ body: JSON.stringify({
+ ...payload,
+ stream: payload.stream ?? readAiStreamingPreference(),
+ }),
signal: options.signal,
});
if (!response.ok) {
diff --git a/docs/openapi.json b/docs/openapi.json
index 87f94c32..3889a42b 100644
--- a/docs/openapi.json
+++ b/docs/openapi.json
@@ -193,7 +193,7 @@
},
"/api/v1/ai/generate": {
"post": {
- "summary": "Stream a note AI action using the current workspace model",
+ "summary": "Run a note AI action using the current workspace model",
"requestBody": {
"required": true,
"content": {
@@ -206,6 +206,7 @@
"locale": { "type": "string", "maxLength": 35 },
"title": { "type": "string", "maxLength": 160 },
"contentMarkdown": { "type": "string", "maxLength": 300000 },
+ "stream": { "type": "boolean", "default": false, "description": "Stream normalized text deltas when enabled; disabled by default for lower Worker CPU usage" },
"targetLanguage": { "type": "string", "enum": ["en", "zh-CN", "zh-TW", "ja", "ko", "es", "fr", "de", "pt"], "description": "Required when the action or selected prompt requests a target language" },
"tone": { "type": "string", "enum": ["professional", "friendly", "casual", "direct"] },
"instruction": { "type": "string", "minLength": 1, "maxLength": 2000, "description": "Freeform instruction; ignored when promptId is supplied" }
diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts
index f68ee06f..f2ec88b8 100644
--- a/packages/client/src/index.ts
+++ b/packages/client/src/index.ts
@@ -332,6 +332,7 @@ export const createEdgeEverClient = (options: EdgeEverClientOptions = {}) => {
locale?: string;
title: string;
contentMarkdown: string;
+ stream?: boolean;
targetLanguage?: AiTargetLanguage;
tone?: AiTone;
instruction?: string;
diff --git a/packages/shared/src/i18n/en-US.ts b/packages/shared/src/i18n/en-US.ts
index 3dc07d63..4ac24cc2 100644
--- a/packages/shared/src/i18n/en-US.ts
+++ b/packages/shared/src/i18n/en-US.ts
@@ -182,6 +182,10 @@ 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.",
+ aiStreamingAria: "Stream AI responses",
linkOpenModifierTitle: "Open links with Ctrl/⌘ + click while editing",
linkOpenModifierDescription: "On by default: hold Ctrl/⌘ and click to open links, preventing accidental opens while editing. Turn off to use a single click. Desktop only.",
linkOpenModifierAria: "Require Ctrl or ⌘ click to open links while editing",
diff --git a/packages/shared/src/i18n/zh-CN.ts b/packages/shared/src/i18n/zh-CN.ts
index 985f6987..b57b4045 100644
--- a/packages/shared/src/i18n/zh-CN.ts
+++ b/packages/shared/src/i18n/zh-CN.ts
@@ -182,6 +182,10 @@ export const zhCN = {
imageCompressionTitle: "压缩笔记内图片",
imageCompressionDescription: "上传大图时在本地压缩,节省资源占用。",
imageCompressionAria: "是否压缩笔记内图片",
+ aiGenerationTitle: "AI 生成",
+ aiStreamingTitle: "流式返回 AI 结果",
+ aiStreamingDescription: "开启后可逐步看到生成内容,反馈更及时;但流式处理会解析大量响应分片,在 CPU 限制严格的 Cloudflare Workers 免费版上,长内容更容易生成失败。建议优先保持关闭以获得更好的稳定性。",
+ aiStreamingAria: "是否流式返回 AI 结果",
linkOpenModifierTitle: "编辑时用 Ctrl/⌘ + 点击打开链接",
linkOpenModifierDescription: "默认开启:需按住 Ctrl/⌘ 再点击链接,避免编辑时误触;关闭后可单击打开(仅桌面)。",
linkOpenModifierAria: "编辑时是否需要 Ctrl 或 ⌘ 再点击才能打开链接",
diff --git a/packages/shared/src/schemas.ts b/packages/shared/src/schemas.ts
index aaa310c4..95a6ad8e 100644
--- a/packages/shared/src/schemas.ts
+++ b/packages/shared/src/schemas.ts
@@ -215,6 +215,7 @@ export const AiGenerateSchema = z.object({
locale: z.string().trim().min(2).max(35).optional(),
title: z.string().trim().max(160).default(""),
contentMarkdown: z.string().max(300_000),
+ stream: z.boolean().default(false),
targetLanguage: z.enum(AI_TARGET_LANGUAGES).optional(),
tone: z.enum(AI_TONES).optional(),
instruction: z.string().trim().min(1).max(2_000).optional(),