Skip to content

Comments

Fix RPC extension UI session reconciliation for editor/newSession flows#127

Open
jorgeavaldez wants to merge 8 commits intodnouri:masterfrom
jorgeavaldez:feat/rpc/support-editor-resolve-session-changes
Open

Fix RPC extension UI session reconciliation for editor/newSession flows#127
jorgeavaldez wants to merge 8 commits intodnouri:masterfrom
jorgeavaldez:feat/rpc/support-editor-resolve-session-changes

Conversation

@jorgeavaldez
Copy link
Contributor

@jorgeavaldez jorgeavaldez commented Feb 18, 2026

Fixes RPC-mode extension UX so extension-driven flows (for example the handoff extension) behave like the pi CLI.

Handoff flow:

  • generate a prompt
  • let user edit it
  • start a new session
  • insert drafted prompt into the main input buffer

There were three gaps affecting extension flows:

  1. missing support for extension_ui_request method editor
  2. no explicit session-switch event when extensions call ctx.newSession()
  3. session reconciliation after editor responses could fail when callbacks ran outside the chat buffer (e.g. temporary editor buffer context)

What changed

  • Added full extension_ui_request editor support:

    • temporary editor replaces the existing input area (same window)
    • C-c C-c submit, C-c C-k cancel
    • restores previous buffer and cleans up temporary editor buffer on completion
  • Fixed unsupported extension UI responses to always echo the original request :id (for correct RPC correlation).

  • Added extension session reconciliation after extension-driven UI actions:

    • run get_state, compare previous/current session identity (session-file, fallback session-id)
    • if changed, reload get_messages history and update usage/header
    • otherwise refresh state/header only
  • Expanded reconciliation triggers:

    • after sending extension UI responses (confirm / select / input / editor)
    • after set_editor_text
    • agent_end fallback sync for hook/tool-driven session changes
  • Added handling for editor callbacks from non-chat buffers:

    • pi-coding-agent--extension-ui-send-response now accepts optional chat-buf
    • pi-coding-agent--extension-ui-sync-session-state now accepts optional proc/chat-buf
    • editor submit/cancel captures originating chat buffer and passes it through, so reconciliation runs against the correct session even when callback execution context is the temporary editor buffer

Validation

Added/updated unit tests for:

  • editor submit/cancel behavior
  • unsupported-method response correlation
  • session sync changed vs unchanged paths after set_editor_text
  • agent_end fallback sync
  • extension UI response paths triggering sync
  • editor submit sync when callback runs outside chat buffer
  • handoff-style flow simulation: editor submit → new session state reconcile → set_editor_text

Render test suite passes when run against the local checkout.

Disclaimer: This pull request was put together with assistance from an LLM. I reviewed and revised it to the best of my abilities, and I do believe I have a solid understanding of how it works and why this is a good fix 😄

@jorgeavaldez jorgeavaldez force-pushed the feat/rpc/support-editor-resolve-session-changes branch from 55001f1 to 7a2cf41 Compare February 18, 2026 20:27
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