bingocode 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/bingo-win.cjs +34 -3
- package/desktop/README.md +30 -0
- package/desktop/bunfig.toml +1 -0
- package/desktop/index.html +17 -0
- package/desktop/package.json +55 -0
- package/desktop/pnpm-lock.yaml +3832 -0
- package/desktop/public/app-icon.jpg +0 -0
- package/desktop/public/fonts/inter-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/inter-latin.woff2 +0 -0
- package/desktop/public/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/jetbrains-mono-latin.woff2 +0 -0
- package/desktop/public/fonts/manrope-latin-ext.woff2 +0 -0
- package/desktop/public/fonts/manrope-latin.woff2 +0 -0
- package/desktop/public/fonts/material-symbols-outlined.woff2 +0 -0
- package/desktop/public/icons/bilibili.svg +1 -0
- package/desktop/public/icons/douyin.svg +1 -0
- package/desktop/public/icons/github.svg +3 -0
- package/desktop/public/icons/xiaohongshu.svg +1 -0
- package/desktop/scripts/build-macos-arm64.sh +270 -0
- package/desktop/scripts/build-sidecars.ts +183 -0
- package/desktop/scripts/build-windows-x64.ps1 +295 -0
- package/desktop/scripts/scan-missing-imports.ts +235 -0
- package/desktop/sidecars/claude-sidecar.ts +156 -0
- package/desktop/src/App.tsx +5 -0
- package/desktop/src/__tests__/agentsSettings.test.tsx +349 -0
- package/desktop/src/__tests__/pages.test.tsx +290 -0
- package/desktop/src/__tests__/skillsSettings.test.tsx +205 -0
- package/desktop/src/api/adapters.ts +12 -0
- package/desktop/src/api/agents.ts +36 -0
- package/desktop/src/api/cliTasks.ts +28 -0
- package/desktop/src/api/client.ts +63 -0
- package/desktop/src/api/computerUse.ts +76 -0
- package/desktop/src/api/filesystem.ts +30 -0
- package/desktop/src/api/hahaOAuth.ts +38 -0
- package/desktop/src/api/models.ts +28 -0
- package/desktop/src/api/providers.ts +63 -0
- package/desktop/src/api/search.ts +29 -0
- package/desktop/src/api/sessions.ts +56 -0
- package/desktop/src/api/settings.ts +20 -0
- package/desktop/src/api/skills.ts +19 -0
- package/desktop/src/api/tasks.ts +36 -0
- package/desktop/src/api/teams.ts +44 -0
- package/desktop/src/api/websocket.ts +164 -0
- package/desktop/src/components/chat/AskUserQuestion.tsx +268 -0
- package/desktop/src/components/chat/AssistantMessage.tsx +29 -0
- package/desktop/src/components/chat/AttachmentGallery.tsx +113 -0
- package/desktop/src/components/chat/ChatInput.tsx +622 -0
- package/desktop/src/components/chat/CodeViewer.tsx +161 -0
- package/desktop/src/components/chat/ComputerUsePermissionModal.test.tsx +174 -0
- package/desktop/src/components/chat/ComputerUsePermissionModal.tsx +311 -0
- package/desktop/src/components/chat/DiffViewer.tsx +157 -0
- package/desktop/src/components/chat/FileSearchMenu.tsx +198 -0
- package/desktop/src/components/chat/ImageGalleryModal.tsx +91 -0
- package/desktop/src/components/chat/InlineImageGallery.tsx +106 -0
- package/desktop/src/components/chat/InlineTaskSummary.tsx +60 -0
- package/desktop/src/components/chat/MermaidRenderer.test.tsx +98 -0
- package/desktop/src/components/chat/MermaidRenderer.tsx +361 -0
- package/desktop/src/components/chat/MessageActionBar.tsx +27 -0
- package/desktop/src/components/chat/MessageList.test.tsx +313 -0
- package/desktop/src/components/chat/MessageList.tsx +249 -0
- package/desktop/src/components/chat/PermissionDialog.tsx +262 -0
- package/desktop/src/components/chat/SessionTaskBar.test.tsx +99 -0
- package/desktop/src/components/chat/SessionTaskBar.tsx +159 -0
- package/desktop/src/components/chat/StreamingIndicator.tsx +41 -0
- package/desktop/src/components/chat/TerminalChrome.tsx +35 -0
- package/desktop/src/components/chat/ThinkingBlock.tsx +87 -0
- package/desktop/src/components/chat/ToolCallBlock.tsx +247 -0
- package/desktop/src/components/chat/ToolCallGroup.tsx +617 -0
- package/desktop/src/components/chat/ToolResultBlock.tsx +107 -0
- package/desktop/src/components/chat/UserMessage.tsx +38 -0
- package/desktop/src/components/chat/chatBlocks.test.tsx +136 -0
- package/desktop/src/components/chat/clipboard.ts +25 -0
- package/desktop/src/components/chat/composerUtils.test.ts +55 -0
- package/desktop/src/components/chat/composerUtils.ts +149 -0
- package/desktop/src/components/controls/ModelSelector.tsx +156 -0
- package/desktop/src/components/controls/PermissionModeSelector.tsx +229 -0
- package/desktop/src/components/layout/AppShell.tsx +107 -0
- package/desktop/src/components/layout/ContentRouter.tsx +27 -0
- package/desktop/src/components/layout/ProjectFilter.tsx +126 -0
- package/desktop/src/components/layout/Sidebar.test.tsx +158 -0
- package/desktop/src/components/layout/Sidebar.tsx +384 -0
- package/desktop/src/components/layout/StatusBar.tsx +31 -0
- package/desktop/src/components/layout/TabBar.test.tsx +136 -0
- package/desktop/src/components/layout/TabBar.tsx +318 -0
- package/desktop/src/components/layout/TitleBar.tsx +96 -0
- package/desktop/src/components/layout/WindowControls.test.tsx +69 -0
- package/desktop/src/components/layout/WindowControls.tsx +89 -0
- package/desktop/src/components/markdown/MarkdownRenderer.test.tsx +100 -0
- package/desktop/src/components/markdown/MarkdownRenderer.tsx +229 -0
- package/desktop/src/components/settings/ClaudeOfficialLogin.tsx +107 -0
- package/desktop/src/components/shared/Button.tsx +63 -0
- package/desktop/src/components/shared/CopyButton.tsx +58 -0
- package/desktop/src/components/shared/DirectoryPicker.tsx +316 -0
- package/desktop/src/components/shared/Dropdown.tsx +91 -0
- package/desktop/src/components/shared/Input.tsx +38 -0
- package/desktop/src/components/shared/Modal.tsx +65 -0
- package/desktop/src/components/shared/ProjectContextChip.tsx +30 -0
- package/desktop/src/components/shared/Spinner.tsx +30 -0
- package/desktop/src/components/shared/Textarea.tsx +38 -0
- package/desktop/src/components/shared/Toast.tsx +47 -0
- package/desktop/src/components/shared/UpdateChecker.tsx +90 -0
- package/desktop/src/components/skills/SkillDetail.test.tsx +89 -0
- package/desktop/src/components/skills/SkillDetail.tsx +403 -0
- package/desktop/src/components/skills/SkillList.tsx +254 -0
- package/desktop/src/components/tasks/DayOfWeekPicker.tsx +57 -0
- package/desktop/src/components/tasks/NewTaskModal.tsx +407 -0
- package/desktop/src/components/tasks/PromptEditor.tsx +74 -0
- package/desktop/src/components/tasks/TaskEmptyState.tsx +30 -0
- package/desktop/src/components/tasks/TaskList.tsx +46 -0
- package/desktop/src/components/tasks/TaskRow.tsx +253 -0
- package/desktop/src/components/tasks/TaskRunsPanel.tsx +195 -0
- package/desktop/src/components/teams/TeamStatusBar.tsx +147 -0
- package/desktop/src/config/providerPresets.ts +78 -0
- package/desktop/src/config/spinnerVerbs.ts +193 -0
- package/desktop/src/hooks/useKeyboardShortcuts.ts +60 -0
- package/desktop/src/i18n/index.ts +54 -0
- package/desktop/src/i18n/locales/en.ts +670 -0
- package/desktop/src/i18n/locales/zh.ts +670 -0
- package/desktop/src/lib/__tests__/cronDescribe.test.ts +93 -0
- package/desktop/src/lib/cronDescribe.ts +188 -0
- package/desktop/src/lib/desktopRuntime.ts +54 -0
- package/desktop/src/lib/parseRunOutput.ts +79 -0
- package/desktop/src/main.tsx +13 -0
- package/desktop/src/mocks/data.ts +202 -0
- package/desktop/src/pages/ActiveSession.test.tsx +181 -0
- package/desktop/src/pages/ActiveSession.tsx +219 -0
- package/desktop/src/pages/AdapterSettings.tsx +375 -0
- package/desktop/src/pages/AgentTeams.tsx +200 -0
- package/desktop/src/pages/ComputerUseSettings.tsx +420 -0
- package/desktop/src/pages/EmptySession.tsx +518 -0
- package/desktop/src/pages/NewTaskModal.tsx +346 -0
- package/desktop/src/pages/ScheduledTasks.tsx +66 -0
- package/desktop/src/pages/ScheduledTasksEmpty.tsx +152 -0
- package/desktop/src/pages/ScheduledTasksList.tsx +416 -0
- package/desktop/src/pages/SessionControls.tsx +460 -0
- package/desktop/src/pages/Settings.tsx +1448 -0
- package/desktop/src/pages/ToolInspection.tsx +235 -0
- package/desktop/src/stores/adapterStore.ts +106 -0
- package/desktop/src/stores/agentStore.ts +34 -0
- package/desktop/src/stores/chatStore.test.ts +505 -0
- package/desktop/src/stores/chatStore.ts +850 -0
- package/desktop/src/stores/cliTaskStore.ts +152 -0
- package/desktop/src/stores/hahaOAuthStore.test.ts +77 -0
- package/desktop/src/stores/hahaOAuthStore.ts +97 -0
- package/desktop/src/stores/providerStore.ts +101 -0
- package/desktop/src/stores/sessionStore.test.ts +63 -0
- package/desktop/src/stores/sessionStore.ts +102 -0
- package/desktop/src/stores/settingsStore.ts +120 -0
- package/desktop/src/stores/skillStore.ts +51 -0
- package/desktop/src/stores/tabStore.ts +169 -0
- package/desktop/src/stores/taskStore.ts +68 -0
- package/desktop/src/stores/teamStore.ts +344 -0
- package/desktop/src/stores/uiStore.ts +100 -0
- package/desktop/src/stores/updateStore.test.ts +71 -0
- package/desktop/src/stores/updateStore.ts +221 -0
- package/desktop/src/theme/globals.css +465 -0
- package/desktop/src/types/adapter.ts +33 -0
- package/desktop/src/types/chat.ts +152 -0
- package/desktop/src/types/cliTask.ts +24 -0
- package/desktop/src/types/provider.ts +62 -0
- package/desktop/src/types/session.ts +27 -0
- package/desktop/src/types/settings.ts +22 -0
- package/desktop/src/types/skill.ts +38 -0
- package/desktop/src/types/task.ts +56 -0
- package/desktop/src/types/team.ts +38 -0
- package/desktop/src-tauri/Cargo.lock +5549 -0
- package/desktop/src-tauri/Cargo.toml +20 -0
- package/desktop/src-tauri/app-icon.svg +13 -0
- package/desktop/src-tauri/build.rs +3 -0
- package/desktop/src-tauri/capabilities/default.json +106 -0
- package/desktop/src-tauri/icons/android/mipmap-anydpi-v26/ic_launcher.xml +5 -0
- package/desktop/src-tauri/icons/android/values/ic_launcher_background.xml +4 -0
- package/desktop/src-tauri/icons/icon.icns +0 -0
- package/desktop/src-tauri/icons/icon.ico +0 -0
- package/desktop/src-tauri/src/lib.rs +408 -0
- package/desktop/src-tauri/src/main.rs +6 -0
- package/desktop/src-tauri/tauri.conf.json +78 -0
- package/desktop/src-tauri/tauri.macos.conf.json +18 -0
- package/desktop/src-tauri/tauri.release-ci.json +5 -0
- package/desktop/src-tauri/tauri.windows.conf.json +16 -0
- package/desktop/src-tauri/windows-installer-hooks.nsh +17 -0
- package/desktop/tsconfig.json +25 -0
- package/desktop/vite.config.ts +26 -0
- package/desktop/vitest.config.ts +18 -0
- package/package.json +1 -1
- package/src/commands/desktop/desktop.tsx +9 -0
- package/src/commands/desktop/index.ts +26 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import '@testing-library/jest-dom'
|
|
4
|
+
import { act } from 'react'
|
|
5
|
+
|
|
6
|
+
vi.mock('../components/chat/MessageList', () => ({
|
|
7
|
+
MessageList: () => <div data-testid="message-list" />,
|
|
8
|
+
}))
|
|
9
|
+
|
|
10
|
+
vi.mock('../components/chat/ChatInput', () => ({
|
|
11
|
+
ChatInput: () => <div data-testid="chat-input" />,
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
vi.mock('../components/teams/TeamStatusBar', () => ({
|
|
15
|
+
TeamStatusBar: () => <div data-testid="team-status-bar" />,
|
|
16
|
+
}))
|
|
17
|
+
|
|
18
|
+
vi.mock('../components/chat/SessionTaskBar', () => ({
|
|
19
|
+
SessionTaskBar: () => <div data-testid="session-task-bar" />,
|
|
20
|
+
}))
|
|
21
|
+
|
|
22
|
+
import { ActiveSession } from './ActiveSession'
|
|
23
|
+
import { useChatStore } from '../stores/chatStore'
|
|
24
|
+
import { useCLITaskStore } from '../stores/cliTaskStore'
|
|
25
|
+
import { useSessionStore } from '../stores/sessionStore'
|
|
26
|
+
import { useTabStore } from '../stores/tabStore'
|
|
27
|
+
import { useTeamStore } from '../stores/teamStore'
|
|
28
|
+
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
vi.useRealTimers()
|
|
31
|
+
useTabStore.setState({ tabs: [], activeTabId: null })
|
|
32
|
+
useSessionStore.setState({ sessions: [], activeSessionId: null, isLoading: false, error: null })
|
|
33
|
+
useChatStore.setState({ sessions: {} })
|
|
34
|
+
useTeamStore.setState({ teams: [], activeTeam: null, memberColors: new Map(), error: null })
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
describe('ActiveSession task polling', () => {
|
|
38
|
+
it('refreshes CLI tasks repeatedly while a turn is active', async () => {
|
|
39
|
+
vi.useFakeTimers()
|
|
40
|
+
|
|
41
|
+
const sessionId = 'polling-session'
|
|
42
|
+
const originalCliTaskState = useCLITaskStore.getState()
|
|
43
|
+
const fetchSessionTasks = vi.fn().mockResolvedValue(undefined)
|
|
44
|
+
|
|
45
|
+
useCLITaskStore.setState({
|
|
46
|
+
sessionId,
|
|
47
|
+
tasks: [],
|
|
48
|
+
fetchSessionTasks,
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
useSessionStore.setState({
|
|
52
|
+
sessions: [{
|
|
53
|
+
id: sessionId,
|
|
54
|
+
title: 'Polling Session',
|
|
55
|
+
createdAt: '2026-04-10T00:00:00.000Z',
|
|
56
|
+
modifiedAt: '2026-04-10T00:00:00.000Z',
|
|
57
|
+
messageCount: 1,
|
|
58
|
+
projectPath: '',
|
|
59
|
+
workDir: null,
|
|
60
|
+
workDirExists: true,
|
|
61
|
+
}],
|
|
62
|
+
activeSessionId: sessionId,
|
|
63
|
+
isLoading: false,
|
|
64
|
+
error: null,
|
|
65
|
+
})
|
|
66
|
+
useTabStore.setState({
|
|
67
|
+
tabs: [{ sessionId, title: 'Polling Session', type: 'session', status: 'idle' }],
|
|
68
|
+
activeTabId: sessionId,
|
|
69
|
+
})
|
|
70
|
+
useChatStore.setState({
|
|
71
|
+
sessions: {
|
|
72
|
+
[sessionId]: {
|
|
73
|
+
messages: [],
|
|
74
|
+
chatState: 'thinking',
|
|
75
|
+
connectionState: 'connected',
|
|
76
|
+
streamingText: '',
|
|
77
|
+
streamingToolInput: '',
|
|
78
|
+
activeToolUseId: null,
|
|
79
|
+
activeToolName: null,
|
|
80
|
+
activeThinkingId: null,
|
|
81
|
+
pendingPermission: null,
|
|
82
|
+
pendingComputerUsePermission: null,
|
|
83
|
+
tokenUsage: { input_tokens: 0, output_tokens: 0 },
|
|
84
|
+
elapsedSeconds: 0,
|
|
85
|
+
statusVerb: '',
|
|
86
|
+
slashCommands: [],
|
|
87
|
+
agentTaskNotifications: {},
|
|
88
|
+
elapsedTimer: null,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const { unmount } = render(<ActiveSession />)
|
|
94
|
+
|
|
95
|
+
expect(fetchSessionTasks).toHaveBeenCalledWith(sessionId)
|
|
96
|
+
|
|
97
|
+
await act(async () => {
|
|
98
|
+
await vi.advanceTimersByTimeAsync(2200)
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
expect(
|
|
102
|
+
fetchSessionTasks.mock.calls.filter(([currentSessionId]) => currentSessionId === sessionId),
|
|
103
|
+
).toHaveLength(3)
|
|
104
|
+
|
|
105
|
+
unmount()
|
|
106
|
+
useCLITaskStore.setState(originalCliTaskState)
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('keeps member sessions interactive and skips leader task polling', () => {
|
|
110
|
+
const memberSessionId = 'team-member:security-reviewer@test-team'
|
|
111
|
+
const originalCliTaskState = useCLITaskStore.getState()
|
|
112
|
+
const fetchSessionTasks = vi.fn().mockResolvedValue(undefined)
|
|
113
|
+
|
|
114
|
+
useCLITaskStore.setState({
|
|
115
|
+
sessionId: null,
|
|
116
|
+
tasks: [],
|
|
117
|
+
fetchSessionTasks,
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
useTeamStore.setState({
|
|
121
|
+
teams: [],
|
|
122
|
+
activeTeam: {
|
|
123
|
+
name: 'test-team',
|
|
124
|
+
leadAgentId: 'team-lead@test-team',
|
|
125
|
+
leadSessionId: 'leader-session',
|
|
126
|
+
members: [
|
|
127
|
+
{
|
|
128
|
+
agentId: 'team-lead@test-team',
|
|
129
|
+
role: 'team-lead',
|
|
130
|
+
status: 'running',
|
|
131
|
+
sessionId: 'leader-session',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
agentId: 'security-reviewer@test-team',
|
|
135
|
+
role: 'security-reviewer',
|
|
136
|
+
status: 'running',
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
memberColors: new Map(),
|
|
141
|
+
error: null,
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
useTabStore.setState({
|
|
145
|
+
tabs: [{ sessionId: memberSessionId, title: 'security-reviewer', type: 'session', status: 'idle' }],
|
|
146
|
+
activeTabId: memberSessionId,
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
useChatStore.setState({
|
|
150
|
+
sessions: {
|
|
151
|
+
[memberSessionId]: {
|
|
152
|
+
messages: [],
|
|
153
|
+
chatState: 'thinking',
|
|
154
|
+
connectionState: 'connected',
|
|
155
|
+
streamingText: '',
|
|
156
|
+
streamingToolInput: '',
|
|
157
|
+
activeToolUseId: null,
|
|
158
|
+
activeToolName: null,
|
|
159
|
+
activeThinkingId: null,
|
|
160
|
+
pendingPermission: null,
|
|
161
|
+
pendingComputerUsePermission: null,
|
|
162
|
+
tokenUsage: { input_tokens: 0, output_tokens: 0 },
|
|
163
|
+
elapsedSeconds: 0,
|
|
164
|
+
statusVerb: '',
|
|
165
|
+
slashCommands: [],
|
|
166
|
+
agentTaskNotifications: {},
|
|
167
|
+
elapsedTimer: null,
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
const { queryByTestId, unmount } = render(<ActiveSession />)
|
|
173
|
+
|
|
174
|
+
expect(queryByTestId('chat-input')).toBeInTheDocument()
|
|
175
|
+
expect(queryByTestId('session-task-bar')).not.toBeInTheDocument()
|
|
176
|
+
expect(fetchSessionTasks).not.toHaveBeenCalled()
|
|
177
|
+
|
|
178
|
+
unmount()
|
|
179
|
+
useCLITaskStore.setState(originalCliTaskState)
|
|
180
|
+
})
|
|
181
|
+
})
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { useEffect, useMemo } from 'react'
|
|
2
|
+
import { useTabStore } from '../stores/tabStore'
|
|
3
|
+
import { useSessionStore } from '../stores/sessionStore'
|
|
4
|
+
import { useChatStore } from '../stores/chatStore'
|
|
5
|
+
import { useCLITaskStore } from '../stores/cliTaskStore'
|
|
6
|
+
import { useTeamStore } from '../stores/teamStore'
|
|
7
|
+
import { useTranslation } from '../i18n'
|
|
8
|
+
import { MessageList } from '../components/chat/MessageList'
|
|
9
|
+
import { ChatInput } from '../components/chat/ChatInput'
|
|
10
|
+
import { ComputerUsePermissionModal } from '../components/chat/ComputerUsePermissionModal'
|
|
11
|
+
import { TeamStatusBar } from '../components/teams/TeamStatusBar'
|
|
12
|
+
import { SessionTaskBar } from '../components/chat/SessionTaskBar'
|
|
13
|
+
|
|
14
|
+
const TASK_POLL_INTERVAL_MS = 1000
|
|
15
|
+
|
|
16
|
+
export function ActiveSession() {
|
|
17
|
+
const activeTabId = useTabStore((s) => s.activeTabId)
|
|
18
|
+
const sessions = useSessionStore((s) => s.sessions)
|
|
19
|
+
const connectToSession = useChatStore((s) => s.connectToSession)
|
|
20
|
+
const sessionState = useChatStore((s) => activeTabId ? s.sessions[activeTabId] : undefined)
|
|
21
|
+
const pendingComputerUsePermission = sessionState?.pendingComputerUsePermission ?? null
|
|
22
|
+
const fetchSessionTasks = useCLITaskStore((s) => s.fetchSessionTasks)
|
|
23
|
+
const trackedTaskSessionId = useCLITaskStore((s) => s.sessionId)
|
|
24
|
+
const hasIncompleteTasks = useCLITaskStore((s) => s.tasks.some((task) => task.status !== 'completed'))
|
|
25
|
+
const chatState = sessionState?.chatState ?? 'idle'
|
|
26
|
+
const tokenUsage = sessionState?.tokenUsage ?? { input_tokens: 0, output_tokens: 0 }
|
|
27
|
+
|
|
28
|
+
const session = sessions.find((s) => s.id === activeTabId)
|
|
29
|
+
const memberInfo = useTeamStore((s) => activeTabId ? s.getMemberBySessionId(activeTabId) : null)
|
|
30
|
+
const activeTeam = useTeamStore((s) => s.activeTeam)
|
|
31
|
+
const isMemberSession = !!memberInfo
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (activeTabId && !isMemberSession) {
|
|
35
|
+
connectToSession(activeTabId)
|
|
36
|
+
}
|
|
37
|
+
}, [activeTabId, isMemberSession, connectToSession])
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!activeTabId || isMemberSession) return
|
|
41
|
+
|
|
42
|
+
const shouldPollTasks =
|
|
43
|
+
chatState !== 'idle' ||
|
|
44
|
+
(trackedTaskSessionId === activeTabId && hasIncompleteTasks)
|
|
45
|
+
|
|
46
|
+
if (!shouldPollTasks) return
|
|
47
|
+
|
|
48
|
+
void fetchSessionTasks(activeTabId)
|
|
49
|
+
|
|
50
|
+
const timer = setInterval(() => {
|
|
51
|
+
void fetchSessionTasks(activeTabId)
|
|
52
|
+
}, TASK_POLL_INTERVAL_MS)
|
|
53
|
+
|
|
54
|
+
return () => clearInterval(timer)
|
|
55
|
+
}, [
|
|
56
|
+
activeTabId,
|
|
57
|
+
isMemberSession,
|
|
58
|
+
chatState,
|
|
59
|
+
trackedTaskSessionId,
|
|
60
|
+
hasIncompleteTasks,
|
|
61
|
+
fetchSessionTasks,
|
|
62
|
+
])
|
|
63
|
+
|
|
64
|
+
const t = useTranslation()
|
|
65
|
+
const messages = sessionState?.messages ?? []
|
|
66
|
+
const streamingText = sessionState?.streamingText ?? ''
|
|
67
|
+
const isEmpty = messages.length === 0 && !streamingText
|
|
68
|
+
|
|
69
|
+
const isActive = chatState !== 'idle'
|
|
70
|
+
const totalTokens = tokenUsage.input_tokens + tokenUsage.output_tokens
|
|
71
|
+
|
|
72
|
+
const lastUpdated = useMemo(() => {
|
|
73
|
+
if (!session?.modifiedAt) return ''
|
|
74
|
+
const diff = Date.now() - new Date(session.modifiedAt).getTime()
|
|
75
|
+
if (diff < 60000) return t('session.timeJustNow')
|
|
76
|
+
if (diff < 3600000) return t('session.timeMinutes', { n: Math.floor(diff / 60000) })
|
|
77
|
+
if (diff < 86400000) return t('session.timeHours', { n: Math.floor(diff / 3600000) })
|
|
78
|
+
return t('session.timeDays', { n: Math.floor(diff / 86400000) })
|
|
79
|
+
}, [session?.modifiedAt, t])
|
|
80
|
+
|
|
81
|
+
if (!activeTabId) return null
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div className="flex-1 flex flex-col relative overflow-hidden bg-background text-on-surface">
|
|
85
|
+
{isMemberSession && (
|
|
86
|
+
<div className="shrink-0 border-b border-[var(--color-border)] bg-[var(--color-surface-container)]">
|
|
87
|
+
<div className="mx-auto max-w-[860px] flex items-center justify-between gap-4 px-8 py-2">
|
|
88
|
+
<div className="min-w-0">
|
|
89
|
+
<div className="flex items-center gap-3">
|
|
90
|
+
{memberInfo?.status === 'running' && (
|
|
91
|
+
<span className="flex h-2 w-2 rounded-full bg-[var(--color-warning)] animate-pulse-dot" />
|
|
92
|
+
)}
|
|
93
|
+
{memberInfo?.status === 'completed' && (
|
|
94
|
+
<span className="material-symbols-outlined text-[14px] text-[var(--color-success)]" style={{ fontVariationSettings: "'FILL' 1" }}>check_circle</span>
|
|
95
|
+
)}
|
|
96
|
+
<span className="material-symbols-outlined text-[14px] text-[var(--color-text-tertiary)]">smart_toy</span>
|
|
97
|
+
<span className="text-sm font-semibold text-[var(--color-text-primary)]">
|
|
98
|
+
{memberInfo?.role}
|
|
99
|
+
</span>
|
|
100
|
+
{activeTeam && (
|
|
101
|
+
<span className="text-[10px] text-[var(--color-text-tertiary)]">
|
|
102
|
+
@ {activeTeam.name}
|
|
103
|
+
</span>
|
|
104
|
+
)}
|
|
105
|
+
</div>
|
|
106
|
+
<p className="mt-1 text-[11px] text-[var(--color-text-tertiary)]">
|
|
107
|
+
{t('teams.memberSessionHint')}
|
|
108
|
+
</p>
|
|
109
|
+
</div>
|
|
110
|
+
<button
|
|
111
|
+
onClick={() => {
|
|
112
|
+
if (activeTeam?.leadSessionId) {
|
|
113
|
+
useTabStore.getState().openTab(
|
|
114
|
+
activeTeam.leadSessionId,
|
|
115
|
+
t('teams.leader'),
|
|
116
|
+
'session',
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
}}
|
|
120
|
+
disabled={!activeTeam?.leadSessionId}
|
|
121
|
+
className="flex shrink-0 items-center gap-1 text-xs font-medium text-[var(--color-text-secondary)] hover:text-[var(--color-text-primary)] transition-colors disabled:opacity-50 disabled:hover:text-[var(--color-text-secondary)]"
|
|
122
|
+
>
|
|
123
|
+
<span className="material-symbols-outlined text-[14px]">arrow_back</span>
|
|
124
|
+
{t('teams.backToLeader')}
|
|
125
|
+
</button>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
)}
|
|
129
|
+
|
|
130
|
+
{isEmpty ? (
|
|
131
|
+
<div className="flex flex-1 flex-col items-center justify-center p-8 pb-32">
|
|
132
|
+
<div className="flex max-w-md flex-col items-center text-center">
|
|
133
|
+
{isMemberSession ? (
|
|
134
|
+
<>
|
|
135
|
+
<span className="material-symbols-outlined text-[48px] mb-4 text-[var(--color-text-tertiary)]">smart_toy</span>
|
|
136
|
+
<p className="text-[var(--color-text-secondary)]">
|
|
137
|
+
{memberInfo?.status === 'running'
|
|
138
|
+
? `${memberInfo.role} ${t('teams.working')}`
|
|
139
|
+
: t('teams.noMessages')}
|
|
140
|
+
</p>
|
|
141
|
+
</>
|
|
142
|
+
) : (
|
|
143
|
+
<>
|
|
144
|
+
<img src="/app-icon.jpg" alt="Claude Code Haha" className="mb-6 h-24 w-24 rounded-[22px]" style={{ boxShadow: 'var(--shadow-dropdown)' }} />
|
|
145
|
+
<h1 className="mb-2 text-3xl font-extrabold tracking-tight text-[var(--color-text-primary)]" style={{ fontFamily: 'var(--font-headline)' }}>
|
|
146
|
+
{t('empty.title')}
|
|
147
|
+
</h1>
|
|
148
|
+
<p className="mx-auto max-w-xs text-[var(--color-text-secondary)]" style={{ fontFamily: 'var(--font-body)' }}>
|
|
149
|
+
{t('empty.subtitle')}
|
|
150
|
+
</p>
|
|
151
|
+
</>
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
) : (
|
|
156
|
+
<>
|
|
157
|
+
{!isMemberSession && (
|
|
158
|
+
<div className="mx-auto flex w-full max-w-[860px] items-center border-b border-outline-variant/10 px-8 py-3">
|
|
159
|
+
<div className="flex-1">
|
|
160
|
+
<h1 className="text-lg font-bold font-headline text-on-surface leading-tight">
|
|
161
|
+
{session?.title || t('session.untitled')}
|
|
162
|
+
</h1>
|
|
163
|
+
<div className="flex items-center gap-2 text-[10px] text-outline font-medium mt-1">
|
|
164
|
+
{isActive && (
|
|
165
|
+
<span className="flex items-center gap-1">
|
|
166
|
+
<span className="w-1.5 h-1.5 rounded-full bg-[var(--color-success)] animate-pulse-dot" />
|
|
167
|
+
{t('session.active')}
|
|
168
|
+
</span>
|
|
169
|
+
)}
|
|
170
|
+
{totalTokens > 0 && (
|
|
171
|
+
<>
|
|
172
|
+
<span className="text-[var(--color-outline)]">·</span>
|
|
173
|
+
<span>{totalTokens.toLocaleString()} t</span>
|
|
174
|
+
</>
|
|
175
|
+
)}
|
|
176
|
+
{lastUpdated && (
|
|
177
|
+
<>
|
|
178
|
+
<span className="text-[var(--color-outline)]">·</span>
|
|
179
|
+
<span>{t('session.lastUpdated', { time: lastUpdated })}</span>
|
|
180
|
+
</>
|
|
181
|
+
)}
|
|
182
|
+
{session?.messageCount !== undefined && session.messageCount > 0 && (
|
|
183
|
+
<>
|
|
184
|
+
<span className="text-[var(--color-outline)]">·</span>
|
|
185
|
+
<span>{t('session.messages', { count: session.messageCount })}</span>
|
|
186
|
+
</>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
{session?.workDirExists === false && (
|
|
190
|
+
<div className="mt-2 inline-flex max-w-full items-center gap-2 rounded-lg border border-[var(--color-error)]/20 bg-[var(--color-error)]/8 px-3 py-1.5 text-[11px] text-[var(--color-error)]">
|
|
191
|
+
<span className="material-symbols-outlined text-[14px]">warning</span>
|
|
192
|
+
<span className="truncate">
|
|
193
|
+
{t('session.workspaceUnavailable', { dir: session.workDir || 'directory no longer exists' })}
|
|
194
|
+
</span>
|
|
195
|
+
</div>
|
|
196
|
+
)}
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
)}
|
|
200
|
+
|
|
201
|
+
<MessageList />
|
|
202
|
+
</>
|
|
203
|
+
)}
|
|
204
|
+
|
|
205
|
+
{!isMemberSession && <SessionTaskBar />}
|
|
206
|
+
|
|
207
|
+
<TeamStatusBar />
|
|
208
|
+
|
|
209
|
+
<ChatInput variant={isEmpty && !isMemberSession ? 'hero' : 'default'} />
|
|
210
|
+
|
|
211
|
+
{!isMemberSession && activeTabId ? (
|
|
212
|
+
<ComputerUsePermissionModal
|
|
213
|
+
sessionId={activeTabId}
|
|
214
|
+
request={pendingComputerUsePermission?.request ?? null}
|
|
215
|
+
/>
|
|
216
|
+
) : null}
|
|
217
|
+
</div>
|
|
218
|
+
)
|
|
219
|
+
}
|