小橙子 bdec9242e5
fix(server): force CLI restart when provider config edits land mid-session (#56)
Symptom: after editing a provider's baseUrl / apiKey / apiFormat / model
mapping in the desktop UI, an already-running chat session keeps using
its spawn-time env snapshot. Most visible failure mode: rename or remove
a model id and the next user turn upstreams the stale literal, getting

  错误: There's an issue with the selected model (mimo-v2.5-pro). It
  may not exist or you may not have access to it. Run --model to pick
  a different model.

verbatim from the provider's 404 wrapped in getAssistantMessageFromError
(src/services/api/errors.ts).

Cause: handleSetRuntimeConfig short-circuits when the
(providerId, modelId, effort, thinkingEnabled) tuple is unchanged.
The desktop fan-out re-emits set_runtime_config on every provider
update, but for non-modelId edits the tuple is identical so nothing
restarts. The CLI never re-reads providers.json — its
ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN / ANTHROPIC_MODEL env is
captured at spawn and immutable until the next respawn.

Fix:

1) Add a monotonic `revision` counter to SavedProvider, bumped in
   ProviderService.updateProvider on every save (src/server/types/
   provider.ts, src/server/services/providerService.ts).

2) Capture the revision into RuntimeOverride.providerRevision in
   handleSetRuntimeConfig, and extend the short-circuit to compare it
   (src/server/ws/handler.ts). When the user updates a provider, the
   bumped revision flows into the next set_runtime_config, the
   short-circuit fails, and scheduleRestartSessionWithRuntimeConfig
   respawns the CLI with fresh env from buildProviderManagedEnv.

3) Add a stale-modelId guard in getRuntimeSettings: when the
   persisted runtime modelId is no longer present in any of the
   active provider's four model slots, fall back to
   provider.models.main rather than letting --model pass an unknown
   id to the upstream. Mirrors the existing stale-providerId guard.

4) Extract the override equality into runtimeOverridesMatch (pure)
   and unit-lock it.

Tested:
  - bun test src/server/__tests__/runtime-override-match.test.ts → 10/10
    (covers undefined prev, all-fields-match, providerRevision
    differs forces restart, absent-revision treated as 0, modelId /
    providerId / effort / thinkingEnabled diffs)
  - bun test src/server/__tests__/providers.test.ts → 32/32, includes
    new "bumps the revision counter monotonically" case
  - bun test src/server/__tests__/conversations.test.ts → 160/160
    pass when run individually; the 3 deferred-restart e2e cases are
    flake-prone in batch (pre-existing, not introduced here)
  - cd desktop && bun run lint → tsc --noEmit clean

Confidence: high
Scope-risk: narrow

Co-authored-by: 你的姓名 <you@example.com>
2026-06-16 03:50:23 +08:00
2026-06-16 00:50:56 +08:00
2026-04-01 10:30:17 +08:00

Code Council

Code Council

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

A Claude Code build repaired from the source leaked from Anthropic's npm registry on 2026-03-31. Code Council is now primarily a desktop Claude Code workspace for macOS, Windows, and Linux: sessions, projects, branch / Worktree launch, right-side file changes, code diffs, permission review, provider setup, Computer Use, H5 remote access, IM integration, and scheduled tasks in one app.

Desktop Preview · Install · Highlights · Sponsorship · More Docs


Desktop Preview

The Code Council desktop app brings sessions, multi-project navigation, branch / Worktree controls, right-side file changes, code diffs, permission review, provider setup, and remote access into one graphical workspace for daily development flows beyond the terminal.

Download Desktop   Install Guide

Desktop workspace
Desktop Workspace
Right-side changes and Worktree
Right-side Changes & Worktree
Code editing
Code Editing & Diff View
Permission control
Permission Review & AI Questions
H5 remote access
H5 Remote Access
Token usage
Token Usage
Computer Use
Computer Use
Scheduled tasks
Scheduled Tasks

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. This build is currently unsigned, so the first launch needs a one-time manual approval (clear quarantine on macOS, click "Run anyway" on Windows). See the desktop installation guide.

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 global usage for more configuration options.


Desktop Highlights

  • Multi-session workspace: tabs, project switching, terminal entry, and session history in one place.
  • Branch / Worktree launch: choose a repository branch and decide whether to use the current working tree or an isolated Worktree.
  • Right-side file changes: review changed files, added/removed lines, and current workspace state while chatting.
  • Visual code changes: inspect edits, file writes, and diffs directly in the desktop app.
  • Permission review: approve risky commands, tool calls, and model follow-up questions in the GUI.
  • Multi-provider setup: configure Anthropic-compatible APIs, third-party models, WebSearch fallback, and local options.
  • Computer Use: let the agent take screenshots, click, type, and control desktop apps after authorization.
  • H5 remote access: open the current desktop session from a phone or another device with a one-time token.
  • IM integration: chat, switch projects, and approve actions through Telegram / Feishu / WeChat / DingTalk.
  • Scheduled tasks and usage stats: create planned tasks and track local token usage trends.

More Documentation

Document Description
Environment Variables Full env var reference and configuration methods
Third-Party Models Using OpenAI / DeepSeek / Ollama and other non-Anthropic models
Contributing Local tests, live model baselines, PR gates, and release gates
Memory System Cross-session persistent memory usage and implementation
Multi-Agent System Agent orchestration, parallel tasks and Teams collaboration
Skills System Extensible capability plugins, custom workflows and conditional activation
IM Integration Remote chat, project switching, and permission approval via Telegram / Feishu / WeChat / DingTalk
Computer Use Desktop control (screenshots, mouse, keyboard) — Architecture
Desktop App Electron + React GUI client — Quick Start | Architecture | Installation
Global Usage Run claude-haha from any directory
FAQ Common error troubleshooting
Source Fixes Fixes compared with the original leaked source
Project Structure Code directory structure

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
JieKou AI
接口AI
Thanks to JieKou AI for sponsoring this project. JieKou AI provides official model resources with stable, high-performance API access. Subscription bundles are priced at 20% off the official rate; new users who register through this link and bind GitHub can claim a $3 coupon.
ShengSuanYun Thanks to ShengSuanYun for sponsoring this project. ShengSuanYun is an industrial-grade AI task parallel execution platform for AI Native Teams, aggregating Claude, ChatGPT, Gemini, and other LLM, image, and video model capacity through direct, non-reverse-engineered access. Its platform SLA reaches 99.7%, with service status available online. It also supports dedicated enterprise gateways, cost and permission controls, smart routing, security protection, BYOK, usage-based billing, upcoming tokens plans, and invoicing. New users registering through this link can receive 10 yuan in model credits plus a 10% first top-up bonus.

📧 Contact: relakkes@gmail.com


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

Thanks

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.

Star History

If this project helps you, please support it with a Star so more people can discover Code Council.

Star History Chart

Disclaimer

This repository is based on the Claude Code source leaked from the Anthropic npm registry on 2026-03-31. All original source code copyrights belong to Anthropic. It is provided for learning and research purposes only.

Description
Claude Code 本地可运行版本 - mirror from GitHub
Readme 537 MiB
Languages
TypeScript 98.7%
CSS 0.3%
Rust 0.2%
Shell 0.2%
Python 0.2%
Other 0.3%