Skip to content

Commit 9311f10

Browse files
committed
ui(chat): move browser globe to task header; show grey when inactive and green Active when session active
1 parent 622f43a commit 9311f10

File tree

2 files changed

+62
-30
lines changed

2 files changed

+62
-30
lines changed

webview-ui/src/components/chat/ChatTextArea.tsx

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { forwardRef, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"
22
import { useEvent } from "react-use"
33
import DynamicTextArea from "react-textarea-autosize"
4-
import { VolumeX, Image, WandSparkles, SendHorizontal, MessageSquareX, Globe } from "lucide-react"
4+
import { VolumeX, Image, WandSparkles, SendHorizontal, MessageSquareX } from "lucide-react"
55

66
import { mentionRegex, mentionRegexGlobal, commandRegexGlobal, unescapeSpaces } from "@roo/context-mentions"
77
import { WebviewMessage } from "@roo/WebviewMessage"
@@ -21,7 +21,7 @@ import {
2121
} from "@src/utils/context-mentions"
2222
import { cn } from "@src/lib/utils"
2323
import { convertToMentionPath } from "@src/utils/path-mentions"
24-
import { StandardTooltip, Button } from "@src/components/ui"
24+
import { StandardTooltip } from "@src/components/ui"
2525

2626
import Thumbnails from "../common/Thumbnails"
2727
import { ModeSelector } from "./ModeSelector"
@@ -1264,32 +1264,14 @@ export const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
12641264
</button>
12651265
</StandardTooltip>
12661266
)}
1267-
{!isEditMode && showBrowserDockToggle && (
1268-
<StandardTooltip content={t("chat:browser.session")}>
1269-
<Button
1270-
variant="ghost"
1271-
size="sm"
1272-
aria-label={t("chat:browser.session")}
1273-
onClick={() => vscode.postMessage({ type: "openBrowserSessionPanel" })}
1274-
className={cn(
1275-
"relative h-5 w-5 p-0",
1276-
"text-vscode-foreground opacity-85",
1277-
"hover:opacity-100 hover:bg-[rgba(255,255,255,0.03)]",
1278-
"focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder",
1279-
)}>
1280-
<Globe
1281-
className="w-4 h-4"
1282-
style={{
1283-
color: isBrowserSessionActive
1284-
? "#4ade80"
1285-
: "var(--vscode-descriptionForeground)",
1286-
}}
1287-
/>
1288-
</Button>
1289-
</StandardTooltip>
1290-
)}
12911267
{!isEditMode ? <IndexingStatusBadge /> : null}
12921268
{!isEditMode && cloudUserInfo && <CloudAccountSwitcher />}
1269+
{/* keep props referenced after moving browser button */}
1270+
<div
1271+
className="hidden"
1272+
data-browser-session-active={isBrowserSessionActive}
1273+
data-show-browser-dock-toggle={showBrowserDockToggle}
1274+
/>
12931275
</div>
12941276
</div>
12951277
</div>

webview-ui/src/components/chat/TaskHeader.tsx

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { memo, useEffect, useRef, useState } from "react"
1+
import { memo, useEffect, useRef, useState, useMemo } from "react"
22
import { useTranslation } from "react-i18next"
33
import { useCloudUpsell } from "@src/hooks/useCloudUpsell"
44
import { CloudUpsellDialog } from "@src/components/cloud/CloudUpsellDialog"
55
import DismissibleUpsell from "@src/components/common/DismissibleUpsell"
6-
import { FoldVertical, ChevronUp, ChevronDown } from "lucide-react"
6+
import { FoldVertical, ChevronUp, ChevronDown, Globe } from "lucide-react"
77
import prettyBytes from "pretty-bytes"
88

99
import type { ClineMessage } from "@roo-code/types"
@@ -13,9 +13,10 @@ import { findLastIndex } from "@roo/array"
1313

