From 35cbde39ffd459593589b36318a6bc2962703599 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Wed, 1 Jul 2026 14:02:33 -0400 Subject: fix(eat): guard against a nil charset wedging the terminal EAT 0.9.4's parser accepts more charset-designation final bytes than its store step maps. A designation like ESC ( A (UK) isn't one of the two it handles ("0" and "B"), so it stores nil as that slot's charset. The next character written then fails (cl-assert charset) in eat--t-write. Since writes run off the output-queue timer, it repeats once per output chunk. An agent terminal that emits one of these bytes throws "cl-assertion-failed (charset)" hundreds of times and stops rendering. I added filter-args advice on eat--t-set-charset that coerces a nil charset to us-ascii before it's stored, so an unmapped designation falls back to plain ASCII instead of wedging. Patching the vendored pcase would be cleaner, but a package update reverts it. The advice loads with eat, since the target is an internal function. --- modules/eat-config.el | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'modules') diff --git a/modules/eat-config.el b/modules/eat-config.el index 1de24dc4..d66507c4 100644 --- a/modules/eat-config.el +++ b/modules/eat-config.el @@ -83,6 +83,33 @@ ARGS is (TERMINAL OUTPUT)." (advice-add 'eat-term-process-output :filter-args #'cj/--eat-reset-sgr-at-newline) +;; EAT 0.9.4 charset-designation bug. Its parser (eat--t-handle-output) accepts +;; a wide set of final bytes for an `ESC ( x' charset designation, but the store +;; step (eat--t-set-charset) only maps two of them: "0" -> dec-line-drawing and +;; "B" -> us-ascii. Any other accepted byte (e.g. ESC ( A, the UK set) falls +;; through the `pcase' to nil, and nil gets stored as that slot's charset. The +;; next character written then trips (cl-assert charset) in eat--t-write, and +;; because writes are driven by the eat--process-output-queue timer it errors +;; once per output chunk -- the "cl-assertion-failed (charset) [N times]" storm. +;; We can't patch the vendored pcase without a fork the next package update would +;; revert, so guard the one function that injects the nil: coerce a nil charset +;; to us-ascii (the safe default the byte would have mapped to) before it lands. + +(declare-function eat--t-set-charset "eat") + +(defun cj/--eat-charset-never-nil (args) + "`:filter-args' advice for `eat--t-set-charset'. +ARGS is (SLOT CHARSET). Return it with a nil CHARSET replaced by +`us-ascii', so EAT never stores nil for a charset designation it does +not recognize (which would later trip (cl-assert charset) on write)." + (list (car args) (or (cadr args) 'us-ascii))) + +;; eat--t-set-charset is an internal function defined only once eat.el loads +;; (the package is deferred), so add the advice after load rather than at top +;; level. +(with-eval-after-load 'eat + (advice-add 'eat--t-set-charset :filter-args #'cj/--eat-charset-never-nil)) + ;; ------------------------------- eat package --------------------------------- (use-package eat -- cgit v1.2.3