Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(studio): avoid requeue success toast for skipped commits (#5118)
yufenga1c2b18798d6
diff --git a/web-studio/src/i18n/locales/en/workspace.ts b/web-studio/src/i18n/locales/en/workspace.tsindex cde5ef7e8..dd9cd9a0c 100644--- a/web-studio/src/i18n/locales/en/workspace.ts+++ b/web-studio/src/i18n/locales/en/workspace.ts@@ -387,6 +387,10 @@ const workspace = {},},tasksPage: {+ retry: {+ noPendingMessages: 'No new task created: this session has no pending messages',+ commitSkipped: 'No new task created: this session commit was skipped',+ },title: 'Task Center',description:'Track background work such as resource processing, session commits, and reindexing.',diff --git a/web-studio/src/i18n/locales/zh-CN/workspace.ts b/web-studio/src/i18n/locales/zh-CN/workspace.tsindex 0d151704e..d007e0b13 100644--- a/web-studio/src/i18n/locales/zh-CN/workspace.ts+++ b/web-studio/src/i18n/locales/zh-CN/workspace.ts@@ -376,6 +376,10 @@ const workspace = {},},tasksPage: {+ retry: {+ noPendingMessages: '未创建新任务:该会话没有待提交消息',+ commitSkipped: '未创建新任务:本次会话提交已跳过',+ },title: '任务中心',description: '集中查看资源处理、会话提交和重建索引等后台任务。',refresh: '刷新',diff --git a/web-studio/src/routes/tasks/-lib/localize-commit-result.ts b/web-studio/src/routes/tasks/-lib/localize-commit-result.tsnew file mode 100644index 000000000..5035713ad--- /dev/null+++ b/web-studio/src/routes/tasks/-lib/localize-commit-result.ts@@ -0,0 +1,12 @@+import type { TFunction } from 'i18next'++export function localizeSkippedCommit(+ reason: string,+ t: TFunction<'tasksPage'>,+): string {+ return t(+ reason === 'no_messages'+ ? 'retry.noPendingMessages'+ : 'retry.commitSkipped',+ )+}diff --git a/web-studio/src/routes/tasks/route.test.tsx b/web-studio/src/routes/tasks/route.test.tsxindex 82a95e831..fe943462c 100644--- a/web-studio/src/routes/tasks/route.test.tsx+++ b/web-studio/src/routes/tasks/route.test.tsx@@ -7,7 +7,13 @@ import type * as TanStackRouter from '@tanstack/react-router'import en from '#/i18n/locales/en/workspace'import zh from '#/i18n/locales/zh-CN/workspace'import { QueryClient, QueryClientProvider } from '@tanstack/react-query'-import { cleanup, render, screen, within } from '@testing-library/react'+import {+ cleanup,+ render,+ screen,+ waitFor,+ within,+} from '@testing-library/react'import userEvent from '@testing-library/user-event'import {afterEach,@@ -19,6 +25,8 @@ import {vi,} from 'vitest'+import { toast } from 'sonner'+import { commitSession } from '#/lib/sessions/api'import { Route } from './route'import type { TaskRecord } from './-lib/task-record'@@ -38,6 +46,9 @@ vi.mock('#/lib/ov-client', () => ({vi.mock('#/gen/ov-client', () => ({ postResources: vi.fn() }))vi.mock('#/lib/sessions/api', () => ({ commitSession: vi.fn() }))+vi.mock('sonner', () => ({+ toast: { info: vi.fn(), success: vi.fn(), error: vi.fn() },+}))vi.mock('#/hooks/use-app-connection', () => ({useAppConnection: () => ({ identityScopeKey: 'test/test' }),}))@@ -103,6 +114,7 @@ function expectRunningRows(count: number) {}beforeEach(() => {+ vi.clearAllMocks()records = runningTasks(12)clientMocks.getTasks.mockReset()// Model the API contract: filtering precedes ordering and the result limit.@@ -219,3 +231,77 @@ describe('task status presentation', () => {})})})++describe('session commit re-trigger feedback', () => {+ beforeEach(() => {+ records = [+ {+ task_id: 'failed-commit',+ task_type: 'session_commit',+ resource_id: 'session-1',+ status: 'failed',+ created_at: 100,+ },+ ]+ vi.mocked(commitSession).mockReset()+ })++ it.each([+ [+ 'en',+ 'no_messages',+ 'No new task created: this session has no pending messages',+ ],+ ['zh-CN', 'no_messages', '未创建新任务:该会话没有待提交消息'],+ [+ 'en',+ 'all_within_keep_window',+ 'No new task created: this session commit was skipped',+ ],+ ['zh-CN', 'all_within_keep_window', '未创建新任务:本次会话提交已跳过'],+ ['en', undefined, 'No new task created: this session commit was skipped'],+ ])(+ 'reports skipped commits without success in %s (%s)',+ async (lng, reason, message) => {+ vi.mocked(commitSession).mockResolvedValue({+ status: 'skipped',+ reason,+ task_id: null,+ } as Awaited<ReturnType<typeof commitSession>>)+ const user = await renderPage(lng)+ await user.click(+ await screen.findByTitle(+ lng === 'en' ? 'Re-trigger Task' : '重新发起任务',+ ),+ )+ await waitFor(() => expect(toast.info).toHaveBeenCalledWith(message))+ expect(commitSession).toHaveBeenCalledWith('session-1')+ expect(toast.info).toHaveBeenCalledTimes(1)+ expect(toast.success).not.toHaveBeenCalled()+ expect(toast.error).not.toHaveBeenCalled()+ },+ )++ it('reports success when a new task is accepted', async () => {+ vi.mocked(commitSession).mockResolvedValue({+ status: 'accepted',+ task_id: 'new-task',+ } as Awaited<ReturnType<typeof commitSession>>)+ const user = await renderPage()+ await user.click(await screen.findByTitle('Re-trigger Task'))+ await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(1))+ expect(toast.info).not.toHaveBeenCalled()+ expect(toast.error).not.toHaveBeenCalled()+ })++ it('reports request errors without success', async () => {+ vi.mocked(commitSession).mockRejectedValue(new Error('Commit failed'))+ const user = await renderPage()+ await user.click(await screen.findByTitle('Re-trigger Task'))+ await waitFor(() =>+ expect(toast.error).toHaveBeenCalledWith('Commit failed'),+ )+ expect(toast.info).not.toHaveBeenCalled()+ expect(toast.success).not.toHaveBeenCalled()+ })+})diff --git a/web-studio/src/routes/tasks/route.tsx b/web-studio/src/routes/tasks/route.tsxindex b4ba8e560..1723d8be4 100644--- a/web-studio/src/routes/tasks/route.tsx+++ b/web-studio/src/routes/tasks/route.tsx@@ -53,6 +53,7 @@ import { normalizeTaskStatus } from '#/routes/tasks/-lib/task-record'import type { TaskRecord } from '#/routes/tasks/-lib/task-record'import { formatTaskDuration, getTaskDate } from '#/routes/tasks/-lib/task-time'import { fetchTasks, MAX_TASKS } from './-lib/task-list'+import { localizeSkippedCommit } from './-lib/localize-commit-result'import type { TaskStatusFilter, TaskTypeFilter } from './-lib/task-list'import { getTaskPipelineGroups } from './-lib/task-pipeline'@@ -135,13 +136,8 @@ function TasksRoute() {// ── 1. task_type 精确匹配优先(不受 URI 前缀干扰)──────────────────────if (task.task_type === 'session_commit') {const res = await commitSession(task.resource_id)- const resAny = res as any- if (resAny?.result?.reason === 'no_messages' || resAny?.reason === 'no_messages') {- toast.info(- i18n.language.startsWith('zh')- ? '该会话无未提交消息,已无需重复入队'- : 'Session has no pending uncommitted messages',- )+ if (res.status === 'skipped' || res.reason === 'no_messages') {+ return { res, task, skippedReason: res.reason ?? 'skipped' }}return { res, task }}@@ -197,7 +193,11 @@ function TasksRoute() {onError: (error) => {toast.error(error instanceof Error ? error.message : String(error))},- onSuccess: async () => {+ onSuccess: async (result) => {+ if ('skippedReason' in result && result.skippedReason) {+ toast.info(localizeSkippedCommit(result.skippedReason, t))+ return+ }toast.success(i18n.language.startsWith('zh')? '重新入队请求已发送,后端正在处理新任务!'diff --git a/web-studio/types/ov-server/api/v1/sessions.ts b/web-studio/types/ov-server/api/v1/sessions.tsindex 59090149e..1433c7ef3 100644--- a/web-studio/types/ov-server/api/v1/sessions.ts+++ b/web-studio/types/ov-server/api/v1/sessions.ts@@ -72,4 +72,11 @@ export type SessionMeta = SessionDetailexport type CreateSessionResult = SessionCreatedResultexport type DeleteSessionResult = SessionDeletedResultexport type AddMessageResult = MessageAddedResult-export type CommitSessionResult = CommitResult+export type CommitSessionResult = Omit<+ CommitResult,+ 'archive_uri' | 'task_id'+> & {+ archive_uri: string | null+ task_id: string | null+ reason?: string+}