Fix visible non-workspace editor context for chat#323
Open
mralonsocorona wants to merge 2 commits into
Open
Conversation
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves current-editor chat context handling for visible Eclipse text editors that expose an IDocument but are not backed by a workspace IFile (e.g., JDT class-file/source-attachment editors). It does so by introducing an internal, read-only copilot-visible-editor://... URI for the current visible editor and enabling workspace/readFile to resolve that URI via the referenced-file service when the normal workspace file read returns “file not found”.
Changes:
- Extend
IReferencedFileServicewith optional methods to expose a non-workspace current-editor URI and to read that editor’s snapshot text. - Add visible-editor snapshot tracking in the UI referenced-file service and generate stable internal URIs for it.
- Update
workspace/readFileto fall back to the visible-editor snapshot only whenFileUtils.readFileWithStats(...)yields the existing “file not found: ” result, with new unit tests covering the fallback behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| com.microsoft.copilot.eclipse.ui/src/com/microsoft/copilot/eclipse/ui/chat/services/ReferencedFileService.java | Tracks a read-only snapshot + internal URI for non-IFile visible text editors and serves snapshot reads via IReferencedFileService. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageClient.java | Uses the new current-editor URI fallback for conversation context and adds workspace/readFile fallback to the visible-editor snapshot on “file not found”. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/chat/service/IReferencedFileService.java | Adds default methods for current-editor URI exposure and snapshot reads (non-breaking for other implementations). |
| com.microsoft.copilot.eclipse.core.test/src/com/microsoft/copilot/eclipse/core/lsp/CopilotLanguageClientTests.java | Adds tests for current-editor URI resolution and readFile fallback behavior. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes current-editor chat context for visible Eclipse text editors that expose an
IDocumentbut are not backed by a workspaceIFile, such as JDT class-file/source-attachment editors.The existing workspace
IFilepath remains unchanged. When no workspace file is available, the active visible editor document is exposed through a read-only internalcopilot-visible-editor://...URI, andworkspace/readFilecan resolve that URI through the referenced-file service.Fixes #117.
Details
IFilecurrent-editor context as the first-priority path.IReferencedFileService.IFiletext editors.FileUtils.readFileWithStats(...)as the primaryworkspace/readFilepath.file not found: <uri>result.Validation
git diff --check./mvnw checkstyle:check./mvnw test