feat: optimize CLI channel to replace Claude Code/Codex#376
Merged
Conversation
When SandboxRouter has docker enabled, inject a built-in docker sandbox entry (named __docker__) into the runner list so users can see and switch to it from both the web UI and Feishu settings card. Changes: - tools/sandbox_router.go: add HasDocker(), DockerImage(), SetTokenStore(); SandboxForUser now reads user_settings.active_runner to respect user choice - tools/docker_sandbox.go: add Image() method - tools/sandbox_runner.go: SetRunnerTokenDB also sets router's tokenStore - main.go: RunnerList callback injects docker entry when router has docker - channel/web_api.go: reject DELETE for built-in docker sandbox - channel/feishu_settings.go: show docker as 'Docker Sandbox (内置)', hide delete button, guard against deletion - web/src/components/RunnerPanel.tsx: special handling for __docker__ (no delete, no connect command, always online)
- Add channel/cli.go: CLI Channel implementation with Bubble Tea TUI - Add cmd/cli/main.go: Standalone CLI entry point - Add channel/card_converter.go: Shared Feishu Card converter - Add docs/cli-channel.md: User documentation - Update go.mod: Add Bubble Tea, Lipgloss, Glamour dependencies - Add bus.IsPartial field for streaming support - Update channel/web.go to use shared card converter - Update README.md with CLI Channel usage Features: - Real-time streaming output with progress indicators - Markdown rendering with syntax highlighting - Multi-line input with keyboard shortcuts - Tool progress and SubAgent status display - Graceful shutdown handling - Window resize support Testing: - 67 test cases with 91.38% coverage - All CI checks passed (Build/Lint/Test) Co-authored-by: xbot <xbot@example.com>
glamour.WithAutoStyle() queries terminal background color via OSC 11,
the response (e.g. ]11;rgb:1e1e/1e1e/1e1e\) leaks into textarea stdin
and gets displayed as garbled text.
Fix:
- Replace glamour.WithAutoStyle() with glamour.WithStandardStyle("dark")
- Clear textarea in Init() to absorb any residual OSC responses
termenv.DefaultOutput() queries terminal background color by sending
OSC 11 (\x1b]11;?\x1b\). The terminal response leaks into textarea
stdin and displays as garbled text (e.g. ]11;rgb:1e1e/1e1e/1e1e\).
Fix: Set termenv default output with WithTTY(false) in init() to
prevent any terminal queries. Combined with previous fix:
- glamour.WithStandardStyle("dark") instead of WithAutoStyle()
- textarea.Reset() in Init() as safety net
- Incremental rendering: cached history + dirty flag + streaming fast path - Tool call visualization: completed tools summary cards - /model command: alias for /set-model - /context command: passthrough to agent layer - Non-interactive streaming: diff-based stdout output - Session resume: --resume/--new flags - Tab completion: 9 known commands with cycle selection - Ctrl+K: interactive context editing (delete last N messages) - maxInt() replaced with Go builtin max() - inputReady field restored for test compatibility
b8b515a to
cec41f8
Compare
added 4 commits
March 31, 2026 17:34
- Updated `bubbletea` to v1.3.10 and `lipgloss` to v1.1.0 for improved performance. - Replaced `charmbracelet/x/ansi` with v0.10.1 and added `charmbracelet/x/cellbuf` for better rendering support. - Enhanced `compactMessages` function to include a new `maxContextTokens` parameter, optimizing message handling and token budget management. - Introduced `formatCompactLine` function to format messages for compaction history, ensuring clarity and consistency in output. - Added tests for CLI progress rendering and message handling to ensure robustness and prevent regressions.
…ummary - Add HistoryLoader callback to CLIChannelConfig for session restore on restart - Reconstruct tool_summary messages from IterationHistory JSON (Detail field) - Display thinking + tools grouped by iteration in bordered panel - Filter intermediate assistant/tool messages from history - Runtime and restored history now render identically - Remove automatic /context info on startup - Fix S1016 staticcheck and remove unused syncWriter
…pinner fix - Ctrl+Enter/Ctrl+J for newline in textarea (Enter sends) - ChatID uses absWorkDir for per-directory session isolation - Spinner animation fixed: spinner.TickMsg now triggers viewport refresh - Status bar: show 'processing' instead of 'thinking' when no progress event; show active tool name or phase-specific hints - Full-width message rendering: removed narrow bubble borders, glamour renderer uses terminal width - Logger: new LogDir field (priority over WorkDir), CLI logs to xbotHome - cmd/cli renamed to cmd/xbot-cli (go install produces xbot-cli binary) - main.go refactored: extract cliApp for shared init between modes - Inject SetDirectSend/SetChannelFinder for structured progress events - config.go refactored: file+env+defaults three-layer config loading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CLI channel 全面优化,对标 Claude Code / Codex 终端体验。基于
feat/cli-channel分支增量改进。Changes
channel/cli.gochannel/cli_test.gocmd/cli/main.goagent/engine_wire.gochannel/web.go核心特性
cachedHistory分离 +dirty标记 + 流式只渲染最后一条,长对话不卡顿--resume默认恢复、--new强制新会话Verification
go build ./...— 编译通过go vet— 无警告golangci-lint— 0 issuesgo test -race ./...— 全量测试通过