Skip to content

fix: Capture chat buffer in new-session callback#36

Merged
dnouri merged 1 commit intomasterfrom
fix/new-session-async-callback
Jan 7, 2026
Merged

fix: Capture chat buffer in new-session callback#36
dnouri merged 1 commit intomasterfrom
fix/new-session-async-callback

Conversation

@dnouri
Copy link
Owner

@dnouri dnouri commented Jan 7, 2026

The async callback in pi-coding-agent-new-session relied on current buffer context to find the chat buffer, but async callbacks run in arbitrary buffer contexts.

This caused pi-coding-agent--clear-chat-buffer to silently do nothing when the callback was executed in a non-pi buffer.

Fix: Capture chat-buf before the async call and use with-current-buffer in the callback, consistent with other commands like pi-coding-agent-cycle-thinking.

Also add buffer-live-p check to handle case where buffer is killed while waiting for RPC response.

The async callback in pi-coding-agent-new-session relied on
current buffer context to find the chat buffer, but async
callbacks run in arbitrary buffer contexts.

This caused pi-coding-agent--clear-chat-buffer to silently do
nothing when the callback was executed in a non-pi buffer.

Fix: Capture chat-buf before the async call and use
with-current-buffer in the callback, consistent with other
commands like pi-coding-agent-cycle-thinking.

Also add buffer-live-p check to handle case where buffer is
killed while waiting for RPC response.
@dnouri dnouri merged commit 1aa6da3 into master Jan 7, 2026
6 of 7 checks passed
@dnouri dnouri deleted the fix/new-session-async-callback branch January 7, 2026 13:15
dnouri added a commit that referenced this pull request Feb 25, 2026
The async callback in pi-coding-agent-new-session relied on
current buffer context to find the chat buffer, but async
callbacks run in arbitrary buffer contexts.

This caused pi-coding-agent--clear-chat-buffer to silently do
nothing when the callback was executed in a non-pi buffer.

Fix: Capture chat-buf before the async call and use
with-current-buffer in the callback, consistent with other
commands like pi-coding-agent-cycle-thinking.

Also add buffer-live-p check to handle case where buffer is
killed while waiting for RPC response.
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