已关闭
feat(actions): gc actions run watch — 轮询监控 run 直到终态 #507
aflyingto创建于  8月10日关闭于  8月10日
aflyingto成员
8月10日 创建

背景

拆自专项 issue gitcode-cli/cli#506 §3.1。对齐 gh run watch。

需求

新增 gc actions run watch <run-id> 命令,客户端定时轮询 GetActionsRun API 直到 run 状态为终态,实时展示 stage/job 执行进度。

无需新 API

纯客户端轮询,复用已有 api.GetActionsRun(api/queries_actions.go)。终态判断:COMPLETED / FAILED / CANCELED / IGNORED / PAUSED / SUSPEND。

命令接口

gc actions run watch <run-id> -R owner/repo [flags]

Flags:

  • --interval <seconds>:刷新间隔,默认 3 秒(对齐 gh)
  • --compact:仅展示相关/失败 step(对齐 gh)
  • --exit-status:run 失败时返回非零退出码
  • -R, --repo:仓库(全局标准 flag)
  • --json:JSON 输出(轮询结果)

行为

  1. 首次拉取 run 详情,展示 stage/job 概览
  2. 按 --interval 定时轮询,刷新 stage/job 状态(TTY 下清屏重绘)
  3. 非 TTY 环境不阻塞轮询,输出单次快照后退出(符合 agent-friendly 契约)
  4. run 进入终态后停止轮询,输出最终结果
  5. --exit-status 时终态为 FAILED/CANCELED 返回退出码 1

对齐 gh 参考

gh run watch <run-id> [--compact] [--exit-status] [--interval <seconds>]

验收标准

Refs gitcode-cli/cli#506

likedislike
Aaflyingto成员
8月10日 添加了label:agent-friendlyenhancementscope/actions
aflyingto成员
8月10日 评论:

验证记录

验证版本: main (5c57973)
验证命令: gc actions run --help + 源码审查 pkg/cmd/actions/run/
验证结果:

  • gc actions run 当前只有 list 和 view 两个子命令
  • 无 watch 子命令
  • api.GetActionsRun 已实现,返回 WorkflowRunDetail(含 Status 字段和 Stages/Jobs)
  • 终态判断依据 Status 字段:COMPLETED/FAILED/CANCELED/IGNORED/PAUSED/SUSPEND
  • pkg/iostreams 已有 IsStdoutTTY/CanPrompt 支持

结论: 确认功能缺失,API 已就绪,可实现。

likedislike
Aaflyingto成员
8月10日 关联了pull request:feat(actions): add gc actions run watch — poll run until terminal state
Aaflyingto成员
8月10日 关闭了 issue