Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit 1071717

Browse files
committed
feat(ui): add terminal session indicator in TaskHeader
- Add activeTerminalSessions count to ExtensionState type - Add ProcessManager query in ClineProvider.getState() to count running sessions - Add TerminalSquare icon indicator in TaskHeader showing session count - Show indicator only when there are active sessions (green icon + count) - Add i18n translations for terminal session tooltip - Update ExtensionStateContext test with new property
1 parent 56da141 commit 1071717

5 files changed

Lines changed: 46 additions & 1 deletion

File tree

packages/types/src/vscode-extension-host.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ export type ExtensionState = Pick<
385385
organizationSettingsVersion?: number
386386

387387
isBrowserSessionActive: boolean // Actual browser session state
388+
activeTerminalSessions: number // Count of active terminal sessions for current task
388389

389390
autoCondenseContext: boolean
390391
autoCondenseContextPercent: number

src/core/webview/ClineProvider.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import { EMBEDDING_MODEL_PROFILES } from "../../shared/embeddingModels"
6262
import { ProfileValidator } from "../../shared/ProfileValidator"
6363

6464
import { Terminal } from "../../integrations/terminal/Terminal"
65+
import { ProcessManager } from "../../integrations/terminal/ProcessManager"
6566
import { downloadTask, getTaskFileName } from "../../integrations/misc/export-markdown"
6667
import { resolveDefaultSaveUri, saveLastExportPath } from "../../utils/export"
6768
import { getTheme } from "../../integrations/theme/getTheme"
@@ -2074,6 +2075,7 @@ export class ClineProvider
20742075
openRouterImageGenerationSelectedModel,
20752076
featureRoomoteControlEnabled,
20762077
isBrowserSessionActive,
2078+
activeTerminalSessions,
20772079
} = await this.getState()
20782080

20792081
let cloudOrganizations: CloudOrganizationMembership[] = []
@@ -2123,6 +2125,7 @@ export class ClineProvider
21232125
alwaysAllowModeSwitch: alwaysAllowModeSwitch ?? false,
21242126
alwaysAllowSubtasks: alwaysAllowSubtasks ?? false,
21252127
isBrowserSessionActive,
2128+
activeTerminalSessions,
21262129
allowedMaxRequests,
21272130
allowedMaxCost,
21282131
autoCondenseContext: autoCondenseContext ?? true,
@@ -2357,6 +2360,14 @@ export class ClineProvider
23572360
// Get actual browser session state
23582361
const isBrowserSessionActive = this.getCurrentTask()?.browserSession?.isSessionActive() ?? false
23592362

2363+
// Get active terminal sessions count for current task
2364+
const currentTaskId = this.getCurrentTask()?.taskId
2365+
const activeTerminalSessions = currentTaskId
2366+
? ProcessManager.getInstance()
2367+
.listSessions(currentTaskId)
2368+
.filter((s) => s.running).length
2369+
: 0
2370+
23602371
// Return the same structure as before.
23612372
return {
23622373
apiConfiguration: providerSettings,
@@ -2375,6 +2386,7 @@ export class ClineProvider
23752386
alwaysAllowSubtasks: stateValues.alwaysAllowSubtasks ?? false,
23762387
alwaysAllowFollowupQuestions: stateValues.alwaysAllowFollowupQuestions ?? false,
23772388
isBrowserSessionActive,
2389+
activeTerminalSessions,
23782390
followupAutoApproveTimeoutMs: stateValues.followupAutoApproveTimeoutMs ?? 60000,
23792391
diagnosticsEnabled: stateValues.diagnosticsEnabled ?? true,
23802392
allowedMaxRequests: stateValues.allowedMaxRequests,

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
FoldVertical,
1212
Globe,
1313
ArrowLeft,
14+
TerminalSquare,
1415
} from "lucide-react"
1516
import prettyBytes from "pretty-bytes"
1617

@@ -68,7 +69,8 @@ const TaskHeader = ({
6869
todos,
6970
}: TaskHeaderProps) => {
7071
const { t } = useTranslation()
71-
const { apiConfiguration, currentTaskItem, clineMessages, isBrowserSessionActive } = useExtensionState()
72+
const { apiConfiguration, currentTaskItem, clineMessages, isBrowserSessionActive, activeTerminalSessions } =
73+
useExtensionState()
7274
const { id: modelId, info: model } = useSelectedModel(apiConfiguration)
7375
const [isTaskExpanded, setIsTaskExpanded] = useState(false)
7476
const [showLongRunningTaskMessage, setShowLongRunningTaskMessage] = useState(false)
@@ -369,6 +371,30 @@ const TaskHeader = ({
369371
)}
370372
</div>
371373
)}
374+
{(activeTerminalSessions ?? 0) > 0 && (
375+
<div className="flex items-center gap-1" onClick={(e) => e.stopPropagation()}>
376+
<StandardTooltip
377+
content={t("chat:terminal.sessionsRunning", { count: activeTerminalSessions })}>
378+
<div
379+
className={cn(
380+
"relative flex items-center justify-center h-5 w-5 p-0",
381+
"text-vscode-foreground opacity-85",
382+
)}>
383+
<TerminalSquare
384+
className="w-4 h-4"
385+
style={{
386+
color: "#4ade80",
387+
}}
388+
/>
389+
</div>
390+
</StandardTooltip>
391+
<span
392+
className="text-sm font-medium"
393+
style={{ color: "var(--vscode-testing-iconPassed)" }}>
394+
{activeTerminalSessions}
395+
</span>
396+
</div>
397+
)}
372398
</div>
373399
)}
374400
{/* Expanded state: Show task text and images */}

webview-ui/src/context/__tests__/ExtensionStateContext.spec.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ describe("mergeExtensionState", () => {
219219
taskSyncEnabled: false,
220220
featureRoomoteControlEnabled: false,
221221
isBrowserSessionActive: false,
222+
activeTerminalSessions: 0,
222223
checkpointTimeout: DEFAULT_CHECKPOINT_TIMEOUT_SECONDS, // Add the checkpoint timeout property
223224
}
224225

webview-ui/src/i18n/locales/en/chat.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@
407407
"close": "Close browser"
408408
}
409409
},
410+
"terminal": {
411+
"sessionsRunning_one": "{{count}} terminal session running",
412+
"sessionsRunning_other": "{{count}} terminal sessions running",
413+
"sessionsRunning": "{{count}} terminal session(s) running"
414+
},
410415
"codeblock": {
411416
"tooltips": {
412417
"expand": "Expand code block",

0 commit comments

Comments
 (0)