Skip to content

fix: comply with MCP IDE companion spec for diff tools#3

Open
erikson84 wants to merge 4 commits into
vaijab:masterfrom
erikson84:master
Open

fix: comply with MCP IDE companion spec for diff tools#3
erikson84 wants to merge 4 commits into
vaijab:masterfrom
erikson84:master

Conversation

@erikson84
Copy link
Copy Markdown

  • openDiff: Return empty content on success instead of text message
  • closeDiff: Return file content (from scratch buffer) in TextContent
  • accept_diff: Use scratch buffer content to preserve user edits

These changes ensure proper async notification flow and prevent the agent from receiving stale file state when re-proposing changes.

@erikson84
Copy link
Copy Markdown
Author

Fix diff handling to match MCP spec + preserve user edits

What changed:

  • openDiff: Returns empty content instead of "Diff view opened..." message
  • closeDiff: Now returns the actual file content from the scratch buffer
  • accept_diff: Uses scratch buffer content so user edits in the diff window aren't lost

Why: The agent was getting confused because:

  1. It didn't know the diff was async (non-empty response made it think it was done)
  2. User edits were being ignored
  3. When re-proposing, the agent had stale file state → "blank line at EOF" issue

Result: Diff accepting now works better - agent waits for proper notifications and user edits are preserved!

BTW, thank you very much for your plugin! It's the best I found so far for integrating Gemini CLI with Neovim, with a little help from sidekick.nvim.

- openDiff: Return empty content on success instead of text message
- closeDiff: Return file content (from scratch buffer) in TextContent
- accept_diff: Use scratch buffer content to preserve user edits

These changes ensure proper async notification flow and prevent
the agent from receiving stale file state when re-proposing changes.
Erikson Kaszubowski added 3 commits May 18, 2026 09:29
- Implement stateful LRU (Least Recently Used) manager in Lua
- Use millisecond timestamps for accurate file ordering
- Truncate selected text to 16KB to prevent RPC overhead
- Add robust handling for file renames and deletions
- Document TERM_PROGRAM workaround for CLI detection
- add filereadable check before loading buffers in ensure_buffer
- refine trailing newline handling in accept_diff and close_diff
- simplify accept_diff by delegating buffer updates to RPC
- refactor BufFilePost autocmd callback for brevity
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