1
- import type { CancellationToken , ProgressOptions , Uri } from 'vscode' ;
1
+ import type { CancellationToken , ProgressOptions } from 'vscode' ;
2
2
import { ProgressLocation , window , workspace } from 'vscode' ;
3
3
import type { Source } from '../constants.telemetry' ;
4
4
import type { Container } from '../container' ;
5
5
import type { GitReference } from '../git/models/reference' ;
6
6
import { getChangesForChangelog } from '../git/utils/-webview/log.utils' ;
7
7
import { createRevisionRange , shortenRevision } from '../git/utils/revision.utils' ;
8
8
import { showGenericErrorMessage } from '../messages' ;
9
- import type { AIGenerateChangelogChanges , AIResultContext } from '../plus/ai/aiProviderService' ;
9
+ import type { AIGenerateChangelogChanges } from '../plus/ai/aiProviderService' ;
10
10
import { getAIResultContext } from '../plus/ai/utils/-webview/ai.utils' ;
11
11
import { showComparisonPicker } from '../quickpicks/comparisonPicker' ;
12
12
import { command } from '../system/-webview/command' ;
13
- import { setContext } from '../system/-webview/context' ;
14
- import type { Deferrable } from '../system/function/debounce' ;
15
- import { debounce } from '../system/function/debounce' ;
16
13
import type { Lazy } from '../system/lazy' ;
17
14
import { lazy } from '../system/lazy' ;
18
15
import { Logger } from '../system/logger' ;
@@ -25,36 +22,6 @@ export interface GenerateChangelogCommandArgs {
25
22
source ?: Source ;
26
23
}
27
24
28
- // Storage for AI feedback context associated with changelog documents
29
- const changelogFeedbackContexts = new Map < string , AIResultContext > ( ) ;
30
- export function getChangelogFeedbackContext ( documentUri : string ) : AIResultContext | undefined {
31
- return changelogFeedbackContexts . get ( documentUri ) ;
32
- }
33
- function setChangelogFeedbackContext ( documentUri : string , context : AIResultContext ) : void {
34
- changelogFeedbackContexts . set ( documentUri , context ) ;
35
- }
36
- function clearChangelogFeedbackContext ( documentUri : string ) : void {
37
- changelogFeedbackContexts . delete ( documentUri ) ;
38
- }
39
-
40
- // Storage for changelog document URIs
41
- const changelogUris = new Set < Uri > ( ) ;
42
- let _updateChangelogContextDebounced : Deferrable < ( ) => void > | undefined ;
43
- function updateChangelogContext ( ) : void {
44
- _updateChangelogContextDebounced ??= debounce ( ( ) => {
45
- void setContext ( 'gitlens:tabs:ai:changelog' , [ ...changelogUris ] ) ;
46
- } , 100 ) ;
47
- _updateChangelogContextDebounced ( ) ;
48
- }
49
- function addChangelogUri ( uri : Uri ) : void {
50
- changelogUris . add ( uri ) ;
51
- updateChangelogContext ( ) ;
52
- }
53
- function removeChangelogUri ( uri : Uri ) : void {
54
- changelogUris . delete ( uri ) ;
55
- updateChangelogContext ( ) ;
56
- }
57
-
58
25
@command ( )
59
26
export class GenerateChangelogCommand extends GlCommandBase {
60
27
constructor ( private readonly container : Container ) {
@@ -158,17 +125,7 @@ export async function generateChangelogAndOpenMarkdownDocument(
158
125
const document = await workspace . openTextDocument ( { language : 'markdown' , content : content } ) ;
159
126
if ( feedbackContext ) {
160
127
// Store feedback context for this document
161
- setChangelogFeedbackContext ( document . uri . toString ( ) , feedbackContext ) ;
162
- // Add to changelog URIs context even for no-results documents
163
- addChangelogUri ( document . uri ) ;
164
- // Clean up context when document is closed
165
- const disposable = workspace . onDidCloseTextDocument ( closedDoc => {
166
- if ( closedDoc . uri . toString ( ) === document . uri . toString ( ) ) {
167
- clearChangelogFeedbackContext ( document . uri . toString ( ) ) ;
168
- removeChangelogUri ( document . uri ) ;
169
- disposable . dispose ( ) ;
170
- }
171
- } ) ;
128
+ container . aiFeedback . addChangelogDocument ( document . uri , feedbackContext ) ;
172
129
}
173
130
await window . showTextDocument ( document ) ;
174
131
}
0 commit comments