1414
import { formatLargeNumber } from "@src/utils/format"
1515
import { cn } from "@src/lib/utils"
16-
import { StandardTooltip } from "@src/components/ui"
16+
import { StandardTooltip, Button } from "@src/components/ui"
1717
import { useExtensionState } from "@src/context/ExtensionStateContext"
1818
import { useSelectedModel } from "@/components/ui/hooks/useSelectedModel"
19+
import { vscode } from "@src/utils/vscode"
1920

2021
import Thumbnails from "../common/Thumbnails"
2122

@@ -50,7 +51,7 @@ const TaskHeader = ({
5051
todos,
5152
}: TaskHeaderProps) => {
5253
const { t } = useTranslation()
53-
const { apiConfiguration, currentTaskItem, clineMessages } = useExtensionState()
54+
const { apiConfiguration, currentTaskItem, clineMessages, isBrowserSessionActive } = useExtensionState()
5455
const { id: modelId, info: model } = useSelectedModel(apiConfiguration)
5556
const [isTaskExpanded, setIsTaskExpanded] = useState(false)
5657
const [showLongRunningTaskMessage, setShowLongRunningTaskMessage] = useState(false)
@@ -86,6 +87,21 @@ const TaskHeader = ({
8687
const textRef = useRef<HTMLDivElement>(null)
8788
const contextWindow = model?.contextWindow || 1
8889

90+
// Detect if this task had any browser session activity so we can show a grey globe when inactive
91+
const browserSessionStartIndex = useMemo(() => {
92+
const msgs = clineMessages || []
93+
for (let i = 0; i < msgs.length; i++) {
94+
const m = msgs[i] as any
95+
if (m?.ask === "browser_action_launch") return i
96+
if (m?.say === "browser_session_status" && typeof m.text === "string" && m.text.includes("opened")) {
97+
return i
98+
}
99+
}
100+
return -1
101+
}, [clineMessages])
102+
103+
const showBrowserGlobe = browserSessionStartIndex !== -1 || !!isBrowserSessionActive
104+
89105
const condenseButton = (
90106
<StandardTooltip content={t("chat:task.condenseContext")}>
91107
<button
@@ -325,6 +341,40 @@ const TaskHeader = ({
325341
</div>
326342
</>
327343
)}
344+
{/* Browser session status moved from bottom bar to header (bottom-right) */}
345+
{showBrowserGlobe && (
346+
<div
347+
className="absolute bottom-2 right-3 flex items-center gap-1"
348+
onClick={(e) => e.stopPropagation()}>
349+
<StandardTooltip content={t("chat:browser.session")}>
350+
<Button
351+
variant="ghost"
352+
size="sm"
353+
aria-label={t("chat:browser.session")}
354+
onClick={() => vscode.postMessage({ type: "openBrowserSessionPanel" } as any)}
355+
className={cn(
356+
"relative h-5 w-5 p-0",
357+
"text-vscode-foreground opacity-85",
358+
"hover:opacity-100 hover:bg-[rgba(255,255,255,0.03)]",
359+
"focus:outline-none focus-visible:ring-1 focus-visible:ring-vscode-focusBorder",
360+
)}>
361+
<Globe
362+
className="w-4 h-4"
363+
style={{
364+
color: isBrowserSessionActive
365+
? "#4ade80"
366+
: "var(--vscode-descriptionForeground)",
367+
}}
368+
/>
369+
</Button>
370+
</StandardTooltip>
371+
{isBrowserSessionActive && (
372+
<span className="text-sm font-medium" style={{ color: "var(--vscode-testing-iconPassed)" }}>
373+
Active
374+
</span>
375+
)}
376+
</div>
377+
)}
328378
</div>
329379
<TodoListDisplay todos={todos ?? (task as any)?.tool?.todos ?? []} />
330380
<CloudUpsellDialog open={isOpen} onOpenChange={closeUpsell} onConnect={handleConnect} />

0 commit comments

Comments
 (0)