OpenViking icon indicating copy to clipboard operation
OpenViking copied to clipboard

[Bug]: Web Studio Task Center reports a successful re-queue when session_commit actually no-ops (no_messages)

Open liuz0010 opened this issue 2 months ago • 0 comments

Issue Origin: Observed and reproduced in a real environment (self-hosted v0.4.19, read-only API inspection + Studio UI).

Bug Description

In the Web Studio Task Center (/studio/tasks), clicking Re-queue on a failed session_commit task always raises the success toast 重新入队请求已发送,后端正在处理新任务! / Re-queue request submitted successfully! — even when the server enqueued nothing at all.

For session_commit tasks the action does not retry the task; it calls commitSession(resource_id). When the session's live message buffer is already empty (the normal state after a failed commit, see #4982), the server answers with a no_messages no-op. The code does detect that condition and shows an informational toast, but it does not abort the mutation: line 144 still returns a success result, so onSuccess fires and the success toast is shown regardless. The operator is told that work was submitted when nothing was submitted.

Steps to Reproduce

  1. Have a session_commit background task in terminal failed state (any failure cause; here: upstream LLM timeout).
  2. Open /studio/tasks.
  3. Click the Re-queue (rotate) action on the failed row.
  4. Observe the toast: 重新入队请求已发送,后端正在处理新任务! (zh) / Re-queue request submitted successfully! (en).
  5. Check the backend: no new task is created, the queue's Requeued counter stays 0, and the session's commit_count / last_commit_at do not change.

Expected Behavior

If the server did not enqueue any work, the UI must not report success. A no_messages response should abort the mutation (throw, or return a distinguished result) so that onError runs and the user only sees the informational message — or, if the action genuinely cannot retry that task type, the control should be disabled/hidden. Acceptance: after step 3 above, either a real new task exists in GET /api/v1/tasks, or the UI shows a non-success message and no success toast.

Actual Behavior

toast.success(...) in onSuccess fires unconditionally for every session_commit task that has a resource_id, including when the server responded with a no-op.

Minimal Reproducible Example

web-studio/src/routes/tasks/route.tsx — identical on main and on tag v0.4.19 (f3afef11637f2d7c11e4b1f36ed2f90630737cdc) at the time of writing:

 134:      if (task.task_type === 'session_commit') {
 135:        const res = await commitSession(task.resource_id)
 136:        const resAny = res as any
 137:        if (resAny?.result?.reason === 'no_messages' || resAny?.reason === 'no_messages') {
 138:          toast.info(
 139:            i18n.language.startsWith('zh')
 140:              ? '该会话无未提交消息,已无需重复入队'
 141:              : 'Session has no pending uncommitted messages',
 142:          )
 143:        }
 144:        return { res, task }          // ← still a success result when the server skipped the commit
 145:      }
 198:    onSuccess: async () => {
 199:      toast.success(
 200:        i18n.language.startsWith('zh')
 201:          ? '重新入队请求已发送,后端正在处理新任务!'
 202:          : 'Re-queue request submitted successfully!',
 203:      )
 204:      await queryClient.invalidateQueries({ queryKey: ['tasks'] })
 205:    },

The branch is also inconsistent with its two siblings: the viking:// path (route.tsx:154-162) and the fallback path (route.tsx:184-192) both throw when the response reports a failure, so onError is reachable there. Only the session_commit branch has no failure path.

Error Logs

Evidence collected read-only against a self-hosted v0.4.19 instance (host replaced with <self-hosted>):

# Two failed session_commit tasks
GET /api/v1/tasks
  f01a203c-446f-4fff-b966-7de6d1c09ca9 | session_commit | failed | resource_id=mcp-store-550e315e7ae5
      error="Request timed out."  created=2026-09-14T13:12:17Z  updated=2026-09-14T13:22:17Z
  d42d2612-88c1-4dcd-a694-4226e9318b09 | session_commit | failed | resource_id=mcp-store-3045ea887d3a
      error="Request timed out."  created=2026-09-14T12:00:46Z  updated=2026-09-14T12:15:50Z

# What the click actually sent — no reindex call, no task-creating call, zero 4xx
GET /api/v1/console/audit
  2026-09-14T13:39:01Z | POST | /api/v1/sessions/{session_id}/commit | 200
  2026-09-14T13:39:03Z | POST | /api/v1/sessions/{session_id}/commit | 200

# The commit was accepted and did nothing
GET /api/v1/sessions/mcp-store-550e315e7ae5
  commit_count: 1
  last_commit_at: "2026-09-14T13:12:17.030Z"   # unchanged by the click
  updated_at:     "2026-09-14T13:39:01.733Z"   # bumped by the click
GET /api/v1/sessions/mcp-store-3045ea887d3a
  commit_count: 1
  last_commit_at: "2026-09-14T12:00:46.797Z"   # unchanged by the click
  updated_at:     "2026-09-14T13:39:03.602Z"   # bumped by the click

# Nothing was enqueued
GET /api/v1/observer/queue
  | SessionCommit  | Pending 0 | In Progress 0 | Processed 5 | Requeued 0 | Errors 0 |

# And no new task appeared afterwards
GET /api/v1/tasks   # newest entry is still the pre-click 2026-09-14T13:12:38Z task

The same pattern repeated for earlier clicks (three commit calls within 6 seconds at 13:21:44Z, 13:21:45Z, 13:21:50Z), each followed by no change in commit_count and no new task.

OpenViking Version

0.4.19 (tag f3afef11637f2d7c11e4b1f36ed2f90630737cdc); confirmed still present on main.

Python Version

3.13 (server container)

Operating System

Linux

Additional Context

  • Relation to #4982 (not a duplicate). The backend half — failed session_commit archives cannot be listed or retried, and commit / extract are no-ops against an empty live buffer — is already tracked in #4982. This issue is about the UI reporting success for such a no-op. The two are independent: #4982 can be implemented without touching this code, and this code remains wrong even after a real retry endpoint exists. Conversely, fixing this does not give users a way to recover a failed archive — it only stops the UI from lying about it.
  • Consequence. For session_commit tasks the Task Center's Re-queue action is effectively a placebo button, and it actively hides the failure mode described in #4982 from the operator (they see "request submitted successfully", then nothing happens, with no error anywhere).
  • Suggested fix. Treat a no_messages / status === 'skipped' response as a non-success outcome in the session_commit branch — throw so onError surfaces it, or return a distinct result that onSuccess checks before showing the success toast. Note that the current check only looks at reason === 'no_messages' and ignores status === 'skipped', which is what the server actually returns for this case ({"status":"skipped","reason":"no_messages","task_id":null}).
  • web-studio/src/routes/tasks/route.test.tsx on main mocks commitSession but only asserts task-status presentation, so this branch is currently untested.

liuz0010 avatar Sep 14 '26 14:09 liuz0010