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--default-geometry.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--default-geometry.el')
| -rw-r--r-- | tests/test-ai-vterm--default-geometry.el | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/test-ai-vterm--default-geometry.el b/tests/test-ai-vterm--default-geometry.el new file mode 100644 index 00000000..f8ec08c9 --- /dev/null +++ b/tests/test-ai-vterm--default-geometry.el @@ -0,0 +1,56 @@ +;;; test-ai-vterm--default-geometry.el --- Tests for host-aware display defaults -*- lexical-binding: t; -*- + +;;; Commentary: +;; ai-vterm's default display geometry is host-aware: a laptop opens the +;; agent from the bottom (75% height), a desktop opens it from the right +;; (50% width). `cj/--ai-vterm-default-direction' and +;; `cj/--ai-vterm-default-size' encapsulate the `env-laptop-p' branch; +;; they feed the default fallbacks in `cj/--ai-vterm-capture-state' and +;; `cj/--ai-vterm-display-saved'. +;; +;; `env-laptop-p' is stubbed per-test so the assertions are deterministic +;; regardless of the host the suite runs on. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'ai-vterm) + +(ert-deftest test-ai-vterm--default-direction-laptop () + "Normal: on a laptop the default direction is `below'." + (cl-letf (((symbol-function 'env-laptop-p) (lambda () t))) + (should (eq (cj/--ai-vterm-default-direction) 'below)))) + +(ert-deftest test-ai-vterm--default-direction-desktop () + "Normal: on a desktop the default direction is `right'." + (cl-letf (((symbol-function 'env-laptop-p) (lambda () nil))) + (should (eq (cj/--ai-vterm-default-direction) 'right)))) + +(ert-deftest test-ai-vterm--default-size-laptop () + "Normal: on a laptop the default size is `cj/ai-vterm-laptop-height'." + (let ((cj/ai-vterm-laptop-height 0.75) + (cj/ai-vterm-desktop-width 0.5)) + (cl-letf (((symbol-function 'env-laptop-p) (lambda () t))) + (should (= (cj/--ai-vterm-default-size) 0.75))))) + +(ert-deftest test-ai-vterm--default-size-desktop () + "Normal: on a desktop the default size is `cj/ai-vterm-desktop-width'." + (let ((cj/ai-vterm-laptop-height 0.75) + (cj/ai-vterm-desktop-width 0.5)) + (cl-letf (((symbol-function 'env-laptop-p) (lambda () nil))) + (should (= (cj/--ai-vterm-default-size) 0.5))))) + +(ert-deftest test-ai-vterm--default-size-respects-custom-values () + "Boundary: the helper returns the customized values, not the literals." + (let ((cj/ai-vterm-laptop-height 0.6) + (cj/ai-vterm-desktop-width 0.33)) + (cl-letf (((symbol-function 'env-laptop-p) (lambda () t))) + (should (= (cj/--ai-vterm-default-size) 0.6))) + (cl-letf (((symbol-function 'env-laptop-p) (lambda () nil))) + (should (= (cj/--ai-vterm-default-size) 0.33))))) + +(provide 'test-ai-vterm--default-geometry) +;;; test-ai-vterm--default-geometry.el ends here |
