Skip to content

fix(codecompanion): support editor_context backend for MCP resource vars - #292

Open
mahsank wants to merge 1 commit into
ravitemer:mainfrom
mahsank:fix/codecompanion-v19-make-vars
Open

fix(codecompanion): support editor_context backend for MCP resource vars#292
mahsank wants to merge 1 commit into
ravitemer:mainfrom
mahsank:fix/codecompanion-v19-make-vars

Conversation

@mahsank

@mahsank mahsank commented Jul 3, 2026

Copy link
Copy Markdown

Description

This PR fixes CodeCompanion v19 compatibility for MCP resource variables in mcphub.nvim.

Root cause

mcphub.nvim assumed config.interactions.chat.variables always exists.
On CodeCompanion v19, this table can be missing, which causes a startup crash when make_vars = true (pairs() called on nil).

What this changes

  • Adds runtime backend detection for resource variable registration:
    • config.interactions.chat.variables (legacy backend)
    • config.interactions.shared.editor_context (CodeCompanion v19+ backend)
    • config.interactions.chat.editor_context (fallback)
  • Preserves existing user-facing identifiers and syntax:
    • #{mcp:...}
  • Keeps backward compatibility with older CodeCompanion layouts.

Related Issue(s)

Screenshots

N/A (no UI changes)

Checklist

  • I've read the contributing guidelines and have adhered to them in this PR
  • I've updated the README and/or relevant docs pages (N/A: no documentation source changes)
  • I've run make test to ensure all tests pass (see Notes)
  • I've run make format to format the code (see Notes)
  • I've run make docs to update the vimdoc pages (N/A: no documentation source changes)

Notes

  • make format fails locally in pre-existing/unrelated files (outside this PR), due to parser errors around continue labels.
  • make test fails locally in an unrelated baseline test:
    • tests/native/neovim/files/edit_file/test_edit_ui.lua | reject_all_functionality
    • Can not use child.lua_func because child process is blocked
  • The failure is outside files changed by this PR.
  • The modified file in this PR is:
    • lua/mcphub/extensions/codecompanion/variables.lua

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

Labels

None yet

Projects

None yet

1 participant