refactor(frontend): git actions should be enabled at all times (#11063)

This commit is contained in:
Hiep Le 2025-09-24 21:31:51 +07:00 committed by GitHub
parent 11edf33b97
commit 12dc256b5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 7 additions and 60 deletions

View File

@ -342,13 +342,7 @@ describe("InteractiveChatBox", () => {
// Simulate parent component updating the value prop
rerender(
<MemoryRouter>
<InteractiveChatBox
onSubmit={onSubmit}
onStop={onStop}
isWaitingForUserInput={true}
hasSubstantiveAgentActions={true}
optimisticUserMessage={false}
/>
<InteractiveChatBox onSubmit={onSubmit} onStop={onStop} />
</MemoryRouter>,
);

View File

@ -60,13 +60,7 @@ describe("Check for hardcoded English strings", () => {
test("InteractiveChatBox should not have hardcoded English strings", () => {
const { container } = renderWithProviders(
<MemoryRouter>
<InteractiveChatBox
onSubmit={() => {}}
onStop={() => {}}
isWaitingForUserInput={false}
hasSubstantiveAgentActions={false}
optimisticUserMessage={false}
/>
<InteractiveChatBox onSubmit={() => {}} onStop={() => {}} />
</MemoryRouter>,
);

View File

@ -156,10 +156,6 @@ export function ChatInterface() {
setFeedbackPolarity(polarity);
};
const isWaitingForUserInput =
curAgentState === AgentState.AWAITING_USER_INPUT ||
curAgentState === AgentState.FINISHED;
// Create a ScrollProvider with the scroll hook values
const scrollProviderValue = {
scrollRef,
@ -235,9 +231,6 @@ export function ChatInterface() {
<InteractiveChatBox
onSubmit={handleSendMessage}
onStop={handleStop}
isWaitingForUserInput={isWaitingForUserInput}
hasSubstantiveAgentActions={hasSubstantiveAgentActions}
optimisticUserMessage={!!optimisticUserMessage}
/>
</div>

View File

@ -8,14 +8,12 @@ import { Provider } from "#/types/settings";
interface GitControlBarPrButtonProps {
onSuggestionsClick: (value: string) => void;
isEnabled: boolean;
hasRepository: boolean;
currentGitProvider: Provider;
}
export function GitControlBarPrButton({
onSuggestionsClick,
isEnabled,
hasRepository,
currentGitProvider,
}: GitControlBarPrButtonProps) {
@ -24,7 +22,7 @@ export function GitControlBarPrButton({
const { providers } = useUserProviders();
const providersAreSet = providers.length > 0;
const isButtonEnabled = isEnabled && providersAreSet && hasRepository;
const isButtonEnabled = providersAreSet && hasRepository;
const handlePrClick = () => {
posthog.capture("create_pr_button_clicked");

View File

@ -8,12 +8,10 @@ import { I18nKey } from "#/i18n/declaration";
interface GitControlBarPullButtonProps {
onSuggestionsClick: (value: string) => void;
isEnabled: boolean;
}
export function GitControlBarPullButton({
onSuggestionsClick,
isEnabled,
}: GitControlBarPullButtonProps) {
const { t } = useTranslation();
@ -22,7 +20,7 @@ export function GitControlBarPullButton({
const providersAreSet = providers.length > 0;
const hasRepository = conversation?.selected_repository;
const isButtonEnabled = isEnabled && providersAreSet && hasRepository;
const isButtonEnabled = providersAreSet && hasRepository;
const handlePullClick = () => {
posthog.capture("pull_button_clicked");

View File

@ -8,14 +8,12 @@ import { Provider } from "#/types/settings";
interface GitControlBarPushButtonProps {
onSuggestionsClick: (value: string) => void;
isEnabled: boolean;
hasRepository: boolean;
currentGitProvider: Provider;
}
export function GitControlBarPushButton({
onSuggestionsClick,
isEnabled,
hasRepository,
currentGitProvider,
}: GitControlBarPushButtonProps) {
@ -24,7 +22,7 @@ export function GitControlBarPushButton({
const { providers } = useUserProviders();
const providersAreSet = providers.length > 0;
const isButtonEnabled = isEnabled && providersAreSet && hasRepository;
const isButtonEnabled = providersAreSet && hasRepository;
const handlePushClick = () => {
posthog.capture("push_button_clicked");

View File

@ -11,17 +11,9 @@ import { GitControlBarTooltipWrapper } from "./git-control-bar-tooltip-wrapper";
interface GitControlBarProps {
onSuggestionsClick: (value: string) => void;
isWaitingForUserInput: boolean;
hasSubstantiveAgentActions: boolean;
optimisticUserMessage: boolean;
}
export function GitControlBar({
onSuggestionsClick,
isWaitingForUserInput,
hasSubstantiveAgentActions,
optimisticUserMessage,
}: GitControlBarProps) {
export function GitControlBar({ onSuggestionsClick }: GitControlBarProps) {
const { t } = useTranslation();
const { data: conversation } = useActiveConversation();
@ -30,12 +22,6 @@ export function GitControlBar({
const gitProvider = conversation?.git_provider as Provider;
const selectedBranch = conversation?.selected_branch;
// Button is enabled when the agent is waiting for user input, has substantive actions, and no optimistic message
const isButtonEnabled =
isWaitingForUserInput &&
hasSubstantiveAgentActions &&
!optimisticUserMessage;
const hasRepository = !!selectedRepository;
return (
@ -73,7 +59,6 @@ export function GitControlBar({
>
<GitControlBarPullButton
onSuggestionsClick={onSuggestionsClick}
isEnabled={isButtonEnabled}
/>
</GitControlBarTooltipWrapper>
@ -84,7 +69,6 @@ export function GitControlBar({
>
<GitControlBarPushButton
onSuggestionsClick={onSuggestionsClick}
isEnabled={isButtonEnabled}
hasRepository={hasRepository}
currentGitProvider={gitProvider}
/>
@ -97,7 +81,6 @@ export function GitControlBar({
>
<GitControlBarPrButton
onSuggestionsClick={onSuggestionsClick}
isEnabled={isButtonEnabled}
hasRepository={hasRepository}
currentGitProvider={gitProvider}
/>

View File

@ -13,17 +13,11 @@ import { RootState } from "#/store";
interface InteractiveChatBoxProps {
onSubmit: (message: string, images: File[], files: File[]) => void;
onStop: () => void;
isWaitingForUserInput: boolean;
hasSubstantiveAgentActions: boolean;
optimisticUserMessage: boolean;
}
export function InteractiveChatBox({
onSubmit,
onStop,
isWaitingForUserInput,
hasSubstantiveAgentActions,
optimisticUserMessage,
}: InteractiveChatBoxProps) {
const {
images,
@ -159,12 +153,7 @@ export function InteractiveChatBox({
conversationStatus={conversation?.status || null}
/>
<div className="mt-4">
<GitControlBar
onSuggestionsClick={handleSuggestionsClick}
isWaitingForUserInput={isWaitingForUserInput}
hasSubstantiveAgentActions={hasSubstantiveAgentActions}
optimisticUserMessage={optimisticUserMessage}
/>
<GitControlBar onSuggestionsClick={handleSuggestionsClick} />
</div>
</div>
);