gugugaga 8b2f9102a5 fix(runtime): converge background tasks on Stop and runtime loss (#1441)
* fix(server): reap background shell tasks on Stop and after runtime exit

A session's background shell task (Bash `run_in_background`, Dream, workflow)
is tracked as a non-Agent task, and nothing on the server ever bounded or
reaped one. A user Stop only interrupted the foreground turn and the Agent
tasks, so the shell kept running after the user had asked everything to stop.
A client disconnect let the CLI live forever, because the disconnect watcher
waits for `hasActiveBackgroundTasks` to clear and a task that never emits a
terminal notification never clears it. A hard runtime death published no
terminal state at all, so a later reconnect re-hydrated a ghost "Running"
entry that could never reach a terminal state.

This closes all three from one file of server bookkeeping:

- `handleStopGeneration` now reaps the session's non-Agent background tasks
  through the same `requestControl` stop path the panel's per-task Stop uses,
  and the 3-second force-kill guard watches them too. Programmatic stops
  (turn stop, runtime-config restart) keep the previous narrow behavior.
- A new 31-minute ceiling bounds a session that a disconnected client keeps
  alive through background tasks alone; when it elapses the shared runtime is
  stopped and terminal bookends are published. A reconnect clears the ceiling.
- `close()` and `closeStoppedAgentsAfterRuntimeExit` publish terminal bookends
  whenever the runtime is already gone but task records remain, instead of
  leaving them to be re-hydrated as "Running".

The new timer registry is released by `cleanupSessionRuntimeState` and
classified as `cleared` in the session-state cleanup guard, so a ceiling
scheduled for a session cannot outlive that session.

会话的后台 shell 任务(Bash `run_in_background`、Dream、workflow)登记为非 Agent 任务,
服务端一直没有收掉它们的路径:按停止键只断前台轮和 Agent 任务,shell 还在跑;客户端断开后
CLI 因为 `hasActiveBackgroundTasks` 恒为真而一直存活;运行时崩溃又不写终态,重连后又
变成幽灵 Running。这次在 handler 一处收掉这三种:

- 按停止键时一并停掉本会话的非 Agent 后台任务,走面板单任务 Stop 同一个 stop 通路,
  三秒强杀闸也一并盯住它们;程序化停止(停轮、重启换配置)仍走原来的窄路径。
- 新增 31 分钟硬上限:没有客户端、只靠后台任务续命的会话,到期就停掉共享运行时并写终态;
  重连则撤销该计时。
- 运行时已经没了但任务记录还在时,`close()` 与 `closeStoppedAgentsAfterRuntimeExit`
  直接写终态,不再留着让重连把 Running 灌回来。

Refs #1132

* fix(runtime): converge background tasks and reap orphaned shells

* fix(desktop): restore stopped shell tasks after cold history load

---------

Co-authored-by: gugugaga <267102352+omazili-guga@users.noreply.github.com>
Co-authored-by: 程序员阿江(Relakkes) <relakkes@gmail.com>
2026-10-05 22:33:35 +08:00
2026-10-02 02:45:29 +08:00
2026-04-01 10:30:17 +08:00
2026-07-29 09:23:05 +08:00
2026-10-04 17:19:21 +08:00
2026-10-04 17:19:21 +08:00

cc-haha

cc-haha — Open-source desktop for Claude Code

GitHub Stars GitHub Forks GitHub Issues GitHub Pull Requests License English 中文 Docs

简体中文 · English

cc-haha is a desktop Claude Code workspace for macOS, Windows, and Linux: multi-session workspaces, global search, branch / Worktree launch, diff review, built-in browser preview, GUI permission approval, any model — Claude, ChatGPT, Grok, presets, or local endpoints — image generation, visual MCP & SubAgent managers, an Agent Teams workbench, dynamic Workflow orchestration, model trace, Computer Use, skill marketplace, colour themes, desktop pets, H5 remote access, IM integration, and scheduled tasks, all in one app. On macOS, Computer Use can operate other apps without taking over your physical mouse or keyboard.

Desktop Preview · Install · Highlights · More Docs · Sponsorship · User Group


Desktop Preview

Download Desktop

Watch the 62-second cc-haha film
A 62-second film made with Claude, with no narration. Opens the video in your browser.

Start here: install the app → connect a model → run your first session → explore settings → try real workflows. For hands-free cross-app work on macOS, follow the Computer Use guide.


Sponsorship & Partnership

This project is maintained in the author's spare time. Corporate or individual sponsorships are welcome to support ongoing development. Custom features, integrations, and business partnerships are also open for discussion.

Sponsor Description
AruHub Thanks to AruHub for sponsoring this project! AruHub focuses on providing developers with a stable, long-term primary API upstream service. Built for high-frequency AI coding workflows such as Codex and Claude Code, it offers official GPT API access through enterprise groups and stable Claude enterprise groups for sustained use, with support for leading models including GPT and Claude. Image 2 / 2.5 is available around the clock, starting at CNY 0.04 per image. Pay-as-you-go billing supports high-volume enterprise usage, invoicing, and refunds. Register through the exclusive link to receive US$1 in credit usable across all models, with no model restrictions.
ApiSmart Thanks to ApiSmart for sponsoring this project. ApiSmart provides unified access to leading AI models through a single API. Use one API key to connect with LLM, image, and video models through an OpenAI-compatible interface. Easily switch between models, simplify billing, and improve reliability with intelligent routing and automatic failover.

📧 Contact: relakkes@gmail.com


Install the Desktop App

  1. Download the macOS / Windows / Linux desktop installer from Releases.
  2. On first launch, configure your model provider, API key, and default model in Settings.
  3. Public macOS releases require signing and notarization. Draft or unsigned temporary builds may still need one-time manual approval. Unsigned Windows installers may show SmartScreen; click "More info" -> "Run anyway". See the desktop installation guide.

Release trust and privacy: Code signing policy · Privacy and network access

Run the CLI from Source

For users who want to debug the underlying CLI, server, or local development flow:

bun install
cp .env.example .env
./bin/claude-haha

See environment variables and CLI setup for more configuration options.


User Group

Scan the QR code below to join the cc-haha user group on WeCom (WeChat Work) — the conversation there is mostly in Chinese. For questions and bug reports in English, Issues is the better place. For enterprise deployment, customization, or Agent development needs, contact the author NanmiCoder.

cc-haha WeCom user group QR code


☕ Buy Me a Coffee

If this project helps you, consider buying me a coffee — every bit of support keeps this project going ❤️

WeChat Pay
WeChat Pay
Alipay
Alipay
Buy Me a Coffee
Buy Me a Coffee

Desktop Highlights

  • Multi-session workspace: tabs, project switching, terminal entry, and session history in one place, with a resizable sidebar.
  • Global search: press Cmd+K to search across every session and jump to the match.
  • Branch / Worktree launch: choose a repository branch and decide whether to use the current working tree or an isolated Worktree.
  • Review edits file by file: the workspace lists this turn's changes; open any file for a syntax-highlighted diff, or undo the whole turn.
  • Built-in browser preview: the page your agent just edited renders right inside the app, cookies and login state included.
  • Five permission modes: from "ask every time" to "skip permissions" — risky commands, tool calls, and follow-up questions are all approved in the GUI.
  • Bring your own model: sign in to Claude, ChatGPT, or Grok; use presets for DeepSeek, Kimi, Zhipu GLM and others; or point it at LM Studio and Ollama running locally.
  • Image generation: generate and edit images right in the chat — sign in with ChatGPT or Grok for instant use, or plug in any OpenAI-compatible Images API.
  • Visual MCP manager: add and edit MCP servers in a GUI — STDIO / Streamable HTTP / SSE, with project, shared, or global scope.
  • Six colour themes: white, paper, warm classic, celadon, ink night, and ink blue — optionally following your system's light/dark setting.
  • Skill marketplace: discover, preview, and install third-party skills from ClawHub / SkillHub, with source and safety status shown up front.
  • Session activity panel: track task progress, background tasks, SubAgents, and sources in one side panel.
  • Visual SubAgent manager: create and tune SubAgents in a GUI — model, tools, and permission mode.
  • Agent Teams workbench: visualize multi-agent collaboration in the GUI — members, tasks, a communication feed, and a dependency-lane canvas.
  • Dynamic Workflow orchestration: the model writes and runs orchestration scripts on the fly, driving subagents concurrently or in pipelines, with phase views, interrupts, and resume.
  • Model trace: every model request is logged locally with status and timing — search and filter to diagnose stuck or failed calls.
  • Computer Use: let the agent take screenshots, click, type, and control desktop apps after authorization; the native macOS runtime does not take over your physical mouse or keyboard.
  • Desktop pets: Dada, Huhu, Bubu, and Huihui change what they do with the task at hand — or raise one of your own (off by default).
  • H5 remote access: scan a QR code to continue the session in your phone browser; locking the screen won't kill a running task.
  • IM integration: chat, switch projects, and approve actions through Telegram / Feishu / WeChat / DingTalk / WhatsApp / WeCom / QQ / Slack.
  • Scheduled tasks and usage stats: run planned tasks in their own sessions and track local token usage trends.

More Documentation

Full documentation site: https://cchaha.ai

Section Documents
Getting started What this is · Download and install · Connect a model provider · Your first session · Troubleshooting
Desktop features Feature overview · Computer Use · Desktop pets · Phone H5 and IM relay
IM integrations Overview and pairing · Feishu · Telegram · WeChat · DingTalk · WhatsApp · WeCom · QQ · Slack
CLI Install and run · Command reference · Environment variables
Internals Desktop architecture · Multi-agent system · Skills system · Memory system · Computer Use architecture · Local server and API · Channel system · Project structure · Contributing and quality gates

Tech Stack

Category Technology
Language TypeScript
Desktop app Electron
Desktop UI React + Vite
Local runtime Bun
Terminal UI React + Ink
CLI parsing Commander.js
API Anthropic SDK
Protocols MCP, LSP

Acknowledgements

Thanks to the following open-source projects and community practices for reference and inspiration:

  • React: frontend engineering and component-based UI ecosystem.
  • Electron: cross-platform desktop app capabilities and engineering practices.
  • cc-switch: reference for model provider configuration.
  • LINUX DO: a new ideal developer community.

⭐ Star History

If this project helps you, please support it with a ⭐ Star so more people can discover cc-haha.

Star History Chart
S
Description
No description provided
Readme MIT 596 MiB
Languages
TypeScript 96.3%
Swift 2.3%
CSS 0.3%
Python 0.3%
JavaScript 0.2%
Other 0.5%