Skip to content

Commit

Permalink
[Freestyler] Don't show "Fix this issue" button when the last action …
Browse files Browse the repository at this point in the history
…was to "fix this issue"

Fixed: 338931042
Change-Id: Id3b714174d0c20c1a848d9e09dae6d96a08e53fd
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5677363
Reviewed-by: Nikolay Vitkov <nvitkov@chromium.org>
Auto-Submit: Ergün Erdoğmuş <ergunsh@chromium.org>
Commit-Queue: Ergün Erdoğmuş <ergunsh@chromium.org>
  • Loading branch information
ergunsh authored and Devtools-frontend LUCI CQ committed Jul 5, 2024
1 parent ba76776 commit e3ba596
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
2 changes: 2 additions & 0 deletions front_end/panels/freestyler/FreestylerPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export class FreestylerPanel extends UI.Panel.Panel {
inspectElementToggled: this.#toggleSearchElementAction.toggled(),
selectedNode: this.#selectedNode,
isLoading: false,
lastActionIsFixThisIssue: false,
onTextSubmit: this.#handleTextSubmit.bind(this),
onInspectElementClick: this.#handleSelectElementClick.bind(this),
onRateClick: this.#handleRateClick.bind(this),
Expand Down Expand Up @@ -247,6 +248,7 @@ export class FreestylerPanel extends UI.Panel.Panel {
entity: ChatMessageEntity.USER,
text,
});
this.#viewProps.lastActionIsFixThisIssue = text === FIX_THIS_ISSUE_PROMPT;
this.#viewProps.isLoading = true;
let systemMessage: ModelChatMessage = {
entity: ChatMessageEntity.MODEL,
Expand Down
34 changes: 18 additions & 16 deletions front_end/panels/freestyler/components/FreestylerChatUi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,24 @@ export const enum Rating {
NEGATIVE = 'negative',
}

export type Props = {
onTextSubmit: (text: string) => void,
onInspectElementClick: () => void,
onRateClick: (rpcId: number, rate: Rating) => void,
onAcceptConsentClick: () => void,
onCancelClick: () => void,
onFixThisIssueClick: () => void,
inspectElementToggled: boolean,
state: State,
aidaAvailability: Host.AidaClient.AidaAvailability,
messages: ChatMessage[],
selectedNode: SDK.DOMModel.DOMNode|null,
isLoading: boolean,
export interface Props {
onTextSubmit: (text: string) => void;
onInspectElementClick: () => void;
onRateClick: (rpcId: number, rate: Rating) => void;
onAcceptConsentClick: () => void;
onCancelClick: () => void;
onFixThisIssueClick: () => void;
inspectElementToggled: boolean;
state: State;
aidaAvailability: Host.AidaClient.AidaAvailability;
messages: ChatMessage[];
selectedNode: SDK.DOMModel.DOMNode|null;
isLoading: boolean;
// If there is a `confirmSideEffectDialog`, we show the
// confirmation dialog for executing that specific code.
confirmSideEffectDialog?: ConfirmSideEffectDialog,
};
confirmSideEffectDialog?: ConfirmSideEffectDialog;
lastActionIsFixThisIssue: boolean;
}

// The model returns multiline code blocks in an erroneous way with the language being in new line.
// This renderer takes that into account and correctly updates the parsed multiline token with the language
Expand Down Expand Up @@ -381,7 +382,8 @@ export class FreestylerChatUi extends HTMLElement {

// TODO: We should only show "Fix this issue" button when the answer suggests fix or fixes.
// We shouldn't show this when the answer is complete like a confirmation without any suggestion.
const shouldShowFixThisIssueButton = isLast && message.steps.at(-1)?.step === Step.ANSWER;
const shouldShowFixThisIssueButton =
isLast && message.steps.at(-1)?.step === Step.ANSWER && !this.#props.lastActionIsFixThisIssue;
const shouldShowRating = (!this.#props.confirmSideEffectDialog && isLast) || !isLast;
const shouldShowLoading = !this.#props.confirmSideEffectDialog && this.#props.isLoading && isLast;
// clang-format off
Expand Down
1 change: 1 addition & 0 deletions front_end/ui/components/docs/freestyler/basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const component = new Freestyler.FreestylerChatUi({
messages,
selectedNode: {} as unknown as SDK.DOMModel.DOMNode,
isLoading: false,
lastActionIsFixThisIssue: false,
});

document.getElementById('container')?.appendChild(component);
1 change: 1 addition & 0 deletions front_end/ui/components/docs/freestyler/empty_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const component = new Freestyler.FreestylerChatUi({
messages: [],
selectedNode: {} as unknown as SDK.DOMModel.DOMNode,
isLoading: false,
lastActionIsFixThisIssue: false,
});

document.getElementById('container')?.appendChild(component);

0 comments on commit e3ba596

Please sign in to comment.