Skip to content

Commit

Permalink
track notebook for auto-edits (#6449)
Browse files Browse the repository at this point in the history
The PR adds the support for the notebook in the `auto-edits`.
1. By default each cell is treated as a separate document, hence we get
limited context for the current file. We add the content for the full
file.
2. All the context sources used to ignore the notebooks. Now, all
following the context sources tracks the support for notebooks and
context is persisted between `py` and `ipynb`:
 - Recent Edits
 - Diagnostics
 - Recent View Port 

## Test plan
existing CI and Manual testing to check behaviour in case of notebook

---------

Co-authored-by: Valery Bugakov <[email protected]>
  • Loading branch information
hitesh-1997 and valerybugakov authored Dec 27, 2024
1 parent d6919f2 commit 1afb0e9
Show file tree
Hide file tree
Showing 24 changed files with 813 additions and 112 deletions.
16 changes: 12 additions & 4 deletions lib/shared/src/completions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ interface AutocompleteContextSnippetMetadata {
retrieverMetadata?: AutocompleteContextSnippetMetadataFields
}

export interface AutocompleteFileContextSnippet {
export interface AutocompleteBaseContextSnippet {
type: 'base'
identifier: string
uri: URI
startLine: number
endLine: number
content: string
/**
* Metadata populated by the context retriever.
Expand All @@ -30,12 +29,21 @@ export interface AutocompleteFileContextSnippet {
metadata?: AutocompleteContextSnippetMetadata
}

export interface AutocompleteSymbolContextSnippet extends AutocompleteFileContextSnippet {
export interface AutocompleteFileContextSnippet extends Omit<AutocompleteBaseContextSnippet, 'type'> {
type: 'file'
startLine: number
endLine: number
}

export interface AutocompleteSymbolContextSnippet extends Omit<AutocompleteFileContextSnippet, 'type'> {
type: 'symbol'
symbol: string
}

export type AutocompleteContextSnippet =
| AutocompleteFileContextSnippet
| AutocompleteSymbolContextSnippet
| AutocompleteBaseContextSnippet

export interface DocumentContext extends DocumentDependentContext, LinesContext {
position: vscode.Position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('DefaultUserPromptStrategy', () => {
identifier: string,
filePath = 'foo.ts'
): AutocompleteContextSnippet => ({
type: 'file',
content,
identifier,
uri: testFileUri(filePath),
Expand Down
Loading

0 comments on commit 1afb0e9

Please sign in to comment.