feat(cli): add /review slash command for PR review#9
Merged
Conversation
Mirrors Claude Code's local /review: a static prompt template that points the agent at `gh pr list/view/diff` and asks for a structured review across correctness / conventions / performance / test coverage / security. The prompt is tighter than CC's verbatim version because xc's system prompt is more investigation-biased — without explicit guardrails, an empty `gh pr list` triggered 8+ tool calls (auth status, branch -a, status, diff, etc.) before the model pivoted to reviewing local uncommitted changes. The no-arg branch now stops on empty output and forbids further probing.
6 tasks
woai3c
added a commit
that referenced
this pull request
May 7, 2026
…tle (#10) When two stdout writes would land within MIN_COMMIT_GAP_MS (50ms), the second is throttled via setTimeout. If a height-changing render arrives before that timer fires, the supersede path (`commit-throttle- superseded-by-height`) calls clearTimeout — but the throttled render's payload, which carried the new scrollback bytes, is then garbage collected. `writtenMessageCountRef` had already been bumped synchronously, so subsequent renders don't re-emit those bytes either. Net effect: the message vanishes from the visible scrollback even though it lives in `state.messages`. Reproducing this required a multi-line commit followed by a frame shrink (e.g. end-of-turn spinner removal). One observed case: streaming "Here's the open PR:\n\n**PR #9**...\n\nWhich PR..." across two buffer commits — the first commit drew "Here's the open PR:" then scheduled a 1ms throttle for the rest. The shrink at finishReason=stop fired 1ms later, supersede cancelled the throttle, and the final two paragraphs were lost on screen. Fix: hoist the per-render `scrollbackContent` accumulator into a cross-render `pendingScrollbackRef`. doFlush clears it only after the write actually lands. If the throttle is cancelled, the bytes survive to the next render — `didCommitMessages` stays true (because scrollbackContent is non-empty), the geometry path includes the bytes in the new render's preBuf, and they reach stdout alongside the new (smaller) frame in a single atomic write — no extra flicker, no lost text. Also clears the ref in the /clear path, since wiping scrollback makes any pending bytes stale (their messages no longer exist).
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
/review [PR#]斜杠命令,对齐 Claude Code 的本地/review实现:把一段静态 prompt 模板交给主 agent,由模型用gh pr list/view/diff拿数据,按 代码正确性 / 项目规范 / 性能 / 测试覆盖 / 安全 五维度输出结构化审查/init一致:echoCommand(text)+submit(REVIEW_PROMPT(arg), { silent: true }),无新增工具、无服务端逻辑、无 sub-agentREADME.md/README.en.md的 feature 列表与斜杠命令表Why this prompt is tighter than CC's verbatim
最初按 CC 的
LOCAL_REVIEW_PROMPT一字照搬(4 步 + 5 维度)。在 xc 上跑/review无参数时,模型把gh pr list的空输出(无开放 PR)解读成"命令可疑",连续 8+ 次 tool call 去查gh auth status、git remote -v、gh pr list --state all、git branch -a、git status、git log、git diff HEAD……最后越权 review 本地未提交变更。根因是 xc 的 system prompt 比 CC 更偏 root-cause / thoroughness 导向,同一段宽松的步骤化 prompt 在 xc 上会发散。修法是把无参数分支锁死:
No open PRs in this repository — re-run /review <number>并 STOPgh auth/ branch / diff / status / 未提交变更Use \gh` directly — no wrappers,堵住模型偶发幻觉出rtk/gh-aux` 等包装器的 casepackages/cli/src/ui/components/App.tsx注释里有完整诊断说明,避免后人误把它"还原成 CC 原版"Test plan
pnpm typecheck通过/review(无参)→ 单次gh pr list,空仓库返回固定提示语并停止,无后续探查/review <num>(有参)→ 模型按gh pr view+gh pr diff顺序拿数据,输出结构化 review/help与 Tab 补全菜单可见/review