Support optional editor context in GitHub issue investigation#410
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 26042939a6
ℹ️ 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".
| 4. No need to make code change. Provide analysis only." | ||
| issue-url source-instruction))) | ||
| issue-url source-instruction))) | ||
| (if (and include-context (or buffer-file-name (use-region-p))) |
There was a problem hiding this comment.
Honor pinned context outside file buffers
When Investigate issue is invoked from a non-file buffer such as Magit status, pinned repository context can still be available because ai-code--format-repo-context-info keys off default-directory, but this guard returns the base prompt before checking it (and the caller mirrors the same buffer-file-name/region test). As a result C-u/include-context silently drops the stored repo context, which is one of the advertised context sources; build the blocks first or include repo/visible context in the availability test.
Useful? React with 👍 / 👎.
| (ai-code--get-region-location-info | ||
| (region-beginning) | ||
| (region-end)))) |
There was a problem hiding this comment.
Load discussion helpers before using regions
When ai-code-github is loaded without ai-code-discussion and the user has an active region and accepts context, this call is reached but the helper is only declared, not required, so Emacs signals (void-function ai-code--get-region-location-info) before sending the prompt. The explain-code-change branch requires ai-code-discussion, but the issue-investigation context path needs the same require or an fboundp guard before using the region helper.
Useful? React with 👍 / 👎.
This pull request enables the "Investigate issue" command (
C-c a vwith the mode selection of "Investigate issue") to optionally include local editor context such as the current active file name, current function (viawhich-function), active region text, list of other visible files in the window, and pinned repository context.Changes
ai-code-pull-or-review-diff-fileand its downstream helperai-code--pull-or-review-pr-with-sourceinai-code-github.elto accept a prefix argumentarg.y-or-n-pto prompt the user if they want to include the editor context when investigating a GitHub issue (if any editor context is available).ai-code--build-issue-investigation-init-promptto build theLocal Contextblock and append it to the investigation prompt if requested.test/test_ai-code-github.elto properly handle variadic/optional arguments, and added a TDD-oriented unit test checking correct prompt generation and context embedding.Verification
test_ai-code-github.elpass successfully.Closing #395