v0.3.2
🆕 Highlights
IllusionCode v0.3.2 is a comprehensive asynchronous refactoring and stability release. This release introduces a full asynchronous overhaul of the tool layer, UI layer, LSP client, and channel SDK, resolves critical agent task lifecycle issues, adds MCP multi-protocol transport support, and introduces a new multi-line text input architecture with improved UX for the question modal and auth flow.
Key Changes
- Full Async Refactoring — Tool layer, UI input/modal, LSP client, and channel SDK fully async with proper queue-based architecture
- Agent Stability — Fixed root cause of Ctrl+X hangs, agent carding, orphan tasks, and GC preemption of fire-and-forget tasks
- MCP Multi-Protocol — HTTP/SSE/WebSocket transport support for MCP client connections
- Auth Token Support — Full
auth_tokenfield support across env config, CLI, API client, and web UI - New Text Input Architecture — MeasuredText, Cursor, and MultilineTextInput rewritten for proper display-line handling
- Mid-Turn Drain — New mid-turn drain mechanism with improved QuestionModal UX
🚀 New Features
MCP & Agent
- MCP Multi-Protocol Transport — HTTP/SSE/WebSocket transport support for MCP client connections
- Activity-Aware Timeout — Agent tool now uses activity-aware timeout for both foreground and background modes
- Sub-Agent Progress Tracking — Foreground mode now displays sub-agent progress tracking
- Agent Force Cancel — Added
force_cancelmechanism with proper ContextVar token reset (Ctrl+X root cause fix)
Authentication
- Auth Token Support — Full
auth_tokenfield support acrossEnvConfig,AnthropicApiClient,resolve_auth(), runtime, CLI (/login//logout), and web UI - Auth Type Selection — Login flow now supports authentication type selection branch (custom format + anthropic)
- Auth Display —
/logincommand displays current authentication type - Credential Persistence —
create_envsavesapi_keytocredentials.json; web env creation also persistsauth_token
UI/UX
- Mid-Turn Drain — Added mid-turn drain mechanism for smoother QuestionModal option rendering
- QuestionModal Pagination — Improved QuestionModal UX with todo/statusbar auto-hide, option preview pagination
- MeasuredText & Cursor — New
MeasuredTexttext measurement core class andCursorimmutable cursor model - TodoPanel Optimization — Optimized TodoPanel display with shared text utility functions
Core Infrastructure
- stderr_redirect — New module for fd-level stderr redirection to prevent logging deadlocks
- signals — New cross-platform SIGINT handler module
- aioqueue — New async queue with shutdown sentinel support
🔧 Refactoring
Full Async Overhaul
- Tool Layer — File I/O, subprocess, rglob, and all tool operations fully async
- UI Layer — Input, modal, and batch delete operations fully async
- LSP Client — Full async rewrite with thread-safe
_pendingand MCP gather exception handling - Channel SDK — Dedicated executor per channel SDK, large file I/O async,
except BaseExceptionsplitting - ReactBackendHost — Write path: queue + single consumer write loop; Read path: daemon thread + instant request processing; Shutdown: three-task concurrent with graceful shutdown
- WebBackendHost — Queue-based writes with graceful shutdown
- agent_executor —
message_queuereplaced with aioqueue + blocking consumer
Frontend Refactoring
- MultilineTextInput — Rewritten using Cursor model for proper display-line handling
- PromptInput — Passes
columnsto input, removessanitizeInput - Ctrl+U Behavior — Changed to delete current display line (not logical line), fixing cross-line deletion and Ink double-newline issues
- Footer Cleanup — Removed slash command hints from footer, optimized shortcut hints and placeholder
- Removed Deprecated — Cleaned up deprecated
ref_count.pyand related references, removedfast_mode,structured_output_tool, andis_interactivefunctionality
🛠️ Important Fixes
Agent Stability
- Ctrl+X Root Cause —
agent_executornow usesasyncio.wait FIRST_COMPLETEDinstead ofwait_forto prevent coroutine hanging - Force Cancel —
agent force_cancelnow properly interrupts and resets ContextVar tokens - Orphan Tasks —
as_completedexception path explicitly cancels unfinished tasks - Fire-and-Forget — Full project fire-and-forget task strong reference fix to prevent GC preemption
- BackgroundAgentTracker — Added
shutdown+wait_for_completionwith timeout protection - daemon_ipc — Plan B: Future + CloseHandle to unblock uncancellable threads
- Agent Wake Event — Fixed
notify_completed wake_eventregression causing agent mode to hang
Channels
- Feishu — Fixed file send
file_type/msg_typemismatch causing 230055 error; fixed WS client reconnection event loop conflict - Channel Inbound — Added queue shutdown sentinel and
_pending_repliesFuture resolve for graceful channel shutdown - Controller Init — Added missing
_dispatch_tasksinitialization for QQStreamingController and FeishuStreamingCardController
Permission & UI
- "Always Allow" Persistence — Fixed
"always allow"permission not persisting topermissions.json - StatusBar — Fixed StatusBar display issues and concurrent permission request deadlock; hides both divider and spacing when Todo is active
- Permission Modal — Fixed TUI permission modal not disappearing and Ctrl+X not terminating tasks
- TodoPanel — Fixed TodoPanel hiding logic during modals, using
externallyHiddenproperty to prevent state loss
Text Input
- Ctrl+U — Fixed cross-line deletion and Ink double-newline; at display line start, deletes previous character to join with previous line
- Column Width — Reduced column width by 1 to eliminate single-character standalone line issue
- Truncation — Removed
truncate-endfrom Text to prevent"..."content truncation - Slash Command Bar — Optimized display truncation and question card divider line color
Auth & Config
- Strict Provider — Double-layer defense to fix
tool_use/tool_resultpairing issue in strict provider - CLI — Uses
typer.prompt()instead of custom prompt;ApiKeyFlowerror messages more generic - merge_cli_overrides — Added
auth_tokensupport;save_settingsstrips empty fields - UnboundLocalError — Fixed
auth_fieldvariable initialization to avoid UnboundLocalError - resolve_auth() — Correctly determines auth type and passes to
AnthropicApiClient
MCP
- Config Parsing — Supports
streamableHttp,sse,websocketprotocols and unwrapped multi-server format
CI/CD
- Integration Tests — Added end-to-end integration tests (backend refactoring verification)
- Test Utils — Added missing
tests/test_services/__init__.pyto resolve basename conflict - UTF-8 Protocol Test — Rewrote UTF-8 protocol byte test to adapt to queue mode
_emit
Installation
pip install (Recommended)
pip install illusion-code==0.3.2From Source
git clone https://github.com/YunTaiHua/illusion-code.git
cd illusion-code
pip install .Quick Start
illusion auth login # Configure API credentials
illusion # Start TUI interactive session
illusion web # Launch Web UI
illusion -p "Analyze the project structure" # Print mode (non-interactive)Documentation
中文版本
🆕 重点更新
IllusionCode v0.3.2 是一个全面异步重构和稳定性版本。本次版本引入了工具层、UI 层、LSP 客户端和渠道 SDK 的全面异步化改造,解决了关键的 agent 任务生命周期问题,新增了 MCP 多协议传输支持,并引入了全新的多行文本输入架构和优化的 question 模态框与认证流程交互体验。
关键更新
- 全面异步重构 — 工具层、UI 输入/模态框、LSP 客户端和渠道 SDK 全面异步化,采用基于队列的架构
- Agent 稳定性 — 修复 Ctrl+X 卡死的根因、agent 卡住、孤儿任务和 GC 抢收 fire-and-forget 任务的问题
- MCP 多协议 — MCP 客户端支持 HTTP/SSE/WebSocket 传输连接
- Auth Token 支持 — 在 env 配置、CLI、API 客户端和 Web UI 中全面支持
auth_token字段 - 新文本输入架构 — 引入 MeasuredText、Cursor 和重写的 MultilineTextInput,正确处理显示行
- Mid-Turn Drain — 新增 mid-turn drain 机制,优化 QuestionModal 交互体验
🚀 新功能
MCP 与 Agent
- MCP 多协议传输 — MCP 客户端支持 HTTP/SSE/WebSocket 传输连接
- 活动感知超时 — Agent 工具前后台模式均采用活动感知超时机制
- 子代理进度追踪 — 前台模式支持子代理进度追踪显示
- Agent 强制取消 — 新增
force_cancel机制,正确重置 ContextVar token(Ctrl+X 根因修复)
认证
- Auth Token 支持 — 在
EnvConfig、AnthropicApiClient、resolve_auth()、运行时、CLI(/login//logout)和 Web UI 中全面支持auth_token字段 - 认证类型选择 — 登录流程新增认证方式选择分支(自定义格式 + anthropic)
- 认证类型显示 —
/login命令显示当前认证类型 - 凭据持久化 —
create_env将api_key保存到credentials.json;Web 环境创建也持久化auth_token
UI/UX
- Mid-Turn Drain — 新增 mid-turn drain 机制,优化 QuestionModal 选项渲染
- QuestionModal 分页 — 优化 question 模态框 UX,自动隐藏 todo/statusbar,添加预览分页
- MeasuredText 与 Cursor — 新增
MeasuredText文本测量核心类和Cursor不可变光标模型 - TodoPanel 优化 — 优化 TodoPanel 显示,提取共享文本工具函数
核心基础设施
- stderr_redirect — 新增 fd 级 stderr 重定向模块,防止 logging 死锁
- signals — 新增跨平台 SIGINT 处理器模块
- aioqueue — 新增带 shutdown 哨兵的异步队列
🔧 重构
全面异步化改造
- 工具层 — 文件 I/O、subprocess、rglob 和所有工具操作全面异步化
- UI 层 — 输入、模态框和批量删除操作全面异步化
- LSP 客户端 — 全面异步重写,线程安全的
_pending和 MCP gather 异常处理 - 渠道 SDK — 每个渠道 SDK 使用专用 executor,大文件 I/O 异步化,
except BaseException拆分 - ReactBackendHost — 写路径:队列 + 单一消费者写循环;读路径:daemon 线程 + 即时请求处理;关闭:三任务并发 + 优雅关闭
- WebBackendHost — 基于队列的写入 + 优雅关闭
- agent_executor —
message_queue替换为 aioqueue + 阻塞式消费
前端重构
- MultilineTextInput — 使用 Cursor 模型重写,正确处理显示行
- PromptInput — 传入
columns到输入组件,移除sanitizeInput - Ctrl+U 行为 — 改为删除当前显示行(display line),修复跨行删除和 Ink 二次换行问题
- Footer 清理 — 删除 footer 中的
/指令提示,优化快捷键提示和输入框 placeholder - 废弃代码清理 — 清理已废弃的
ref_count.py及相关引用,移除fast_mode、structured_output_tool和is_interactive功能
🛠️ 重要修复
Agent 稳定性
- Ctrl+X 根因 —
agent_executor使用asyncio.wait FIRST_COMPLETED替代wait_for,防止协程卡死 - 强制取消 —
agent force_cancel正确中断并重置 ContextVar token - 孤儿任务 —
as_completed异常路径显式取消未完成任务 - Fire-and-Forget — 全项目 fire-and-forget task 强引用修复,防止 GC 抢先回收
- BackgroundAgentTracker — 新增
shutdown+wait_for_completion超时保护 - daemon_ipc — 方案 B:Future + CloseHandle 解除不可取消线程阻塞
- Agent 唤醒事件 — 修复
notify_completed wake_event回归导致 agent 模式卡住
渠道
- 飞书 — 修复文件发送
file_type/msg_type不匹配导致 230055 错误;修复 WS 客户端重连时事件循环冲突 - 渠道入站 — 添加 queue shutdown 哨兵和
_pending_repliesFuture resolve,实现优雅渠道关闭 - 控制器初始化 — 补全 QQStreamingController 和 FeishuStreamingCardController 的
_dispatch_tasks初始化
权限与 UI
- "总是允许"持久化 — 修复"总是允许"权限未持久化到
permissions.json - StatusBar — 修复 StatusBar 显示问题和并发权限请求死锁;有 Todo 时同时隐藏分割线和间距
- 权限模态框 — 修复 TUI 权限模态框不消失和 Ctrl+X 无法终止任务
- TodoPanel — 修复模态框期间 TodoPanel 隐藏逻辑,使用
externallyHidden属性避免状态丢失
文本输入
- Ctrl+U — 修复跨行删除和 Ink 二次换行;在 display line 行首时删除前一个字符连接上一行
- 列宽 — 列宽减 1 消除单字符独立成行问题
- 截断 — 移除 Text 的
truncate-end,避免"..."截断内容 - 斜杠指令栏 — 优化显示截断与问题卡片分割线颜色
认证与配置
- Strict Provider — 双层防御修复 strict provider 的
tool_use/tool_result配对问题 - CLI — 使用
typer.prompt()替代自定义提示;ApiKeyFlow错误消息更通用 - merge_cli_overrides — 添加
auth_token支持;save_settings剥离空字段 - UnboundLocalError — 修复
auth_field变量初始化避免 UnboundLocalError - resolve_auth() — 正确判断认证类型并传递给
AnthropicApiClient
MCP
- 配置解析 — 支持
streamableHttp、sse、websocket协议和无包装多服务器格式
CI/CD
- 集成测试 — 新增端到端集成测试(后端重构验证)
- 测试工具 — 补全
tests/test_services/__init__.py解决 basename 冲突 - UTF-8 协议测试 — 重写 UTF-8 协议字节测试以适配 queue 模式
_emit
安装
pip 安装(推荐)
pip install illusion-code==0.3.2从源码安装
git clone https://github.com/YunTaiHua/illusion-code.git
cd illusion-code
pip install .快速开始
illusion auth login # 配置 API 认证
illusion # 启动 TUI 交互式会话
illusion web # 启动 Web 界面
illusion -p "分析项目结构" # Print 模式(非交互)