From 2a66439ca6cae0bccaeeb778afacefb54eb9a33b Mon Sep 17 00:00:00 2001 From: OpenHands Date: Thu, 19 Dec 2024 09:39:00 -0500 Subject: [PATCH] Fix issue #5676: [Bug]: Frontend Hyperlink in Chat window should open link in a new tab (#5677) Co-authored-by: Xingyao Wang --- .../components/features/chat/chat-message.tsx | 2 ++ .../components/features/markdown/anchor.tsx | 20 +++++++++++++++++++ openhands/server/session/manager.py | 1 + pyproject.toml | 2 ++ 4 files changed, 25 insertions(+) create mode 100644 frontend/src/components/features/markdown/anchor.tsx diff --git a/frontend/src/components/features/chat/chat-message.tsx b/frontend/src/components/features/chat/chat-message.tsx index c960ad4a01b2..c3be33e76b33 100644 --- a/frontend/src/components/features/chat/chat-message.tsx +++ b/frontend/src/components/features/chat/chat-message.tsx @@ -5,6 +5,7 @@ import { code } from "../markdown/code"; import { cn } from "#/utils/utils"; import { ul, ol } from "../markdown/list"; import { CopyToClipboardButton } from "#/components/shared/buttons/copy-to-clipboard-button"; +import { anchor } from "../markdown/anchor"; interface ChatMessageProps { type: "user" | "assistant"; @@ -62,6 +63,7 @@ export function ChatMessage({ code, ul, ol, + a: anchor, }} remarkPlugins={[remarkGfm]} > diff --git a/frontend/src/components/features/markdown/anchor.tsx b/frontend/src/components/features/markdown/anchor.tsx new file mode 100644 index 000000000000..519d5e9a789c --- /dev/null +++ b/frontend/src/components/features/markdown/anchor.tsx @@ -0,0 +1,20 @@ +import React from "react"; +import { ExtraProps } from "react-markdown"; + +export function anchor({ + href, + children, +}: React.ClassAttributes & + React.AnchorHTMLAttributes & + ExtraProps) { + return ( + + {children} + + ); +} diff --git a/openhands/server/session/manager.py b/openhands/server/session/manager.py index 2ccfa21457ff..7ab8d2a817b5 100644 --- a/openhands/server/session/manager.py +++ b/openhands/server/session/manager.py @@ -202,6 +202,7 @@ async def _cleanup_detached_conversations(self): except Exception: logger.warning('error_cleaning_detached_conversations', exc_info=True) await asyncio.sleep(15) + async def init_or_join_session( self, sid: str, connection_id: str, session_init_data: SessionInitData ): diff --git a/pyproject.toml b/pyproject.toml index 18f3e9a5ccf4..54e0594f9ed6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,6 +100,7 @@ reportlab = "*" [tool.coverage.run] concurrency = ["gevent"] + [tool.poetry.group.runtime.dependencies] jupyterlab = "*" notebook = "*" @@ -129,6 +130,7 @@ ignore = ["D1"] [tool.ruff.lint.pydocstyle] convention = "google" + [tool.poetry.group.evaluation.dependencies] streamlit = "*" whatthepatch = "*"