Skip to content

Commit 7805b16

Browse files
committed
respect eca-chat-window-side for non-side-window chat display
1 parent 42322cc commit 7805b16

3 files changed

Lines changed: 49 additions & 33 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Changelog
22

33
## Unreleased
4-
4+
- Respect `eca-chat-window-side` (and width/height) even when `eca-chat-use-side-window` is nil, displaying the chat on that side via `display-buffer-in-direction`. To avoid overlapping/duplicate windows, placement now reuses the window already showing the chat, otherwise replaces another visible chat window in place (new-tab behavior), and only opens a new window when there is nothing to reuse.
55
- Add a context-usage bar in the chat mode-line, left of the token usage, showing how full the model context window is, colored by category (system prompt, rules, skills, AGENTS.md, tool definitions, tool calls, conversation, free space), each a distinct color. In graphical frames it renders pixel-width thin segments for high granularity (small percentages stay visible); terminals fall back to block characters. Same footprint either way (`eca-chat-context-bar-width`). Colors come from the server (canonical `color`/`freeColor`) so they are consistent; hover the bar for a legend that maps each category to its server emoji swatch (`emoji`/`freeEmoji`, matching the `/context` command output), or click to run the new `/context` command. Configurable via `eca-chat-context-bar-width` and the `:context-bar` module in `eca-chat-mode-line-format`. Needs an eca server that sends `contextBreakdown` in `usage` content.
66
- Auto-dismiss a pending `ask_user` question when another client (e.g. an SSE/web client in remote mode, see eca 0.139.0) answers it first. The server resolves the `ask_user` tool out from under us and sends a `toolCalled`/`toolCallRejected` for that tool-call id but no longer expects our answer (it cancels our request); we now correlate that id with `eca-chat--pending-question` and clear the stale answer-mode prompt state instead of staying stuck waiting for input.
77
- Paginate long chats instead of replaying the full history on open. With `eca-chat-history-page-size` non-nil (default 50), `eca-chat-resume` opens a chat with only the newest page and shows a clickable "Load older messages" control at the top to page through earlier history on demand via the new `chat/history` request (also bound to `C-c C-S-o`). Older pages are prepended above the existing content, reusing the streaming renderer (subagent nesting included) and kept read-only like the rest of the history. Set `eca-chat-history-page-size` to nil to keep the previous full-replay behavior.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,10 @@ Chat
133133
- `eca-chat-parent-mode`: Set major-mode of chat parent, can be `markdown-mode`, `markdown-view-mode` or `gfm-view-mode` (default)
134134
- `eca-chat-mode-hook`: Hooks to run after entering `eca-chat-mode`.
135135
- `eca-chat-finished-hook`: Hooks to run after finishing a chat prompt.
136-
- `eca-chat-use-side-window`: Whether the chat buffer is displayed in a side window or a normal window.
137-
- `eca-chat-window-side`: On which side (`left`, `right`, `top`, `bottom`) the chat side window appears.
138-
- `eca-chat-window-width`: Width of the chat side window when on the left or right.
139-
- `eca-chat-window-height`: Height of the chat side window when on the top or bottom.
136+
- `eca-chat-use-side-window`: Whether the chat buffer is displayed in a dedicated side window or a normal window. Either way it is placed on `eca-chat-window-side`.
137+
- `eca-chat-window-side`: On which side (`left`, `right`, `top`, `bottom`) the chat window appears (respected for both side and normal windows).
138+
- `eca-chat-window-width`: Width of the chat window when on the left or right.
139+
- `eca-chat-window-height`: Height of the chat window when on the top or bottom.
140140
- `eca-chat-focus-on-open`: Whether to focus the chat window when it opens.
141141
- `eca-chat-auto-add-repomap`: Whether to automatically include repoMap context when opening ECA.
142142
- `eca-chat-auto-add-cursor`: Whether to automatically track the cursor position and add it as context.

eca-chat.el

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ For when chat went back to idle state."
4848

