@@ -29,10 +29,10 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c
29
29
import { IDialogService } from 'vs/platform/dialogs/common/dialogs' ;
30
30
import { IInstantiationService , ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
31
31
import { ILogService } from 'vs/platform/log/common/log' ;
32
- import { EditResponse , EmptyResponse , ErrorResponse , IInteractiveEditorSessionService , MarkdownResponse , MarkdownResponseCropState , Session , SessionExchange } from 'vs/workbench/contrib/interactiveEditor/browser/interactiveEditorSession' ;
32
+ import { EditResponse , EmptyResponse , ErrorResponse , IInteractiveEditorSessionService , MarkdownResponse , Session , SessionExchange } from 'vs/workbench/contrib/interactiveEditor/browser/interactiveEditorSession' ;
33
33
import { EditModeStrategy , LivePreviewStrategy , LiveStrategy , PreviewStrategy } from 'vs/workbench/contrib/interactiveEditor/browser/interactiveEditorStrategies' ;
34
34
import { InteractiveEditorZoneWidget } from 'vs/workbench/contrib/interactiveEditor/browser/interactiveEditorWidget' ;
35
- import { CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST , CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK , IInteractiveEditorRequest , IInteractiveEditorResponse , INTERACTIVE_EDITOR_ID , EditMode , InteractiveEditorResponseFeedbackKind , CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE , InteractiveEditorResponseType , CTX_INTERACTIVE_EDITOR_DID_EDIT , CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor' ;
35
+ import { CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST , CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK , IInteractiveEditorRequest , IInteractiveEditorResponse , INTERACTIVE_EDITOR_ID , EditMode , InteractiveEditorResponseFeedbackKind , CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE , InteractiveEditorResponseType , CTX_INTERACTIVE_EDITOR_DID_EDIT } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor' ;
36
36
import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat' ;
37
37
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService' ;
38
38
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/services/notebookEditorService' ;
@@ -85,7 +85,6 @@ export class InteractiveEditorController implements IEditorContribution {
85
85
private readonly _store = new DisposableStore ( ) ;
86
86
private readonly _zone : InteractiveEditorZoneWidget ;
87
87
private readonly _ctxHasActiveRequest : IContextKey < boolean > ;
88
- private readonly _ctxMessageCropState : IContextKey < 'cropped' | 'not_cropped' | 'expanded' > ;
89
88
private readonly _ctxLastResponseType : IContextKey < undefined | InteractiveEditorResponseType > ;
90
89
private readonly _ctxDidEdit : IContextKey < boolean > ;
91
90
private readonly _ctxLastFeedbackKind : IContextKey < 'helpful' | 'unhelpful' | '' > ;
@@ -111,7 +110,6 @@ export class InteractiveEditorController implements IEditorContribution {
111
110
@IAccessibilityService private readonly _accessibilityService : IAccessibilityService ,
112
111
@IKeybindingService private readonly _keybindingService : IKeybindingService ,
113
112
) {
114
- this . _ctxMessageCropState = CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE . bindTo ( contextKeyService ) ;
115
113
this . _ctxHasActiveRequest = CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST . bindTo ( contextKeyService ) ;
116
114
this . _ctxDidEdit = CTX_INTERACTIVE_EDITOR_DID_EDIT . bindTo ( contextKeyService ) ;
117
115
this . _ctxLastResponseType = CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE . bindTo ( contextKeyService ) ;
@@ -473,7 +471,7 @@ export class InteractiveEditorController implements IEditorContribution {
473
471
const { response } = this . _activeSession . lastExchange ! ;
474
472
if ( response instanceof EditResponse ) {
475
473
// edit response -> complex...
476
- this . updateMarkdownMessage ( undefined ) ;
474
+ this . _zone . widget . updateMarkdownMessage ( undefined ) ;
477
475
478
476
const canContinue = this . _strategy . checkChanges ( response ) ;
479
477
if ( ! canContinue ) {
@@ -524,13 +522,15 @@ export class InteractiveEditorController implements IEditorContribution {
524
522
525
523
} else if ( response instanceof MarkdownResponse ) {
526
524
// clear status, show MD message
525
+ const renderedMarkdown = renderMarkdown ( response . raw . message , { inline : true } ) ;
527
526
this . _zone . widget . updateStatus ( '' ) ;
528
- this . updateMarkdownMessage ( response ) ;
527
+ this . _zone . widget . updateMarkdownMessage ( renderedMarkdown . element ) ;
529
528
this . _zone . widget . updateToolbar ( true ) ;
529
+ this . _zone . widget . updateMarkdownMessageExpansionState ( this . _activeSession . lastExpansionState ) ;
530
530
531
531
} else if ( response instanceof EditResponse ) {
532
532
// edit response -> complex...
533
- this . updateMarkdownMessage ( undefined ) ;
533
+ this . _zone . widget . updateMarkdownMessage ( undefined ) ;
534
534
this . _zone . widget . updateToolbar ( true ) ;
535
535
536
536
const canContinue = this . _strategy . checkChanges ( response ) ;
@@ -579,22 +579,6 @@ export class InteractiveEditorController implements IEditorContribution {
579
579
580
580
// ---- controller API
581
581
582
- updateMarkdownMessage ( response : MarkdownResponse | undefined ) : void {
583
- if ( response ) {
584
- const renderedMarkdown = renderMarkdown ( response . raw . message , { inline : true } ) ;
585
- this . _zone . widget . updateMarkdownMessage ( renderedMarkdown . element ) ;
586
- let cropState = response . cropState ;
587
- if ( ! cropState ) {
588
- cropState = this . _zone . widget . isMarkdownMessageOverflowing ( ) ? MarkdownResponseCropState . CROPPED : MarkdownResponseCropState . NOT_CROPPED ;
589
- }
590
- this . _ctxMessageCropState . set ( cropState ) ;
591
- response . cropState = cropState ;
592
- this . _zone . widget . updateToggleState ( cropState === MarkdownResponseCropState . EXPANDED ) ;
593
- } else {
594
- this . _zone . widget . updateMarkdownMessage ( undefined ) ;
595
- this . _ctxMessageCropState . reset ( ) ;
596
- }
597
- }
598
582
accept ( ) : void {
599
583
this . _messages . fire ( Message . ACCEPT_INPUT ) ;
600
584
}
@@ -642,12 +626,9 @@ export class InteractiveEditorController implements IEditorContribution {
642
626
}
643
627
644
628
updateExpansionState ( expand : boolean ) {
645
- const response = this . _activeSession ?. lastExchange ! . response ;
646
- if ( response instanceof MarkdownResponse ) {
647
- const cropState = expand ? MarkdownResponseCropState . EXPANDED : MarkdownResponseCropState . CROPPED ;
648
- response . cropState = cropState ;
649
- this . _ctxMessageCropState . set ( cropState ) ;
650
- this . _zone . widget . updateToggleState ( expand ) ;
629
+ if ( this . _activeSession ) {
630
+ this . _zone . widget . updateMarkdownMessageExpansionState ( expand ) ;
631
+ this . _activeSession . lastExpansionState = expand ;
651
632
}
652
633
}
653
634
0 commit comments