bingocode 1.0.3 → 1.0.5
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/package.json +3 -7
- package/desktop/README.md +0 -30
- package/desktop/bunfig.toml +0 -1
- package/desktop/index.html +0 -17
- package/desktop/package.json +0 -55
- package/desktop/pnpm-lock.yaml +0 -3832
- 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 +0 -1
- package/desktop/public/icons/douyin.svg +0 -1
- package/desktop/public/icons/github.svg +0 -3
- package/desktop/public/icons/xiaohongshu.svg +0 -1
- package/desktop/scripts/build-macos-arm64.sh +0 -270
- package/desktop/scripts/build-sidecars.ts +0 -183
- package/desktop/scripts/build-windows-x64.ps1 +0 -295
- package/desktop/scripts/scan-missing-imports.ts +0 -235
- package/desktop/sidecars/claude-sidecar.ts +0 -156
- package/desktop/src/App.tsx +0 -5
- package/desktop/src/__tests__/agentsSettings.test.tsx +0 -349
- package/desktop/src/__tests__/pages.test.tsx +0 -290
- package/desktop/src/__tests__/skillsSettings.test.tsx +0 -205
- package/desktop/src/api/adapters.ts +0 -12
- package/desktop/src/api/agents.ts +0 -36
- package/desktop/src/api/cliTasks.ts +0 -28
- package/desktop/src/api/client.ts +0 -63
- package/desktop/src/api/computerUse.ts +0 -76
- package/desktop/src/api/filesystem.ts +0 -30
- package/desktop/src/api/hahaOAuth.ts +0 -38
- package/desktop/src/api/models.ts +0 -28
- package/desktop/src/api/providers.ts +0 -63
- package/desktop/src/api/search.ts +0 -29
- package/desktop/src/api/sessions.ts +0 -56
- package/desktop/src/api/settings.ts +0 -20
- package/desktop/src/api/skills.ts +0 -19
- package/desktop/src/api/tasks.ts +0 -36
- package/desktop/src/api/teams.ts +0 -44
- package/desktop/src/api/websocket.ts +0 -164
- package/desktop/src/components/chat/AskUserQuestion.tsx +0 -268
- package/desktop/src/components/chat/AssistantMessage.tsx +0 -29
- package/desktop/src/components/chat/AttachmentGallery.tsx +0 -113
- package/desktop/src/components/chat/ChatInput.tsx +0 -622
- package/desktop/src/components/chat/CodeViewer.tsx +0 -161
- package/desktop/src/components/chat/ComputerUsePermissionModal.test.tsx +0 -174
- package/desktop/src/components/chat/ComputerUsePermissionModal.tsx +0 -311
- package/desktop/src/components/chat/DiffViewer.tsx +0 -157
- package/desktop/src/components/chat/FileSearchMenu.tsx +0 -198
- package/desktop/src/components/chat/ImageGalleryModal.tsx +0 -91
- package/desktop/src/components/chat/InlineImageGallery.tsx +0 -106
- package/desktop/src/components/chat/InlineTaskSummary.tsx +0 -60
- package/desktop/src/components/chat/MermaidRenderer.test.tsx +0 -98
- package/desktop/src/components/chat/MermaidRenderer.tsx +0 -361
- package/desktop/src/components/chat/MessageActionBar.tsx +0 -27
- package/desktop/src/components/chat/MessageList.test.tsx +0 -313
- package/desktop/src/components/chat/MessageList.tsx +0 -249
- package/desktop/src/components/chat/PermissionDialog.tsx +0 -262
- package/desktop/src/components/chat/SessionTaskBar.test.tsx +0 -99
- package/desktop/src/components/chat/SessionTaskBar.tsx +0 -159
- package/desktop/src/components/chat/StreamingIndicator.tsx +0 -41
- package/desktop/src/components/chat/TerminalChrome.tsx +0 -35
- package/desktop/src/components/chat/ThinkingBlock.tsx +0 -87
- package/desktop/src/components/chat/ToolCallBlock.tsx +0 -247
- package/desktop/src/components/chat/ToolCallGroup.tsx +0 -617
- package/desktop/src/components/chat/ToolResultBlock.tsx +0 -107
- package/desktop/src/components/chat/UserMessage.tsx +0 -38
- package/desktop/src/components/chat/chatBlocks.test.tsx +0 -136
- package/desktop/src/components/chat/clipboard.ts +0 -25
- package/desktop/src/components/chat/composerUtils.test.ts +0 -55
- package/desktop/src/components/chat/composerUtils.ts +0 -149
- package/desktop/src/components/controls/ModelSelector.tsx +0 -156
- package/desktop/src/components/controls/PermissionModeSelector.tsx +0 -229
- package/desktop/src/components/layout/AppShell.tsx +0 -107
- package/desktop/src/components/layout/ContentRouter.tsx +0 -27
- package/desktop/src/components/layout/ProjectFilter.tsx +0 -126
- package/desktop/src/components/layout/Sidebar.test.tsx +0 -158
- package/desktop/src/components/layout/Sidebar.tsx +0 -384
- package/desktop/src/components/layout/StatusBar.tsx +0 -31
- package/desktop/src/components/layout/TabBar.test.tsx +0 -136
- package/desktop/src/components/layout/TabBar.tsx +0 -318
- package/desktop/src/components/layout/TitleBar.tsx +0 -96
- package/desktop/src/components/layout/WindowControls.test.tsx +0 -69
- package/desktop/src/components/layout/WindowControls.tsx +0 -89
- package/desktop/src/components/markdown/MarkdownRenderer.test.tsx +0 -100
- package/desktop/src/components/markdown/MarkdownRenderer.tsx +0 -229
- package/desktop/src/components/settings/ClaudeOfficialLogin.tsx +0 -107
- package/desktop/src/components/shared/Button.tsx +0 -63
- package/desktop/src/components/shared/CopyButton.tsx +0 -58
- package/desktop/src/components/shared/DirectoryPicker.tsx +0 -316
- package/desktop/src/components/shared/Dropdown.tsx +0 -91
- package/desktop/src/components/shared/Input.tsx +0 -38
- package/desktop/src/components/shared/Modal.tsx +0 -65
- package/desktop/src/components/shared/ProjectContextChip.tsx +0 -30
- package/desktop/src/components/shared/Spinner.tsx +0 -30
- package/desktop/src/components/shared/Textarea.tsx +0 -38
- package/desktop/src/components/shared/Toast.tsx +0 -47
- package/desktop/src/components/shared/UpdateChecker.tsx +0 -90
- package/desktop/src/components/skills/SkillDetail.test.tsx +0 -89
- package/desktop/src/components/skills/SkillDetail.tsx +0 -403
- package/desktop/src/components/skills/SkillList.tsx +0 -254
- package/desktop/src/components/tasks/DayOfWeekPicker.tsx +0 -57
- package/desktop/src/components/tasks/NewTaskModal.tsx +0 -407
- package/desktop/src/components/tasks/PromptEditor.tsx +0 -74
- package/desktop/src/components/tasks/TaskEmptyState.tsx +0 -30
- package/desktop/src/components/tasks/TaskList.tsx +0 -46
- package/desktop/src/components/tasks/TaskRow.tsx +0 -253
- package/desktop/src/components/tasks/TaskRunsPanel.tsx +0 -195
- package/desktop/src/components/teams/TeamStatusBar.tsx +0 -147
- package/desktop/src/config/providerPresets.ts +0 -78
- package/desktop/src/config/spinnerVerbs.ts +0 -193
- package/desktop/src/hooks/useKeyboardShortcuts.ts +0 -60
- package/desktop/src/i18n/index.ts +0 -54
- package/desktop/src/i18n/locales/en.ts +0 -670
- package/desktop/src/i18n/locales/zh.ts +0 -670
- package/desktop/src/lib/__tests__/cronDescribe.test.ts +0 -93
- package/desktop/src/lib/cronDescribe.ts +0 -188
- package/desktop/src/lib/desktopRuntime.ts +0 -54
- package/desktop/src/lib/parseRunOutput.ts +0 -79
- package/desktop/src/main.tsx +0 -13
- package/desktop/src/mocks/data.ts +0 -202
- package/desktop/src/pages/ActiveSession.test.tsx +0 -181
- package/desktop/src/pages/ActiveSession.tsx +0 -219
- package/desktop/src/pages/AdapterSettings.tsx +0 -375
- package/desktop/src/pages/AgentTeams.tsx +0 -200
- package/desktop/src/pages/ComputerUseSettings.tsx +0 -420
- package/desktop/src/pages/EmptySession.tsx +0 -518
- package/desktop/src/pages/NewTaskModal.tsx +0 -346
- package/desktop/src/pages/ScheduledTasks.tsx +0 -66
- package/desktop/src/pages/ScheduledTasksEmpty.tsx +0 -152
- package/desktop/src/pages/ScheduledTasksList.tsx +0 -416
- package/desktop/src/pages/SessionControls.tsx +0 -460
- package/desktop/src/pages/Settings.tsx +0 -1448
- package/desktop/src/pages/ToolInspection.tsx +0 -235
- package/desktop/src/stores/adapterStore.ts +0 -106
- package/desktop/src/stores/agentStore.ts +0 -34
- package/desktop/src/stores/chatStore.test.ts +0 -505
- package/desktop/src/stores/chatStore.ts +0 -850
- package/desktop/src/stores/cliTaskStore.ts +0 -152
- package/desktop/src/stores/hahaOAuthStore.test.ts +0 -77
- package/desktop/src/stores/hahaOAuthStore.ts +0 -97
- package/desktop/src/stores/providerStore.ts +0 -101
- package/desktop/src/stores/sessionStore.test.ts +0 -63
- package/desktop/src/stores/sessionStore.ts +0 -102
- package/desktop/src/stores/settingsStore.ts +0 -120
- package/desktop/src/stores/skillStore.ts +0 -51
- package/desktop/src/stores/tabStore.ts +0 -169
- package/desktop/src/stores/taskStore.ts +0 -68
- package/desktop/src/stores/teamStore.ts +0 -344
- package/desktop/src/stores/uiStore.ts +0 -100
- package/desktop/src/stores/updateStore.test.ts +0 -71
- package/desktop/src/stores/updateStore.ts +0 -221
- package/desktop/src/theme/globals.css +0 -465
- package/desktop/src/types/adapter.ts +0 -33
- package/desktop/src/types/chat.ts +0 -152
- package/desktop/src/types/cliTask.ts +0 -24
- package/desktop/src/types/provider.ts +0 -62
- package/desktop/src/types/session.ts +0 -27
- package/desktop/src/types/settings.ts +0 -22
- package/desktop/src/types/skill.ts +0 -38
- package/desktop/src/types/task.ts +0 -56
- package/desktop/src/types/team.ts +0 -38
- package/desktop/src-tauri/Cargo.lock +0 -5549
- package/desktop/src-tauri/Cargo.toml +0 -20
- package/desktop/src-tauri/app-icon.svg +0 -13
- package/desktop/src-tauri/build.rs +0 -3
- package/desktop/src-tauri/capabilities/default.json +0 -106
- package/desktop/src-tauri/icons/android/mipmap-anydpi-v26/ic_launcher.xml +0 -5
- package/desktop/src-tauri/icons/android/values/ic_launcher_background.xml +0 -4
- 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 +0 -408
- package/desktop/src-tauri/src/main.rs +0 -6
- package/desktop/src-tauri/tauri.conf.json +0 -78
- package/desktop/src-tauri/tauri.macos.conf.json +0 -18
- package/desktop/src-tauri/tauri.release-ci.json +0 -5
- package/desktop/src-tauri/tauri.windows.conf.json +0 -16
- package/desktop/src-tauri/windows-installer-hooks.nsh +0 -17
- package/desktop/tsconfig.json +0 -25
- package/desktop/vite.config.ts +0 -26
- package/desktop/vitest.config.ts +0 -18
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState, useCallback, useMemo, useRef } from 'react'
|
|
2
|
-
import { useSessionStore } from '../../stores/sessionStore'
|
|
3
|
-
import { useUIStore } from '../../stores/uiStore'
|
|
4
|
-
import { useTranslation } from '../../i18n'
|
|
5
|
-
import { ProjectFilter } from './ProjectFilter'
|
|
6
|
-
import type { SessionListItem } from '../../types/session'
|
|
7
|
-
import { useTabStore, SETTINGS_TAB_ID, SCHEDULED_TAB_ID } from '../../stores/tabStore'
|
|
8
|
-
import { useChatStore } from '../../stores/chatStore'
|
|
9
|
-
|
|
10
|
-
const isTauri = typeof window !== 'undefined' && ('__TAURI_INTERNALS__' in window || '__TAURI__' in window)
|
|
11
|
-
const isWindows = typeof navigator !== 'undefined' && /Win/.test(navigator.platform)
|
|
12
|
-
|
|
13
|
-
type TimeGroup = 'today' | 'yesterday' | 'last7days' | 'last30days' | 'older'
|
|
14
|
-
|
|
15
|
-
const TIME_GROUP_ORDER: TimeGroup[] = ['today', 'yesterday', 'last7days', 'last30days', 'older']
|
|
16
|
-
|
|
17
|
-
export function Sidebar() {
|
|
18
|
-
const sessions = useSessionStore((s) => s.sessions)
|
|
19
|
-
const selectedProjects = useSessionStore((s) => s.selectedProjects)
|
|
20
|
-
const error = useSessionStore((s) => s.error)
|
|
21
|
-
const fetchSessions = useSessionStore((s) => s.fetchSessions)
|
|
22
|
-
const deleteSession = useSessionStore((s) => s.deleteSession)
|
|
23
|
-
const renameSession = useSessionStore((s) => s.renameSession)
|
|
24
|
-
const addToast = useUIStore((s) => s.addToast)
|
|
25
|
-
const activeTabId = useTabStore((s) => s.activeTabId)
|
|
26
|
-
const closeTab = useTabStore((s) => s.closeTab)
|
|
27
|
-
const disconnectSession = useChatStore((s) => s.disconnectSession)
|
|
28
|
-
const [searchQuery, setSearchQuery] = useState('')
|
|
29
|
-
const [contextMenu, setContextMenu] = useState<{ id: string; x: number; y: number } | null>(null)
|
|
30
|
-
const [renamingId, setRenamingId] = useState<string | null>(null)
|
|
31
|
-
const [renameValue, setRenameValue] = useState('')
|
|
32
|
-
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
fetchSessions()
|
|
35
|
-
}, [fetchSessions])
|
|
36
|
-
|
|
37
|
-
// Close context menu on click outside
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (!contextMenu) return
|
|
40
|
-
const close = () => setContextMenu(null)
|
|
41
|
-
document.addEventListener('click', close)
|
|
42
|
-
return () => document.removeEventListener('click', close)
|
|
43
|
-
}, [contextMenu])
|
|
44
|
-
|
|
45
|
-
// Filter by selected projects, then by search query
|
|
46
|
-
const filteredSessions = useMemo(() => {
|
|
47
|
-
let result = sessions
|
|
48
|
-
if (selectedProjects.length > 0) {
|
|
49
|
-
result = result.filter((s) => selectedProjects.includes(s.projectPath))
|
|
50
|
-
}
|
|
51
|
-
if (searchQuery) {
|
|
52
|
-
const q = searchQuery.toLowerCase()
|
|
53
|
-
result = result.filter((s) => s.title.toLowerCase().includes(q))
|
|
54
|
-
}
|
|
55
|
-
return result
|
|
56
|
-
}, [sessions, selectedProjects, searchQuery])
|
|
57
|
-
|
|
58
|
-
// Group by time
|
|
59
|
-
const timeGroups = useMemo(() => groupByTime(filteredSessions), [filteredSessions])
|
|
60
|
-
|
|
61
|
-
const handleContextMenu = useCallback((e: React.MouseEvent, id: string) => {
|
|
62
|
-
e.preventDefault()
|
|
63
|
-
setContextMenu({ id, x: e.clientX, y: e.clientY })
|
|
64
|
-
}, [])
|
|
65
|
-
|
|
66
|
-
const handleDelete = useCallback(async (id: string) => {
|
|
67
|
-
setContextMenu(null)
|
|
68
|
-
await deleteSession(id)
|
|
69
|
-
disconnectSession(id)
|
|
70
|
-
closeTab(id)
|
|
71
|
-
}, [closeTab, deleteSession, disconnectSession])
|
|
72
|
-
|
|
73
|
-
const handleStartRename = useCallback((id: string, currentTitle: string) => {
|
|
74
|
-
setContextMenu(null)
|
|
75
|
-
setRenamingId(id)
|
|
76
|
-
setRenameValue(currentTitle)
|
|
77
|
-
}, [])
|
|
78
|
-
|
|
79
|
-
const handleFinishRename = useCallback(async () => {
|
|
80
|
-
if (renamingId && renameValue.trim()) {
|
|
81
|
-
await renameSession(renamingId, renameValue.trim())
|
|
82
|
-
}
|
|
83
|
-
setRenamingId(null)
|
|
84
|
-
setRenameValue('')
|
|
85
|
-
}, [renamingId, renameValue, renameSession])
|
|
86
|
-
|
|
87
|
-
const startDraggingRef = useRef<(() => Promise<void>) | null>(null)
|
|
88
|
-
|
|
89
|
-
useEffect(() => {
|
|
90
|
-
if (!isTauri) return
|
|
91
|
-
import(/* @vite-ignore */ '@tauri-apps/api/window')
|
|
92
|
-
.then(({ getCurrentWindow }) => {
|
|
93
|
-
const win = getCurrentWindow()
|
|
94
|
-
startDraggingRef.current = () => win.startDragging()
|
|
95
|
-
})
|
|
96
|
-
.catch(() => {})
|
|
97
|
-
}, [])
|
|
98
|
-
|
|
99
|
-
const handleSidebarDrag = useCallback((e: React.MouseEvent) => {
|
|
100
|
-
if ((e.target as HTMLElement).closest('button, input, textarea, select, a, [role="button"]')) return
|
|
101
|
-
startDraggingRef.current?.()
|
|
102
|
-
}, [])
|
|
103
|
-
|
|
104
|
-
const t = useTranslation()
|
|
105
|
-
|
|
106
|
-
const TIME_GROUP_LABELS: Record<TimeGroup, string> = {
|
|
107
|
-
today: t('sidebar.timeGroup.today'),
|
|
108
|
-
yesterday: t('sidebar.timeGroup.yesterday'),
|
|
109
|
-
last7days: t('sidebar.timeGroup.last7days'),
|
|
110
|
-
last30days: t('sidebar.timeGroup.last30days'),
|
|
111
|
-
older: t('sidebar.timeGroup.older'),
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<aside onMouseDown={handleSidebarDrag} className="w-[var(--sidebar-width)] h-full flex flex-col bg-[var(--color-surface-sidebar)] border-r border-[var(--color-border)] select-none">
|
|
116
|
-
{/* Brand logo — extra top padding in desktop to clear macOS traffic lights (not needed on Windows) */}
|
|
117
|
-
<div className={`px-3 pb-1.5 flex items-center justify-between ${isTauri && !isWindows ? 'pt-[44px]' : 'pt-3'}`}>
|
|
118
|
-
<div className="flex items-center gap-2.5">
|
|
119
|
-
<img src="/app-icon.jpg" alt="" className="h-8 w-8 rounded-lg flex-shrink-0" />
|
|
120
|
-
<span className="text-[13px] font-semibold tracking-tight text-[var(--color-text-primary)]" style={{ fontFamily: 'var(--font-headline)' }}>
|
|
121
|
-
Claude Code <span className="text-[var(--color-primary-container)]">Haha</span>
|
|
122
|
-
</span>
|
|
123
|
-
</div>
|
|
124
|
-
<a
|
|
125
|
-
href="https://github.com/NanmiCoder/cc-haha"
|
|
126
|
-
target="_blank"
|
|
127
|
-
rel="noopener noreferrer"
|
|
128
|
-
className="rounded-md p-1 text-[var(--color-text-tertiary)] transition-colors hover:text-[var(--color-text-primary)] hover:bg-[var(--color-surface-hover)]"
|
|
129
|
-
title="GitHub"
|
|
130
|
-
>
|
|
131
|
-
<GitHubIcon />
|
|
132
|
-
</a>
|
|
133
|
-
</div>
|
|
134
|
-
{/* Navigation */}
|
|
135
|
-
<div className="px-3 pb-3 flex flex-col gap-0.5">
|
|
136
|
-
<NavItem
|
|
137
|
-
active={false}
|
|
138
|
-
onClick={async () => {
|
|
139
|
-
try {
|
|
140
|
-
// Use current active session's workDir as default for new session
|
|
141
|
-
const currentTabId = useTabStore.getState().activeTabId
|
|
142
|
-
const currentSession = currentTabId
|
|
143
|
-
? useSessionStore.getState().sessions.find((s) => s.id === currentTabId)
|
|
144
|
-
: null
|
|
145
|
-
const workDir = currentSession?.workDir || undefined
|
|
146
|
-
const sessionId = await useSessionStore.getState().createSession(workDir)
|
|
147
|
-
useTabStore.getState().openTab(sessionId, t('sidebar.newSession'))
|
|
148
|
-
useChatStore.getState().connectToSession(sessionId)
|
|
149
|
-
} catch (error) {
|
|
150
|
-
addToast({
|
|
151
|
-
type: 'error',
|
|
152
|
-
message:
|
|
153
|
-
error instanceof Error ? error.message : t('sidebar.sessionListFailed'),
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
}}
|
|
157
|
-
icon={<PlusIcon />}
|
|
158
|
-
>
|
|
159
|
-
{t('sidebar.newSession')}
|
|
160
|
-
</NavItem>
|
|
161
|
-
<NavItem
|
|
162
|
-
active={activeTabId === SCHEDULED_TAB_ID}
|
|
163
|
-
onClick={() => useTabStore.getState().openTab(SCHEDULED_TAB_ID, t('sidebar.scheduled'), 'scheduled')}
|
|
164
|
-
icon={<ClockIcon />}
|
|
165
|
-
>
|
|
166
|
-
{t('sidebar.scheduled')}
|
|
167
|
-
</NavItem>
|
|
168
|
-
</div>
|
|
169
|
-
|
|
170
|
-
{/* Project filter */}
|
|
171
|
-
<div className="px-3 pb-1 flex items-center justify-between">
|
|
172
|
-
<ProjectFilter />
|
|
173
|
-
</div>
|
|
174
|
-
|
|
175
|
-
{/* Search */}
|
|
176
|
-
<div className="px-3 pb-2">
|
|
177
|
-
<input
|
|
178
|
-
id="sidebar-search"
|
|
179
|
-
type="text"
|
|
180
|
-
placeholder={t('sidebar.searchPlaceholder')}
|
|
181
|
-
value={searchQuery}
|
|
182
|
-
onChange={(e) => setSearchQuery(e.target.value)}
|
|
183
|
-
className="w-full h-7 px-2 text-xs rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text-primary)] placeholder:text-[var(--color-text-tertiary)] outline-none focus:border-[var(--color-border-focus)]"
|
|
184
|
-
/>
|
|
185
|
-
</div>
|
|
186
|
-
|
|
187
|
-
{/* Session list — grouped by time */}
|
|
188
|
-
<div className="flex-1 overflow-y-auto px-3">
|
|
189
|
-
{error && (
|
|
190
|
-
<div className="mx-1 mt-2 rounded-[var(--radius-md)] border border-[var(--color-error)]/20 bg-[var(--color-error)]/5 px-3 py-2">
|
|
191
|
-
<div className="text-xs font-medium text-[var(--color-error)]">{t('sidebar.sessionListFailed')}</div>
|
|
192
|
-
<div className="mt-1 text-[11px] text-[var(--color-text-secondary)] break-words">{error}</div>
|
|
193
|
-
<button
|
|
194
|
-
onClick={() => fetchSessions()}
|
|
195
|
-
className="mt-2 text-[11px] font-medium text-[var(--color-brand)] hover:underline"
|
|
196
|
-
>
|
|
197
|
-
{t('common.retry')}
|
|
198
|
-
</button>
|
|
199
|
-
</div>
|
|
200
|
-
)}
|
|
201
|
-
{filteredSessions.length === 0 && (
|
|
202
|
-
<div className="px-3 py-4 text-xs text-[var(--color-text-tertiary)] text-center">
|
|
203
|
-
{searchQuery ? t('sidebar.noMatching') : t('sidebar.noSessions')}
|
|
204
|
-
</div>
|
|
205
|
-
)}
|
|
206
|
-
{TIME_GROUP_ORDER.map((group) => {
|
|
207
|
-
const items = timeGroups.get(group)
|
|
208
|
-
if (!items || items.length === 0) return null
|
|
209
|
-
return (
|
|
210
|
-
<div key={group} className="mb-1">
|
|
211
|
-
<div className="px-2 pt-3 pb-1 text-[11px] font-semibold text-[var(--color-text-tertiary)] tracking-wide">
|
|
212
|
-
{TIME_GROUP_LABELS[group]}
|
|
213
|
-
</div>
|
|
214
|
-
{items.map((session) => (
|
|
215
|
-
<div key={session.id} className="relative">
|
|
216
|
-
{renamingId === session.id ? (
|
|
217
|
-
<input
|
|
218
|
-
autoFocus
|
|
219
|
-
value={renameValue}
|
|
220
|
-
onChange={(e) => setRenameValue(e.target.value)}
|
|
221
|
-
onBlur={handleFinishRename}
|
|
222
|
-
onKeyDown={(e) => {
|
|
223
|
-
if (e.key === 'Enter') handleFinishRename()
|
|
224
|
-
if (e.key === 'Escape') { setRenamingId(null); setRenameValue('') }
|
|
225
|
-
}}
|
|
226
|
-
className="w-full px-3 py-2 text-sm rounded-[var(--radius-md)] border border-[var(--color-border-focus)] bg-[var(--color-surface)] text-[var(--color-text-primary)] outline-none ml-1"
|
|
227
|
-
/>
|
|
228
|
-
) : (
|
|
229
|
-
<button
|
|
230
|
-
onClick={() => {
|
|
231
|
-
useTabStore.getState().openTab(session.id, session.title)
|
|
232
|
-
useChatStore.getState().connectToSession(session.id)
|
|
233
|
-
}}
|
|
234
|
-
onContextMenu={(e) => handleContextMenu(e, session.id)}
|
|
235
|
-
className={`
|
|
236
|
-
w-full flex items-center gap-2 pl-4 pr-3 py-1.5 text-sm text-left rounded-[var(--radius-md)] transition-colors duration-200 group
|
|
237
|
-
${session.id === activeTabId
|
|
238
|
-
? 'bg-[var(--color-surface-selected)] text-[var(--color-text-primary)]'
|
|
239
|
-
: 'text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-hover)]'
|
|
240
|
-
}
|
|
241
|
-
`}
|
|
242
|
-
>
|
|
243
|
-
<span className="w-1 h-1 rounded-full flex-shrink-0" style={{
|
|
244
|
-
backgroundColor: session.id === activeTabId ? 'var(--color-brand)' : 'var(--color-text-tertiary)',
|
|
245
|
-
opacity: session.id === activeTabId ? 1 : 0.5,
|
|
246
|
-
}} />
|
|
247
|
-
<span className="truncate flex-1">{session.title || 'Untitled'}</span>
|
|
248
|
-
{!session.workDirExists && (
|
|
249
|
-
<span
|
|
250
|
-
className="text-[10px] text-[var(--color-warning)] flex-shrink-0"
|
|
251
|
-
title={session.workDir ?? ''}
|
|
252
|
-
>
|
|
253
|
-
{t('sidebar.missingDir')}
|
|
254
|
-
</span>
|
|
255
|
-
)}
|
|
256
|
-
<span className="text-[10px] text-[var(--color-text-tertiary)] flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity">
|
|
257
|
-
{formatRelativeTime(session.modifiedAt)}
|
|
258
|
-
</span>
|
|
259
|
-
</button>
|
|
260
|
-
)}
|
|
261
|
-
</div>
|
|
262
|
-
))}
|
|
263
|
-
</div>
|
|
264
|
-
)
|
|
265
|
-
})}
|
|
266
|
-
</div>
|
|
267
|
-
|
|
268
|
-
{/* Settings button at bottom */}
|
|
269
|
-
<div className="p-3 border-t border-[var(--color-border)]">
|
|
270
|
-
<NavItem
|
|
271
|
-
active={activeTabId === SETTINGS_TAB_ID}
|
|
272
|
-
onClick={() => useTabStore.getState().openTab(SETTINGS_TAB_ID, t('sidebar.settings'), 'settings')}
|
|
273
|
-
icon={<span className="material-symbols-outlined text-[18px]">settings</span>}
|
|
274
|
-
>
|
|
275
|
-
{t('sidebar.settings')}
|
|
276
|
-
</NavItem>
|
|
277
|
-
</div>
|
|
278
|
-
|
|
279
|
-
{/* Context menu */}
|
|
280
|
-
{contextMenu && (
|
|
281
|
-
<div
|
|
282
|
-
className="fixed z-50 bg-[var(--color-surface)] border border-[var(--color-border)] rounded-[var(--radius-md)] py-1 min-w-[140px]"
|
|
283
|
-
style={{ left: contextMenu.x, top: contextMenu.y, boxShadow: 'var(--shadow-dropdown)' }}
|
|
284
|
-
>
|
|
285
|
-
<button
|
|
286
|
-
onClick={() => {
|
|
287
|
-
const session = sessions.find(s => s.id === contextMenu.id)
|
|
288
|
-
handleStartRename(contextMenu.id, session?.title || '')
|
|
289
|
-
}}
|
|
290
|
-
className="w-full px-3 py-1.5 text-xs text-left text-[var(--color-text-primary)] hover:bg-[var(--color-surface-hover)] transition-colors"
|
|
291
|
-
>
|
|
292
|
-
{t('common.rename')}
|
|
293
|
-
</button>
|
|
294
|
-
<button
|
|
295
|
-
onClick={() => handleDelete(contextMenu.id)}
|
|
296
|
-
className="w-full px-3 py-1.5 text-xs text-left text-[var(--color-error)] hover:bg-[var(--color-surface-hover)] transition-colors"
|
|
297
|
-
>
|
|
298
|
-
{t('common.delete')}
|
|
299
|
-
</button>
|
|
300
|
-
</div>
|
|
301
|
-
)}
|
|
302
|
-
</aside>
|
|
303
|
-
)
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function groupByTime(sessions: SessionListItem[]): Map<TimeGroup, SessionListItem[]> {
|
|
307
|
-
const groups = new Map<TimeGroup, SessionListItem[]>()
|
|
308
|
-
const now = new Date()
|
|
309
|
-
const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime()
|
|
310
|
-
const startOfYesterday = startOfToday - 86400000
|
|
311
|
-
const sevenDaysAgo = startOfToday - 7 * 86400000
|
|
312
|
-
const thirtyDaysAgo = startOfToday - 30 * 86400000
|
|
313
|
-
|
|
314
|
-
for (const session of sessions) {
|
|
315
|
-
const ts = new Date(session.modifiedAt).getTime()
|
|
316
|
-
let group: TimeGroup
|
|
317
|
-
if (ts >= startOfToday) group = 'today'
|
|
318
|
-
else if (ts >= startOfYesterday) group = 'yesterday'
|
|
319
|
-
else if (ts >= sevenDaysAgo) group = 'last7days'
|
|
320
|
-
else if (ts >= thirtyDaysAgo) group = 'last30days'
|
|
321
|
-
else group = 'older'
|
|
322
|
-
|
|
323
|
-
if (!groups.has(group)) groups.set(group, [])
|
|
324
|
-
groups.get(group)!.push(session)
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
return groups
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
function NavItem({ active, onClick, icon, children }: { active: boolean; onClick: () => void; icon: React.ReactNode; children: React.ReactNode }) {
|
|
331
|
-
return (
|
|
332
|
-
<button
|
|
333
|
-
onClick={onClick}
|
|
334
|
-
className={`
|
|
335
|
-
w-full flex items-center gap-2.5 px-3 py-2 text-sm rounded-[var(--radius-md)] transition-colors duration-200
|
|
336
|
-
${active
|
|
337
|
-
? 'bg-[var(--color-surface-selected)] text-[var(--color-text-primary)] font-medium'
|
|
338
|
-
: 'text-[var(--color-text-secondary)] hover:bg-[var(--color-surface-hover)] hover:text-[var(--color-text-primary)]'
|
|
339
|
-
}
|
|
340
|
-
`}
|
|
341
|
-
>
|
|
342
|
-
{icon}
|
|
343
|
-
{children}
|
|
344
|
-
</button>
|
|
345
|
-
)
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
function formatRelativeTime(dateStr: string): string {
|
|
349
|
-
const diff = Date.now() - new Date(dateStr).getTime()
|
|
350
|
-
const min = Math.floor(diff / 60000)
|
|
351
|
-
if (min < 1) return 'now'
|
|
352
|
-
if (min < 60) return `${min}m`
|
|
353
|
-
const hr = Math.floor(min / 60)
|
|
354
|
-
if (hr < 24) return `${hr}h`
|
|
355
|
-
const day = Math.floor(hr / 24)
|
|
356
|
-
if (day < 30) return `${day}d`
|
|
357
|
-
return `${Math.floor(day / 30)}mo`
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
function GitHubIcon() {
|
|
361
|
-
return (
|
|
362
|
-
<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor">
|
|
363
|
-
<path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" />
|
|
364
|
-
</svg>
|
|
365
|
-
)
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function PlusIcon() {
|
|
369
|
-
return (
|
|
370
|
-
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
371
|
-
<line x1="12" y1="5" x2="12" y2="19" />
|
|
372
|
-
<line x1="5" y1="12" x2="19" y2="12" />
|
|
373
|
-
</svg>
|
|
374
|
-
)
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function ClockIcon() {
|
|
378
|
-
return (
|
|
379
|
-
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
380
|
-
<circle cx="12" cy="12" r="10" />
|
|
381
|
-
<polyline points="12 6 12 12 16 14" />
|
|
382
|
-
</svg>
|
|
383
|
-
)
|
|
384
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useSettingsStore } from '../../stores/settingsStore'
|
|
2
|
-
import { useSessionStore } from '../../stores/sessionStore'
|
|
3
|
-
import { useTabStore } from '../../stores/tabStore'
|
|
4
|
-
|
|
5
|
-
export function StatusBar() {
|
|
6
|
-
const { currentModel } = useSettingsStore()
|
|
7
|
-
const activeTabId = useTabStore((s) => s.activeTabId)
|
|
8
|
-
const projectPath = useSessionStore((s) => s.sessions.find((session) => session.id === activeTabId)?.projectPath)
|
|
9
|
-
|
|
10
|
-
const projectName = projectPath
|
|
11
|
-
? projectPath.split('-').filter(Boolean).pop() || ''
|
|
12
|
-
: ''
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<div className="h-[var(--statusbar-height)] flex items-center justify-between px-4 border-t border-[var(--color-border)] bg-[var(--color-surface-sidebar)] select-none text-[11px]">
|
|
16
|
-
<div className="flex items-center gap-3">
|
|
17
|
-
{projectName && (
|
|
18
|
-
<span className="text-[var(--color-text-secondary)] font-[var(--font-mono)]">{projectName}</span>
|
|
19
|
-
)}
|
|
20
|
-
</div>
|
|
21
|
-
|
|
22
|
-
<div className="flex items-center gap-4">
|
|
23
|
-
{currentModel && (
|
|
24
|
-
<span className="text-[var(--color-text-tertiary)] font-[var(--font-mono)]">
|
|
25
|
-
{currentModel.name}
|
|
26
|
-
</span>
|
|
27
|
-
)}
|
|
28
|
-
</div>
|
|
29
|
-
</div>
|
|
30
|
-
)
|
|
31
|
-
}
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'
|
|
2
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
3
|
-
import '@testing-library/jest-dom'
|
|
4
|
-
|
|
5
|
-
vi.mock('../../i18n', () => ({
|
|
6
|
-
useTranslation: () => (key: string) => {
|
|
7
|
-
const translations: Record<string, string> = {
|
|
8
|
-
'tabs.close': 'Close',
|
|
9
|
-
'tabs.closeOthers': 'Close Others',
|
|
10
|
-
'tabs.closeLeft': 'Close Left',
|
|
11
|
-
'tabs.closeRight': 'Close Right',
|
|
12
|
-
'tabs.closeAll': 'Close All',
|
|
13
|
-
'tabs.closeConfirmTitle': 'Session Running',
|
|
14
|
-
'tabs.closeConfirmMessage': 'Still running',
|
|
15
|
-
'tabs.closeConfirmKeep': 'Keep Running',
|
|
16
|
-
'tabs.closeConfirmStop': 'Stop & Close',
|
|
17
|
-
'common.cancel': 'Cancel',
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return translations[key] ?? key
|
|
21
|
-
},
|
|
22
|
-
}))
|
|
23
|
-
|
|
24
|
-
vi.mock('./WindowControls', () => ({
|
|
25
|
-
WindowControls: () => <div data-testid="window-controls" />,
|
|
26
|
-
showWindowControls: true,
|
|
27
|
-
}))
|
|
28
|
-
|
|
29
|
-
describe('TabBar', () => {
|
|
30
|
-
beforeEach(() => {
|
|
31
|
-
class ResizeObserverMock {
|
|
32
|
-
constructor(_callback: ResizeObserverCallback) {}
|
|
33
|
-
|
|
34
|
-
observe(_target: Element) {}
|
|
35
|
-
|
|
36
|
-
disconnect() {}
|
|
37
|
-
unobserve() {}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
Object.defineProperty(window, 'ResizeObserver', {
|
|
41
|
-
configurable: true,
|
|
42
|
-
value: ResizeObserverMock,
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
vi.resetModules()
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
afterEach(async () => {
|
|
49
|
-
const { useTabStore } = await import('../../stores/tabStore')
|
|
50
|
-
const { useChatStore } = await import('../../stores/chatStore')
|
|
51
|
-
|
|
52
|
-
useTabStore.setState({ tabs: [], activeTabId: null })
|
|
53
|
-
useChatStore.setState({
|
|
54
|
-
sessions: {},
|
|
55
|
-
} as Partial<ReturnType<typeof useChatStore.getState>>)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
it('keeps the overflow button flush against window controls on Windows', async () => {
|
|
59
|
-
const { TabBar } = await import('./TabBar')
|
|
60
|
-
const { useTabStore } = await import('../../stores/tabStore')
|
|
61
|
-
const { useChatStore } = await import('../../stores/chatStore')
|
|
62
|
-
|
|
63
|
-
useTabStore.setState({
|
|
64
|
-
tabs: [
|
|
65
|
-
{ sessionId: 'tab-1', title: 'Untitled Session', type: 'session', status: 'idle' },
|
|
66
|
-
{ sessionId: 'tab-2', title: 'Settings', type: 'settings', status: 'idle' },
|
|
67
|
-
{ sessionId: 'tab-3', title: 'hello', type: 'session', status: 'idle' },
|
|
68
|
-
{ sessionId: 'tab-4', title: 'overflow', type: 'session', status: 'idle' },
|
|
69
|
-
],
|
|
70
|
-
activeTabId: 'tab-1',
|
|
71
|
-
})
|
|
72
|
-
useChatStore.setState({
|
|
73
|
-
sessions: {},
|
|
74
|
-
disconnectSession: vi.fn(),
|
|
75
|
-
} as Partial<ReturnType<typeof useChatStore.getState>>)
|
|
76
|
-
|
|
77
|
-
await act(async () => {
|
|
78
|
-
render(<TabBar />)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
const scrollRegion = screen.getByTestId('tab-bar').querySelector('.overflow-x-hidden')
|
|
82
|
-
expect(scrollRegion).toBeInTheDocument()
|
|
83
|
-
|
|
84
|
-
Object.defineProperty(scrollRegion!, 'clientWidth', {
|
|
85
|
-
configurable: true,
|
|
86
|
-
get: () => 240,
|
|
87
|
-
})
|
|
88
|
-
Object.defineProperty(scrollRegion!, 'scrollWidth', {
|
|
89
|
-
configurable: true,
|
|
90
|
-
get: () => 720,
|
|
91
|
-
})
|
|
92
|
-
Object.defineProperty(scrollRegion!, 'scrollLeft', {
|
|
93
|
-
configurable: true,
|
|
94
|
-
get: () => 0,
|
|
95
|
-
})
|
|
96
|
-
Object.defineProperty(scrollRegion!, 'scrollBy', {
|
|
97
|
-
configurable: true,
|
|
98
|
-
value: vi.fn(),
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
act(() => {
|
|
102
|
-
fireEvent.scroll(scrollRegion!)
|
|
103
|
-
})
|
|
104
|
-
|
|
105
|
-
await waitFor(() => {
|
|
106
|
-
expect(screen.getByTestId('window-controls')).toBeInTheDocument()
|
|
107
|
-
expect(screen.getByText('chevron_right').closest('button')).toBeInTheDocument()
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
const rightButton = screen.getByText('chevron_right').closest('button')
|
|
111
|
-
expect(rightButton?.nextElementSibling).toBe(screen.getByTestId('window-controls'))
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
it('marks the tab bar as a native drag region', async () => {
|
|
115
|
-
const { TabBar } = await import('./TabBar')
|
|
116
|
-
const { useTabStore } = await import('../../stores/tabStore')
|
|
117
|
-
const { useChatStore } = await import('../../stores/chatStore')
|
|
118
|
-
|
|
119
|
-
useTabStore.setState({
|
|
120
|
-
tabs: [
|
|
121
|
-
{ sessionId: 'tab-1', title: 'Untitled Session', type: 'session', status: 'idle' },
|
|
122
|
-
],
|
|
123
|
-
activeTabId: 'tab-1',
|
|
124
|
-
})
|
|
125
|
-
useChatStore.setState({
|
|
126
|
-
sessions: {},
|
|
127
|
-
disconnectSession: vi.fn(),
|
|
128
|
-
} as Partial<ReturnType<typeof useChatStore.getState>>)
|
|
129
|
-
|
|
130
|
-
await act(async () => {
|
|
131
|
-
render(<TabBar />)
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
expect(screen.getByTestId('tab-bar')).toHaveAttribute('data-tauri-drag-region')
|
|
135
|
-
})
|
|
136
|
-
})
|