Skip to content

Support optional editor context in GitHub issue investigation#410

Merged
tninja merged 1 commit into
mainfrom
kang_feat_1
Jun 25, 2026
Merged

Support optional editor context in GitHub issue investigation#410
tninja merged 1 commit into
mainfrom
kang_feat_1

Conversation

@tninja

@tninja tninja commented Jun 25, 2026

Copy link
Copy Markdown
Owner

This pull request enables the "Investigate issue" command (C-c a v with the mode selection of "Investigate issue") to optionally include local editor context such as the current active file name, current function (via which-function), active region text, list of other visible files in the window, and pinned repository context.

Changes

  • Updated ai-code-pull-or-review-diff-file and its downstream helper ai-code--pull-or-review-pr-with-source in ai-code-github.el to accept a prefix argument arg.
  • Introduced an interactive check using y-or-n-p to prompt the user if they want to include the editor context when investigating a GitHub issue (if any editor context is available).
  • Updated ai-code--build-issue-investigation-init-prompt to build the Local Context block and append it to the investigation prompt if requested.
  • Fixed mock functions inside test/test_ai-code-github.el to properly handle variadic/optional arguments, and added a TDD-oriented unit test checking correct prompt generation and context embedding.

Verification

  • Ran checkdoc and byte-compilation on modified Emacs Lisp files ensuring no warnings or errors.
  • Verified that all 33 tests in test_ai-code-github.el pass successfully.

Closing #395

@tninja tninja merged commit 435558c into main Jun 25, 2026
4 checks passed

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

Copy link
Copy Markdown

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: 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".

Comment thread ai-code-github.el
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)))

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 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 👍 / 👎.

Comment thread ai-code-github.el
Comment on lines +197 to +199
(ai-code--get-region-location-info
(region-beginning)
(region-end))))

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 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 👍 / 👎.

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.

1 participant