refactor : Improve frontend setup doc and locale error (#6850)

Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
This commit is contained in:
Dai Dao 2025-02-21 17:14:44 -05:00 committed by GitHub
parent a20f299579
commit e109f7e58e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 42 additions and 24 deletions

View File

@ -24,6 +24,10 @@ jobs:
uses: docker/setup-buildx-action@v3
- name: Install tmux
run: sudo apt-get update && sudo apt-get install -y tmux
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Install poetry via pipx
run: pipx install poetry
- name: Set up Python

View File

@ -32,6 +32,10 @@ jobs:
uses: docker/setup-buildx-action@v3
- name: Install tmux
run: sudo apt-get update && sudo apt-get install -y tmux
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
- name: Install poetry via pipx
run: pipx install poetry
- name: Set up Python

View File

@ -81,10 +81,10 @@ check-nodejs:
@if command -v node > /dev/null; then \
NODE_VERSION=$(shell node --version | sed -E 's/v//g'); \
IFS='.' read -r -a NODE_VERSION_ARRAY <<< "$$NODE_VERSION"; \
if [ "$${NODE_VERSION_ARRAY[0]}" -ge 20 ]; then \
if [ "$${NODE_VERSION_ARRAY[0]}" -ge 22 ]; then \
echo "$(BLUE)Node.js $$NODE_VERSION is already installed.$(RESET)"; \
else \
echo "$(RED)Node.js 20.x or later is required. Please install Node.js 20.x or later to continue.$(RESET)"; \
echo "$(RED)Node.js 22.x or later is required. Please install Node.js 22.x or later to continue.$(RESET)"; \
exit 1; \
fi; \
else \

View File

@ -26,6 +26,7 @@ i18n
.init({
fallbackLng: "en",
debug: import.meta.env.NODE_ENV === "development",
load: "languageOnly",
});
export default i18n;

View File

@ -1,4 +1,4 @@
from fastapi import APIRouter, Request
from fastapi import APIRouter, Request, status
from fastapi.responses import JSONResponse
from openhands.core.logger import openhands_logger as logger
@ -40,11 +40,13 @@ async def get_vscode_url(request: Request):
runtime: Runtime = request.state.conversation.runtime
logger.debug(f'Runtime type: {type(runtime)}')
logger.debug(f'Runtime VSCode URL: {runtime.vscode_url}')
return JSONResponse(status_code=200, content={'vscode_url': runtime.vscode_url})
return JSONResponse(
status_code=status.HTTP_200_OK, content={'vscode_url': runtime.vscode_url}
)
except Exception as e:
logger.error(f'Error getting VSCode URL: {e}')
return JSONResponse(
status_code=500,
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
content={
'vscode_url': None,
'error': f'Error getting VSCode URL: {e}',

View File

@ -1,4 +1,4 @@
from fastapi import APIRouter, Request
from fastapi import APIRouter, Request, status
from fastapi.responses import JSONResponse
from openhands.core.logger import openhands_logger as logger
@ -50,9 +50,10 @@ async def submit_feedback(request: Request, conversation_id: str):
)
try:
feedback_data = await call_sync_from_async(store_feedback, feedback)
return JSONResponse(status_code=200, content=feedback_data)
return JSONResponse(status_code=status.HTTP_200_OK, content=feedback_data)
except Exception as e:
logger.error(f'Error submitting feedback: {e}')
return JSONResponse(
status_code=500, content={'error': 'Failed to submit feedback'}
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
content={'error': 'Failed to submit feedback'},
)

View File

@ -1,4 +1,4 @@
from fastapi import APIRouter, Depends
from fastapi import APIRouter, Depends, status
from fastapi.responses import JSONResponse
from pydantic import SecretStr
@ -33,13 +33,13 @@ async def get_github_repositories(
except GhAuthenticationError as e:
return JSONResponse(
content=str(e),
status_code=401,
status_code=status.HTTP_401_UNAUTHORIZED,
)
except GHUnknownException as e:
return JSONResponse(
content=str(e),
status_code=500,
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
)
@ -56,13 +56,13 @@ async def get_github_user(
except GhAuthenticationError as e:
return JSONResponse(
content=str(e),
status_code=401,
status_code=status.HTTP_401_UNAUTHORIZED,
)
except GHUnknownException as e:
return JSONResponse(
content=str(e),
status_code=500,
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
)
@ -79,13 +79,13 @@ async def get_github_installation_ids(
except GhAuthenticationError as e:
return JSONResponse(
content=str(e),
status_code=401,
status_code=status.HTTP_401_UNAUTHORIZED,
)
except GHUnknownException as e:
return JSONResponse(
content=str(e),
status_code=500,
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
)
@ -108,11 +108,11 @@ async def search_github_repositories(
except GhAuthenticationError as e:
return JSONResponse(
content=str(e),
status_code=401,
status_code=status.HTTP_401_UNAUTHORIZED,
)
except GHUnknownException as e:
return JSONResponse(
content=str(e),
status_code=500,
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
)

View File

@ -2,7 +2,7 @@ import uuid
from datetime import datetime, timezone
from typing import Callable
from fastapi import APIRouter, Body, Request
from fastapi import APIRouter, Body, Request, status
from fastapi.responses import JSONResponse
from pydantic import BaseModel, SecretStr
@ -165,7 +165,7 @@ async def new_conversation(request: Request, data: InitSessionRequest):
'message': str(e),
'msg_id': 'CONFIGURATION$SETTINGS_NOT_FOUND',
},
status_code=400,
status_code=status.HTTP_400_BAD_REQUEST,
)
except LLMAuthenticationError as e:
@ -175,7 +175,7 @@ async def new_conversation(request: Request, data: InitSessionRequest):
'message': str(e),
'msg_id': 'STATUS$ERROR_LLM_AUTHENTICATION',
},
status_code=400,
status_code=status.HTTP_400_BAD_REQUEST,
)

View File

@ -2,6 +2,7 @@ from fastapi import (
APIRouter,
HTTPException,
Request,
status,
)
app = APIRouter(prefix='/api/conversations/{conversation_id}')
@ -23,7 +24,10 @@ async def security_api(request: Request):
HTTPException: If the security analyzer is not initialized.
"""
if not request.state.conversation.security_analyzer:
raise HTTPException(status_code=404, detail='Security analyzer not initialized')
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail='Security analyzer not initialized',
)
return await request.state.conversation.security_analyzer.handle_api_request(
request

View File

@ -1,4 +1,4 @@
from fastapi import APIRouter, Request
from fastapi import APIRouter, Request, status
from fastapi.responses import JSONResponse
from openhands.core.logger import openhands_logger as logger
@ -28,11 +28,13 @@ async def get_trajectory(request: Request):
trajectory = []
async for event in async_stream:
trajectory.append(event_to_trajectory(event))
return JSONResponse(status_code=200, content={'trajectory': trajectory})
return JSONResponse(
status_code=status.HTTP_200_OK, content={'trajectory': trajectory}
)
except Exception as e:
logger.error(f'Error getting trajectory: {e}', exc_info=True)
return JSONResponse(
status_code=500,
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
content={
'trajectory': None,
'error': f'Error getting trajectory: {e}',