From 5e1afeaa1fc9504b5991e2b892d6f72318aec26c Mon Sep 17 00:00:00 2001 From: wangxiaojuan Date: Mon, 9 Sep 2024 10:18:53 +0800 Subject: [PATCH] fix: update data reporting parameter (#4000) --- .../widget/inline-chat/inline-chat.handler.ts | 27 +++++++++++-------- .../src/types/ai-native/reporter.ts | 2 ++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/packages/ai-native/src/browser/widget/inline-chat/inline-chat.handler.ts b/packages/ai-native/src/browser/widget/inline-chat/inline-chat.handler.ts index fdbee86589..25e5a060cb 100644 --- a/packages/ai-native/src/browser/widget/inline-chat/inline-chat.handler.ts +++ b/packages/ai-native/src/browser/widget/inline-chat/inline-chat.handler.ts @@ -1,6 +1,5 @@ import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di'; import { AINativeConfigService, IAIInlineChatService, PreferenceService } from '@opensumi/ide-core-browser'; -import { AIActionItem } from '@opensumi/ide-core-browser/lib/components/ai-native/index'; import { AIInlineChatContentWidgetId, AINativeSettingSectionsId, @@ -256,7 +255,10 @@ export class InlineChatHandler extends Disposable { }, execute: handler.execute ? handler.execute!.bind(this, monacoEditor, this.cancelIndicator.token) : undefined, providerPreview: previewer(), - action, + extraData: { + actionSource: source === 'codeAction' ? ActionSourceEnum.CodeAction : ActionSourceEnum.InlineChat, + actionType: action.name, + }, }); }), ); @@ -278,8 +280,7 @@ export class InlineChatHandler extends Disposable { message: value, type: AISerivceType.InlineChatInput, source: 'input', - actionSource: ActionSourceEnum.InlineChat, - actionType: ActionTypeEnum.Send, + actionSource: ActionSourceEnum.InlineChatInput, }); return relationId; }, @@ -291,6 +292,10 @@ export class InlineChatHandler extends Disposable { handler.providePreviewStrategy && strategy === ERunStrategy.PREVIEW ? handler.providePreviewStrategy.bind(this, monacoEditor, value, this.cancelIndicator.token) : undefined, + extraData: { + actionSource: ActionSourceEnum.InlineChatInput, + actionType: strategy, + }, }); }), ); @@ -508,7 +513,6 @@ export class InlineChatHandler extends Disposable { isDrop: false, code: modifyContent, originCode: originContent, - actionSource: ActionSourceEnum.InlineChat, actionType: ActionTypeEnum.Accept, }); runWhenIdle(() => { @@ -522,7 +526,6 @@ export class InlineChatHandler extends Disposable { isReceive: false, code: modifyContent, originCode: originContent, - actionSource: ActionSourceEnum.InlineChat, actionType: ActionTypeEnum.Discard, }); runWhenIdle(() => { @@ -536,7 +539,6 @@ export class InlineChatHandler extends Disposable { isReceive: false, code: modifyContent, originCode: originContent, - actionSource: ActionSourceEnum.InlineChat, actionType: ActionTypeEnum.Regenerate, }); this.handleDiffPreviewStrategy({ @@ -570,9 +572,12 @@ export class InlineChatHandler extends Disposable { reporterFn: () => string; execute?: () => MaybePromise; providerPreview?: () => MaybePromise; - action?: AIActionItem; + extraData?: { + actionSource: string; + actionType: string; + }; }) { - const { monacoEditor, reporterFn, execute, providerPreview, action } = params; + const { monacoEditor, reporterFn, execute, providerPreview, extraData } = params; const selection = monacoEditor.getSelection(); if (!selection) { this.logger.error('No selection found, aborting inline chat action.'); @@ -597,8 +602,8 @@ export class InlineChatHandler extends Disposable { crossSelection, relationId, isRetry: false, - actionSource: ActionSourceEnum.InlineChat, - actionType: action?.name, + actionSource: extraData?.actionSource, + actionType: extraData?.actionType, }); } } diff --git a/packages/core-common/src/types/ai-native/reporter.ts b/packages/core-common/src/types/ai-native/reporter.ts index 12ed7decd1..c48ddaf1f6 100644 --- a/packages/core-common/src/types/ai-native/reporter.ts +++ b/packages/core-common/src/types/ai-native/reporter.ts @@ -18,6 +18,8 @@ export enum ActionSourceEnum { Chat = 'chat', // 编辑器内联 Chat InlineChat = 'inlineChat', + // 编辑器内联 ChatInput + InlineChatInput = 'inlineChatInput', // 编辑器内 Action CodeAction = 'codeAction', // 终端