🤯 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.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
lint: Warp id conversion logic
Rene Wang972809deed95
diff --git a/src/app/[variants]/(main)/page/index.tsx b/src/app/[variants]/(main)/page/index.tsxindex 37c4c5bf597..297ee1db092 100644--- a/src/app/[variants]/(main)/page/index.tsx+++ b/src/app/[variants]/(main)/page/index.tsx@@ -5,6 +5,7 @@ import { useParams } from 'react-router-dom';import Loading from '@/components/Loading/BrandTextLoading';import PageExplorer from '@/features/PageExplorer';+import { standardizeIdentifier } from '@/utils/identifier';import PageTitle from './features/PageTitle';@@ -19,7 +20,7 @@ const PagesPage = memo(() => {<><PageTitle /><Suspense fallback={<Loading debugId="PagesPage" />}>- <PageExplorer pageId={`docs_${id}`} />+ <PageExplorer pageId={standardizeIdentifier(id ?? '', 'docs')} /></Suspense></>);diff --git a/src/features/PageEditor/Header/useMenu.tsx b/src/features/PageEditor/Header/useMenu.tsxindex b6809d8da15..18dc3e99aaa 100644--- a/src/features/PageEditor/Header/useMenu.tsx+++ b/src/features/PageEditor/Header/useMenu.tsx@@ -12,6 +12,9 @@ import { systemStatusSelectors } from '@/store/global/selectors';import { usePageEditorStore, useStoreApi } from '../store';+/**+ * Action menu for the page editor.+ */export const useMenu = (): { menuItems: any[] } => {const { t } = useTranslation(['file', 'common', 'chat']);const { message, modal } = App.useApp();diff --git a/src/features/Portal/Document/Header.tsx b/src/features/Portal/Document/Header.tsxindex 0caf3757bc8..6920c013ca2 100644--- a/src/features/Portal/Document/Header.tsx+++ b/src/features/Portal/Document/Header.tsx@@ -13,6 +13,7 @@ import { chatPortalSelectors } from '@/store/chat/selectors';import { useNotebookStore } from '@/store/notebook';import { notebookSelectors } from '@/store/notebook/selectors';import { oneLineEllipsis } from '@/styles';+import { standardizeIdentifier } from '@/utils/identifier';import AutoSaveHint from './AutoSaveHint';@@ -42,7 +43,7 @@ const Header = () => {// Navigate to the page editor// Note: /page route automatically adds 'docs_' prefix to the id- navigate(`/page/${documentId.replace(/^docs_/, '')}`);+ navigate(`/page/${standardizeIdentifier(documentId)}`);} finally {setLoading(false);}diff --git a/src/store/file/slices/document/action.ts b/src/store/file/slices/document/action.tsindex b9515554df8..8aee35dfd08 100644--- a/src/store/file/slices/document/action.ts+++ b/src/store/file/slices/document/action.ts@@ -4,6 +4,7 @@ import { type StateCreator } from 'zustand/vanilla';import { documentService } from '@/services/document';import { useGlobalStore } from '@/store/global';import { DocumentSourceType, type LobeDocument } from '@/types/document';+import { standardizeIdentifier } from '@/utils/identifier';import { setNamespace } from '@/utils/storeDebug';import { type FileStore } from '../../store';@@ -16,7 +17,7 @@ const ALLOWED_DOCUMENT_FILE_TYPES = new Set(['custom/document', 'application/pdfconst EDITOR_DOCUMENT_FILE_TYPE = 'custom/document';const updateUrl = (docId: string | null) => {- const dryPageId = docId?.replace('docs_', '');+ const dryPageId = standardizeIdentifier(docId ?? '') ?? '';const newPath = dryPageId ? `/page/${dryPageId}` : '/page';window.history.replaceState({}, '', newPath);diff --git a/src/utils/identifier.ts b/src/utils/identifier.tsnew file mode 100644index 00000000000..f52f683b842--- /dev/null+++ b/src/utils/identifier.ts@@ -0,0 +1,17 @@+/**+ * Turn id like `docs_123` to `123`. Or add prefix to the identifier.+ * @param identifier - The identifier to standardize.+ * @returns The standardized identifier.+ */++const standardizeIdentifier = (identifier: string, prefix?: 'docs' | 'agt') => {+ if (identifier.includes('_')) {+ return identifier.split('_')[1];+ } else if (prefix) {+ return `${prefix}_${identifier}`;+ }++ return identifier;+};++export { standardizeIdentifier };