π OpenHands: AI-Driven Development
feat: show live agent activity in chat (#16110)
Chanhyo Jung2feab551c4c1
diff --git a/__tests__/components/chat/chat-interface.test.tsx b/__tests__/components/chat/chat-interface.test.tsxindex 7139fae2c8..ffcb8c09fa 100644--- a/__tests__/components/chat/chat-interface.test.tsx+++ b/__tests__/components/chat/chat-interface.test.tsx@@ -1,12 +1,4 @@-import {- afterEach,- beforeEach,- describe,- expect,- it,- test,- vi,-} from "vitest";+import { afterEach, beforeEach, describe, expect, it, test, vi } from "vitest";import {fireEvent,render,@@ -27,7 +19,11 @@ import { useErrorMessageStore } from "#/stores/error-message-store";import { useOptimisticUserMessageStore } from "#/stores/optimistic-user-message-store";import { useConfig } from "#/hooks/query/use-config";import { useUnifiedUploadFiles } from "#/hooks/mutation/use-unified-upload-files";-import type { MessageEvent } from "#/types/agent-server/core";+import {+ SecurityRisk,+ type ActionEvent,+ type MessageEvent,+} from "#/types/agent-server/core";import { useEventStore } from "#/stores/use-event-store";import { useAgentState } from "#/hooks/use-agent-state";import { useLoadOlderEvents } from "#/hooks/use-load-older-events";@@ -256,11 +252,7 @@ describe("ChatInterface - Chat Suggestions", () => {},});- renderWithQueryClient(- <ChatInterface />,- queryClient,- "/task-abc",- );+ renderWithQueryClient(<ChatInterface />, queryClient, "/task-abc");expect(screen.queryByTestId("chat-suggestions")).not.toBeInTheDocument();});@@ -282,11 +274,7 @@ describe("ChatInterface - Chat Suggestions", () => {},});- renderWithQueryClient(- <ChatInterface />,- queryClient,- "/task-abc",- );+ renderWithQueryClient(<ChatInterface />, queryClient, "/task-abc");expect(screen.queryByTestId("chat-suggestions")).not.toBeInTheDocument();});@@ -884,6 +872,59 @@ describe("ChatInterface - Auto-scroll on submit (issue #817)", () => {});describe("ChatInterface - Status Indicator", () => {+ it("shows the unresolved terminal action while the agent is running", () => {+ const terminalAction: ActionEvent = {+ id: "action-running-terminal",+ timestamp: "2026-07-27T18:00:00Z",+ source: "agent",+ thought: [],+ thinking_blocks: [],+ action: {+ kind: "TerminalAction",+ command: "git status",+ is_input: false,+ timeout: null,+ reset: false,+ },+ tool_name: "terminal",+ tool_call_id: "tool-running-terminal",+ tool_call: {+ id: "tool-running-terminal",+ type: "function",+ function: {+ name: "terminal",+ arguments: '{"command":"git status"}',+ },+ },+ llm_response_id: "response-running-terminal",+ security_risk: SecurityRisk.LOW,+ };+ useEventStore.setState({+ events: [terminalAction],+ eventIds: new Set([terminalAction.id]),+ uiEvents: [terminalAction],+ });+ vi.mocked(useAgentState).mockReturnValue({+ curAgentState: AgentState.RUNNING,+ });++ renderChatInterfaceWithRouter();++ const chip = screen.getByTestId("live-activity-chip");+ expect(chip).toHaveTextContent("ACTION_MESSAGE$RUN");+ expect(chip.parentElement).toHaveClass("inset-x-9");+ });++ it("hides the live activity chip when the agent is no longer running", () => {+ vi.mocked(useAgentState).mockReturnValue({+ curAgentState: AgentState.PAUSED,+ });++ renderChatInterfaceWithRouter();++ expect(screen.queryByTestId("live-activity-chip")).not.toBeInTheDocument();+ });+it("should render ChatStatusIndicator when agent is not awaiting user input / conversation is NOT ready", () => {vi.mocked(useAgentState).mockReturnValue({curAgentState: AgentState.LOADING,diff --git a/__tests__/components/features/chat/typing-indicator.test.ts b/__tests__/components/features/chat/typing-indicator.test.tsnew file mode 100644index 0000000000..2426b62e79--- /dev/null+++ b/__tests__/components/features/chat/typing-indicator.test.ts@@ -0,0 +1,294 @@+import { describe, expect, it } from "vitest";+import { deriveLiveActivity } from "#/components/features/chat/typing-indicator";+import {+ SecurityRisk,+ type ActionEvent,+ type ObservationEvent,+ type UserRejectObservation,+} from "#/types/agent-server/core";+import type { Action } from "#/types/agent-server/core/base/action";+import type { ACPToolCallEvent } from "#/types/agent-server/core/events/acp-tool-call-event";+import type { OHEvent } from "#/stores/use-event-store";++const makeActionEvent = (+ id: string,+ action: Action,+ summary?: string,+): ActionEvent => ({+ id,+ timestamp: `2026-07-27T18:00:${id.padStart(2, "0")}Z`,+ source: "agent",+ thought: [],+ thinking_blocks: [],+ action,+ tool_name: action.kind,+ tool_call_id: `tool-${id}`,+ tool_call: {+ id: `tool-${id}`,+ type: "function",+ function: {+ name: action.kind,+ arguments: "{}",+ },+ },+ llm_response_id: `response-${id}`,+ security_risk: SecurityRisk.LOW,+ summary,+});++const makeObservationEvent = (+ id: string,+ action: ActionEvent,+): ObservationEvent => ({+ id,+ timestamp: `2026-07-27T18:01:${id.padStart(2, "0")}Z`,+ source: "environment",+ tool_name: action.tool_name,+ tool_call_id: action.tool_call_id,+ action_id: action.id,+ observation: {+ kind: "TerminalObservation",+ content: [],+ command: "git status",+ exit_code: 0,+ is_error: false,+ timeout: false,+ metadata: {+ exit_code: 0,+ pid: 1,+ username: "openhands",+ hostname: "runtime",+ prefix: "",+ suffix: "",+ working_dir: "/workspace/project",+ py_interpreter_path: null,+ },+ },+});++const makeUserRejectObservation = (+ id: string,+ action: ActionEvent,+): UserRejectObservation => ({+ id,+ timestamp: `2026-07-27T18:01:${id.padStart(2, "0")}Z`,+ source: "environment",+ tool_name: action.tool_name,+ tool_call_id: action.tool_call_id,+ action_id: action.id,+ rejection_reason: "Rejected by user",+});++const makeACPEvent = (+ id: string,+ status: ACPToolCallEvent["status"],+): ACPToolCallEvent => ({+ id: `${id}-${status ?? "legacy"}`,+ timestamp: "2026-07-27T18:02:00Z",+ kind: "ACPToolCallEvent",+ source: "agent",+ tool_call_id: id,+ title: "Read README.md",+ status,+ tool_kind: "read",+ raw_input: null,+ raw_output: null,+ content: null,+ is_error: status === "failed",+});++describe("deriveLiveActivity", () => {+ it.each([+ {+ name: "terminal command",+ action: {+ kind: "TerminalAction",+ command: "git status",+ is_input: false,+ timeout: null,+ reset: false,+ } satisfies Action,+ expected: {+ kind: "translation",+ key: "ACTION_MESSAGE$RUN",+ values: { command: "git status" },+ },+ },+ {+ name: "file read",+ action: {+ kind: "FileEditorAction",+ command: "view",+ path: "README.md",+ file_text: null,+ old_str: null,+ new_str: null,+ insert_line: null,+ view_range: null,+ } satisfies Action,+ expected: {+ kind: "translation",+ key: "ACTION_MESSAGE$READ",+ values: { path: "README.md" },+ },+ },+ {+ name: "code search",+ action: {+ kind: "GrepAction",+ pattern: "VITE_",+ path: null,+ include: null,+ } satisfies Action,+ expected: {+ kind: "translation",+ key: "ACTION_MESSAGE$GREP",+ values: { pattern: "VITE_" },+ },+ },+ ])("describes an unresolved $name", ({ action, expected }) => {+ const event = makeActionEvent("1", action);++ expect(deriveLiveActivity([event])).toEqual(expected);+ });++ it("moves to the next unresolved regular action as observations arrive", () => {+ const first = makeActionEvent("1", {+ kind: "TerminalAction",+ command: "npm test",+ is_input: false,+ timeout: null,+ reset: false,+ });+ const second = makeActionEvent("2", {+ kind: "FileEditorAction",+ command: "view",+ path: "README.md",+ file_text: null,+ old_str: null,+ new_str: null,+ insert_line: null,+ view_range: null,+ });+ const secondObservation = makeObservationEvent("3", second);+ const firstObservation = makeObservationEvent("4", first);++ expect(deriveLiveActivity([first, second, secondObservation])).toEqual({+ kind: "translation",+ key: "ACTION_MESSAGE$RUN",+ values: { command: "npm test" },+ });+ expect(+ deriveLiveActivity([first, second, secondObservation, firstObservation]),+ ).toEqual({+ kind: "translation",+ key: "ACTION_MESSAGE$THINK",+ values: {},+ });+ });++ it("treats a rejected regular action as resolved", () => {+ const rejected = makeActionEvent("1", {+ kind: "TerminalAction",+ command: "rm -rf build",+ is_input: false,+ timeout: null,+ reset: false,+ });++ expect(+ deriveLiveActivity([rejected, makeUserRejectObservation("2", rejected)]),+ ).toEqual({+ kind: "translation",+ key: "ACTION_MESSAGE$THINK",+ values: {},+ });+ });++ it("shows the next unresolved action after a newer action is rejected", () => {+ const remaining = makeActionEvent("1", {+ kind: "TerminalAction",+ command: "git status",+ is_input: false,+ timeout: null,+ reset: false,+ });+ const rejected = makeActionEvent("2", {+ kind: "TerminalAction",+ command: "npm publish",+ is_input: false,+ timeout: null,+ reset: false,+ });++ expect(+ deriveLiveActivity([+ remaining,+ rejected,+ makeUserRejectObservation("3", rejected),+ ]),+ ).toEqual({+ kind: "translation",+ key: "ACTION_MESSAGE$RUN",+ values: { command: "git status" },+ });+ });++ it.each([+ "completed",+ "failed",+ null,+ ] satisfies readonly ACPToolCallEvent["status"][])(+ "drops an ACP label when the same call becomes %s",+ (terminalStatus) => {+ const started = makeACPEvent("acp-read", "in_progress");++ expect(deriveLiveActivity([started])).toEqual({+ kind: "translation",+ key: "ACTION_MESSAGE$ACP_READ",+ values: { title: "README.md" },+ });+ expect(+ deriveLiveActivity([started, makeACPEvent("acp-read", terminalStatus)]),+ ).toEqual({+ kind: "translation",+ key: "ACTION_MESSAGE$THINK",+ values: {},+ });+ },+ );++ it("falls back to Thinking for unsupported and planning-only actions", () => {+ const unsupported = makeActionEvent("1", {+ kind: "SwitchLLMAction",+ profile_name: "fast",+ reason: "Short task",+ });+ const planningOnly = {+ ...makeActionEvent("2", {+ kind: "TerminalAction",+ command: "git status",+ is_input: false,+ timeout: null,+ reset: false,+ }),+ isFromPlanningAgent: true,+ } satisfies OHEvent;++ expect(deriveLiveActivity([unsupported])).toEqual({+ kind: "translation",+ key: "ACTION_MESSAGE$THINK",+ values: {},+ });+ expect(deriveLiveActivity([planningOnly])).toEqual({+ kind: "translation",+ key: "ACTION_MESSAGE$THINK",+ values: {},+ });+ expect(deriveLiveActivity([])).toEqual({+ kind: "translation",+ key: "ACTION_MESSAGE$THINK",+ values: {},+ });+ });+});diff --git a/src/components/conversation-events/chat/event-content-helpers/get-action-event-title.ts b/src/components/conversation-events/chat/event-content-helpers/get-action-event-title.tsnew file mode 100644index 0000000000..9e49321606--- /dev/null+++ b/src/components/conversation-events/chat/event-content-helpers/get-action-event-title.ts@@ -0,0 +1,140 @@+import { CANVAS_UI_CLIENT_ACTION_KIND } from "#/constants/canvas-ui";+import type { ActionEvent } from "#/types/agent-server/core";++export type EventTitleDescriptor =+ | {+ readonly kind: "translation";+ readonly key: string;+ readonly values: Readonly<Record<string, unknown>>;+ }+ | {+ readonly kind: "text";+ readonly text: string;+ };++export const trimEventTitleText = (text: string, maxLength: number): string => {+ if (!text) return "";+ return text.length > maxLength ? `${text.substring(0, maxLength)}...` : text;+};++const isServerFallbackSummary = (summary: string): boolean =>+ /^[a-z][a-z0-9_]*\s*:\s*[[{]/i.test(summary);++export const getActionSummaryTitle = (event: ActionEvent): string | null => {+ const summary = event.summary?.trim().replace(/\s+/g, " ") || "";+ return !summary || isServerFallbackSummary(summary) ? null : summary;+};++export const getActionEventTitleDescriptor = (+ event: ActionEvent,+): EventTitleDescriptor => {+ const summary = getActionSummaryTitle(event);+ if (summary) {+ return { kind: "text", text: summary };+ }++ const actionType = event.action.kind;++ switch (actionType) {+ case "ExecuteBashAction":+ case "TerminalAction":+ return {+ kind: "translation",+ key: "ACTION_MESSAGE$RUN",+ values: { command: trimEventTitleText(event.action.command, 80) },+ };+ case "FileEditorAction":+ case "StrReplaceEditorAction": {+ const key =+ event.action.command === "view"+ ? "ACTION_MESSAGE$READ"+ : event.action.command === "create"+ ? "ACTION_MESSAGE$WRITE"+ : "ACTION_MESSAGE$EDIT";+ return {+ kind: "translation",+ key,+ values: { path: event.action.path },+ };+ }+ case "MCPToolAction":+ return {+ kind: "translation",+ key: "ACTION_MESSAGE$CALL_TOOL_MCP",+ values: { mcp_tool_name: event.tool_name },+ };+ case "InvokeSkillAction":+ return {+ kind: "translation",+ key: "ACTION_MESSAGE$INVOKE_SKILL",+ values: { name: event.action.name },+ };+ case "TaskAction":+ return {+ kind: "translation",+ key: "ACTION_MESSAGE$TASK",+ values: { name: event.action.subagent_type },+ };+ case "ThinkAction":+ return {+ kind: "translation",+ key: "ACTION_MESSAGE$THINK",+ values: {},+ };+ case "FinishAction":+ return {+ kind: "translation",+ key: "ACTION_MESSAGE$FINISH",+ values: {},+ };+ case "TaskTrackerAction":+ return {+ kind: "translation",+ key: "ACTION_MESSAGE$TASK_TRACKING",+ values: {},+ };+ case "GrepAction":+ return {+ kind: "translation",+ key: "ACTION_MESSAGE$GREP",+ values: {+ pattern: event.action.pattern+ ? trimEventTitleText(event.action.pattern, 50)+ : "",+ },+ };+ case "GlobAction":+ return {+ kind: "translation",+ key: "ACTION_MESSAGE$GLOB",+ values: {+ pattern: event.action.pattern+ ? trimEventTitleText(event.action.pattern, 50)+ : "",+ },+ };+ case "BrowserNavigateAction":+ case "BrowserClickAction":+ case "BrowserTypeAction":+ case "BrowserGetStateAction":+ case "BrowserGetContentAction":+ case "BrowserScrollAction":+ case "BrowserGoBackAction":+ case "BrowserListTabsAction":+ case "BrowserSwitchTabAction":+ case "BrowserCloseTabAction":+ return {+ kind: "translation",+ key: "ACTION_MESSAGE$BROWSE",+ values: {},+ };+ case "CanvasUIAction":+ case CANVAS_UI_CLIENT_ACTION_KIND:+ return { kind: "text", text: "CANVASUI" };+ default:+ return {+ kind: "text",+ text: String(actionType).replace("Action", "").toUpperCase(),+ };+ }+};diff --git a/src/components/conversation-events/chat/event-content-helpers/get-event-content.tsx b/src/components/conversation-events/chat/event-content-helpers/get-event-content.tsxindex e5f96f2c1d..e8dd3d840d 100644--- a/src/components/conversation-events/chat/event-content-helpers/get-event-content.tsx+++ b/src/components/conversation-events/chat/event-content-helpers/get-event-content.tsx@@ -1,9 +1,6 @@import { Trans } from "react-i18next";import React from "react";-import {- CANVAS_UI_CLIENT_ACTION_KIND,- CANVAS_UI_CLIENT_TOOL_NAME,-} from "#/constants/canvas-ui";+import { CANVAS_UI_CLIENT_TOOL_NAME } from "#/constants/canvas-ui";import {OpenHandsEvent,ObservationEvent,@@ -30,16 +27,17 @@ import { SkillReadyEvent, isSkillReadyEvent } from "./create-skill-ready-event";import { resolveVisualizerBody } from "../../../features/chat/tool-visualizers/dispatcher";import i18n from "#/i18n";import { I18nKey } from "#/i18n/declaration";--const trimText = (text: string, maxLength: number): string => {- if (!text) return "";- return text.length > maxLength ? `${text.substring(0, maxLength)}...` : text;-};+import {+ getActionEventTitleDescriptor,+ getActionSummaryTitle,+ trimEventTitleText,+ type EventTitleDescriptor,+} from "./get-action-event-title";// Helper function to create title from translation keyconst createTitleFromKey = (key: string,- values: Record<string, unknown>,+ values: Readonly<Record<string, unknown>>,): React.ReactNode => {if (!i18n.exists(key)) {return key;@@ -58,26 +56,12 @@ const createTitleFromKey = ();};-/**- * Detects the agent-server's default summary fallback, which has the shape- * `{tool_name}: {json-args}` (see `_extract_summary` in- * `openhands/sdk/agent/agent.py`). When the LLM omits a summary the server- * dumps the raw arguments JSON, which renders as a huge unreadable blob in- * the chat. Treat that case as "no summary" so the action-kind specific- * title (e.g. "Editing <path>", "Running <cmd>") is used instead.- */-const isServerFallbackSummary = (summary: string): boolean =>- /^[a-z][a-z0-9_]*\s*:\s*[[{]/i.test(summary);--const getSummaryTitleForActionEvent = (- event: ActionEvent,-): React.ReactNode | null => {- const summary = event.summary?.trim().replace(/\s+/g, " ") || "";- if (!summary || isServerFallbackSummary(summary)) {- return null;- }- return summary;-};+const renderTitleDescriptor = (+ descriptor: EventTitleDescriptor,+): React.ReactNode =>+ descriptor.kind === "text"+ ? descriptor.text+ : createTitleFromKey(descriptor.key, descriptor.values);const getNonEmptyString = (value: unknown,@@ -92,7 +76,7 @@ const getNonEmptyString = (return null;}- return maxLength ? trimText(trimmed, maxLength) : trimmed;+ return maxLength ? trimEventTitleText(trimmed, maxLength) : trimmed;};const getVisionInspectActionTitle = (@@ -154,106 +138,7 @@ const getActionEventTitle = (event: OpenHandsEvent): React.ReactNode => {return visionInspectTitle;}- const summaryTitle = getSummaryTitleForActionEvent(event);- if (summaryTitle) {- return summaryTitle;- }-- const actionType = event.action.kind;- let actionKey = "";- let actionValues: Record<string, unknown> = {};-- switch (actionType) {- case "ExecuteBashAction":- case "TerminalAction":- actionKey = "ACTION_MESSAGE$RUN";- actionValues = {- command: trimText(event.action.command, 80),- };- break;- case "FileEditorAction":- case "StrReplaceEditorAction":- if (event.action.command === "view") {- actionKey = "ACTION_MESSAGE$READ";- } else if (event.action.command === "create") {- actionKey = "ACTION_MESSAGE$WRITE";- } else {- actionKey = "ACTION_MESSAGE$EDIT";- }- actionValues = {- path: event.action.path,- };- break;- case "MCPToolAction":- actionKey = "ACTION_MESSAGE$CALL_TOOL_MCP";- actionValues = {- mcp_tool_name: event.tool_name,- };- break;- case "InvokeSkillAction":- actionKey = "ACTION_MESSAGE$INVOKE_SKILL";- actionValues = {- name: event.action.name,- };- break;- case "TaskAction":- actionKey = "ACTION_MESSAGE$TASK";- actionValues = {- name: event.action.subagent_type,- };- break;- case "ThinkAction":- actionKey = "ACTION_MESSAGE$THINK";- break;- case "FinishAction":- actionKey = "ACTION_MESSAGE$FINISH";- break;- case "TaskTrackerAction":- actionKey = "ACTION_MESSAGE$TASK_TRACKING";- break;- case "GrepAction":- actionKey = "ACTION_MESSAGE$GREP";- actionValues = {- pattern:- "pattern" in event.action && event.action.pattern- ? trimText(String(event.action.pattern), 50)- : "",- };- break;- case "GlobAction":- actionKey = "ACTION_MESSAGE$GLOB";- actionValues = {- pattern:- "pattern" in event.action && event.action.pattern- ? trimText(String(event.action.pattern), 50)- : "",- };- break;- case "BrowserNavigateAction":- case "BrowserClickAction":- case "BrowserTypeAction":- case "BrowserGetStateAction":- case "BrowserGetContentAction":- case "BrowserScrollAction":- case "BrowserGoBackAction":- case "BrowserListTabsAction":- case "BrowserSwitchTabAction":- case "BrowserCloseTabAction":- actionKey = "ACTION_MESSAGE$BROWSE";- break;- case "CanvasUIAction":- case CANVAS_UI_CLIENT_ACTION_KIND:- return "CANVASUI";- default:- // For unknown actions, use the type name- return String(actionType).replace("Action", "").toUpperCase();- }-- if (actionKey) {- return createTitleFromKey(actionKey, actionValues);- }-- return actionType;+ return renderTitleDescriptor(getActionEventTitleDescriptor(event));};// Observation Event Processing@@ -280,7 +165,7 @@ const getObservationEventTitle = (return visionInspectTitle;}- const summaryTitle = getSummaryTitleForActionEvent(correspondingAction);+ const summaryTitle = getActionSummaryTitle(correspondingAction);if (summaryTitle) {return summaryTitle;}@@ -296,7 +181,7 @@ const getObservationEventTitle = (observationKey = "OBSERVATION_MESSAGE$RUN";observationValues = {command: event.observation.command- ? trimText(event.observation.command, 80)+ ? trimEventTitleText(event.observation.command, 80): "",};break;@@ -366,7 +251,7 @@ const getObservationEventTitle = (observationKey = "OBSERVATION_MESSAGE$GLOB";observationValues = {pattern: event.observation.pattern- ? trimText(event.observation.pattern, 50)+ ? trimEventTitleText(event.observation.pattern, 50): "",};break;@@ -374,7 +259,7 @@ const getObservationEventTitle = (observationKey = "OBSERVATION_MESSAGE$GREP";observationValues = {pattern: event.observation.pattern- ? trimText(event.observation.pattern, 50)+ ? trimEventTitleText(event.observation.pattern, 50): "",};break;diff --git a/src/components/features/chat/chat-interface.tsx b/src/components/features/chat/chat-interface.tsxindex 4f5db98fe1..72c80ba4ec 100644--- a/src/components/features/chat/chat-interface.tsx+++ b/src/components/features/chat/chat-interface.tsx@@ -624,8 +624,8 @@ export function ChatInterface() {</div>) : (curAgentState === AgentState.RUNNING && (- <div className="absolute left-1/2 transform -translate-x-1/2 bottom-0 pointer-events-auto">- <TypingIndicator />+ <div className="pointer-events-none absolute inset-x-9 bottom-0 flex justify-center">+ <TypingIndicator events={allConversationEvents} /></div>))}diff --git a/src/components/features/chat/typing-indicator.tsx b/src/components/features/chat/typing-indicator.tsxindex 92a363ad75..8aaf0486df 100644--- a/src/components/features/chat/typing-indicator.tsx+++ b/src/components/features/chat/typing-indicator.tsx@@ -1,9 +1,161 @@-export function TypingIndicator() {+import { Trans } from "react-i18next";+import type { OHEvent } from "#/stores/use-event-store";+import type { UserRejectObservation } from "#/types/agent-server/core";+import {+ isACPToolCallEvent,+ isActionEvent,+ isAgentErrorEvent,+ isObservationEvent,+} from "#/types/agent-server/type-guards";+import {+ getACPToolCallTitleKey,+ stripRedundantTitlePrefix,+} from "#/components/conversation-events/chat/event-content-helpers/get-acp-tool-call-content";+import {+ getActionEventTitleDescriptor,+ getActionSummaryTitle,+ type EventTitleDescriptor,+} from "#/components/conversation-events/chat/event-content-helpers/get-action-event-title";+import { MonoComponent } from "./mono-component";+import { PathComponent } from "./path-component";++const THINKING_ACTIVITY: EventTitleDescriptor = {+ kind: "translation",+ key: "ACTION_MESSAGE$THINK",+ values: {},+};++const LIVE_ACTION_KINDS = new Set([+ "ExecuteBashAction",+ "TerminalAction",+ "FileEditorAction",+ "StrReplaceEditorAction",+ "MCPToolAction",+ "InvokeSkillAction",+ "TaskAction",+ "ThinkAction",+ "TaskTrackerAction",+ "GrepAction",+ "GlobAction",+ "BrowserNavigateAction",+ "BrowserClickAction",+ "BrowserTypeAction",+ "BrowserGetStateAction",+ "BrowserGetContentAction",+ "BrowserScrollAction",+ "BrowserGoBackAction",+ "BrowserListTabsAction",+ "BrowserSwitchTabAction",+ "BrowserCloseTabAction",+]);++const getLiveActionTitle = (event: OHEvent): EventTitleDescriptor | null => {+ if (!isActionEvent(event)) return null;++ const summary = getActionSummaryTitle(event);+ if (summary) {+ return { kind: "text", text: summary };+ }++ return LIVE_ACTION_KINDS.has(event.action.kind)+ ? getActionEventTitleDescriptor(event)+ : null;+};++const isUserRejectObservation = (+ event: OHEvent,+): event is UserRejectObservation =>+ event.source === "environment" && "rejection_reason" in event;++export const deriveLiveActivity = (+ events: readonly OHEvent[],+): EventTitleDescriptor => {+ const resolvedActionIds = new Set<string>();+ const resolvedToolCallIds = new Set<string>();++ for (let index = events.length - 1; index >= 0; index -= 1) {+ const event = events[index];+ if (event.isFromPlanningAgent) {+ continue;+ }++ if (isObservationEvent(event) || isUserRejectObservation(event)) {+ resolvedActionIds.add(event.action_id);+ resolvedToolCallIds.add(event.tool_call_id);+ continue;+ }++ if (isAgentErrorEvent(event)) {+ resolvedToolCallIds.add(event.tool_call_id);+ continue;+ }++ if (isACPToolCallEvent(event)) {+ const isInProgress =+ event.status === "pending" || event.status === "in_progress";+ if (!isInProgress) {+ resolvedToolCallIds.add(event.tool_call_id);+ continue;+ }+ if (resolvedToolCallIds.has(event.tool_call_id)) {+ continue;+ }++ const title = stripRedundantTitlePrefix(event);+ return title+ ? {+ kind: "translation",+ key: getACPToolCallTitleKey(event),+ values: { title },+ }+ : THINKING_ACTIVITY;+ }++ if (+ isActionEvent(event) &&+ !resolvedActionIds.has(event.id) &&+ !resolvedToolCallIds.has(event.tool_call_id)+ ) {+ return getLiveActionTitle(event) ?? THINKING_ACTIVITY;+ }+ }++ return THINKING_ACTIVITY;+};++interface TypingIndicatorProps {+ readonly events: readonly OHEvent[];+}++export function TypingIndicator({ events }: TypingIndicatorProps) {+ const activity = deriveLiveActivity(events);+return (- <div className="flex items-center space-x-1.5 rounded-full bg-[var(--oh-surface)] px-3 py-1.5">- <span className="h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:0ms]" />- <span className="h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:75ms]" />- <span className="h-1.5 w-1.5 rounded-full bg-[var(--oh-muted)] animate-[bounce_0.5s_infinite] translate-y-[1px] [animation-delay:150ms]" />+ <div+ className="flex min-w-0 max-w-full items-center gap-2 rounded-full border border-[var(--oh-border)] bg-[var(--oh-surface)] px-3 py-1.5 text-xs text-[var(--oh-text-secondary)]"+ data-testid="live-activity-chip"+ role="status"+ aria-live="polite"+ >+ <span+ aria-hidden="true"+ className="size-1.5 shrink-0 animate-pulse rounded-full bg-[var(--oh-status-success)] motion-reduce:animate-none"+ />+ <span className="min-w-0 truncate">+ {activity.kind === "text" ? (+ activity.text+ ) : (+ <Trans+ ns="openhands"+ i18nKey={activity.key}+ values={activity.values}+ components={{+ path: <PathComponent />,+ cmd: <MonoComponent />,+ }}+ />+ )}+ </span></div>);}