diff --git a/frontend/__tests__/initial-query.test.tsx b/frontend/__tests__/initial-query.test.tsx index 6508f156b260..da499d98cd10 100644 --- a/frontend/__tests__/initial-query.test.tsx +++ b/frontend/__tests__/initial-query.test.tsx @@ -9,12 +9,12 @@ describe("Initial Query Behavior", () => { it("should clear initial query when clearInitialQuery is dispatched", () => { // Set up initial query in the store store.dispatch(setInitialQuery("test query")); - expect(store.getState().initalQuery.initialQuery).toBe("test query"); + expect(store.getState().initialQuery.initialQuery).toBe("test query"); // Clear the initial query store.dispatch(clearInitialQuery()); // Verify initial query is cleared - expect(store.getState().initalQuery.initialQuery).toBeNull(); + expect(store.getState().initialQuery.initialQuery).toBeNull(); }); }); diff --git a/frontend/src/components/features/chat/action-suggestions.tsx b/frontend/src/components/features/chat/action-suggestions.tsx index 2a7e51479cb7..70cb1762382e 100644 --- a/frontend/src/components/features/chat/action-suggestions.tsx +++ b/frontend/src/components/features/chat/action-suggestions.tsx @@ -1,8 +1,10 @@ import posthog from "posthog-js"; import React from "react"; +import { useSelector } from "react-redux"; import { SuggestionItem } from "#/components/features/suggestions/suggestion-item"; import { useAuth } from "#/context/auth-context"; import { DownloadModal } from "#/components/shared/download-modal"; +import type { RootState } from "#/store"; interface ActionSuggestionsProps { onSuggestionsClick: (value: string) => void; @@ -12,6 +14,9 @@ export function ActionSuggestions({ onSuggestionsClick, }: ActionSuggestionsProps) { const { gitHubToken } = useAuth(); + const { selectedRepository } = useSelector( + (state: RootState) => state.initialQuery, + ); const [isDownloading, setIsDownloading] = React.useState(false); const [hasPullRequest, setHasPullRequest] = React.useState(false); @@ -27,7 +32,7 @@ export function ActionSuggestions({ onClose={handleDownloadClose} isOpen={isDownloading} /> - {gitHubToken ? ( + {gitHubToken && selectedRepository ? (
{!hasPullRequest ? ( <> diff --git a/frontend/src/components/features/chat/chat-interface.tsx b/frontend/src/components/features/chat/chat-interface.tsx index bfc65b3e75d7..3a73ef77f9bd 100644 --- a/frontend/src/components/features/chat/chat-interface.tsx +++ b/frontend/src/components/features/chat/chat-interface.tsx @@ -45,7 +45,7 @@ export function ChatInterface() { const [feedbackModalIsOpen, setFeedbackModalIsOpen] = React.useState(false); const [messageToSend, setMessageToSend] = React.useState(null); const { selectedRepository, importedProjectZip } = useSelector( - (state: RootState) => state.initalQuery, + (state: RootState) => state.initialQuery, ); const handleSendMessage = async (content: string, files: File[]) => { diff --git a/frontend/src/components/features/controls/controls.tsx b/frontend/src/components/features/controls/controls.tsx index d7c3fc7673e1..994a5f5101db 100644 --- a/frontend/src/components/features/controls/controls.tsx +++ b/frontend/src/components/features/controls/controls.tsx @@ -20,7 +20,7 @@ export function Controls({ }: ControlsProps) { const { gitHubToken } = useAuth(); const { selectedRepository } = useSelector( - (state: RootState) => state.initalQuery, + (state: RootState) => state.initialQuery, ); const projectMenuCardData = React.useMemo( diff --git a/frontend/src/components/features/project-menu/ProjectMenuCard.tsx b/frontend/src/components/features/project-menu/ProjectMenuCard.tsx index 54512bd141e9..f9a0e1686c23 100644 --- a/frontend/src/components/features/project-menu/ProjectMenuCard.tsx +++ b/frontend/src/components/features/project-menu/ProjectMenuCard.tsx @@ -1,11 +1,9 @@ import React from "react"; import posthog from "posthog-js"; import EllipsisH from "#/icons/ellipsis-h.svg?react"; -import { createChatMessage } from "#/services/chat-service"; import { ProjectMenuCardContextMenu } from "./project.menu-card-context-menu"; import { ProjectMenuDetailsPlaceholder } from "./project-menu-details-placeholder"; import { ProjectMenuDetails } from "./project-menu-details"; -import { useWsClient } from "#/context/ws-client-provider"; import { ConnectToGitHubModal } from "#/components/shared/modals/connect-to-github-modal"; import { ModalBackdrop } from "#/components/shared/modals/modal-backdrop"; import { DownloadModal } from "#/components/shared/download-modal"; @@ -23,8 +21,6 @@ export function ProjectMenuCard({ isConnectedToGitHub, githubData, }: ProjectMenuCardProps) { - const { send } = useWsClient(); - const [contextMenuIsOpen, setContextMenuIsOpen] = React.useState(false); const [connectToGitHubModalOpen, setConnectToGitHubModalOpen] = React.useState(false); @@ -34,26 +30,6 @@ export function ProjectMenuCard({ setContextMenuIsOpen((prev) => !prev); }; - const handlePushToGitHub = () => { - posthog.capture("push_to_github_button_clicked"); - const rawEvent = { - content: ` -Please push the changes to GitHub and open a pull request. -`, - imageUrls: [], - timestamp: new Date().toISOString(), - pending: false, - }; - const event = createChatMessage( - rawEvent.content, - rawEvent.imageUrls, - rawEvent.timestamp, - ); - - send(event); // send to socket - setContextMenuIsOpen(false); - }; - const handleDownloadWorkspace = () => { posthog.capture("download_workspace_button_clicked"); setDownloading(true); @@ -69,7 +45,6 @@ Please push the changes to GitHub and open a pull request. setConnectToGitHubModalOpen(true)} - onPushToGitHub={handlePushToGitHub} onDownloadWorkspace={handleDownloadWorkspace} onClose={() => setContextMenuIsOpen(false)} /> diff --git a/frontend/src/components/features/project-menu/project.menu-card-context-menu.tsx b/frontend/src/components/features/project-menu/project.menu-card-context-menu.tsx index d2ffc3fa7774..d476ffdaf932 100644 --- a/frontend/src/components/features/project-menu/project.menu-card-context-menu.tsx +++ b/frontend/src/components/features/project-menu/project.menu-card-context-menu.tsx @@ -7,7 +7,6 @@ import { I18nKey } from "#/i18n/declaration"; interface ProjectMenuCardContextMenuProps { isConnectedToGitHub: boolean; onConnectToGitHub: () => void; - onPushToGitHub: () => void; onDownloadWorkspace: () => void; onClose: () => void; } @@ -15,7 +14,6 @@ interface ProjectMenuCardContextMenuProps { export function ProjectMenuCardContextMenu({ isConnectedToGitHub, onConnectToGitHub, - onPushToGitHub, onDownloadWorkspace, onClose, }: ProjectMenuCardContextMenuProps) { @@ -31,11 +29,6 @@ export function ProjectMenuCardContextMenu({ {t(I18nKey.PROJECT_MENU_CARD_CONTEXT_MENU$CONNECT_TO_GITHUB_LABEL)} )} - {isConnectedToGitHub && ( - - {t(I18nKey.PROJECT_MENU_CARD_CONTEXT_MENU$PUSH_TO_GITHUB_LABEL)} - - )} {t(I18nKey.PROJECT_MENU_CARD_CONTEXT_MENU$DOWNLOAD_FILES_LABEL)} diff --git a/frontend/src/components/shared/task-form.tsx b/frontend/src/components/shared/task-form.tsx index 07299a682453..cd7b4a7c8e9c 100644 --- a/frontend/src/components/shared/task-form.tsx +++ b/frontend/src/components/shared/task-form.tsx @@ -31,7 +31,7 @@ export const TaskForm = React.forwardRef((_, ref) => { const { settings } = useUserPrefs(); const { selectedRepository, files } = useSelector( - (state: RootState) => state.initalQuery, + (state: RootState) => state.initialQuery, ); const [text, setText] = React.useState(""); diff --git a/frontend/src/routes/_oh.app/hooks/use-handle-runtime-active.ts b/frontend/src/routes/_oh.app/hooks/use-handle-runtime-active.ts index 1edba35b67bf..449916216630 100644 --- a/frontend/src/routes/_oh.app/hooks/use-handle-runtime-active.ts +++ b/frontend/src/routes/_oh.app/hooks/use-handle-runtime-active.ts @@ -25,7 +25,7 @@ export const useHandleRuntimeActive = () => { const runtimeActive = !RUNTIME_INACTIVE_STATES.includes(curAgentState); const { importedProjectZip } = useSelector( - (state: RootState) => state.initalQuery, + (state: RootState) => state.initialQuery, ); const userId = React.useMemo(() => { diff --git a/frontend/src/routes/_oh.app/hooks/use-ws-status-change.ts b/frontend/src/routes/_oh.app/hooks/use-ws-status-change.ts index 0eced2e249b0..1b1c4c69ae8f 100644 --- a/frontend/src/routes/_oh.app/hooks/use-ws-status-change.ts +++ b/frontend/src/routes/_oh.app/hooks/use-ws-status-change.ts @@ -8,11 +8,7 @@ import { import { createChatMessage } from "#/services/chat-service"; import { setCurrentAgentState } from "#/state/agent-slice"; import { addUserMessage } from "#/state/chat-slice"; -import { - clearSelectedRepository, - clearFiles, - clearInitialQuery, -} from "#/state/initial-query-slice"; +import { clearFiles, clearInitialQuery } from "#/state/initial-query-slice"; import { RootState } from "#/store"; import { AgentState } from "#/types/agent-state"; @@ -25,11 +21,11 @@ export const useWSStatusChange = () => { const statusRef = React.useRef(null); const { selectedRepository } = useSelector( - (state: RootState) => state.initalQuery, + (state: RootState) => state.initialQuery, ); const { files, importedProjectZip, initialQuery } = useSelector( - (state: RootState) => state.initalQuery, + (state: RootState) => state.initialQuery, ); const sendInitialQuery = (query: string, base64Files: string[]) => { @@ -52,7 +48,6 @@ export const useWSStatusChange = () => { let additionalInfo = ""; if (gitHubToken && selectedRepository) { - dispatch(clearSelectedRepository()); additionalInfo = `Repository ${selectedRepository} has been cloned to /workspace. Please check the /workspace for files.`; } else if (importedProjectZip) { // if there's an uploaded project zip, add it to the chat diff --git a/frontend/src/routes/_oh.app/route.tsx b/frontend/src/routes/_oh.app/route.tsx index 558db16ed9a5..f44492c3f950 100644 --- a/frontend/src/routes/_oh.app/route.tsx +++ b/frontend/src/routes/_oh.app/route.tsx @@ -37,7 +37,7 @@ function AppContent() { useConversationConfig(); const { selectedRepository } = useSelector( - (state: RootState) => state.initalQuery, + (state: RootState) => state.initialQuery, ); const { updateCount } = useSelector((state: RootState) => state.browser); diff --git a/frontend/src/store.ts b/frontend/src/store.ts index 7c27f37cfa16..3d20023d07fb 100644 --- a/frontend/src/store.ts +++ b/frontend/src/store.ts @@ -12,7 +12,7 @@ import statusReducer from "./state/status-slice"; export const rootReducer = combineReducers({ fileState: fileStateReducer, - initalQuery: initialQueryReducer, + initialQuery: initialQueryReducer, browser: browserReducer, chat: chatReducer, code: codeReducer,