🤯 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
🐛 fix(resource): keep parsed uploads out of the My docs and Shared docs sections (#21513)
Arvin Xucff916e0d85a
diff --git a/e2e/src/steps/page/page-crud.steps.ts b/e2e/src/steps/page/page-crud.steps.tsindex a3c46c04140..3ea50a5784c 100644--- a/e2e/src/steps/page/page-crud.steps.ts+++ b/e2e/src/steps/page/page-crud.steps.ts@@ -139,6 +139,9 @@ async function waitForPageWorkspaceReady(world: CustomWorld): Promise<void> {throw new Error('Page workspace did not become ready in time');}+/** Clicks on the new page button before giving up on a mask that keeps returning. */+const NEW_PAGE_CLICK_ATTEMPTS = 3;+async function clickNewPageButton(world: CustomWorld): Promise<void> {// The one-time "Pages and Resources are now Docs" notice is a modal: while it// is up, the click lands on the mask and no page is created.@@ -166,7 +169,18 @@ async function clickNewPageButton(world: CustomWorld): Promise<void> {if ((await candidate.count()) === 0) continue;if (!(await candidate.isVisible())) continue;- await candidate.click();+ // The notice can mount after the dismissal above (it waits for the user+ // preference and the Docs home list), and then its mask swallows the click+ // until the step times out. Dismiss it again and retry instead.+ for (let attempt = 1; ; attempt++) {+ try {+ await candidate.click({ timeout: 5000 });+ break;+ } catch (error) {+ if (attempt >= NEW_PAGE_CLICK_ATTEMPTS) throw error;+ await dismissDocsMergeNotice(world, 1500);+ }+ }await world.page.waitForTimeout(500);return;}@@ -297,71 +311,72 @@ Given('用户在 Page 页面有一个文稿', { timeout: 60_000 }, async functioconsole.log(` ✅ 找到文稿: ${uniqueTitle}`);});-Given('用户在 Page 页面有一个文稿 {string}', { timeout: 60_000 }, async function (- this: CustomWorld,- title: string,-) {- console.log(' 📍 Step: 导航到 Page 页面...');- await openDocsHome(this);-- console.log(' 📍 Step: 通过 UI 创建新文稿...');- await clickNewPageButton(this);- await this.page.waitForTimeout(1500);-- // Wait for the new page to be created- await this.page.waitForURL(/\/resource\/page\/.+/, { timeout: WAIT_TIMEOUT });-- // Default title is "无标题" (Untitled) - support both languages- const defaultTitleRegex = /^(无标题|Untitled)$/;-- console.log(` 📍 Step: 通过右键菜单重命名文稿为 "${title}"...`);- // Find the new page in sidebar (use link selector to avoid matching editor title)- // Sidebar page items are rendered as <a href="/resource/page/xxx"> links- const pageItem = this.page- .locator('a[href*="/resource/page/"]')- .filter({ hasText: defaultTitleRegex })- .first();- await expect(pageItem).toBeVisible({ timeout: 5000 });-- // Right-click to open context menu- await pageItem.click({ button: 'right' });- await this.page.waitForTimeout(500);-- // Select rename option- const renameOption = this.page.getByRole('menuitem', { name: /rename|重命名/i });- await expect(renameOption).toBeVisible({ timeout: 5000 });- await renameOption.click();- await this.page.waitForTimeout(800);+Given(+ '用户在 Page 页面有一个文稿 {string}',+ { timeout: 60_000 },+ async function (this: CustomWorld, title: string) {+ console.log(' 📍 Step: 导航到 Page 页面...');+ await openDocsHome(this);++ console.log(' 📍 Step: 通过 UI 创建新文稿...');+ await clickNewPageButton(this);+ await this.page.waitForTimeout(1500);++ // Wait for the new page to be created+ await this.page.waitForURL(/\/resource\/page\/.+/, { timeout: WAIT_TIMEOUT });++ // Default title is "无标题" (Untitled) - support both languages+ const defaultTitleRegex = /^(无标题|Untitled)$/;++ console.log(` 📍 Step: 通过右键菜单重命名文稿为 "${title}"...`);+ // Find the new page in sidebar (use link selector to avoid matching editor title)+ // Sidebar page items are rendered as <a href="/resource/page/xxx"> links+ const pageItem = this.page+ .locator('a[href*="/resource/page/"]')+ .filter({ hasText: defaultTitleRegex })+ .first();+ await expect(pageItem).toBeVisible({ timeout: 5000 });++ // Right-click to open context menu+ await pageItem.click({ button: 'right' });+ await this.page.waitForTimeout(500);++ // Select rename option+ const renameOption = this.page.getByRole('menuitem', { name: /rename|重命名/i });+ await expect(renameOption).toBeVisible({ timeout: 5000 });+ await renameOption.click();+ await this.page.waitForTimeout(800);++ // Wait for the rename field to appear+ const popoverInput = await findRenameInput(this);++ if (!popoverInput) {+ throw new Error(+ 'Could not find rename input: expected [data-testid="page-rename-input"] inline or a popover input',+ );+ }- // Wait for the rename field to appear- const popoverInput = await findRenameInput(this);+ await expect(popoverInput).toBeVisible({ timeout: 5000 });- if (!popoverInput) {- throw new Error(- 'Could not find rename input: expected [data-testid="page-rename-input"] inline or a popover input',- );- }+ // Clear and input the new name+ await popoverInput.click();+ await popoverInput.clear();+ await popoverInput.fill(title);- await expect(popoverInput).toBeVisible({ timeout: 5000 });+ // Press Enter to confirm+ await popoverInput.press('Enter');+ await this.page.waitForTimeout(1000);- // Clear and input the new name- await popoverInput.click();- await popoverInput.clear();- await popoverInput.fill(title);-- // Press Enter to confirm- await popoverInput.press('Enter');- await this.page.waitForTimeout(1000);+ console.log(' 📍 Step: 查找文稿...');+ const renamedItem = this.page.getByText(title, { exact: true }).first();+ await expect(renamedItem).toBeVisible({ timeout: WAIT_TIMEOUT });- console.log(' 📍 Step: 查找文稿...');- const renamedItem = this.page.getByText(title, { exact: true }).first();- await expect(renamedItem).toBeVisible({ timeout: WAIT_TIMEOUT });+ this.testContext.targetItemTitle = title;+ this.testContext.targetType = 'page';- this.testContext.targetItemTitle = title;- this.testContext.targetType = 'page';-- console.log(` ✅ 找到文稿: ${title}`);-});+ console.log(` ✅ 找到文稿: ${title}`);+ },+);// ============================================// When Stepsdiff --git a/src/store/page/action.list.test.ts b/src/store/page/action.list.test.tsindex 25c96e970c4..b6e6a3112f1 100644--- a/src/store/page/action.list.test.ts+++ b/src/store/page/action.list.test.ts@@ -67,7 +67,7 @@ const lobeDoc = (id: string, overrides: Partial<LobeDocument> = {}): LobeDocumen});/** The replica sync queries the slice registered with the SWR driver. */-const syncCalls = async (name: 'pageDetail' | 'pageList') => {+const syncCalls = async (name: 'pageDetail' | 'pageList' | 'pageSection') => {const { useClientDataSWR } = await import('@/libs/swr');return vi.mocked(useClientDataSWR)@@ -140,6 +140,36 @@ describe('pageActions — useFetchDocuments', () => {});});+describe('pageActions — useFetchPageSection', () => {+ it('lists authored pages only, never parsed uploads', async () => {+ renderHook(() => pageActions.useFetchPageSection('mine', 20));+ const [call] = await syncCalls('pageSection');++ vi.mocked(documentService.queryDocuments).mockResolvedValue({+ items: [+ row('docs_page'),+ // A page written into a library keeps a mirror file id; still a page.+ row('docs_library_page', { fileId: 'file_mirror' }),+ // An uploaded .txt parsed into a document is a Drive file, not a page.+ row('docs_parsed_upload', {+ fileId: 'file_upload',+ filename: 'run-transcript.txt',+ source: 'files/2026-10-23/a.txt',+ sourceType: 'file',+ }),+ ],+ total: 3,+ });++ const docs = (await call.fetcher()) as LobeDocument[];++ expect(documentService.queryDocuments).toHaveBeenCalledWith(+ expect.objectContaining({ creator: 'self', sourceTypes: [DocumentSourceType.API] }),+ );+ expect(docs.map((doc) => doc.id)).toEqual(['docs_page', 'docs_library_page']);+ });+});+describe('pageActions — preHydrate', () => {it('seeds the list from the persisted row before anything mounts', async () => {const { pageListResource } = await import('./projection');diff --git a/src/store/page/projection.ts b/src/store/page/projection.tsindex cab597c1205..e10dc2665ef 100644--- a/src/store/page/projection.ts+++ b/src/store/page/projection.ts@@ -150,6 +150,14 @@ export interface PageSectionParams {scope: PageSectionScope;}+/**+ * Source types the page sections list. Only authored pages: `api` covers both+ * plain pages and pages written into a library (those carry a mirror `fileId`,+ * so `fileId` cannot tell them apart from uploads). Parsed uploads are `file`+ * rows with `custom/document` and must stay in the Drive, not here.+ */+const PAGE_SECTION_SOURCE_TYPES: string[] = [DocumentSourceType.API];+export const pageSectionResource = defineReplica<PageSectionParams, LobeDocument[]>({fetcher: async ({ limit, scope }) => {const result = await documentService.queryDocuments({@@ -157,14 +165,18 @@ export const pageSectionResource = defineReplica<PageSectionParams, LobeDocumentcurrent: 0,fileTypes: PAGE_DOCUMENT_FILE_TYPES,pageSize: limit + 1,- sourceTypes: PAGE_DOCUMENT_SOURCE_TYPES,+ sourceTypes: PAGE_SECTION_SOURCE_TYPES,standaloneOnly: true,});- return result.items.filter(isAllowedPageDocument).map(documentItemToLobeDocument);+ return result.items+ .filter((doc) => PAGE_SECTION_SOURCE_TYPES.includes(doc.sourceType))+ .filter(isAllowedPageDocument)+ .map(documentItemToLobeDocument);},key: ({ scope }) => scope,name: 'pageSection',storage: 'localStorage',- version: 1,+ // v2 drops section caches that still hold parsed uploads.+ version: 2,});