From 60f14d2c1aa5074f23ec5bccfa0d233ec6730bdb Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 15 Jun 2026 21:54:55 -0500 Subject: feat(ai-term): dock the agent window by frame aspect ratio The agent window now docks from whichever edge conserves more space, chosen at display time: right on a landscape frame, bottom on a square or portrait one, replacing the host (laptop/desktop) branch. cj/--ai-term-direction-for-aspect is the pure decision; default-size pairs the width or height fraction with it. --- modules/ai-term.el | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'modules') diff --git a/modules/ai-term.el b/modules/ai-term.el index baf752fe7..49d44d25e 100644 --- a/modules/ai-term.el +++ b/modules/ai-term.el @@ -391,22 +391,30 @@ fallback when `cj/--ai-term-last-size' is nil." :type 'number :group 'ai-term) -(defun cj/--ai-term-default-direction () - "Return the host-appropriate default split direction for the agent window. - -`below' on a laptop (bottom horizontal split), `right' on a desktop -(right-side vertical split). Detected via `env-laptop-p'." - (if (env-laptop-p) 'below 'right)) +(defun cj/--ai-term-direction-for-aspect (pixel-width pixel-height) + "Return the space-conserving dock direction for a frame of PIXEL-WIDTH by +PIXEL-HEIGHT. `right' when the frame is wider than tall (dock from the right +edge), `below' when it is square or taller (dock from the bottom)." + (if (> pixel-width pixel-height) 'right 'below)) + +(defun cj/--ai-term-default-direction (&optional frame) + "Return the default split direction for the agent window. + +Chosen at display time from FRAME's pixel aspect ratio (FRAME defaults to the +selected frame): `right' on a landscape frame, `below' on a square or portrait +one -- whichever edge conserves more screen space." + (let ((frame (or frame (selected-frame)))) + (cj/--ai-term-direction-for-aspect (frame-pixel-width frame) + (frame-pixel-height frame)))) (defun cj/--ai-term-default-size () - "Return the host-appropriate default size fraction for the agent window. - -`cj/ai-term-laptop-height' on a laptop, `cj/ai-term-desktop-width' -on a desktop -- pairing with the axis chosen by -`cj/--ai-term-default-direction'." - (if (env-laptop-p) - cj/ai-term-laptop-height - cj/ai-term-desktop-width)) + "Return the default size fraction paired with the chosen direction. + +`cj/ai-term-desktop-width' (a width fraction) when the default direction is +`right', `cj/ai-term-laptop-height' (a height fraction) when it is `below'." + (if (eq (cj/--ai-term-default-direction) 'right) + cj/ai-term-desktop-width + cj/ai-term-laptop-height)) (defvar cj/--ai-term-last-direction nil "Last user-chosen direction for the AI-term display. -- cgit v1.2.3