Skip to content

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

:bug: Keep mobile agent text selections within the current message https://github.com/siyuan-note/siyuan/issues/18744

Danielebfa285ee561
diff --git a/app/src/mobile/util/keyboardToolbar.ts b/app/src/mobile/util/keyboardToolbar.ts
index becb5c0dc6..ae35e6ecf2 100644
--- a/app/src/mobile/util/keyboardToolbar.ts
+++ b/app/src/mobile/util/keyboardToolbar.ts
@@ -61,13 +61,15 @@ export const updateMobilePluginToolbar = (protyle: IProtyle) => {
};
const getAndroidSelectionContainer = (selection: Selection) => {
- const anchorAgentMessages = hasClosestByClassName(selection.anchorNode, "agent-chat__messages", true);
- const focusAgentMessages = hasClosestByClassName(selection.focusNode, "agent-chat__messages", true);
- if (anchorAgentMessages || focusAgentMessages) {
- if (anchorAgentMessages && focusAgentMessages && anchorAgentMessages !== focusAgentMessages) {
- return;
- }
- return (anchorAgentMessages || focusAgentMessages) as HTMLElement;
+ const previousContainer = lastAndroidBoundedSelection?.container;
+ if (previousContainer?.classList.contains("agent-chat__body") &&
+ (previousContainer.contains(selection.anchorNode) || previousContainer.contains(selection.focusNode))) {
+ return previousContainer;
+ }
+ const anchorAgentBody = hasClosestByClassName(selection.anchorNode, "agent-chat__body", true);
+ const focusAgentBody = hasClosestByClassName(selection.focusNode, "agent-chat__body", true);
+ if (anchorAgentBody && anchorAgentBody === focusAgentBody) {
+ return anchorAgentBody;
}
const protyle = getCurrentEditor()?.protyle;