Add Copilot preference for a chat's custom instructions loading (from all projects or from referenced projects only)#136
Conversation
7c28fcc to
8c9cc48
Compare
|
Hi @iloveeclipse, |
There was a problem hiding this comment.
Pull request overview
This PR adds a new chat preference to control how project-level Copilot custom instructions are scoped when starting a chat, so Eclipse can avoid loading unrelated projects’ instruction files and reduce the prompt bloat behind issue #62.
Changes:
- Added a persisted
CustomInstructionsChatLoadScopepreference with UI labels/defaults for chat instruction loading. - Derived workspace folders from selected/current resources in
ChatViewand threaded that list into conversation creation. - Added enum/helper tests and
ResourceUtilscoverage for workspace-folder derivation.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/utils/ResourceUtils.java |
Adds helper to derive distinct accessible workspace folders from selected resources. |
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/messages.properties |
Adds user-facing labels for the new chat instruction scope preference. |
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/Messages.java |
Exposes new NLS message keys. |
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/CustomInstructionPreferencePage.java |
Adds the new combo box to the preferences UI and persists the selection. |
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/preferences/CopilotPreferenceInitializer.java |
Sets the default chat instruction scope preference. |
com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/ChatView.java |
Derives scoped workspace folders before creating a new conversation. |
com.microsoft.copilot.eclipse.ui.test/src/com/microsoft/copilot/eclipse/ui/utils/ResourceUtilsTest.java |
Adds tests for workspace-folder derivation behavior. |
com.microsoft.copilot.eclipse.ui.test/META-INF/MANIFEST.MF |
Adds JUnit params dependency for new parameterized tests. |
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageServerConnection.java |
Adds a createConversation overload that accepts scoped workspace folders. |
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/Constants.java |
Defines the new preference key and enum values/default. |
com.microsoft.copilot.eclipse.core.test/src/com/microsoft/copilot/eclipse/core/CustomInstructionsChatLoadScopeTest.java |
Adds enum serialization/deserialization tests. |
Correct. |
f90fdfc to
6728703
Compare
|
Hi @iloveeclipse,
I've adapted the code to retrieve custom instructions from selected files on each conversation turn, i.e. each time a new prompt is sent to the LS. |
cf9a3ce to
66a07f1
Compare
b897069 to
54024bc
Compare
54024bc to
6fd6559
Compare
|
I have no more comments. @iloveeclipse could you help validate with this patch, your project setup will work as expected? |
I hope to get some time next week for that. |
|
@travkin79 Let's wait for the confirmation, thanks. |
FYI @iloveeclipse: the PR #176 might help you setting up the Eclipse projects when you're going to test this PR. |
Thanks, but it would be also helpful if you could rebase your PR on top of master, I see there 3 merge conflicts now. |
|
Sorry we have so many changes recently |
Not your fault, glad to see progress :-). Interestingly, with 0.17 + this patch I don't see Copilot crashing anymore on every chat interaction with all instruction files enabled, just sometimes, with the original setup and both preference enabled for all projects / only in context. I guess context window calculations is changed? What I see, and I believe it is related, that the Copilot reports following token consumption for both cases (same command, same model, new chat started) I've asked
"Projects from context": "All projects": One error I saw (with "all projects" enabled, one in 5 times) was: Not sure how "138937" vs "7413" turn tokens are counted, we have currently 51 projects with 51 identical instruction files, so I would have expected 51x higher consumption, but we see "only" 18x increase. "Completion tokens" counts 38 vs 1795 are closer to the 51x projects. Anyway, it looks like the change works as expected. |
This PR fixes issue #62 according to the comment #62 (comment)
The PR
CopilotLanguageServerConnection), i.e.Preference page preview (new group highlighted):
