Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lightspeed/schema1: rename InlineSuggestion for consistency #1408

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/features/lightspeed/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ export class LightSpeedAPI {
lightSpeedManager.settingsManager.settings.lightSpeedService.model;

if (rhUserHasSeat && orgOptOutTelemetry) {
if (inputData.inlineSuggestion) {
delete inputData.inlineSuggestion;
if (inputData.inlineSuggestionFeedback) {
delete inputData.inlineSuggestionFeedback;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/features/lightspeed/inlineSuggestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { getCurrentUTCDateTime } from "../utils/dateTime";
import { lightSpeedManager } from "../../extension";
import {
CompletionResponseParams,
InlineSuggestionEvent,
InlineSuggestionFeedbackEvent,
CompletionRequestParams,
} from "../../interfaces/lightspeed";
import {
Expand All @@ -31,7 +31,7 @@ import { LightSpeedServiceSettings } from "../../interfaces/extensionSettings";
import { SuggestionDisplayed } from "./inlineSuggestion/suggestionDisplayed";
import { getAdditionalContext } from "./inlineSuggestion/additionalContext";

let inlineSuggestionData: InlineSuggestionEvent = {};
let inlineSuggestionData: InlineSuggestionFeedbackEvent = {};
let inlineSuggestionDisplayTime: Date;
let previousTriggerPosition: vscode.Position;
let insertTexts: string[] = [];
Expand Down Expand Up @@ -926,7 +926,7 @@ export async function inlineSuggestionUserActionHandler(
suggestionId: string,
isSuggestionAccepted: UserAction = UserAction.REJECTED,
) {
const data: InlineSuggestionEvent = {};
const data: InlineSuggestionFeedbackEvent = {};

data["userActionTime"] =
getCurrentUTCDateTime().getTime() - inlineSuggestionDisplayTime.getTime();
Expand All @@ -938,7 +938,7 @@ export async function inlineSuggestionUserActionHandler(
data["action"] = isSuggestionAccepted;
data["suggestionId"] = suggestionId;
const inlineSuggestionFeedbackPayload = {
inlineSuggestion: data,
inlineSuggestionFeedback: data,
};
lightSpeedManager.apiInstance.feedbackRequest(
inlineSuggestionFeedbackPayload,
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/lightspeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface FeedbackResponseParams {
message: string;
}

export interface InlineSuggestionEvent {
export interface InlineSuggestionFeedbackEvent {
latency?: number;
userActionTime?: number;
documentUri?: string;
Expand Down Expand Up @@ -90,7 +90,7 @@ export interface PlaybookGenerationActionEvent {
}

export interface FeedbackRequestParams {
inlineSuggestion?: InlineSuggestionEvent;
inlineSuggestionFeedback?: InlineSuggestionFeedbackEvent;
sentimentFeedback?: SentimentFeedbackEvent;
suggestionQualityFeedback?: SuggestionQualityEvent;
issueFeedback?: IssueFeedbackEvent;
Expand Down
8 changes: 6 additions & 2 deletions test/testScripts/lightspeed/e2eInlineSuggestion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ export async function testInlineSuggestionProviderCoExistence(): Promise<void> {
const feedbackRequestApiCalls = feedbackRequestSpy.getCalls();
assert.equal(feedbackRequestApiCalls.length, 1);
const inputData: FeedbackRequestParams = feedbackRequestSpy.args[0][0];
assert(inputData?.inlineSuggestion?.action === UserAction.REJECTED);
assert(
inputData?.inlineSuggestionFeedback?.action === UserAction.REJECTED,
);
const ret = feedbackRequestSpy.returnValues[0];
assert(Object.keys(ret).length === 0); // ret should be equal to {}

Expand Down Expand Up @@ -247,7 +249,9 @@ export async function testIgnorePendingSuggestion(): Promise<void> {
const feedbackRequestApiCalls = feedbackRequestSpy.getCalls();
assert.equal(feedbackRequestApiCalls.length, 1);
const inputData: FeedbackRequestParams = feedbackRequestSpy.args[0][0];
assert(inputData?.inlineSuggestion?.action === UserAction.IGNORED);
assert(
inputData?.inlineSuggestionFeedback?.action === UserAction.IGNORED,
);
const ret = feedbackRequestSpy.returnValues[0];
assert(Object.keys(ret).length === 0); // ret should be equal to {}
});
Expand Down
24 changes: 15 additions & 9 deletions test/testScripts/lightspeed/testLightspeed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
} from "../../../src/definitions/lightspeed";
import {
FeedbackRequestParams,
InlineSuggestionEvent,
InlineSuggestionFeedbackEvent,
} from "../../../src/interfaces/lightspeed";
import * as inlineSuggestions from "../../../src/features/lightspeed/inlineSuggestions";

Expand Down Expand Up @@ -149,7 +149,9 @@ export function testLightspeed(): void {
assert.equal(feedbackRequestApiCalls.length, 1);
const inputData: FeedbackRequestParams =
feedbackRequestSpy.args[0][0];
assert(inputData?.inlineSuggestion?.action === UserAction.ACCEPTED);
assert(
inputData?.inlineSuggestionFeedback?.action === UserAction.ACCEPTED,
);
const ret = feedbackRequestSpy.returnValues[0];
assert(Object.keys(ret).length === 0); // ret should be equal to {}
});
Expand All @@ -168,7 +170,9 @@ export function testLightspeed(): void {
assert.equal(feedbackRequestApiCalls.length, 1);
const inputData: FeedbackRequestParams =
feedbackRequestSpy.args[0][0];
assert(inputData?.inlineSuggestion?.action === UserAction.ACCEPTED);
assert(
inputData?.inlineSuggestionFeedback?.action === UserAction.ACCEPTED,
);
const ret = feedbackRequestSpy.returnValues[0];
assert(Object.keys(ret).length === 0); // ret should be equal to {}
});
Expand All @@ -182,7 +186,7 @@ export function testLightspeed(): void {
const inputData: FeedbackRequestParams =
feedbackRequestSpy.args[0][0];
assert(
inputData?.inlineSuggestion?.action === UserAction.REJECTED,
inputData?.inlineSuggestionFeedback?.action === UserAction.REJECTED,
JSON.stringify(inputData, null),
);
const ret = feedbackRequestSpy.returnValues[0];
Expand Down Expand Up @@ -292,7 +296,9 @@ export function testLightspeed(): void {
assert.equal(feedbackRequestApiCalls.length, 1);
const inputData: FeedbackRequestParams =
feedbackRequestSpy.args[0][0];
assert(inputData?.inlineSuggestion?.action === UserAction.IGNORED);
assert(
inputData?.inlineSuggestionFeedback?.action === UserAction.IGNORED,
);
const ret = feedbackRequestSpy.returnValues[0];
assert(Object.keys(ret).length === 0); // ret should be equal to {}
});
Expand Down Expand Up @@ -461,7 +467,7 @@ export function testLightspeed(): void {
"df65f5f1-5c27-4dd4-8c58-3336b534321f",
);

const requestSuggestion: InlineSuggestionEvent =
const requestSuggestion: InlineSuggestionFeedbackEvent =
feedbackRequest.args[0][0].inlineSuggestion;
assert.equal(feedbackRequest.called, true);
assert.equal(
Expand All @@ -481,7 +487,7 @@ export function testLightspeed(): void {
undefined,
);

const requestSuggestion: InlineSuggestionEvent =
const requestSuggestion: InlineSuggestionFeedbackEvent =
feedbackRequest.args[0][0].inlineSuggestion;
assert.equal(feedbackRequest.called, true);
assert.equal(
Expand Down Expand Up @@ -532,7 +538,7 @@ export function testLightspeed(): void {

await inlineSuggestions.rejectPendingSuggestion();

const requestSuggestion: InlineSuggestionEvent =
const requestSuggestion: InlineSuggestionFeedbackEvent =
feedbackRequest.args[0][0].inlineSuggestion;
assert.equal(feedbackRequest.called, true);
assert.equal(
Expand Down Expand Up @@ -599,7 +605,7 @@ export function testLightspeed(): void {

await inlineSuggestions.ignorePendingSuggestion();

const requestSuggestion: InlineSuggestionEvent =
const requestSuggestion: InlineSuggestionFeedbackEvent =
feedbackRequest.args[0][0].inlineSuggestion;
assert.equal(feedbackRequest.called, true);
assert.equal(
Expand Down
Loading