-
Notifications
You must be signed in to change notification settings - Fork 2.1k
bugfix dashboard empty state #709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix dashboard empty state #709
Conversation
Fixes NoFxAiOS#449 ## Problem When users first register and access the dashboard without configuring any traders, the page shows a perpetual loading skeleton with no guidance, resulting in poor UX. ## Solution - Distinguish between "loading" and "empty" states - Show friendly empty state when traders array is empty - Add i18n support for empty state messages (English & Chinese) - Provide clear CTA button to navigate to traders configuration page ## Changes 1. **Updated TraderDetailsPage component** (App.tsx) - Added `onNavigateToTraders` callback prop - Check if `traders` array is loaded and empty - Show empty state UI with icon, title, description, and CTA button - Keep loading skeleton for actual loading states 2. **Added i18n translations** (translations.ts) - `dashboardEmptyTitle`: "No Traders Configured" / "暂无交易员" - `dashboardEmptyDescription`: Helpful guidance text - `goToTradersPage`: "Go to Traders Page" / "前往交易员页面" 3. **Empty State UI Features** - Centered layout with icon and text - Brand-colored robot icon - Clear messaging about what to do next - Prominent CTA button with gradient style - Responsive design ## Testing - ✅ Build passes - ✅ TypeScript compilation succeeds - ✅ Loading skeleton shows during initial load - ✅ Empty state shows when no traders configured - ✅ Normal dashboard shows when traders exist - ✅ CTA button navigates to traders page 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
## Problem
When backend API returns 404 or other errors (e.g., backend not running),
the dashboard shows perpetual loading skeleton because traders data remains
undefined and there's no error handling.
## Solution
- Added error state handling from useSWR
- When API error occurs, show empty state UI instead of loading skeleton
- Set shouldRetryOnError: false to avoid infinite retries when backend is down
- Provide clear guidance to users even when backend is unavailable
## Changes
1. **Updated useSWR call** (App.tsx)
- Extract error state: const { data: traders, error: tradersError }
- Add shouldRetryOnError: false option
- Prevents infinite retry loops when backend is unavailable
2. **Updated TraderDetailsPage component**
- Added tradersError prop and type definition
- Check tradersError first before checking empty state
- Show empty state UI when API fails (likely backend not running)
- Provides same friendly UI whether backend is down or no traders configured
## Testing
- ✅ Build passes
- ✅ TypeScript compilation succeeds
- ✅ Shows loading skeleton initially
- ✅ Shows empty state when API fails (404)
- ✅ Shows empty state when traders array is empty
- ✅ Shows normal dashboard when traders exist
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
Replaced the 📡 emoji in the Signal Source button with a Radio icon from lucide-react to fix a white square appearing in the bottom-right corner on hover. Emojis can cause rendering artifacts when combined with CSS transforms like hover:scale-105. This change makes the button consistent with other buttons that use icon components. Changes: - Added Radio icon import from lucide-react - Replaced emoji with <Radio> component in Signal Source button - Added flex layout and gap for proper icon spacing - Removed emojis from warning text and modal title for consistency 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Changed button container overflow from 'overflow-x-auto' to 'overflow-hidden' to prevent a scrollbar from appearing when buttons scale up on hover. The scrollbar was appearing as a white square in the corner when hovering over buttons. Since the container uses flex-wrap on mobile and only has 4 buttons, overflow-hidden is safe and won't cut off content. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
🤖 Advisory Check ResultsThese are advisory checks to help improve code quality. They won't block your PR from being merged. 📋 PR InformationTitle Format: Recommended formatValid types: Examples:
PR Size: 🟢 Small (146 lines: +140 -6) 🔧 Backend ChecksGo Formatting: ✅ Good Fix locally: go fmt ./... # Format code
go vet ./... # Check for issues
go test ./... # Run tests⚛️ Frontend ChecksBuild & Type Check: ✅ Success Fix locally: cd web
npm run build # Test build (includes type checking)📖 ResourcesQuestions? Feel free to ask in the comments! 🙏 These checks are advisory and won't block your PR from being merged. This comment is automatically generated from pr-checks-run.yml. |
|
Could you pls add some snapshots? |
代码审查报告 - PR #709审查结果:✅ 通过业务层面审查✅ 需求验证
✅ 功能完整性
技术层面审查✅ 实现合理性
✅ UI/UX设计
✅ 性能优化
E2E 验证报告✅ 用户流程验证场景1:后端未运行场景2:无交易员场景3:点击CTA按钮✅ 导航验证
🟡 改进建议(非 BLOCKING)建议1:使用 React Router 导航(如果项目有)当前:手动 import { useNavigate } from 'react-router-dom'
const navigate = useNavigate()
<button onClick={() => navigate('/traders')}>
{t('goToTradersPage', language)}
</button>理由:
建议2:空状态组件复用性当前:两个空状态的代码几乎相同(重复代码) const EmptyState = ({
title,
description,
onAction
}: {
title: string
description: string
onAction: () => void
}) => (
<div className="flex items-center justify-center min-h-[60vh]">
{/* 空状态UI */}
</div>
)
// 使用
if (tradersError) {
return <EmptyState
title={t('dashboardEmptyTitle', language)}
description={t('dashboardEmptyDescription', language)}
onAction={onNavigateToTraders}
/>
}建议3:区分错误类型当前:所有 if (tradersError) {
// 网络错误
if (tradersError.message.includes('Network')) {
return <EmptyState title="网络连接失败" ... />
}
// 认证错误
if (tradersError.message.includes('401')) {
return <EmptyState title="认证失败" ... />
}
// 其他错误
return <EmptyState title="无法加载数据" ... />
}建议4:添加重试按钮(对于错误场景)if (tradersError) {
return (
<EmptyState
title={t('dashboardErrorTitle', language)}
description={t('dashboardErrorDescription', language)}
actions={[
{
label: t('retry', language),
onClick: () => mutate('traders'), // 重新请求
},
{
label: t('goToTradersPage', language),
onClick: onNavigateToTraders,
},
]}
/>
)
}多语言验证✅ i18n 集成
|
hzb1115
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM


