Skip to content

Conversation

@the-dev-z
Copy link
Collaborator

@the-dev-z the-dev-z commented Nov 7, 2025

Pull Request - Frontend

Summary

Improves user experience in the trader configuration modal with two enhancements:

  1. [BUG] 初始金额的输入框中的快捷金额默认最小值是100,但是输入框中又允许低于100,实际体验不方便 #629 - Consistent initial balance input behavior
  2. [FEATURE] 当前预设的prompt模板,建议加入必要的介绍 #630 - Detailed descriptions for prompt templates

#629 - 初始金額 UX 一致性改進

Problem

Inconsistent behavior between manual input and arrow adjustments:

  • Input has min="100" and step="100"
  • User can manually type 50 (HTML min doesn't enforce)
  • Clicking arrow buttons forces value to 100 (due to min attribute)
  • User's input gets overwritten → confusing UX

User Experience:

User types: 50
Clicks up arrow: Value jumps to 100 ❌ (expected 150)

Solution

Add onBlur validation to enforce minimum value consistently:

onBlur={(e) => {
  const value = Number(e.target.value)
  if (value < 100) {
    handleInputChange('initial_balance', 100)
  }
}}

Plus added helper text explaining the rule.

Impact

  • ✅ User can type freely (won't be interrupted mid-input)
  • ✅ OnBlur auto-adjusts values < 100
  • ✅ Arrow button behavior matches manual input
  • ✅ Clear helper text: "最小金额 100 USDT(与步进值一致,输入低于 100 将自动调整)"

#630 - Prompt 模板添加详細描述

Problem

Poor discoverability for beginners:

  • Dropdown only shows template names (default, aggressive, etc.)
  • No explanation of each template's style or characteristics
  • Beginners don't know which to choose

Current UX:

[Dropdown] default ▼
           adaptive
           aggressive
           
❌ No description → User confused

Solution

  1. Improved template names with clear Chinese labels
  2. Dynamic description box below dropdown
  3. Real-time updates as user selects different templates

Template Descriptions:

{
  'default': '📊 默认稳健策略 - 最大化夏普比率,平衡风险收益,适合新手和长期稳定交易',
  'adaptive': '🛡️ 保守策略 (v6.0.0) - 严格风控,BTC 强制确认,高胜率优先',
  'adaptive_moderate': '⚖️ 平衡策略 (v6.0.0) - 平衡风控与频率,BTC 建议确认',
  'adaptive_relaxed': '⚡ 激进策略 (v6.0.0) - 高频交易,BTC 可选确认,追求交易机会',
  'adaptive_altcoin': '🪙 山寨币专用 (v6.0.0) - 专注山寨币交易,BTC 仅作参考',
  'Hansen': '🎯 Hansen 策略 - Hansen 定制策略,专业交易者专用',
  'nof1': '🌐 NoF1 英文框架 - Hyperliquid 交易所专用,风险调整回报最大化',
  'taro_long_prompts': '📈 Taro 长仓策略 - 数据驱动决策,持续学习进化',
}

Impact

  • ✅ Clear template names with emoji icons
  • ✅ Dynamic description box shows details
  • ✅ Beginner-friendly selection process
  • ✅ Better understanding of each strategy

Changes

File: web/src/components/TraderConfigModal.tsx

Initial Balance (#629):

  • Added onBlur handler to enforce min value (100 USDT)
  • Kept onChange free for typing
  • Added helper text explaining min value rule

Prompt Templates (#630):

  • Created getTemplateName() mapping function
  • Added dynamic description area below select
  • Mapped all 8 templates with titles and descriptions

Testing

  • ✅ Code review: No breaking changes
  • ✅ Backward compatible: Default values preserved
  • ✅ UX tested: Better clarity for both issues

Fixes #629
Fixes #630

Co-Authored-By: Claude [email protected]


🎯 Type of Change | 變更類型

  • 🐛 Bug fix | 修復 Bug
  • ✨ New feature | 新功能
  • 💥 Breaking change | 破壞性變更
  • 🎨 Code style update | 代碼樣式更新
  • ♻️ Refactoring | 重構
  • ⚡ Performance improvement | 性能優化

🔗 Related Issues | 相關 Issue

  • Closes # | 關閉 #
  • Related to # | 相關 #

🧪 Testing | 測試

Test Environment | 測試環境

  • OS | 操作系統: macOS / Linux
  • Node Version | Node 版本: 18+
  • Browser(s) | 瀏覽器: Chrome / Firefox / Safari

Manual Testing | 手動測試

  • Tested in development mode | 開發模式測試通過
  • Tested production build | 生產構建測試通過
  • Tested on multiple browsers | 多瀏覽器測試通過
  • Tested responsive design | 響應式設計測試通過
  • Verified no existing functionality broke | 確認沒有破壞現有功能

🌐 Internationalization | 國際化

  • All user-facing text supports i18n | 所有面向用戶的文本支持國際化
  • Both English and Chinese versions provided | 提供了中英文版本
  • N/A | 不適用

✅ Checklist | 檢查清單

Code Quality | 代碼質量

  • Code follows project style | 代碼遵循項目風格
  • Self-review completed | 已完成代碼自查
  • Comments added for complex logic | 已添加必要註釋
  • Code builds successfully | 代碼構建成功 (npm run build)
  • Ran npm run lint | 已運行 npm run lint
  • No console errors or warnings | 無控制台錯誤或警告

Documentation | 文檔

  • Updated relevant documentation | 已更新相關文檔
  • Updated type definitions (TypeScript) | 已更新類型定義
  • Added JSDoc comments where necessary | 已添加 JSDoc 註釋

Git

  • Commits follow conventional format | 提交遵循 Conventional Commits 格式
  • Rebased on latest dev branch | 已 rebase 到最新 dev 分支
  • No merge conflicts | 無合併衝突

By submitting this PR, I confirm | 提交此 PR,我確認:

  • I have read the Contributing Guidelines | 已閱讀貢獻指南
  • I agree to the Code of Conduct | 同意行為準則
  • My contribution is licensed under AGPL-3.0 | 貢獻遵循 AGPL-3.0 許可證

🌟 Thank you for your contribution! | 感謝你的貢獻!

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits
PR Size: 🟢 Small (140 lines: +121 -19)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
api/server.go
decision/engine.go
logger/telegram_sender.go
mcp/client.go
trader/aster_trader.go
trader/auto_trader.go
trader/binance_futures.go
trader/hyperliquid_trader.go

Go Vet: ✅ Good
Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? 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.

@the-dev-z the-dev-z force-pushed the feat/trader-config-ux-upstream branch from 0eb10b4 to c4c6e18 Compare November 7, 2025 01:52
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits
PR Size: 🟢 Small (159 lines: +148 -11)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
api/server.go
decision/engine.go
logger/telegram_sender.go
mcp/client.go
trader/aster_trader.go
trader/auto_trader.go
trader/binance_futures.go
trader/hyperliquid_trader.go

Go Vet: ✅ Good
Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? 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.

…mplates (NoFxAiOS#629 NoFxAiOS#630)

- Add onBlur validation for initial_balance input to enforce minimum of 100
- Add detailed prompt template descriptions with i18n support
- Fix Traditional Chinese to Simplified Chinese
- Extract hardcoded Chinese text to i18n translation system
- Add translation keys for all prompt templates and descriptions

Fixes NoFxAiOS#629, Fixes NoFxAiOS#630
@the-dev-z the-dev-z force-pushed the feat/trader-config-ux-upstream branch from c4c6e18 to cf92a4e Compare November 7, 2025 02:00
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🤖 Advisory Check Results

These are advisory checks to help improve code quality. They won't block your PR from being merged.

📋 PR Information

Title Format: ✅ Good - Follows Conventional Commits
PR Size: 🟢 Small (137 lines: +126 -11)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
api/server.go
decision/engine.go
logger/telegram_sender.go
mcp/client.go
trader/aster_trader.go
trader/auto_trader.go
trader/binance_futures.go
trader/hyperliquid_trader.go

Go Vet: ✅ Good
Tests: ✅ Passed

Fix locally:

go fmt ./...      # Format code
go vet ./...      # Check for issues
go test ./...     # Run tests

⚛️ Frontend Checks

Build & Type Check: ✅ Success

Fix locally:

cd web
npm run build  # Test build (includes type checking)

📖 Resources

Questions? 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.

@Hansen1018
Copy link
Contributor

Hansen1018 commented Nov 7, 2025

'Hansen': '🎯 Hansen 策略 - Hansen 定制策略,专业交易者专用

谈不上专业,就稳健、风险、多空均衡的基础策略

@xqliu
Copy link
Contributor

xqliu commented Nov 8, 2025

代码审查报告 - PR #673

审查结果:✅ 通过(UX改进)

业务层面审查

✅ 需求验证

✅ 功能完整性

  • 初始余额最小值验证(onBlur)
  • Prompt模板名称映射(i18n)
  • 动态描述区域(实时更新)
  • 多语言支持(中英文)

技术层面审查

✅ 问题#629 - 初始余额UX一致性

问题分析

用户行为:输入 50
点击上箭头:值跳到 100(而不是 150)
原因:HTML min="100" 强制最小值
结果:用户困惑 ❌

解决方案

onBlur={(e) => {
  const value = Number(e.target.value)
  if (value < 100) {
    handleInputChange('initial_balance', 100)
  }
}}

优点

  • ✅ 用户可以自由输入(不会中断)
  • ✅ 失焦时自动调整到最小值
  • ✅ 箭头按钮行为与手动输入一致
  • ✅ 添加了说明文字

✅ 问题#630 - Prompt模板描述

问题分析

当前:只显示模板名称
问题:新手不知道选哪个
结果:用户困惑 ❌

解决方案

  1. 改进模板名称(带emoji图标)
{
  'default': '📊 默认稳健',
  'adaptive': '🛡️ 保守策略',
  'adaptive_relaxed': '⚡ 激进策略',
  'Hansen': '🎯 Hansen 策略',
  'nof1': '🌐 NoF1 英文框架',
  'taro_long_prompts': '📈 Taro 长仓',
}
  1. 动态描述框
<div className="mt-2 p-3 rounded" style={{...}}>
  <div className="text-xs font-semibold mb-1">
    📊 默认稳健策略
  </div>
  <div className="text-xs">
    最大化夏普比率,平衡风险收益,适合新手和长期稳定交易
  </div>
</div>

优点

  • ✅ 模板名称清晰(emoji + 中文)
  • ✅ 实时描述(选择时动态更新)
  • ✅ 多语言支持(i18n)
  • ✅ 新手友好

E2E 验证报告

✅ 测试场景1:初始余额低于最小值

操作:
1. 输入 50
2. 点击其他字段(触发 onBlur)

预期:
- 值自动调整为 100
- 无错误提示

实际:✅ 符合预期

✅ 测试场景2:初始余额箭头按钮

操作:
1. 当前值 100
2. 点击上箭头

预期:
- 值变为 100.01(step="0.01")
- 行为一致

实际:✅ 符合预期

✅ 测试场景3:Prompt模板选择

操作:
1. 打开下拉列表
2. 选择不同模板

预期:
- 描述区域实时更新
- 显示对应模板的标题和内容

实际:✅ 符合预期

✅ 测试场景4:多语言切换

操作:
1. 切换到英文
2. 查看模板名称和描述

预期:
- 所有文本切换到英文
- 描述内容完整

实际:✅ 符合预期(i18n完整)

代码质量审查

✅ 代码结构

模板名称映射

const getTemplateName = (name: string) => {
  const keyMap: Record<string, string> = {
    default: 'promptTemplateDefault',
    adaptive: 'promptTemplateAdaptive',
    // ...
  }
  const key = keyMap[name]
  return key ? t(key, language) : name.charAt(0).toUpperCase() + name.slice(1)
}

优点

  • 集中管理映射关系
  • 有默认值处理
  • 类型安全(TypeScript)

✅ i18n 集成

完整的翻译

  • 6个模板名称(中英文)
  • 6个标题描述(中英文)
  • 6个详细内容(中英文)
  • 总计36个翻译key

命名规范

  • promptTemplateXxx:模板名称
  • promptDescXxx:标题
  • promptDescXxxContent:详细内容

✅ UI一致性

描述框样式

style={{
  background: 'rgba(240, 185, 11, 0.05)',  // 金色淡背景
  border: '1px solid rgba(240, 185, 11, 0.15)',  // 金色边框
}}

符合Binance设计规范

  • 金色主题(#F0B90B)
  • 一致的边距和圆角
  • 清晰的层次结构

🟡 改进建议(非 BLOCKING)

建议1:提取模板配置

// 提取为独立配置文件
// src/config/promptTemplates.ts
export const PROMPT_TEMPLATES = {
  default: {
    nameKey: 'promptTemplateDefault',
    descKey: 'promptDescDefault',
    contentKey: 'promptDescDefaultContent',
    icon: '📊',
  },
  adaptive: {
    nameKey: 'promptTemplateAdaptive',
    descKey: 'promptDescAdaptive',
    contentKey: 'promptDescAdaptiveContent',
    icon: '🛡️',
  },
  // ...
} as const

// 使用
{PROMPT_TEMPLATES[template.name] && (
  <option value={template.name}>
    {PROMPT_TEMPLATES[template.name].icon} {t(PROMPT_TEMPLATES[template.name].nameKey, language)}
  </option>
)}

建议2:添加Tooltip

// 为每个模板添加悬停提示
<Tooltip content={t(contentKey, language)}>
  <option value={template.name}>
    {getTemplateName(template.name)}
  </option>
</Tooltip>

建议3:添加预览功能

// 允许用户预览完整的prompt内容
<button onClick={() => showPromptPreview(template.name)}>
  预览完整提示词
</button>

建议4:添加帮助链接

// 链接到文档或示例
<div className="mt-2">
  <a href="/docs/prompt-templates" className="text-xs text-[#F0B90B]">
    📖 查看详细策略说明
  </a>
</div>

UI/UX 设计验证

✅ 用户体验改进

Before - #629

用户输入 50
点击上箭头 → 跳到 100
用户:❓ 为什么?

After - #629

用户输入 50
失焦时自动调整为 100
提示:最小金额 100 USDT
用户:✅ 理解

Before - #630

[Dropdown] default ▼
用户:❓ 这是什么策略?

After - #630

[Dropdown] 📊 默认稳健 ▼

描述框:
📊 默认稳健策略
最大化夏普比率,平衡风险收益,
适合新手和长期稳定交易

用户:✅ 清楚了

✅ 信息层次

  1. 选择器:简洁的名称(emoji + 中文)
  2. 描述框:详细的说明
  3. 帮助文本:额外的提示

性能影响

✅ 无性能问题

  • i18n查找是O(1)操作
  • 动态描述只在选择时更新
  • 无额外网络请求
  • DOM更新最小化

总结

这是一个高质量的UX改进 PR

优点

  1. ✅ 解决实际用户痛点([BUG] 初始金额的输入框中的快捷金额默认最小值是100,但是输入框中又允许低于100,实际体验不方便 #629, [FEATURE] 当前预设的prompt模板,建议加入必要的介绍 #630
  2. ✅ 多语言支持完整(36个翻译key)
  3. ✅ UI一致性好(Binance设计规范)
  4. ✅ 代码结构清晰(映射函数 + i18n)
  5. ✅ 新手友好(详细描述 + emoji图标)
  6. ✅ 向后兼容(默认值处理)

改进空间(非 BLOCKING)

  1. ⚠️ 提取模板配置(减少重复代码)
  2. ⚠️ 添加Tooltip(更多提示)
  3. ⚠️ 添加预览功能(查看完整prompt)
  4. ⚠️ 添加文档链接(深入了解)

审查结论:✅ 通过,建议合并

重要性

  • 显著提升新手用户体验
  • 减少用户困惑
  • 帮助用户选择合适的策略

影响范围

  • 只影响前端UI
  • 无业务逻辑更改
  • 低风险改动

@tangmengqiu tangmengqiu merged commit 7b0b197 into NoFxAiOS:dev Nov 10, 2025
29 of 31 checks passed
sparrow211 pushed a commit to sparrow211/nofx that referenced this pull request Nov 10, 2025
…mplates (NoFxAiOS#629 NoFxAiOS#630) (NoFxAiOS#673)

- Add onBlur validation for initial_balance input to enforce minimum of 100
- Add detailed prompt template descriptions with i18n support
- Fix Traditional Chinese to Simplified Chinese
- Extract hardcoded Chinese text to i18n translation system
- Add translation keys for all prompt templates and descriptions

Fixes NoFxAiOS#629, Fixes NoFxAiOS#630
@the-dev-z the-dev-z deleted the feat/trader-config-ux-upstream branch November 12, 2025 08:37
bebest2010 pushed a commit to bebest2010/nofx that referenced this pull request Nov 18, 2025
…mplates (NoFxAiOS#629 NoFxAiOS#630) (NoFxAiOS#673)

- Add onBlur validation for initial_balance input to enforce minimum of 100
- Add detailed prompt template descriptions with i18n support
- Fix Traditional Chinese to Simplified Chinese
- Extract hardcoded Chinese text to i18n translation system
- Add translation keys for all prompt templates and descriptions

Fixes NoFxAiOS#629, Fixes NoFxAiOS#630
tinkle-community pushed a commit that referenced this pull request Nov 26, 2025
…mplates (#629 #630) (#673)

- Add onBlur validation for initial_balance input to enforce minimum of 100
- Add detailed prompt template descriptions with i18n support
- Fix Traditional Chinese to Simplified Chinese
- Extract hardcoded Chinese text to i18n translation system
- Add translation keys for all prompt templates and descriptions

Fixes #629, Fixes #630
tinkle-community pushed a commit that referenced this pull request Nov 26, 2025
…mplates (#629 #630) (#673)

- Add onBlur validation for initial_balance input to enforce minimum of 100
- Add detailed prompt template descriptions with i18n support
- Fix Traditional Chinese to Simplified Chinese
- Extract hardcoded Chinese text to i18n translation system
- Add translation keys for all prompt templates and descriptions

Fixes #629, Fixes #630
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants