Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Fix issue #5676: [Bug]: Frontend Hyperlink in Chat window should open link in a new tab (#5677)

OpenHands2a66439ca6ca
diff --git a/frontend/src/components/features/chat/chat-message.tsx b/frontend/src/components/features/chat/chat-message.tsx
index c960ad4a01..c3be33e76b 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 0000000000..519d5e9a78
--- /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<HTMLAnchorElement> &
+ React.AnchorHTMLAttributes<HTMLAnchorElement> &
+ ExtraProps) {
+ return (
+ <a
+ className="text-blue-500 hover:underline"
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ {children}
+ </a>
+ );
+}
diff --git a/openhands/server/session/manager.py b/openhands/server/session/manager.py
index 2ccfa21457..7ab8d2a817 100644
--- a/openhands/server/session/manager.py
+++ b/openhands/server/session/manager.py
@@ -202,6 +202,7 @@ class SessionManager:
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 18f3e9a5cc..54e0594f9e 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 = "*"