Skip to content

Add regression tests for shell buffer selection ordering#344

Closed
timvisher-dd wants to merge 6 commits intoxenodium:mainfrom
timvisher-dd:timvisher/fix-shell-buffer-selection-ordering
Closed

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

Conversation

@timvisher-dd
Copy link
Copy Markdown
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.

@timvisher-dd timvisher-dd marked this pull request as ready for review February 26, 2026 21:55
@timvisher-dd
Copy link
Copy Markdown
Contributor Author

Ping on this. Would be nice to have these regression tests locked in. :)

@timvisher-dd timvisher-dd force-pushed the timvisher/fix-shell-buffer-selection-ordering branch 2 times, most recently from 6d3288d to 5586df4 Compare March 15, 2026 16:35
timvisher-dd and others added 6 commits March 15, 2026 14:49
CI workflow runs byte-compilation and ERT tests on push/PR using
GitHub Actions with deps checked out from timvisher-dd/acp.el-plus
and xenodium/shell-maker.

bin/test parses ci.yml with yq so local runs stay in sync with CI
automatically. It symlinks local dependency checkouts into deps/ to
match the CI layout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
New library for sending desktop notifications from Emacs.

In GUI mode on macOS, uses native UNUserNotificationCenter via a
dynamic module (agent-shell-alert-mac.dylib) compiled JIT on first
use (inspired by vterm). When compilation fails (e.g. missing Xcode
CLI tools), a message recommends `xcode-select --install`.

In terminal mode, auto-detects the host terminal emulator and sends
the appropriate OSC escape sequence:
- OSC 9: iTerm2, Ghostty, WezTerm, foot, mintty, ConEmu
- OSC 99: kitty
- OSC 777: urxvt, VTE-based terminals

Inside tmux, wraps in DCS passthrough (checking allow-passthrough
first). Falls back to osascript on macOS when the terminal is
unknown or tmux passthrough is not enabled.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Follows the same pattern as acp.el: a boolean toggle
(agent-shell-logging-enabled, off by default), a per-shell log
buffer stored in state, and label+format-string logging. Adds log
calls to idle notification start/cancel/fire for observability.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
After each agent turn completes, a 30s timer starts. Any user input
in the buffer cancels it; otherwise it fires a desktop notification
via agent-shell-alert. The echo area message is only shown when the
shell buffer is not the active buffer.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>
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