Skip to content

Chore: Improve ai-code-implement-todo inside org-mode file#325

Merged
tninja merged 4 commits intomainfrom
kang_feat_11
Apr 30, 2026
Merged

Chore: Improve ai-code-implement-todo inside org-mode file#325
tninja merged 4 commits intomainfrom
kang_feat_11

Conversation

@tninja
Copy link
Copy Markdown
Owner

@tninja tninja commented Apr 30, 2026

This is an enhancement after #317

  1. The function can work on org section headline without TODO. It just won't work on DONE
  2. If the org buffer is a ai-code-prompt-mode (eg. under .ai-code-files dir). It also support generate AI command summary in-place. So that the ai-code-prompt-mode can track the command result.

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: e95a8056c7

ℹ️ 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-prompt-mode.el Outdated
Comment on lines +429 to +431
(if (and (string-prefix-p "/" final-prompt)
(not (string-match-p " " final-prompt)))
(ai-code--execute-command final-prompt)
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 Preserve slash command execution in prompt-mode headings

When summary appending is enabled on an ai-code-prompt-mode heading, command detection now checks final-prompt instead of the original command text, so a slash command like /status can be converted into a normal prompt and no longer run via ai-code--execute-command. This regression only appears in heading-based prompt buffers (for example task files under .ai.code.files) and breaks direct backend command workflows that previously executed immediately.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enhances ai-code-implement-todo-driven workflows for Org buffers by treating plain Org headlines as implementable prompts (excluding DONE) and adding an optional “append result summary in-place” instruction when operating inside ai-code-prompt-mode task files.

Changes:

  • Expand Org headline detection so ai-code-implement-todo (and routing from ai-code-code-change / ai-code-ask-question) works on plain Org headlines, not only TODO headlines.
  • Move the “append result summary” prompt/instruction into ai-code--insert-prompt when in ai-code-prompt-mode at a heading.
  • Add/adjust ERT coverage for plain Org headline behavior and the new summary-appending flow.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
ai-code-change.el Broadens Org headline detection and updates prompt/error strings to reflect “Org headline” (not only TODO).
ai-code-prompt-mode.el Adds optional summary-append instruction during prompt insertion in ai-code-prompt-mode headings.
test/test_ai-code-change.el Adds tests for plain Org headlines and summary logic (some currently misconfigured to use org-mode).
test/test_ai-code-discussion.el Adds routing test ensuring ai-code-ask-question goes to ai-code-implement-todo on plain Org headlines.

Comment thread ai-code-prompt-mode.el Outdated
Comment on lines +418 to +432
(let* ((processed-prompt (if ai-code-prompt-preprocess-filepaths
(ai-code--preprocess-prompt-text prompt-text)
prompt-text))
(append-summary-p (and (derived-mode-p 'ai-code-prompt-mode)
(org-at-heading-p)
(y-or-n-p "Append result summary to current section? ")))
(final-prompt (if append-summary-p
(concat processed-prompt
(format "\n\nAfter completing, append a concise result summary as a sub-heading at the end of the current section in file %s near line %d."
buffer-file-name (line-number-at-pos)))
processed-prompt)))
(if (and (string-prefix-p "/" final-prompt)
(not (string-match-p " " final-prompt)))
(ai-code--execute-command final-prompt)
(ai-code--write-prompt-to-file-and-send final-prompt))))
Comment thread test/test_ai-code-change.el Outdated
Comment on lines +914 to +920
(require 'org)
(setq buffer-file-name "/tmp/project/plan.org")
(insert "* TODO Build search feature\n")
(insert "Design the API first.\n")
(org-mode)
(goto-char (point-min))

Comment thread test/test_ai-code-change.el Outdated
Comment on lines +937 to +943
(require 'org)
(setq buffer-file-name "/tmp/project/plan.org")
(insert "* TODO Build search feature\n")
(insert "Design the API first.\n")
(org-mode)
(goto-char (point-min))

Comment thread ai-code-change.el
Comment on lines 451 to +455
(cond
((and ask-question-p org-todo-section-info)
(if (and clipboard-context (string-match-p "\\S-" clipboard-context))
"Question about Org TODO headline (clipboard context): "
"Question about Org TODO headline: "))
"Question about Org headline (clipboard context): "
"Question about Org headline: "))
@tninja tninja merged commit a2d0a0a into main Apr 30, 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.

2 participants