aboutsummaryrefslogtreecommitdiff
path: root/tests/test-ai-term--default-geometry.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-20 02:46:52 -0400
committerCraig Jennings <c@cjennings.net>2026-06-20 02:46:52 -0400
commit7e8f771408b7051066fb91fa9c68e80fa52405f7 (patch)
tree367b7209af1c725dbfdf11b321ee6948fa4ac096 /tests/test-ai-term--default-geometry.el
parent63eff9be3bdb86239ba8d3d5aa916ad08967b238 (diff)
downloaddotemacs-7e8f771408b7051066fb91fa9c68e80fa52405f7.tar.gz
dotemacs-7e8f771408b7051066fb91fa9c68e80fa52405f7.zip
feat(windows): dock companion panels by a shared min-column rule
The F9 agent always docked as a right-side column on a landscape frame. On this 138-column frame that left ~68-column panes, too cramped to read code and the agent side by side. The F12 terminal and F10 playlist hardcoded a bottom split with no width-aware path. I added cj/preferred-dock-direction and the cj/window-dock-min-columns defcustom (default 80) to the window-geometry lib: dock side-by-side only when the narrower pane keeps at least the minimum width, otherwise stack below. All three toggles now route through it. F9 drops its pixel-aspect rule. F12 and F10 gain a right-column width default and become adaptive. F10 keeps width and height size memory in separate vars so a resize on one axis doesn't leak to the other.
Diffstat (limited to 'tests/test-ai-term--default-geometry.el')
-rw-r--r--tests/test-ai-term--default-geometry.el53
1 files changed, 32 insertions, 21 deletions
diff --git a/tests/test-ai-term--default-geometry.el b/tests/test-ai-term--default-geometry.el
index 91013862d..1180c1979 100644
--- a/tests/test-ai-term--default-geometry.el
+++ b/tests/test-ai-term--default-geometry.el
@@ -1,18 +1,20 @@
;;; test-ai-term--default-geometry.el --- Tests for host-aware display defaults -*- lexical-binding: t; -*-
;;; Commentary:
-;; ai-term's default display geometry is chosen from the frame's pixel aspect
-;; ratio: a landscape frame docks the agent from the right (a width fraction), a
-;; square or portrait frame docks it from the bottom (a height fraction).
-;; `cj/--ai-term-direction-for-aspect' is the pure decision;
-;; `cj/--ai-term-default-direction' reads the frame and delegates to it;
-;; `cj/--ai-term-default-size' pairs the size fraction with that direction.
-;; They feed the default fallbacks in `cj/--ai-term-capture-state' and
-;; `cj/--ai-term-display-saved'.
+;; ai-term's default display geometry is chosen from the frame's column
+;; width: the agent docks from the right (a width fraction) only when a
+;; side-by-side split would leave both panes at least
+;; `cj/window-dock-min-columns' wide, otherwise from the bottom (a height
+;; fraction). `cj/--ai-term-default-direction' reads the frame width and
+;; delegates the decision to `cj/preferred-dock-direction' (tested in
+;; test-cj-window-geometry-lib.el); `cj/--ai-term-default-size' pairs the
+;; size fraction with that direction. They feed the default fallbacks in
+;; `cj/--ai-term-capture-state' and `cj/--ai-term-display-saved'.
;;
-;; The direction is tested on the pure helper (no frame mocking, which would
-;; trip the native-comp trampoline trap on the frame-pixel-* subrs); the size
-;; helper is tested by stubbing the direction defun.
+;; The direction is tested by stubbing `cj/preferred-dock-direction' (an
+;; ordinary defun -- safe to `cl-letf', unlike the frame-* subrs, which
+;; would trip the native-comp trampoline trap); the size helper is tested
+;; by stubbing the direction defun.
;;; Code:
@@ -22,17 +24,26 @@
(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
(require 'ai-term)
-(ert-deftest test-ai-term--direction-for-aspect-landscape-is-right ()
- "Normal: a wider-than-tall frame docks from the right."
- (should (eq (cj/--ai-term-direction-for-aspect 1920 1080) 'right)))
+(ert-deftest test-ai-term--default-direction-delegates-to-dock-rule ()
+ "Normal: default-direction passes the desktop-width fraction to the dock rule
+and returns its verdict."
+ (let ((cj/ai-term-desktop-width 0.5)
+ captured)
+ (cl-letf (((symbol-function 'cj/preferred-dock-direction)
+ (lambda (cols frac &rest _)
+ (setq captured (list cols frac))
+ 'below)))
+ (should (eq (cj/--ai-term-default-direction) 'below))
+ ;; the fraction passed is the agent's desktop-width
+ (should (= (nth 1 captured) 0.5))
+ ;; the first argument is a column count (the frame width)
+ (should (integerp (nth 0 captured))))))
-(ert-deftest test-ai-term--direction-for-aspect-portrait-is-below ()
- "Normal: a taller-than-wide frame docks from the bottom."
- (should (eq (cj/--ai-term-direction-for-aspect 1080 1920) 'below)))
-
-(ert-deftest test-ai-term--direction-for-aspect-square-is-below ()
- "Boundary: a square frame docks from the bottom (the conserving tie-break)."
- (should (eq (cj/--ai-term-direction-for-aspect 1000 1000) 'below)))
+(ert-deftest test-ai-term--default-direction-returns-right-when-rule-says ()
+ "Normal: when the dock rule returns `right', so does default-direction."
+ (cl-letf (((symbol-function 'cj/preferred-dock-direction)
+ (lambda (&rest _) 'right)))
+ (should (eq (cj/--ai-term-default-direction) 'right))))
(ert-deftest test-ai-term--default-size-pairs-width-with-right ()
"Normal: when the direction is `right' the size is the width fraction."