-
Notifications
You must be signed in to change notification settings - Fork 22
Feat: Support basic Symbol navigation inside AI coding session #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ed57bc9
3a4a6c5
b205107
4b29e14
5c5511f
5af1142
03e1ed9
a4f44ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -268,23 +268,36 @@ into the AI prompt file and optionally sends to AI." | |
| (defun ai-code--explain-dired () | ||
| "Handle explain for Dired buffer." | ||
| (let* ((file-at-point (dired-get-filename nil t)) | ||
| (git-relative-path (when file-at-point | ||
| (car (ai-code--get-git-relative-paths (list file-at-point))))) | ||
| (files-context-string (when git-relative-path | ||
| (concat "\nFiles:\n@" git-relative-path))) | ||
| (all-marked (dired-get-marked-files)) | ||
| (has-marked-files (> (length all-marked) 1)) | ||
| (context-files (if has-marked-files | ||
| all-marked | ||
| (when file-at-point | ||
| (list file-at-point)))) | ||
|
Comment on lines
270
to
+276
|
||
| (git-relative-paths (when context-files | ||
| (ai-code--get-git-relative-paths context-files))) | ||
| (files-context-string (when git-relative-paths | ||
| (concat "\nFiles:\n" | ||
| (mapconcat (lambda (path) (concat "@" path)) | ||
| git-relative-paths | ||
| "\n")))) | ||
| (file-type (if (and file-at-point (file-directory-p file-at-point)) | ||
| "directory" | ||
| "file")) | ||
| (initial-prompt (if git-relative-path | ||
| (format "Please explain the %s at path @%s.\n\nProvide a clear explanation of what this %s contains, its purpose, and its role in the project structure.%s" | ||
| "directory" | ||
| "file")) | ||
| (initial-prompt (cond | ||
| (has-marked-files | ||
| (format "Please explain the selected files or directories.\n\nProvide a clear explanation of what these files or directories contain, their purpose, and their role in the project structure.%s" | ||
| (or files-context-string ""))) | ||
| ((car git-relative-paths) | ||
| (format "Please explain the %s at path @%s.\n\nProvide a clear explanation of what this %s contains, its purpose, and its role in the project structure.%s" | ||
| file-type | ||
| git-relative-path | ||
| (car git-relative-paths) | ||
| file-type | ||
| (or files-context-string "")) | ||
| "No file or directory found at cursor point.")) | ||
| (final-prompt (if git-relative-path | ||
| (ai-code-read-string "Prompt: " initial-prompt) | ||
| initial-prompt))) | ||
| (or files-context-string ""))) | ||
| (t "No file or directory found at cursor point."))) | ||
| (final-prompt (if git-relative-paths | ||
| (ai-code-read-string "Prompt: " initial-prompt) | ||
| initial-prompt))) | ||
| (when final-prompt | ||
| (ai-code--insert-prompt final-prompt)))) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,8 @@ | |||||
|
|
||||||
| (declare-function ai-code-session-navigate-link-at-mouse "ai-code-input" (event)) | ||||||
| (declare-function ai-code-session-navigate-link-at-point "ai-code-input" ()) | ||||||
| (declare-function helm-gtags-find-tag "ext:helm-gtags" (tagname)) | ||||||
|
||||||
| (declare-function helm-gtags-find-tag "ext:helm-gtags" (tagname)) | |
| (declare-function helm-gtags-find-tag "helm-gtags" (tagname)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disambiguate duplicate filenames before opening symbol context
Symbol navigation opens the associated file via ai-code-session-link--resolve-session-file, which resolves basename collisions by taking the first match, so in repos with duplicate filenames (for example multiple utils.py files) clicking a symbol can jump into the wrong file and then run xref/search there. Regular file-link navigation already handles this by prompting when multiple candidates exist, so this path should use equivalent disambiguation instead of silently picking one match.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ai-code--explain-diredonly treats marks as active when> 1entries are returned, so an explicit single marked file is ignored and the command falls back tofile-at-point. In Dired, users commonly mark exactly one file and move point elsewhere before running commands, so this now explains the wrong file/directory in that workflow. Using the same “truly marked” logic asai-code--ask-question-diredwould avoid this regression.Useful? React with 👍 / 👎.