fix: move page ai launcher to pi lab

This commit is contained in:
Agent Board
2026-07-13 09:00:19 +08:00
parent 2f5902e3e7
commit d6a25afa0a
11 changed files with 80 additions and 73 deletions
@@ -4624,15 +4624,29 @@
function installLauncher() {
if (piLabLauncherEl) return;
piLabLauncherEl = el('button', {
type: 'button',
className: 'wolai-page-ai-pi-lab-launcher',
'data-page-ai-pi-lab-launcher': 'true',
title: 'Pi Lab',
'aria-label': '打开 Pi Lab',
}, ');
piLabLauncherEl.addEventListener('click', showPiLab);
document.body.appendChild(piLabLauncherEl);
var hostButton = document.querySelector('[data-mnote-action="open-page-ai-pi-lab"], [data-testid="wolai-floating-ai"]');
if (hostButton instanceof HTMLElement) {
piLabLauncherEl = hostButton;
piLabLauncherEl.setAttribute('data-page-ai-pi-lab-launcher', 'true');
piLabLauncherEl.setAttribute('data-mnote-action', 'open-page-ai-pi-lab');
piLabLauncherEl.setAttribute('aria-label', '打开 Pi Lab');
piLabLauncherEl.setAttribute('title', '打开 Pi Lab');
piLabLauncherEl.textContent = 'π';
} else {
piLabLauncherEl = el('button', {
type: 'button',
className: 'wolai-page-ai-pi-lab-launcher',
'data-page-ai-pi-lab-launcher': 'true',
title: 'Pi Lab',
'aria-label': '打开 Pi Lab',
}, 'π');
document.body.appendChild(piLabLauncherEl);
}
piLabLauncherEl.addEventListener('click', function (event) {
event.preventDefault();
event.stopPropagation();
showPiLab();
});
}
function wireEvents() {
@@ -880,9 +880,9 @@ export function createSidebarPageAiRuntime(context) {
function pageAiOpencodeHostEnabled() {
try {
return window.localStorage ? window.localStorage.getItem('mnote.page_ai.opencode_host') !== '0' : true;
return window.localStorage ? window.localStorage.getItem('mnote.page_ai.opencode_host') === '1' : false;
} catch (_error) {
return true;
return false;
}
}
@@ -3191,6 +3191,16 @@ import { createSidebarPageSettingsRuntime } from './sidebar-page-settings-runtim
return;
}
var pageAiPiLabTrigger = closestAction(e.target, '[data-mnote-action="open-page-ai-pi-lab"]');
if (pageAiPiLabTrigger) {
e.preventDefault();
if (window.createSidebarPageAiPiLabRuntime) {
window.createSidebarPageAiPiLabRuntime({});
}
window.postMessage({ source: 'mnote-sidebar', type: 'mnote:pi-lab-show' }, window.location.origin);
return;
}
var navigationPageTrigger = closestAction(e.target, '[data-mnote-action="open-navigation-page"]');
if (navigationPageTrigger) {
e.preventDefault();
@@ -4159,7 +4159,7 @@ mod tests {
assert!(!html.contains("[data-node-id=\"${escapedId}\"] .tree-link-title"));
assert!(html.contains("data-testid=\"wolai-page-settings-trigger\""));
assert!(html.contains("data-mnote-action=\"open-page-settings\""));
assert!(html.contains("data-mnote-action=\"open-page-ai\""));
assert!(html.contains("data-mnote-action=\"open-page-ai-pi-lab\""));
assert!(html.contains("\"titleEndpoint\":\"/api/documents/title\""));
assert!(html.contains("data-testid=\"mnote-document-workspace\""));
assert!(html.contains("data-document-pane=\"true\""));
@@ -193,7 +193,7 @@ pub fn PageLayout(
</article>
<div class="wolai-floating-actions" aria-label="浮动操作">
<a href="/knowledge" data-testid="mnote-floating-knowledge" class="wolai-floating-button wolai-floating-button--knowledge" aria-label="知识库" title="打开知识库" data-mnote-action="open-knowledge-host"><span class="material-symbols-outlined material-symbols-filled" data-icon="travel_explore" aria-hidden="true"></span></a>
<button type="button" data-testid="wolai-floating-ai" class="wolai-floating-button wolai-floating-button--ai" aria-label="AI 助手" data-state="closed" aria-haspopup="dialog" aria-expanded="false" title="点击 进入空间智能问答" data-mnote-action="open-page-ai"><span class="material-symbols-outlined material-symbols-filled" data-icon="auto_awesome" aria-hidden="true"></span></button>
<button type="button" data-testid="wolai-floating-ai" class="wolai-floating-button wolai-floating-button--ai wolai-floating-button--pi" aria-label="Pi Lab" data-state="closed" aria-haspopup="dialog" aria-expanded="false" title="打开 Pi Lab" data-mnote-action="open-page-ai-pi-lab">{"\u{03c0}"}</button>
</div>
</div>
<div id="mnote-portal-root" data-mnote-portal-root="true"></div>
@@ -544,6 +544,8 @@ mod tests {
html.find(r#"data-testid="mnote-floating-knowledge""#)
< html.find(r#"data-testid="wolai-floating-ai""#)
);
assert!(html.contains(r#"data-mnote-action="open-page-ai-pi-lab""#));
assert!(!html.contains(r#"data-mnote-action="open-page-ai""#));
assert!(!html.contains(r#"data-mnote-action="open-knowledge-rag-settings""#));
assert!(html.contains(r#"data-icon="travel_explore""#));
assert!(crate::ssr::styles::MNOTE_CSS.contains(r#"data-icon="travel_explore""#));
@@ -2383,6 +2383,10 @@
text-decoration: none;
}
.wolai-floating-button--pi {
font-weight: 700;
}
.document-shell[data-page-wide-layout="true"] {
width: min(100%, 980px);
}