Skip to content

♻️ refactor: align lightweight issue views and command helpers#36

Merged
SigureMo merged 1 commit intoShigureLab:mainfrom
ShigureNyako:refactor/issue-24-review-followup
Mar 22, 2026
Merged

♻️ refactor: align lightweight issue views and command helpers#36
SigureMo merged 1 commit intoShigureLab:mainfrom
ShigureNyako:refactor/issue-24-review-followup

Conversation

@ShigureNyako
Copy link
Copy Markdown
Member

@ShigureNyako ShigureNyako commented Mar 22, 2026

Summary

Follow-up review for tracking issue #24 after the merged feature batch in #30, #31, #32, #33, #34, and #35.

This PR keeps the scope intentionally small: it tightens a few shared abstractions, removes one remaining PR/Issue inconsistency, and adds regression coverage around the cleaned-up paths.

Pure refactor

  • extract shared command-option helpers for repeated --body / --body-file parser wiring
  • extract shared selector-resolution helpers so PR/issue commands use the same --repo + subject validation path
  • route repeated PR/issue write-command validation through those helpers instead of re-implementing the same checks in each command
  • move option-helper unit coverage into a dedicated tests/test_command_options.py

Behavior-preserving cleanup

  • keep PR review/comment edit command surfaces unchanged while reducing duplication in pr.py and issue.py
  • document lightweight non-timeline --show combinations in README.md and skills/github-conversation/SKILL.md

Small behavior adjustment

  • align issue view with the lightweight-loading behavior already added to pr view: when --show does not include timeline, the command now skips timeline bootstrap instead of always fetching first/last timeline pages
  • as a result, lightweight issue views also stop rendering timeline-only frontmatter fields that were never actually loaded on that path

Validation

  • uv run pytest -q
  • uv run ruff check .
  • uv run pyright
  • prettier --check README.md skills/github-conversation/SKILL.md
  • uv run gh-llm issue view 24 --repo ShigureLab/gh-llm --show summary,actions

Risk

Low.

The main observable change is limited to non-timeline issue view calls. The rest of the diff is helper consolidation plus regression coverage, so the primary risk is accidental argparse wiring drift, which is covered by the existing CLI tests and the new option-helper tests.

Related Issues

@SigureMo Please review this PR when you have time. Thanks!

Closes #24

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41057731c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

pager = TimelinePager(client)

meta = client.resolve_pull_request(selector=args.pr, repo=args.repo)
meta = _resolve_pr_meta(client=client, args=args)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep pr view --repo working without an explicit --pr

cmd_pr_view() used to delegate directly to GitHubClient.resolve_pull_request(selector=args.pr, repo=args.repo), and that resolver still intentionally omits the selector when it is unset (src/gh_llm/github_api.py:707-711). That matches the GitHub CLI manual for gh pr view, which says “Without an argument, the pull request that belongs to the current branch is displayed.” After switching this call site to _resolve_pr_meta(), gh-llm pr view --repo <owner/repo> now fails with ``--pris required when--repo` is provided`, so users who pass `--repo` only to make repo selection explicit lose the current-branch PR workflow that worked before this refactor.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

@ShigureNyako ShigureNyako left a comment

Choose a reason for hiding this comment

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

独立审阅结论:APPROVE。

说明:当前登录账号就是该 PR 的作者,GitHub 不允许对自己的 PR 提交 APPROVE,因此这里改为以正式 COMMENT review 记录审阅结论。

审阅结论与依据如下:

  • 功能设计:这次把 issue view 的轻量路径补齐到与 pr view 一致;当 --show 不包含 timeline 时,不再无条件做 timeline bootstrap,边界更清晰,也符合轻量查看场景的预期。
  • CLI 交互:--body / --body-file 以及 --pr / --issue 的解析与校验被收敛到共享 helper 后,命令表面行为保持不变,但重复逻辑明显减少,一致性更好。
  • 测试覆盖:新增了 issue view 轻量路径回归测试,以及 option helper 的默认值、--repo+selector 约束、空字符串 body_file 等边界用例。
  • 本地验证:我额外跑了 uv run pytest -quv run ruff check .uv run pyright,均通过。

一个非阻塞的小建议:README / skills/github-conversation/SKILL.md 里关于“non-timeline --show 走 metadata-only loading”的表述,后续可以再收紧一点,避免和 pr view --show checks / --show mergeability 这类仍会补抓状态信息的路径混淆。不过这不影响当前实现合并。

Copy link
Copy Markdown
Contributor

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow 🐾

@SigureMo SigureMo merged commit 6b564bc into ShigureLab:main Mar 22, 2026
2 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.

tracking: 汇总 gh-llm 优化建议

2 participants