-
-
Notifications
You must be signed in to change notification settings - Fork 273
Add Copilot Usage Statistics Feature with gS
as default keymap
#1677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new Copilot usage statistics feature, allowing users to view their Copilot quota usage directly from a centered floating window. Key changes include:
- Added tests to verify correct calculation of usage percentages and proper highlight color selection.
- Enhanced the UI floating window creation to support "center" positioning.
- Introduced a new keymap ("gS") and associated adapter functions to display Copilot usage statistics.
- Updated documentation to reflect the new feature and keymap.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tests/adapters/test_copilot.lua | Added unit tests for verifying Copilot usage and highlight calculations. |
lua/codecompanion/utils/ui.lua | Improved create_float to support centered positioning. |
lua/codecompanion/strategies/chat/keymaps.lua | Added keymap and callback for displaying Copilot stats. |
lua/codecompanion/config.lua | Configured the new keymap and updated callback reference. |
lua/codecompanion/adapters/copilot.lua | Added functions to fetch and present Copilot usage statistics. |
doc/usage/chat-buffer/index.md | Updated keymap documentation to include the new "gS" mapping. |
doc/codecompanion.txt | Updated documentation with new version and keymap details (encoding issues observed). |
doc/codecompanion.txt
Outdated
@@ -1947,7 +1947,7 @@ The fastest way to copy an LLM’s code output is with `gy`. This will yank the | |||
nearest codeblock. | |||
|
|||
|
|||
APPLYING AN LLM’S EDITS TO A BUFFER OR FILE ~ | |||
APPLYING AN LLM�S EDITS TO A BUFFER OR FILE ~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The apostrophe in this line appears to be replaced with a corrupted character sequence. Please ensure that the encoding is corrected to use a standard apostrophe (’).
APPLYING AN LLM��S EDITS TO A BUFFER OR FILE ~ | |
APPLYING AN LLM’S EDITS TO A BUFFER OR FILE ~ |
Copilot uses AI. Check for mistakes.
doc/codecompanion.txt
Outdated
@@ -3139,7 +3140,7 @@ OpenAI adapter. | |||
as a great reference to understand how they’re working with the output of the | |||
API | |||
|
|||
OPENAI’S API OUTPUT | |||
OPENAI�S API OUTPUT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The apostrophe in this line seems to have been corrupted. Please replace the invalid characters with a standard apostrophe (’).
OPENAI��S API OUTPUT | |
OPENAI’S API OUTPUT |
Copilot uses AI. Check for mistakes.
Great, this feature is important, which prompts me that my advanced request has been used 1/3 |
@bassamsdata I pulled your branch and everything seems to be working great! excited for this to get in 👍 |
Ahhh man does this mean we've all reached our Copilot Premium Interactions quotas at the same time 😆?! |
This is yet another absolute killer PR, @bassamsdata! CodeCompanion owes you a lot ❤️ |
Description
This PR adds a feature to display GitHub Copilot usage statistics, similar to what's available in VSCode, JetBrains IDEs, and other editors. Users can now check their quota usage directly within CodeCompanion without switching to other tools or waiting an email from GitHub (when requesting usage data).
Note: Premium interactions quota applies to all models except
gpt-4.1
andgpt-4o
.Usage
Press
gS
in any Copilot chat buffer to display a centered floating window showing:Usage above 80% is highlighted in red (
Error
), below 80% in green (MoreMsg
).Implementation Changes
Existing Code Changes
row="center"
andcol="center"
support tocreate_float()
for window centeringwinborder
option support to respect user's border preferences (inspired by mini.nvim)If this doesn't fit the core, that's completely fine. Happy to maintain it as a separate extension.
However, I feel it’s essential now, especially since they’ve started counting premium requests. :(
Related Issue(s)
This PR is related to the discussion in #1667. Instead of calculating usages locally, it’s better to rely on GitHub for that, as I believe this is essential now, and I haven’t seen any Neovim plugin implement it yet.
Notes:
I’m thinking of adding the Neovim version to the header tomorrow.Also, I believe the reset date should be added now after adding the vscode screenshot.Screenshots
in Vscode:

Checklist
CodeCompanion.has
in the init.lua file for my new featuremake all
to ensure docs are generated, tests pass and my formatting is applied