Skip to content

πŸ™Œ OpenHands: AI-Driven Development

(Chore): Rename GitHub instances to Git (#7625)

Rohit Malhotraa2e9e23569c3
diff --git a/frontend/__tests__/components/features/github/github-repo-selector.test.tsx b/frontend/__tests__/components/features/git/git-repo-selector.test.tsx
similarity index 97%
rename from frontend/__tests__/components/features/github/github-repo-selector.test.tsx
rename to frontend/__tests__/components/features/git/git-repo-selector.test.tsx
index a30cd19904..723864a18f 100644
--- a/frontend/__tests__/components/features/github/github-repo-selector.test.tsx
+++ b/frontend/__tests__/components/features/git/git-repo-selector.test.tsx
@@ -1,7 +1,7 @@
import { screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { renderWithProviders } from "test-utils";
-import { GitRepositorySelector } from "#/components/features/github/github-repo-selector";
+import { GitRepositorySelector } from "#/components/features/git/git-repo-selector";
import OpenHands from "#/api/open-hands";
import { Provider } from "#/types/settings";
@@ -67,7 +67,7 @@ describe("GitRepositorySelector", () => {
const searchPublicRepositoriesSpy = vi.spyOn(
OpenHands,
- "searchGitHubRepositories",
+ "searchGitRepositories",
);
searchPublicRepositoriesSpy.mockResolvedValue(mockSearchedRepos);
diff --git a/frontend/src/api/github.ts b/frontend/src/api/git.ts
similarity index 97%
rename from frontend/src/api/github.ts
rename to frontend/src/api/git.ts
index 5df1d90aca..0412b14d6c 100644
--- a/frontend/src/api/github.ts
+++ b/frontend/src/api/git.ts
@@ -1,4 +1,4 @@
-import { GitRepository } from "#/types/github";
+import { GitRepository } from "#/types/git";
import { extractNextPageFromLink } from "#/utils/extract-next-page-from-link";
import { openHands } from "./open-hands-axios";
diff --git a/frontend/src/api/open-hands-axios.ts b/frontend/src/api/open-hands-axios.ts
index de1bbb8ed2..a20003dc66 100644
--- a/frontend/src/api/open-hands-axios.ts
+++ b/frontend/src/api/open-hands-axios.ts
@@ -3,22 +3,3 @@ import axios from "axios";
export const openHands = axios.create({
baseURL: `${window.location.protocol}//${import.meta.env.VITE_BACKEND_BASE_URL || window?.location.host}`,
});
-export const setAuthTokenHeader = (token: string) => {
- openHands.defaults.headers.common.Authorization = `Bearer ${token}`;
-};
-
-export const setGitHubTokenHeader = (token: string) => {
- openHands.defaults.headers.common["X-GitHub-Token"] = token;
-};
-
-export const removeAuthTokenHeader = () => {
- if (openHands.defaults.headers.common.Authorization) {
- delete openHands.defaults.headers.common.Authorization;
- }
-};
-
-export const removeGitHubTokenHeader = () => {
- if (openHands.defaults.headers.common["X-GitHub-Token"]) {
- delete openHands.defaults.headers.common["X-GitHub-Token"];
- }
-};
diff --git a/frontend/src/api/open-hands.ts b/frontend/src/api/open-hands.ts
index 643812d1e9..e2744d6c8e 100644
--- a/frontend/src/api/open-hands.ts
+++ b/frontend/src/api/open-hands.ts
@@ -14,7 +14,7 @@ import {
} from "./open-hands.types";
import { openHands } from "./open-hands-axios";
import { ApiSettings, PostApiSettings } from "#/types/settings";
-import { GitHubUser, GitRepository } from "#/types/github";
+import { GitUser, GitRepository } from "#/types/git";
class OpenHands {
/**
@@ -306,12 +306,12 @@ class OpenHands {
return data.credits;
}
- static async getGitHubUser(): Promise<GitHubUser> {
- const response = await openHands.get<GitHubUser>("/api/user/info");
+ static async getGitUser(): Promise<GitUser> {
+ const response = await openHands.get<GitUser>("/api/user/info");
const { data } = response;
- const user: GitHubUser = {
+ const user: GitUser = {
id: data.id,
login: data.login,
avatar_url: data.avatar_url,
@@ -328,7 +328,7 @@ class OpenHands {
return response.data;
}
- static async searchGitHubRepositories(
+ static async searchGitRepositories(
query: string,
per_page = 5,
): Promise<GitRepository[]> {
diff --git a/frontend/src/api/open-hands.utils.ts b/frontend/src/api/open-hands.utils.ts
deleted file mode 100644
index c2460d0636..0000000000
--- a/frontend/src/api/open-hands.utils.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { ErrorResponse, FileUploadSuccessResponse } from "./open-hands.types";
-
-export const isOpenHandsErrorResponse = (
- data: ErrorResponse | FileUploadSuccessResponse,
-): data is ErrorResponse =>
- typeof data === "object" && data !== null && "error" in data;
diff --git a/frontend/src/components/features/github/code-not-in-github-link.tsx b/frontend/src/components/features/git/code-not-in-github-link.tsx
similarity index 92%
rename from frontend/src/components/features/github/code-not-in-github-link.tsx
rename to frontend/src/components/features/git/code-not-in-github-link.tsx
index 463ecf5c84..015e53f81c 100644
--- a/frontend/src/components/features/github/code-not-in-github-link.tsx
+++ b/frontend/src/components/features/git/code-not-in-github-link.tsx
@@ -5,7 +5,7 @@ import { setInitialPrompt } from "#/state/initial-query-slice";
const INITIAL_PROMPT = "";
-export function CodeNotInGitHubLink() {
+export function CodeNotInGitLink() {
const dispatch = useDispatch();
const { mutate: createConversation } = useCreateConversation();
@@ -17,7 +17,7 @@ export function CodeNotInGitHubLink() {
return (
<div className="text-xs text-neutral-400">
- Code not in GitHub?{" "}
+ Code not in Git?{" "}
<span
onClick={handleStartFromScratch}
className="underline cursor-pointer"
diff --git a/frontend/src/components/features/github/github-repo-selector.tsx b/frontend/src/components/features/git/git-repo-selector.tsx
similarity index 99%
rename from frontend/src/components/features/github/github-repo-selector.tsx
rename to frontend/src/components/features/git/git-repo-selector.tsx
index dd74b3badb..6e82f455fc 100644
--- a/frontend/src/components/features/github/github-repo-selector.tsx
+++ b/frontend/src/components/features/git/git-repo-selector.tsx
@@ -12,7 +12,7 @@ import { I18nKey } from "#/i18n/declaration";
import { setSelectedRepository } from "#/state/initial-query-slice";
import { useConfig } from "#/hooks/query/use-config";
import { sanitizeQuery } from "#/utils/sanitize-query";
-import { GitRepository } from "#/types/github";
+import { GitRepository } from "#/types/git";
import { Provider, ProviderOptions } from "#/types/settings";
interface GitRepositorySelectorProps {
diff --git a/frontend/src/components/features/github/github-repositories-suggestion-box.tsx b/frontend/src/components/features/git/git-repositories-suggestion-box.tsx
similarity index 93%
rename from frontend/src/components/features/github/github-repositories-suggestion-box.tsx
rename to frontend/src/components/features/git/git-repositories-suggestion-box.tsx
index 4bf2ec2d42..b8c6463079 100644
--- a/frontend/src/components/features/github/github-repositories-suggestion-box.tsx
+++ b/frontend/src/components/features/git/git-repositories-suggestion-box.tsx
@@ -3,7 +3,7 @@ import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router";
import { I18nKey } from "#/i18n/declaration";
import { SuggestionBox } from "#/components/features/suggestions/suggestion-box";
-import { GitRepositorySelector } from "./github-repo-selector";
+import { GitRepositorySelector } from "./git-repo-selector";
import { useAppRepositories } from "#/hooks/query/use-app-repositories";
import { useSearchRepositories } from "#/hooks/query/use-search-repositories";
import { useUserRepositories } from "#/hooks/query/use-user-repositories";
@@ -11,12 +11,12 @@ import { sanitizeQuery } from "#/utils/sanitize-query";
import { useDebounce } from "#/hooks/use-debounce";
import { BrandButton } from "../settings/brand-button";
import GitHubLogo from "#/assets/branding/github-logo.svg?react";
-import { GitHubErrorReponse, GitHubUser } from "#/types/github";
+import { GitHubErrorReponse, GitUser } from "#/types/git";
interface GitRepositoriesSuggestionBoxProps {
handleSubmit: () => void;
gitHubAuthUrl: string | null;
- user: GitHubErrorReponse | GitHubUser | null;
+ user: GitHubErrorReponse | GitUser | null;
}
export function GitRepositoriesSuggestionBox({
diff --git a/frontend/src/components/features/sidebar/sidebar.tsx b/frontend/src/components/features/sidebar/sidebar.tsx
index 8d75eb0b09..9b1f923ace 100644
--- a/frontend/src/components/features/sidebar/sidebar.tsx
+++ b/frontend/src/components/features/sidebar/sidebar.tsx
@@ -3,7 +3,7 @@ import { FaListUl } from "react-icons/fa";
import { useDispatch } from "react-redux";
import posthog from "posthog-js";
import { NavLink, useLocation } from "react-router";
-import { useGitHubUser } from "#/hooks/query/use-github-user";
+import { useGitUser } from "#/hooks/query/use-git-user";
import { UserActions } from "./user-actions";
import { AllHandsLogoButton } from "#/components/shared/buttons/all-hands-logo-button";
import { DocsButton } from "#/components/shared/buttons/docs-button";
@@ -26,7 +26,7 @@ export function Sidebar() {
const location = useLocation();
const dispatch = useDispatch();
const endSession = useEndSession();
- const user = useGitHubUser();
+ const user = useGitUser();
const { data: config } = useConfig();
const {
data: settings,
diff --git a/frontend/src/hooks/query/use-app-repositories.ts b/frontend/src/hooks/query/use-app-repositories.ts
index e7e2669684..c4e188cc7b 100644
--- a/frontend/src/hooks/query/use-app-repositories.ts
+++ b/frontend/src/hooks/query/use-app-repositories.ts
@@ -1,6 +1,6 @@
import { useInfiniteQuery } from "@tanstack/react-query";
import React from "react";
-import { retrieveGitHubAppRepositories } from "#/api/github";
+import { retrieveGitHubAppRepositories } from "#/api/git";
import { useAppInstallations } from "./use-app-installations";
import { useConfig } from "./use-config";
import { useAuth } from "#/context/auth-context";
diff --git a/frontend/src/hooks/query/use-github-user.ts b/frontend/src/hooks/query/use-git-user.ts
similarity index 94%
rename from frontend/src/hooks/query/use-github-user.ts
rename to frontend/src/hooks/query/use-git-user.ts
index e8fcc359cc..41a5565139 100644
--- a/frontend/src/hooks/query/use-github-user.ts
+++ b/frontend/src/hooks/query/use-git-user.ts
@@ -6,7 +6,7 @@ import OpenHands from "#/api/open-hands";
import { useAuth } from "#/context/auth-context";
import { useLogout } from "../mutation/use-logout";
-export const useGitHubUser = () => {
+export const useGitUser = () => {
const { providersAreSet, providerTokensSet } = useAuth();
const { mutateAsync: logout } = useLogout();
@@ -14,7 +14,7 @@ export const useGitHubUser = () => {
const user = useQuery({
queryKey: ["user", providerTokensSet],
- queryFn: OpenHands.getGitHubUser,
+ queryFn: OpenHands.getGitUser,
enabled: providersAreSet && !!config?.APP_MODE,
retry: false,
staleTime: 1000 * 60 * 5, // 5 minutes
diff --git a/frontend/src/hooks/query/use-search-repositories.ts b/frontend/src/hooks/query/use-search-repositories.ts
index 66a2edcc86..29155ea8f9 100644
--- a/frontend/src/hooks/query/use-search-repositories.ts
+++ b/frontend/src/hooks/query/use-search-repositories.ts
@@ -4,7 +4,7 @@ import OpenHands from "#/api/open-hands";
export function useSearchRepositories(query: string) {
return useQuery({
queryKey: ["repositories", query],
- queryFn: () => OpenHands.searchGitHubRepositories(query, 3),
+ queryFn: () => OpenHands.searchGitRepositories(query, 3),
enabled: !!query,
select: (data) => data.map((repo) => ({ ...repo, is_public: true })),
staleTime: 1000 * 60 * 5, // 5 minutes
diff --git a/frontend/src/hooks/query/use-user-repositories.ts b/frontend/src/hooks/query/use-user-repositories.ts
index 40a7b7dd3c..1a1b454f99 100644
--- a/frontend/src/hooks/query/use-user-repositories.ts
+++ b/frontend/src/hooks/query/use-user-repositories.ts
@@ -1,6 +1,6 @@
import { useInfiniteQuery } from "@tanstack/react-query";
import React from "react";
-import { retrieveUserGitRepositories } from "#/api/github";
+import { retrieveUserGitRepositories } from "#/api/git";
import { useConfig } from "./use-config";
import { useAuth } from "#/context/auth-context";
diff --git a/frontend/src/mocks/handlers.ts b/frontend/src/mocks/handlers.ts
index 8c553c0715..3b2311aff6 100644
--- a/frontend/src/mocks/handlers.ts
+++ b/frontend/src/mocks/handlers.ts
@@ -7,7 +7,7 @@ import {
import { DEFAULT_SETTINGS } from "#/services/settings";
import { STRIPE_BILLING_HANDLERS } from "./billing-handlers";
import { ApiSettings, PostApiSettings } from "#/types/settings";
-import { GitHubUser } from "#/types/github";
+import { GitUser } from "#/types/git";
export const MOCK_DEFAULT_USER_SETTINGS: ApiSettings | PostApiSettings = {
llm_model: DEFAULT_SETTINGS.LLM_MODEL,
@@ -156,7 +156,7 @@ export const handlers = [
]),
),
http.get("/api/user/info", () => {
- const user: GitHubUser = {
+ const user: GitUser = {
id: 1,
login: "octocat",
avatar_url: "https://avatars.githubusercontent.com/u/583231?v=4",
diff --git a/frontend/src/routes/_oh._index/route.tsx b/frontend/src/routes/_oh._index/route.tsx
index 2cf3a14b3e..b6d0ea3341 100644
--- a/frontend/src/routes/_oh._index/route.tsx
+++ b/frontend/src/routes/_oh._index/route.tsx
@@ -2,12 +2,12 @@ import React from "react";
import { useDispatch } from "react-redux";
import posthog from "posthog-js";
import { setReplayJson } from "#/state/initial-query-slice";
-import { useGitHubUser } from "#/hooks/query/use-github-user";
+import { useGitUser } from "#/hooks/query/use-git-user";
import { useGitHubAuthUrl } from "#/hooks/use-github-auth-url";
import { useConfig } from "#/hooks/query/use-config";
-import { GitRepositoriesSuggestionBox } from "#/components/features/github/github-repositories-suggestion-box";
+import { GitRepositoriesSuggestionBox } from "#/components/features/git/git-repositories-suggestion-box";
import { ReplaySuggestionBox } from "../../components/features/suggestions/replay-suggestion-box";
-import { CodeNotInGitHubLink } from "#/components/features/github/code-not-in-github-link";
+import { CodeNotInGitLink } from "#/components/features/git/code-not-in-github-link";
import { HeroHeading } from "#/components/shared/hero-heading";
import { TaskForm } from "#/components/shared/task-form";
import { convertFileToText } from "#/utils/convert-file-to-text";
@@ -18,7 +18,7 @@ function Home() {
const formRef = React.useRef<HTMLFormElement>(null);
const { data: config } = useConfig();
- const { data: user } = useGitHubUser();
+ const { data: user } = useGitUser();
const gitHubAuthUrl = useGitHubAuthUrl({
appMode: config?.APP_MODE || null,
@@ -58,7 +58,7 @@ function Home() {
)}
</div>
<div className="w-full flex justify-start mt-2 ml-2">
- <CodeNotInGitHubLink />
+ <CodeNotInGitLink />
</div>
</div>
</div>
diff --git a/frontend/src/state/initial-query-slice.ts b/frontend/src/state/initial-query-slice.ts
index f393d5fca1..14e60f49ab 100644
--- a/frontend/src/state/initial-query-slice.ts
+++ b/frontend/src/state/initial-query-slice.ts
@@ -1,6 +1,6 @@
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
import { Provider } from "#/types/settings";
-import { GitRepository } from "#/types/github";
+import { GitRepository } from "#/types/git";
type SliceState = {
files: string[]; // base64 encoded images
diff --git a/frontend/src/types/github.d.ts b/frontend/src/types/git.d.ts
similarity index 96%
rename from frontend/src/types/github.d.ts
rename to frontend/src/types/git.d.ts
index dc8d8863ac..b45c934e99 100644
--- a/frontend/src/types/github.d.ts
+++ b/frontend/src/types/git.d.ts
@@ -6,7 +6,7 @@ interface GitHubErrorReponse {
status: number;
}
-interface GitHubUser {
+interface GitUser {
id: number;
login: string;
avatar_url: string;
diff --git a/openhands/server/app.py b/openhands/server/app.py
index 93c6aa093f..02ec3fcf22 100644
--- a/openhands/server/app.py
+++ b/openhands/server/app.py
@@ -13,7 +13,7 @@ from openhands import __version__
from openhands.server.routes.conversation import app as conversation_api_router
from openhands.server.routes.feedback import app as feedback_api_router
from openhands.server.routes.files import app as files_api_router
-from openhands.server.routes.github import app as github_api_router
+from openhands.server.routes.git import app as git_api_router
from openhands.server.routes.manage_conversations import (
app as manage_conversation_api_router,
)
@@ -50,5 +50,5 @@ app.include_router(feedback_api_router)
app.include_router(conversation_api_router)
app.include_router(manage_conversation_api_router)
app.include_router(settings_router)
-app.include_router(github_api_router)
+app.include_router(git_api_router)
app.include_router(trajectory_router)
diff --git a/openhands/server/listen.py b/openhands/server/listen.py
index bb37909eb2..7bcc3ad9ef 100644
--- a/openhands/server/listen.py
+++ b/openhands/server/listen.py
@@ -5,9 +5,9 @@ from openhands.server.listen_socket import sio
from openhands.server.middleware import (
AttachConversationMiddleware,
CacheControlMiddleware,
- GitHubTokenMiddleware,
InMemoryRateLimiter,
LocalhostCORSMiddleware,
+ ProviderTokenMiddleware,
RateLimitMiddleware,
)
from openhands.server.static import SPAStaticFiles
@@ -29,6 +29,6 @@ base_app.add_middleware(
rate_limiter=InMemoryRateLimiter(requests=10, seconds=1),
)
base_app.middleware('http')(AttachConversationMiddleware(base_app))
-base_app.middleware('http')(GitHubTokenMiddleware(base_app))
+base_app.middleware('http')(ProviderTokenMiddleware(base_app))
app = socketio.ASGIApp(sio, other_asgi_app=base_app)
diff --git a/openhands/server/middleware.py b/openhands/server/middleware.py
index acb09c287b..9c0aef1ec5 100644
--- a/openhands/server/middleware.py
+++ b/openhands/server/middleware.py
@@ -185,7 +185,7 @@ class AttachConversationMiddleware(SessionMiddlewareInterface):
return response
-class GitHubTokenMiddleware(SessionMiddlewareInterface):
+class ProviderTokenMiddleware(SessionMiddlewareInterface):
def __init__(self, app):
self.app = app
diff --git a/openhands/server/routes/github.py b/openhands/server/routes/git.py
similarity index 100%
rename from openhands/server/routes/github.py
rename to openhands/server/routes/git.py