From 28e0ea10e5a5fb7c03b5bffe6fdd9cea4f4a1d06 Mon Sep 17 00:00:00 2001 From: yanweidong Date: Sat, 25 Jul 2026 23:56:49 +0800 Subject: [PATCH] feat(desktop): add AI session creation and history --- apps/desktop/scripts/visual-check.mjs | 12 +++++++++--- apps/desktop/src/App.tsx | 25 +++++++++++++++++++------ apps/desktop/src/styles.css | 8 ++++++-- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/apps/desktop/scripts/visual-check.mjs b/apps/desktop/scripts/visual-check.mjs index 9a89fc3..794025c 100644 --- a/apps/desktop/scripts/visual-check.mjs +++ b/apps/desktop/scripts/visual-check.mjs @@ -77,7 +77,13 @@ const markdownLayout = await page.evaluate(() => { await page.locator('.markdown-editor-page .content-heading .arco-btn').click() await page.locator('.channel-rail button[title="AI"]').click() await page.waitForSelector('.expert-chips') -const experts = await page.locator('.expert-chips span').count() +const experts = await page.locator('.expert-chips button').count() +const aiSwitches = await page.locator('.ai-page-switch .arco-btn').count() +await page.screenshot({ path: 'test-results/app-ai-new.png', fullPage: true }) +await page.locator('.ai-page-switch .arco-btn').nth(1).click() +await page.waitForSelector('.ai-history-page') +const aiHistory = await page.locator('.ai-history-page').count() +await page.screenshot({ path: 'test-results/app-ai-history.png', fullPage: true }) await page.locator('.profile-trigger').click() await page.getByText('修改资料').waitFor() const profileMenu = await page.getByText('修改资料').count() @@ -94,8 +100,8 @@ if (taskModal !== 1) failures.push('task editor did not open') if (exploreSources !== 2 || exploreDetail !== 1) failures.push(`explore reader did not render: ${JSON.stringify({ exploreSources, exploreDetail })}`) if (documents !== 1) failures.push(`expected one document, got ${documents}`) if (documentActions !== 2 || markdownEditor !== 1) failures.push(`document actions did not render: ${JSON.stringify({ documentActions, markdownEditor })}`) -if (experts !== 1) failures.push(`expected one AI expert, got ${experts}`) +if (experts !== 1 || aiSwitches !== 2 || aiHistory !== 1) failures.push(`AI session pages did not render: ${JSON.stringify({ experts, aiSwitches, aiHistory })}`) if (profileMenu !== 1) failures.push('profile menu did not open') if (errors.length) failures.push(`console errors: ${errors.join('; ')}`) -console.log(JSON.stringify({ home, documents, documentActions, markdownEditor, markdownLayout, experts, taskModal, exploreSources, exploreDetail, profileMenu, errors }, null, 2)) +console.log(JSON.stringify({ home, documents, documentActions, markdownEditor, markdownLayout, experts, aiSwitches, aiHistory, taskModal, exploreSources, exploreDetail, profileMenu, errors }, null, 2)) if (failures.length) throw new Error(failures.join('\n')) diff --git a/apps/desktop/src/App.tsx b/apps/desktop/src/App.tsx index d53c4d7..0498243 100644 --- a/apps/desktop/src/App.tsx +++ b/apps/desktop/src/App.tsx @@ -6,7 +6,7 @@ import { IconSun, IconUpload, IconUser, } from '@arco-design/web-react/icon' import { - ApiError, createMarkdownDocument, createProject, fetchProjectWorkspace, fetchProjects, getCurrentUser, + ApiError, createAISession, createMarkdownDocument, createProject, fetchProjectWorkspace, fetchProjects, getCurrentUser, listAIExperts, listDatasetItems, listDatasetSources, login, setApiBaseUrl, updateCurrentUser, updateTask, uploadDocument, type ApiSession, type CurrentUser, type DatasetItem, type DatasetSource, type Expert, type Project, type Workspace, type WorkspaceTask, @@ -115,7 +115,7 @@ export function App() { {error ? setError('')} /> : null} -
{workspaceMode === 'explore' ? : !projectId ? setProjectModalOpen(true)} /> : visibleWorkspaces.length ? { await uploadDocument(session, projectId, file); await loadWorkspaces() }} onCreateMarkdown={async (input) => { await createMarkdownDocument(session, projectId, input); await loadWorkspaces() }} /> : }
+
{workspaceMode === 'explore' ? : !projectId ? setProjectModalOpen(true)} /> : visibleWorkspaces.length ? { await uploadDocument(session, projectId, file); await loadWorkspaces() }} onCreateMarkdown={async (input) => { await createMarkdownDocument(session, projectId, input); await loadWorkspaces() }} onCreateAISession={async (input) => { await createAISession(session, projectId, input); await loadWorkspaces() }} /> : }
{projectId && workspaceMode === 'workbench' ?