#3959·chatbox

[BUG] Stop can fail silently and lock the session forever: Retry does nothing (no toast, no error) and only restarting the app recovers

Author: smgcdCreated Sep 29, 2026Updated Sep 29, 2026

Environment

  • Chatbox Desktop 1.23.5 (Windows installer), Windows 11 x64
  • Work / Agent mode session with run_command (Full Access)
  • Related but different issue: #3958 — that one is a tool call that never returns (leaked process holding the tool's pipes). This one happens after the tool call has already returned as cancelled.

Summary

In a Work-mode session, after a long-running tool call is cancelled, the session can become permanently locked in a way that gives no feedback at all:

  • the assistant message is no longer streaming,
  • clicking Retry / retry from the last step does absolutely nothing — no toast, no error, no spinner, no new request (not even a failed one in the log),
  • in the same state the composer can also be blocked from submitting,
  • clicking Stop again does nothing either,
  • the only way out is quitting and restarting Chatbox, after which the same retry works instantly.

From the user's point of view the app is alive but that session is dead, and there is no way to tell why — the button simply does nothing.

Observed timeline (own logs: %APPDATA%\\\xyz.chatboxapp.app\logs\main.log)

The tool call at the end of that turn did finish:

12:34:16  [skills:user-exec] agent_operation start   sessionId=e093d773-…  (long-running command)
12:38:50  [skills:user-exec] agent_operation finish  success=false, exitCode=130 (cancelled), durationMs=273903

So the tool returned as cancelled (user pressed Stop) — nothing was left running, so this is not the #3958 pipe/close leak. Immediately afterwards, in that session, Retry/regenerate did nothing at all, no further request appeared anywhere in the log, and restarting the app fixed it instantly. I have also seen this state persist for a long time (user waited 10+ minutes) with no timeout and no error.

Root cause (from the sources shipped in resources/app.asar of 1.23.5)

1. The retry paths abort silently. src/renderer/components/chat/Message.tsx:

typescript
const handleStop = useCallback(async (): Promise<boolean> => {
  if (msg.generating) {
    try {
      await stopMessageAndWait()
      return true
    } catch {
      return false            // <-- failure is swallowed here
    }
  }
  await modifyMessage(sessionId, { ...msg, generating: false }, true)
  return true
}, [msg, sessionId, stopMessageAndWait])

and every retry entry point treats false as "just stop":

typescript
const handleRefresh = useCallback(async () => {
  const gate = getSessionActionGate('regenerate', sessionLocks)
  if (!gate.allowed) { notifyActionBlocked(gate.reason); return }
  if (!(await handleStop())) return          // <-- silent abort: no toast, no error, nothing
  await regenerateInNewFork(sessionId, msg)
}, [sessionLocks, handleStop, msg, notifyActionBlocked, sessionId])

handleRetryLastStep and handleErrorTipRetry do the same. So a failed stop ⇒ a dead button with zero user feedback. (If stopMessageAndWait() never settles instead of rejecting, the click just hangs — equally invisible.)

2. One stuck stop blocks every later one. src/renderer/stores/session/generation-cancellation.ts serializes stops per session:

typescript
function serializeSessionStop(sessionId: string, operation: () => Promise<void>): Promise<void> {
  const previous = sessionStopTasks.get(sessionId)
  const task = previous ? previous.catch(() => {}).then(operation) : operation()
  ...
}

and src/renderer/stores/generationStopOperations.ts de-duplicates by operation key while status === 'stopping', returning the same pending promise. There is no timeout, abort or reset anywhere in that chain — one stop that never settles poisons the session for the rest of the app run.

3. The lock is derived from the in-memory runtime, and nothing reaps a stale one. packages/chatbox-core/src/session/action-gates.ts blocks regenerate while isGenerationLocked(locks) (generatingReplyCount > 0), and that count only includes a generating message whose id is in the active generation runtime set. The runtime is only removed by the stop pipeline / persistStreamingMessage — i.e. exactly the thing that failed. I could not find any watchdog or TTL that clears a runtime stuck in 'stopping'.

4. There is no in-app recovery. src/main/menu.ts registers Reload (Ctrl+R) and "Toggle Developer Tools" only in the development branch of the View submenu; in the production build the View submenu contains only "Toggle Full Screen". Because the lock lives in renderer memory, the user has no option but to quit the whole app (losing the in-flight turn).

Impact

A single failed or hung Stop permanently bricks a session for the rest of the app run, with zero diagnostics. Work-mode sessions that run long commands (installs, dev servers, training runs, tunnels) hit this regularly — I hit it several times in one evening, each time having to restart the whole app.

Suggested fixes

  1. Never fail silently. If handleStop() fails or times out, surface it (toast/error). Today it is indistinguishable from a broken button.
  2. Make the stop pipeline idempotent and self-healing: timeout/abort a stop that doesn't settle, do not queue later retries behind a poisoned stop, and drop the 'stopping' de-dup entry when its task is gone.
  3. Reconcile the lock with reality: if the underlying generation promise/stream no longer exists, clear the runtime phase (and the persisted generating flag), or add a TTL/watchdog that reaps stale stopping runtimes, so a session can't stay locked with nothing running.
  4. Give users a recovery affordance: ship Reload ("restart the session state") in the production build — a menu item, a shortcut, or a button in the error UI — so recovering doesn't require quitting the app.

中文摘要

Work 模式下,长命令被「停止」取消之后,会话有可能永久锁死:助手消息已经不再输出,但点「重试 / 从最后一步重试」完全没有任何反应(没有提示、没有报错、日志里也没有新请求),再点「停止」同样无效,只能退出 Chatbox 重启,重启后同样的重试一秒就好。

日志显示那次工具调用其实已经以 cancelled 返回(exitCode=130,durationMs=273903),所以这不是 #3958 那种"进程占着管道导致工具调用不返回"的问题。

根因:Message.tsx 的 handleStop() 失败时 return false,而 handleRefresh / handleRetryLastStep 收到 false 后静默 return(无任何提示);同时停止流程按会话串行(serializeSessionStop)+ 按 key 去重(startGenerationStop),一旦有一次 stop 没结束,之后所有停止/重试都在队列里干等;而"是否允许重试"取决于内存里的 generation runtime,卡在 stopping 就永远拦着,且没有任何超时/看门狗清理。生产版菜单里也没有 Reload(Ctrl+R 只在开发模式下注册),用户无法重载渲染进程,只能重启整个软件。

建议:① 停止失败必须给出提示,不能静默;② 停止流程要幂等、可超时、可复位;③ runtime 卡死要能被清理(或与真实状态对齐);④ 生产版提供「重新加载/重启会话状态」入口。