Pull Request - Frontend | 前端 PR
建议标题:
fix(ui): add empty state for dashboard when no traders configured📝 Description | 描述
English:
This PR fixes issue #449 where new users accessing the dashboard without configuring any traders would see a perpetual loading skeleton with no guidance. Now, users see a friendly empty state with clear instructions on what to do next.
中文:
此 PR 修复了 issue #449,新用户在未配置任何交易员的情况下访问看板页面时,会看到持续的加载动画而没有任何引导。现在,用户会看到友好的空状态提示,并清楚了解下一步该做什么。
🎯 Type of Change | 变更类型
🔗 Related Issues | 相关 Issue
📋 Changes Made | 具体变更
English:
1. Updated TraderDetailsPage Component
File:
src/App.tsxDistinguish Loading vs Empty States:
tradersisundefined: Show loading skeleton (data is being fetched)tradersis empty array[]: Show empty state UI (no traders configured)tradershas items but!selectedTrader: Show loading skeleton (trader data loading)Added Empty State UI:
Added Navigation Callback:
onNavigateToTradersfor empty state button/traderspage when clicked2. Added I18n Translations
File:
src/i18n/translations.tsEnglish translations:
dashboardEmptyTitle: "No Traders Configured"dashboardEmptyDescription: "You haven't created any AI traders yet. Create your first trader to start automated trading."goToTradersPage: "Go to Traders Page"Chinese translations:
dashboardEmptyTitle: "暂无交易员"dashboardEmptyDescription: "您还未创建任何AI交易员,创建您的第一个交易员以开始自动化交易。"goToTradersPage: "前往交易员页面"中文:
1. 更新 TraderDetailsPage 组件
文件:
src/App.tsx区分加载和空状态:
traders是undefined:显示加载骨架屏(数据正在获取中)traders是空数组[]:显示空状态 UI(未配置交易员)traders有数据但!selectedTrader:显示加载骨架屏(交易员数据加载中)添加空状态 UI:
添加导航回调:
onNavigateToTraders用于空状态按钮/traders页面2. 添加国际化翻译
文件:
src/i18n/translations.ts英文翻译:
dashboardEmptyTitle: "No Traders Configured"dashboardEmptyDescription: "You haven't created any AI traders yet. Create your first trader to start automated trading."goToTradersPage: "Go to Traders Page"中文翻译:
dashboardEmptyTitle: "暂无交易员"dashboardEmptyDescription: "您还未创建任何AI交易员,创建您的第一个交易员以开始自动化交易。"goToTradersPage: "前往交易员页面"📸 Screenshots / Demo | 截图/演示
Before | 变更前:
After | 变更后:
Empty State UI:
Loading State (unchanged):
🧪 Testing | 测试
Test Environment | 测试环境
Manual Testing | 手动测试
Test Scenarios | 测试场景
Scenario 1: New User (No Traders)
/dashboard/traderspageScenario 2: Existing User (Has Traders)
/dashboardScenario 3: Loading State
/dashboardimmediatelyScenario 4: Language Switching
🌐 Internationalization | 国际化
Translation Keys Added:
✅ Checklist | 检查清单
Code Quality | 代码质量
npm run build)npm run lint| 已运行npm run lint(via husky pre-commit)Testing | 测试
Documentation | 文档
Git
devbranch | 已 rebase 到最新dev分支📚 Additional Notes | 补充说明
English:
This is a straightforward UX improvement fix that addresses a common pain point for new users. The solution is clean, maintainable, and follows existing code patterns in the application.
Key Design Decisions:
State Distinction: Used the
tradersarray state to determine:undefined= still loading[]= loaded but empty[...]= has dataUI Pattern: Followed common empty state patterns:
I18n First: All new user-facing text is internationalized from the start
Navigation: Reused existing navigation patterns for consistency
中文:
这是一个直接的用户体验改进修复,解决了新用户的常见痛点。解决方案简洁、易维护,并遵循应用程序中的现有代码模式。
关键设计决策:
状态区分: 使用
traders数组状态判断:undefined= 仍在加载[]= 已加载但为空[...]= 有数据UI 模式: 遵循常见的空状态模式:
优先国际化: 所有新的面向用户的文本从一开始就国际化
导航: 重用现有导航模式以保持一致性
By submitting this PR, I confirm | 提交此 PR,我确认:
🌟 Thank you for your contribution! | 感谢你的贡献!