diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-20 18:10:05 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-20 18:10:05 -0400 |
| commit | feedb78a517a1e86f6bb467756aa2605c7477223 (patch) | |
| tree | 9034c36e430189e7ef19fa74c9ce1d5442ea914d /tests/test-ai-vterm--display-saved.el | |
| parent | 4a6201dd0117df55d164cee969f7c3c8123f6b28 (diff) | |
| download | dotemacs-feedb78a517a1e86f6bb467756aa2605c7477223.tar.gz dotemacs-feedb78a517a1e86f6bb467756aa2605c7477223.zip | |
feat(ai-vterm): default to bottom-75% on laptop, right-50% on desktop
The agent window's default placement was hardcoded to a right-side split at 50% width. That's wrong on a laptop, where the screen is shorter and a bottom split with more height fits better than a narrow side panel.
Pick the default from the host: bottom at 75% height on a laptop, right at 50% width on a desktop, branching on env-laptop-p in cj/--ai-vterm-default-direction and cj/--ai-vterm-default-size. The defaults still feed the existing toggle-capture mechanism, so re-orienting the window mid-session sticks the same way it did before.
Renamed cj/ai-vterm-window-width to cj/ai-vterm-desktop-width and added cj/ai-vterm-laptop-height so each axis has its own knob.
Diffstat (limited to 'tests/test-ai-vterm--display-saved.el')
| -rw-r--r-- | tests/test-ai-vterm--display-saved.el | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/tests/test-ai-vterm--display-saved.el b/tests/test-ai-vterm--display-saved.el index a17df0aa..91cea46e 100644 --- a/tests/test-ai-vterm--display-saved.el +++ b/tests/test-ai-vterm--display-saved.el @@ -20,16 +20,18 @@ (require 'ai-vterm) (require 'testutil-vterm-buffers) -(ert-deftest test-ai-vterm--display-saved-uses-defaults-when-state-nil () - "Normal: nil state -> direction=rightmost, size=cj/ai-vterm-window-width. +(ert-deftest test-ai-vterm--display-saved-uses-desktop-defaults-when-state-nil () + "Normal: nil state on a desktop -> rightmost, size=cj/ai-vterm-desktop-width. The cardinal `right' default maps to the frame-edge variant `rightmost' so agent lands at the frame's right edge regardless of -which window is selected." +which window is selected. `env-laptop-p' is stubbed nil to pin the +desktop branch." (let (received-buf received-alist (cj/--ai-vterm-last-direction nil) (cj/--ai-vterm-last-size nil) - (cj/ai-vterm-window-width 0.5)) - (cl-letf (((symbol-function 'display-buffer-in-direction) + (cj/ai-vterm-desktop-width 0.5)) + (cl-letf (((symbol-function 'env-laptop-p) (lambda () nil)) + ((symbol-function 'display-buffer-in-direction) (lambda (b a) (setq received-buf b received-alist a) 'fake-window))) @@ -39,6 +41,23 @@ which window is selected." (should (= (cdr (assq 'window-width received-alist)) 0.5)) (should (eq (cdr (assq 'inhibit-same-window received-alist)) t)))) +(ert-deftest test-ai-vterm--display-saved-uses-laptop-defaults-when-state-nil () + "Normal: nil state on a laptop -> bottom, size=cj/ai-vterm-laptop-height. +The cardinal `below' default maps to the frame-edge variant `bottom' +and the size lands on the `window-height' axis. `env-laptop-p' is +stubbed t to pin the laptop branch." + (let (received-alist + (cj/--ai-vterm-last-direction nil) + (cj/--ai-vterm-last-size nil) + (cj/ai-vterm-laptop-height 0.75)) + (cl-letf (((symbol-function 'env-laptop-p) (lambda () t)) + ((symbol-function 'display-buffer-in-direction) + (lambda (_b a) (setq received-alist a) 'fake-window))) + (cj/--ai-vterm-display-saved 'fake-buf '((inhibit-same-window . t)))) + (should (eq (cdr (assq 'direction received-alist)) 'bottom)) + (should (= (cdr (assq 'window-height received-alist)) 0.75)) + (should-not (assq 'window-width received-alist)))) + (ert-deftest test-ai-vterm--display-saved-uses-saved-direction-and-size-below () "Normal: saved direction=below maps to bottom edge; size=0.4 passes through." (let (received-alist |
