Skip to content

Avoid pending approval scans during chat redisplay - #307

Open
plux wants to merge 1 commit into
editor-code-assistant:masterfrom
plux:hn/pending-approval-cache
Open

Avoid pending approval scans during chat redisplay#307
plux wants to merge 1 commit into
editor-code-assistant:masterfrom
plux:hn/pending-approval-cache

Conversation

@plux

@plux plux commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

ECA searched the full chat buffer to find pending tool approvals. Emacs ran this
search when it updated the mode line and tab line.

The search became slower as the chat buffer grew. Long chat sessions could
therefore make Emacs slow.

Changes

  • Store pending and completed approvals in buffer-local hash tables.
  • Update the cache when a tool call starts, completes, or is rejected.
  • Restore approval state when ECA loads chat history.
  • Prevent old history from restoring an approval that is already complete.
  • Keep a subagent pending while one of its child approvals is still pending.
  • Send one status update after ECA loads chat history.
  • Publish the final status when a chat fails to open.
  • Keep the existing approval buttons and their text properties.
  • Use the cache for mode-line, tab-line, workspace, Doom, and attention status.

Investigation

A CPU profile showed that the pending approval search used 61.13% of CPU
samples. The ECA mode-line, tab-line, and header-line code used 63.13% of CPU
samples.

I then turned off the ECA chat tab line and custom mode line. The pending
approval search dropped to 3.08% of CPU samples. The related ECA status code
dropped to 0.36%.

These results showed that repeated full-buffer searches caused the slowdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant