Skip to content

Add regression tests for shell buffer selection ordering#344

Open
timvisher-dd wants to merge 1 commit intoxenodium:mainfrom
timvisher-dd:timvisher/fix-shell-buffer-selection-ordering
Open

Add regression tests for shell buffer selection ordering#344
timvisher-dd wants to merge 1 commit intoxenodium:mainfrom
timvisher-dd:timvisher/fix-shell-buffer-selection-ordering

Conversation

@timvisher-dd
Copy link
Contributor

I thought I'd hit a bug where C-u C-c A to create a new shell followed by navigating away and C-c A would route to the older shell instead of the new one. After investigating (buffer-list) ordering empirically with emacs --batch -Q and tracing the code paths, we proved that the current (buffer-list)-based ordering in agent-shell-buffers works correctly for this scenario: select-window (display-buffer ...) (the path used by agent-shell--display-buffer) does promote the buffer.

These tests document and lock down the actual ordering behavior as regression protection:

  • switch-to-buffer and select-window promote a shell to the front
  • with-current-buffer (used by agent-shell--handle) does not promote
  • bury-buffer demotes a shell to the end
  • Buffers created without display stay at the end
  • agent-shell-project-buffers filters by CWD and preserves ordering

Checklist

  • I agree to communicate (PR description and comments) with the author myself (not AI-generated).
  • I've reviewed all code in PR myself and will vouch for its quality.
  • I've read and followed the Contributing guidelines.
  • I've filed a feature request/discussion for a new feature. N/A since this just tests documented behavior.
  • I've added tests where applicable.
  • I've updated documentation where necessary.
  • I've run M-x checkdoc and M-x byte-compile-file.

Validate that agent-shell-buffers and agent-shell-project-buffers
reflect (buffer-list) ordering correctly: switch-to-buffer and
select-window promote, with-current-buffer does not, bury-buffer
demotes, and project filtering preserves order.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@timvisher-dd timvisher-dd marked this pull request as ready for review February 26, 2026 21:55
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