Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

📝 docs(bot): Auto sync agents & plugin to readme

lobehubbotc4f3b4eb6964
diff --git a/changelog/v1.json b/changelog/v1.json
index d86518d5f88..7b06f01bb73 100644
--- a/changelog/v1.json
+++ b/changelog/v1.json
@@ -1,4 +1,11 @@
[
+ {
+ "children": {
+ "improvements": ["Refactor page and notebook document usage."]
+ },
+ "date": "2026-01-10",
+ "version": "2.0.0-next.256"
+ },
{
"children": {
"fixes": ["Fix auto add group member crash."]
diff --git a/src/features/EditorCanvas/actions.ts b/src/features/EditorCanvas/actions.ts
index 675706b22cb..49cb47e7093 100644
--- a/src/features/EditorCanvas/actions.ts
+++ b/src/features/EditorCanvas/actions.ts
@@ -16,12 +16,12 @@ export function openFileSelector(handleFiles: (files: FileList) => void, accept
input.multiple = false;
// Listen for file selection events
- input.onchange = (event) => {
+ input.addEventListener('change', (event) => {
const files = (event.target as HTMLInputElement)?.files;
if (files && files.length > 0) {
handleFiles(files);
}
- };
+ });
// Trigger file selector
input.click();
diff --git a/src/store/chat/slices/portal/initialState.ts b/src/store/chat/slices/portal/initialState.ts
index ff3067086c8..de27590399b 100644
--- a/src/store/chat/slices/portal/initialState.ts
+++ b/src/store/chat/slices/portal/initialState.ts
@@ -8,15 +8,15 @@ export enum ArtifactDisplayMode {
// ============== Portal View Stack Types ==============
export enum PortalViewType {
- Home = 'home',
Artifact = 'artifact',
Document = 'document',
- Notebook = 'notebook',
FilePreview = 'filePreview',
+ GroupThread = 'groupThread',
+ Home = 'home',
MessageDetail = 'messageDetail',
- ToolUI = 'toolUI',
+ Notebook = 'notebook',
Thread = 'thread',
- GroupThread = 'groupThread',
+ ToolUI = 'toolUI',
}
export interface PortalFile {
@@ -27,38 +27,38 @@ export interface PortalFile {
export type PortalViewData =
| { type: PortalViewType.Home }
- | { type: PortalViewType.Artifact; artifact: PortalArtifact }
- | { type: PortalViewType.Document; documentId: string }
+ | { artifact: PortalArtifact; type: PortalViewType.Artifact }
+ | { documentId: string; type: PortalViewType.Document }
| { type: PortalViewType.Notebook }
- | { type: PortalViewType.FilePreview; file: PortalFile }
- | { type: PortalViewType.MessageDetail; messageId: string }
- | { type: PortalViewType.ToolUI; messageId: string; identifier: string }
- | { type: PortalViewType.Thread; threadId?: string; startMessageId?: string }
- | { type: PortalViewType.GroupThread; agentId: string };
+ | { file: PortalFile; type: PortalViewType.FilePreview }
+ | { messageId: string; type: PortalViewType.MessageDetail }
+ | { identifier: string; messageId: string; type: PortalViewType.ToolUI }
+ | { startMessageId?: string; threadId?: string; type: PortalViewType.Thread }
+ | { agentId: string; type: PortalViewType.GroupThread };
// ============== Portal State ==============
export interface ChatPortalState {
- portalArtifactDisplayMode: ArtifactDisplayMode;
- portalStack: PortalViewData[];
- showPortal: boolean;
-
// Legacy fields (kept for backward compatibility during migration)
// TODO: Remove after Phase 3 migration complete
/** @deprecated Use portalStack instead */
portalArtifact?: PortalArtifact;
+ portalArtifactDisplayMode: ArtifactDisplayMode;
/** @deprecated Use portalStack instead */
portalDocumentId?: string;
+
/** @deprecated Use portalStack instead */
portalFile?: PortalFile;
/** @deprecated Use portalStack instead */
portalMessageDetail?: string;
+ portalStack: PortalViewData[];
/** @deprecated Use portalStack instead */
portalThreadId?: string;
/** @deprecated Use portalStack instead */
portalToolMessage?: { id: string; identifier: string };
/** @deprecated Use portalStack instead */
showNotebook?: boolean;
+ showPortal: boolean;
}
export const initialChatPortalState: ChatPortalState = {
diff --git a/src/store/chat/slices/portal/selectors.ts b/src/store/chat/slices/portal/selectors.ts
index 4a5724198e0..d71cd21762e 100644
--- a/src/store/chat/slices/portal/selectors.ts
+++ b/src/store/chat/slices/portal/selectors.ts
@@ -9,7 +9,7 @@ import { type PortalFile, type PortalViewData, PortalViewType } from './initialS
const currentView = (s: ChatStoreState): PortalViewData | null => {
const { portalStack } = s;
- return portalStack[portalStack.length - 1] ?? null;
+ return portalStack.at(-1) ?? null;
};
const currentViewType = (s: ChatStoreState): PortalViewType | null => {
@@ -109,10 +109,10 @@ const messageDetailId = (s: ChatStoreState): string | undefined => {
// Tool UI / Plugin selectors
const currentToolUI = (
s: ChatStoreState,
-): { messageId: string; identifier: string } | undefined => {
+): { identifier: string; messageId: string } | undefined => {
const view = getViewData(s, PortalViewType.ToolUI);
if (view) {
- return { messageId: view.messageId, identifier: view.identifier };
+ return { identifier: view.identifier, messageId: view.messageId };
}
return undefined;
};
diff --git a/src/store/chat/slices/portal/selectors/thread.ts b/src/store/chat/slices/portal/selectors/thread.ts
index 556b4b6ab05..799ce581455 100644
--- a/src/store/chat/slices/portal/selectors/thread.ts
+++ b/src/store/chat/slices/portal/selectors/thread.ts
@@ -5,7 +5,7 @@ import { type PortalViewData, PortalViewType } from '../initialState';
// Helper to get current view
const getCurrentView = (s: ChatStoreState): PortalViewData | null => {
const { portalStack } = s;
- return portalStack[portalStack.length - 1] ?? null;
+ return portalStack.at(-1) ?? null;
};
// Check if current view is Thread
diff --git a/src/store/document/slices/editor/index.ts b/src/store/document/slices/editor/index.ts
index 6967d86a771..fb5abfb1273 100644
--- a/src/store/document/slices/editor/index.ts
+++ b/src/store/document/slices/editor/index.ts
@@ -6,5 +6,5 @@ export {
type EditorState,
initialEditorState,
} from './initialState';
-export { documentReducer, type DocumentDispatch } from './reducer';
+export { type DocumentDispatch, documentReducer } from './reducer';
export { editorSelectors } from './selectors';