Skip to content

feat(cli): 终端诊断用户体验优化 — 补全文档、友好错误提示、更新加载动画#627

Merged
phantom5099 merged 3 commits into
1024XEngineer:mainfrom
pionxe:main
May 11, 2026
Merged

feat(cli): 终端诊断用户体验优化 — 补全文档、友好错误提示、更新加载动画#627
phantom5099 merged 3 commits into
1024XEngineer:mainfrom
pionxe:main

Conversation

@pionxe
Copy link
Copy Markdown
Collaborator

@pionxe pionxe commented May 11, 2026

概述

针对终端诊断功能的三个体验短板进行统一优化:

  1. 补全官网使用文档 — 终端诊断功能缺少用户指南页面
  2. 优化无 shell 会话时的错误提示 — 原网关错误信息对用户不友好
  3. neocode update 添加加载动画 — 更新过程无任何反馈,用户无法判断是否卡死

变更详情

1. 补全双语文档(www/

  • 新建 www/guide/shell-diag.md(中文)和 www/en/guide/shell-diag.md(英文)
  • 覆盖 neocode shellneocode diagneocode diag -ineocode diag auto 的全部用法
  • 包含常见问题章节(含 "未启动 shell 即执行 diag" 的处理说明)
  • www/.vitepress/config.mts 中英文侧边栏同步注册

2. 友好错误提示(internal/cli/shell_diag_commands.go

  • 预检:在三个 command runner 中,当 resolveDiagTargetSessionID() 返回空时直接返回友好提示,不再发起 RPC 调用
  • 后检:在 triggerDiagAction() 中对网关返回的 "target role stream is unavailable" 错误进行包装,附加 "请先执行 neocode shell" 的引导信息
  • 新增 7 个测试用例覆盖预检、后检和错误包装逻辑

3. 更新加载动画(internal/cli/update_command.go

  • 新增 startUpdateSpinner(),以 goroutine 方式在 stderr 输出旋转动画(- \ | /),100ms 每帧
  • defaultUpdateCommandRunner() 中以 defer stop() 包裹 doUpdate() 调用
  • 动画在更新完成或出错时自动清理,不影响 stdout 的结果输出

涉及文件

文件 变更
www/guide/shell-diag.md 新建
www/en/guide/shell-diag.md 新建
www/.vitepress/config.mts 侧边栏注册
internal/cli/shell_diag_commands.go 预检 + 后检 + 辅助函数
internal/cli/shell_diag_commands_test.go 新增 7 个测试
internal/cli/update_command.go 加载动画

验证

  • go test ./internal/cli/... 全部通过
  • go test ./internal/updater/... 全部通过
  • go build ./internal/cli/ 编译通过
  • 本地 VitePress 预览(cd www && pnpm dev)确认页面可访问
  • 实际终端中验证:无 shell 时直接 neocode diag 应看到友好提示
  • 实际终端中验证:neocode update 应看到旋转加载动画

Closes #613

pionxe added 3 commits May 11, 2026 19:37
…g.md, www/.vitepress/config.mts)

  - Created bilingual VitePress guide pages covering neocode shell, neocode diag, neocode diag -i, neocode diag auto, and common issues
  - Registered in both Chinese and English sidebars under "日常使用" / "Daily Use"
  - Pre-check: Added checks in defaultDiagCommandRunner, defaultDiagInteractiveCommandRunner, and defaultDiagAutoCommandRunner — when
  resolveDiagTargetSessionID() returns empty, returns a clear message: "no neocode shell session found; run neocode shell first..."
  - Post-check: Added wrapDiagGatewayError() in triggerDiagAction() — intercepts the "target role stream is unavailable" gateway error and wraps it
  with the friendly message
  - 7 new tests added (shell_diag_commands_test.go)
  - Added startUpdateSpinner() — a goroutine-based rotating character animation (- \ | /) writing to stderr
  - Integrated via defer stop() in defaultUpdateCommandRunner(), wrapping the doUpdate() call
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

Copy link
Copy Markdown

@fennoai fennoai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few issues worth addressing around the new update spinner behavior and the shell-diag docs.

return
case <-ticker.C:
frame := updateSpinnerFrames[i%len(updateSpinnerFrames)]
fmt.Fprintf(os.Stderr, "\r%s Updating...", frame)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

startUpdateSpinner writes directly to os.Stderr, so the new progress output bypasses Cobra's configured stderr stream and always emits terminal control characters even when stderr is redirected. In practice that means tests/embedded callers cannot capture it via cmd.SetErr(...), and neocode update 2>file will record raw \r- Updating... frames instead of a clean log. Please route this through the command's stderr writer and gate the spinner on a real TTY before enabling it.

Comment thread www/guide/shell-diag.md

启动后,你会进入一个由 NeoCode 代理的终端环境。该会话会向 NeoCode Gateway 注册为 shell 角色,从而使后续的诊断命令能够找到目标会话。

> **注意**:所有诊断命令(`neocode diag` 及其子命令)都依赖当前已有一个活跃的 `neocode shell` 会话。请先在一个终端窗口启动 `neocode shell`,然后在另一个终端窗口执行诊断命令。
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new guide says users can start neocode shell in one terminal and then run neocode diag in another, but the implementation here still resolves the target only from --session or NEOCODE_SHELL_SESSION (resolveDiagTargetSessionID). A separate terminal will not inherit the proxy shell's env var automatically, so the documented flow fails with no neocode shell session found unless the user passes --session <session-id> (or runs inside the proxied shell). The wording here and the later examples/FAQ should be updated to match the real behavior.


Once started, you enter a NeoCode-proxied terminal environment. The session registers itself with the NeoCode Gateway as a shell role, allowing subsequent diagnosis commands to locate the target session.

> **Note**: All diagnosis commands (`neocode diag` and its subcommands) depend on an active `neocode shell` session. Start `neocode shell` in one terminal window first, then run diagnosis commands in another.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guide currently says users can run neocode diag from another terminal after starting neocode shell, but the implementation still resolves the target only from --session or NEOCODE_SHELL_SESSION (resolveDiagTargetSessionID). A different terminal session will not see that env var by default, so the documented flow fails unless the user passes --session <session-id> (or runs inside the proxied shell). Please align this note and the later examples/FAQ with the actual CLI behavior.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 11, 2026

Codecov Report

❌ Patch coverage is 80.00000% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/cli/shell_diag_commands.go 80.00% 4 Missing ⚠️
internal/cli/update_command.go 80.00% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

@phantom5099 phantom5099 merged commit 02f8721 into 1024XEngineer:main May 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEF-004: 诊断系统 RPC 错误(高优先级)

2 participants