Skip to content

Commit

Permalink
fix: update data reporting parameter (#4000)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangxiaojuan authored Sep 9, 2024
1 parent cdd361c commit 5e1afea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
},
});
}),
);
Expand All @@ -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;
},
Expand All @@ -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,
},
});
}),
);
Expand Down Expand Up @@ -508,7 +513,6 @@ export class InlineChatHandler extends Disposable {
isDrop: false,
code: modifyContent,
originCode: originContent,
actionSource: ActionSourceEnum.InlineChat,
actionType: ActionTypeEnum.Accept,
});
runWhenIdle(() => {
Expand All @@ -522,7 +526,6 @@ export class InlineChatHandler extends Disposable {
isReceive: false,
code: modifyContent,
originCode: originContent,
actionSource: ActionSourceEnum.InlineChat,
actionType: ActionTypeEnum.Discard,
});
runWhenIdle(() => {
Expand All @@ -536,7 +539,6 @@ export class InlineChatHandler extends Disposable {
isReceive: false,
code: modifyContent,
originCode: originContent,
actionSource: ActionSourceEnum.InlineChat,
actionType: ActionTypeEnum.Regenerate,
});
this.handleDiffPreviewStrategy({
Expand Down Expand Up @@ -570,9 +572,12 @@ export class InlineChatHandler extends Disposable {
reporterFn: () => string;
execute?: () => MaybePromise<void>;
providerPreview?: () => MaybePromise<ChatResponse | InlineChatController>;
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.');
Expand All @@ -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,
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/core-common/src/types/ai-native/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export enum ActionSourceEnum {
Chat = 'chat',
// 编辑器内联 Chat
InlineChat = 'inlineChat',
// 编辑器内联 ChatInput
InlineChatInput = 'inlineChatInput',
// 编辑器内 Action
CodeAction = 'codeAction',
// 终端
Expand Down

0 comments on commit 5e1afea

Please sign in to comment.