Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(desktop): show live status indicators on chat tabs
Josuédcdd9444954b
diff --git a/desktop-app/ui/src/components/ChatTabs/ChatTabs.test.tsx b/desktop-app/ui/src/components/ChatTabs/ChatTabs.test.tsxindex 92718a95d..7e1a824cc 100644--- a/desktop-app/ui/src/components/ChatTabs/ChatTabs.test.tsx+++ b/desktop-app/ui/src/components/ChatTabs/ChatTabs.test.tsx@@ -1,8 +1,11 @@// @vitest-environment jsdomimport { afterEach, describe, expect, it, vi } from 'vitest'+import { makeTaskKey } from '@contexts/AgentTaskTrackerContext/types'+import { ChatListProvider } from '@contexts/ChatListContext'import { cleanup, fireEvent, render, screen } from '@testing-library/react'import { readFileSync } from 'node:fs'import path from 'node:path'+import { createSessionFsmStore, projectSessionState } from '@hooks/domain/sessionFsm'import { ChatTabs } from '.'afterEach(cleanup)@@ -57,4 +60,70 @@ describe('ChatTabs', () => {expect(styles).toMatch(/\.chat-view-tab__select\s*\{[^}]*flex:\s*1 1 auto;/s)expect(styles).toMatch(/\.chat-view-tab__label\s*\{[^}]*text-overflow:\s*ellipsis;/s)})++ it('shows existing running and approval indicators before their tab names', () => {+ const runningKey = makeTaskKey('alpha', 'chat-running')+ const approvalKey = makeTaskKey('beta', 'chat-approval')+ const fsm = createSessionFsmStore()+ fsm.dispatch(runningKey, { type: 'SEND_STARTED', taskId: 'task-running' })+ fsm.dispatch(runningKey, { type: 'TASK_CREATED', taskId: 'task-running' })+ fsm.dispatch(approvalKey, { type: 'SEND_STARTED', taskId: 'task-approval' })+ fsm.dispatch(approvalKey, { type: 'TASK_CREATED', taskId: 'task-approval' })+ fsm.dispatch(approvalKey, {+ type: 'STREAM_SUSPENDED',+ taskId: 'task-approval',+ approval: { requestId: 'request-1', displayName: 'Run shell' },+ })+ const sessionStateByChatKey = Object.fromEntries(+ Object.entries(fsm.getSnapshot()).map(([key, state]) => [key, projectSessionState(state)])+ )++ render(+ <ChatListProvider+ value={{+ activeChatId: 'chat-running',+ chatList: [],+ chatListLoading: false,+ latestChatSessions: [],+ latestChatSessionsLoading: false,+ sessionStateByChatId: {},+ sessionStateByChatKey,+ }}+ >+ <ChatTabs+ tabs={[+ {+ id: 'running',+ agentRef: 'alpha',+ chatId: 'chat-running',+ title: 'Running chat',+ },+ {+ id: 'approval',+ agentRef: 'beta',+ chatId: 'chat-approval',+ title: 'Approval chat',+ },+ { id: 'blank', agentRef: 'alpha', chatId: null, title: 'New chat' },+ ]}+ activeTabId="running"+ onSelect={vi.fn()}+ onClose={vi.fn()}+ />+ </ChatListProvider>+ )++ const running = screen.getByLabelText('Running')+ const awaitingApproval = screen.getByLabelText('Awaiting approval')+ const runningLabel = screen.getByText('Running chat')+ const approvalLabel = screen.getByText('Approval chat')++ expect(screen.getByRole('button', { name: 'Running chat' }).contains(running)).toBe(true)+ expect(screen.getByRole('button', { name: 'Approval chat' }).contains(awaitingApproval)).toBe(+ true+ )+ expect(running.nextElementSibling).toBe(runningLabel)+ expect(awaitingApproval.nextElementSibling).toBe(approvalLabel)+ expect(screen.getAllByRole('status')).toHaveLength(2)+ })})diff --git a/desktop-app/ui/src/components/ChatTabs/index.tsx b/desktop-app/ui/src/components/ChatTabs/index.tsxindex 84ca6d988..b38b35d86 100644--- a/desktop-app/ui/src/components/ChatTabs/index.tsx+++ b/desktop-app/ui/src/components/ChatTabs/index.tsx@@ -1,17 +1,28 @@+import { useContext } from 'react'+import { makeTaskKey } from '@contexts/AgentTaskTrackerContext/types'+import { ChatListContext } from '@contexts/ChatListContext'import { Button } from '@components/Common'+import { ChatStateBadge } from '@components/agents/ChatStateBadge'import type { ChatTabsProps } from './types'export function ChatTabs({ tabs, activeTabId, onSelect, onClose, panelId }: ChatTabsProps) {+ const chatList = useContext(ChatListContext)+return (<div className="chat-view-tabs" role="toolbar" aria-label="Chat tabs"><div className="chat-view-tabs__list">{tabs.map(tab => {const active = tab.id === activeTabId+ const sessionState =+ tab.agentRef && tab.chatId+ ? chatList?.sessionStateByChatKey[makeTaskKey(tab.agentRef, tab.chatId)]+ : undefinedreturn (<div className={`chat-view-tab${active ? ' is-active' : ''}`} key={tab.id}><Buttonalign="start"aria-controls={active ? panelId : undefined}+ aria-label={tab.title}aria-pressed={active}className="chat-view-tab__select"color="neutral"@@ -19,6 +30,7 @@ export function ChatTabs({ tabs, activeTabId, onSelect, onClose, panelId }: Chatsize="sm"variant="ghost">+ <ChatStateBadge sessionState={sessionState} unreadTerminal={false} /><span className="chat-view-tab__label">{tab.title}</span></Button><Button