4949
(defcustom eca-chat-window-side 'right
5050
"Side of the frame where the ECA chat window should appear.
51-
Can be `'left', `'right', `'top', or `'bottom'. This setting will only
52-
be used when `eca-chat-use-side-window' is non-nil."
51+
Can be `'left', `'right', `'top', or `'bottom'. This setting is respected
52+
both when `eca-chat-use-side-window' is non-nil (dedicated side window)
53+
and when it is nil (regular window displayed in the corresponding
54+
direction)."
5355
:type '(choice (const :tag "Left" left)
5456
(const :tag "Right" right)
5557
(const :tag "Top" top)
@@ -67,11 +69,13 @@ be used when `eca-chat-use-side-window' is non-nil."
6769
:group 'eca)
6870

6971
(defcustom eca-chat-use-side-window t
70-
"Whether to display ECA chat in a side window.
72+
"Whether to display ECA chat in a dedicated side window.
7173
When non-nil (default), ECA chat opens in a dedicated side window
7274
controlled by `eca-chat-window-side' and related settings. When nil,
73-
ECA chat opens in a regular buffer that follows standard
74-
`display-buffer' behavior."
75+
ECA chat opens in a regular window, still placed on the side given by
76+
`eca-chat-window-side' with the corresponding width/height, but without
77+
the side-window restrictions (so it can be split or replaced like any
78+
other window)."
7579
:type 'boolean
7680
:group 'eca)
7781

@@ -2522,30 +2526,42 @@ are in progress."
25222526
(select-window (get-buffer-window (buffer-name))))
25232527

25242528
(defun eca-chat--display-buffer (buffer)
2525-
"Display BUFFER in a side window according to customization.
2526-
The window is displayed on the side specified by
2527-
`eca-chat-window-side' with dimensions from
2528-
`eca-chat-window-width' or `eca-chat-window-height'.
2529+
"Display BUFFER according to customization.
2530+
BUFFER is displayed on the side given by `eca-chat-window-side'
2531+
with the size from `eca-chat-window-width' or
2532+
`eca-chat-window-height'. When `eca-chat-use-side-window' is
2533+
non-nil a dedicated side window is used, otherwise a regular
2534+
window in the same direction.
25292535
If `eca-chat-focus-on-open' is non-nil, the window is selected."
2530-
(let ((window
2531-
(if eca-chat-use-side-window
2532-
;; Use side window
2533-
(let* ((side eca-chat-window-side)
2534-
(slot 0)
2535-
(window-parameters '((no-delete-other-windows . t)))
2536-
(display-action
2537-
`((display-buffer-in-side-window)
2538-
(side . ,side)
2539-
(slot . ,slot)
2540-
(dedicated . side)
2541-
,@(when (memq side '(left right))
2542-
`((window-width . ,eca-chat-window-width)))
2543-
,@(when (memq side '(top bottom))
2544-
`((window-height . ,eca-chat-window-height)))
2545-
(window-parameters . ,window-parameters))))
2546-
(display-buffer buffer display-action))
2547-
;; Use regular buffer
2548-
(display-buffer buffer))))
2536+
(let* ((side eca-chat-window-side)
2537+
(size (if (memq side '(left right))
2538+
`((window-width . ,eca-chat-window-width))
2539+
`((window-height . ,eca-chat-window-height))))
2540+
(display-action
2541+
(if eca-chat-use-side-window
2542+
;; Dedicated side window.
2543+
`((display-buffer-in-side-window)
2544+
(side . ,side)
2545+
(slot . 0)
2546+
(dedicated . side)
2547+
,@size
2548+
(window-parameters . ((no-delete-other-windows . t))))
2549+
;; Regular window in the same direction.
2550+
`((display-buffer-in-direction)
2551+
(direction . ,(pcase side ('top 'above) ('bottom 'below) (_ side)))
2552+
,@size)))
2553+
(window
2554+
(or
2555+
;; Already visible: keep it where it is.
2556+
(get-buffer-window buffer)
2557+
;; Another chat is visible: replace it (new-tab behavior).
2558+
(when-let* ((win (get-window-with-predicate
2559+
(lambda (w)
2560+
(buffer-local-value 'eca-chat--id (window-buffer w))))))
2561+
(set-window-buffer win buffer)
2562+
win)
2563+
;; Nothing to reuse: open a new window.
2564+
(display-buffer buffer display-action))))
25492565
;; Select the window to give it focus if configured to do so
25502566
(when (and window eca-chat-focus-on-open)
25512567
(select-window window))

0 commit comments

Comments
 (0)