Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Exclude Electron page fetching from browser and mobile bundles https://github.com/siyuan-note/siyuan/issues/20657

Vanessaeda645de84a5
diff --git a/app/src/layout/dock/agent/frontendCapabilities.test.ts b/app/src/layout/dock/agent/frontendCapabilities.test.ts
index 3647800f2e..67b6e24e09 100644
--- a/app/src/layout/dock/agent/frontendCapabilities.test.ts
+++ b/app/src/layout/dock/agent/frontendCapabilities.test.ts
@@ -57,6 +57,12 @@ for (const platform of ["desktop", "browser", "mobile"]) {
const code = transpileModule(source, {compilerOptions: {
module: ModuleKind.CommonJS, target: ScriptTarget.ES2021,
}}).outputText;
+ if (platform === "desktop") {
+ assert.match(code, /require\("electron"\)/);
+ } else {
+ assert.doesNotMatch(code, /require\("electron"\)/);
+ assert.doesNotMatch(code, /siyuan-web-page-fetch/);
+ }
const exports = {} as typeof import("./frontendCapabilities");
runInNewContext(code, {exports, require: (name: string) => {
assert.ok(name in dependencies, name);
diff --git a/app/src/layout/dock/agent/frontendCapabilities.ts b/app/src/layout/dock/agent/frontendCapabilities.ts
index d8b5261b5a..ebb387be3d 100644
--- a/app/src/layout/dock/agent/frontendCapabilities.ts
+++ b/app/src/layout/dock/agent/frontendCapabilities.ts
@@ -100,6 +100,7 @@ let mobileFrontend = false;
mobileFrontend = true;
/// #endif
+/// #if !BROWSER && !MOBILE
if (!mobileFrontend && !isBrowser()) {
registerCapability({
id: "native/frontend/web_page_fetch",
@@ -133,6 +134,7 @@ if (!mobileFrontend && !isBrowser()) {
},
});
}
+/// #endif
registerCapability({
id: "native/frontend/open_setting",