Skip to content

Conversation

@the-dev-z
Copy link
Collaborator

Pull Request - Frontend | 前端 PR

📝 Description | 描述

English:
This PR fixes a critical bug where the system_prompt_template (strategy template) selection is not persisted when editing a trader. Users would select a strategy template, save the changes, but upon reopening the edit modal, the selection would revert to the default value instead of showing their saved choice.

中文:
修复编辑交易员时策略模板(system_prompt_template)选择无法保存的严重问题。用户选择策略模板并保存后,重新打开编辑窗口时,选择会恢复为默认值而非用户保存的值。


🎯 Type of Change | 变更类型

  • 🐛 Bug fix | 修复 Bug
  • ✨ New feature | 新功能
  • 💥 Breaking change | 破坏性变更
  • 🎨 Code style update | 代码样式更新
  • ♻️ Refactoring | 重构
  • ⚡ Performance improvement | 性能优化

🔗 Related Issues | 相关 Issue

用户反馈:编辑交易员时,策略模板选择无法持久化


📋 Changes Made | 具体变更

English:

中文:


🐛 Root Cause Analysis | 根本原因分析

Timeline:

  1. 2025-11-03 (commit c1f080f): system_prompt_template field support added to trader edit functionality
  2. 2025-11-11 (commit aa0bd93, PR Refactor(UI) : Refactor Frontend: Unified Toasts with Sonner, Introduced Layout System, and Integrated React Router #872): Large-scale UI refactor accidentally removed this line during code reorganization
  3. Result: Both origin/dev and z-dev-v2 branches affected by this regression

Impact:

  • Frontend modal correctly displays the saved system_prompt_template value when opening edit
  • Frontend correctly includes system_prompt_template in the form data
  • BUT the handleSaveEditTrader function was missing this field in the API request object
  • Backend receives incomplete data and doesn't update the template field
  • Next time user opens edit modal, old value is loaded from database

Fix:
Added one line (289) in the request object construction:

system_prompt_template: data.system_prompt_template,

Now the complete flow works:

  1. User selects strategy template in edit modal ✓
  2. Form data includes the selection ✓
  3. API request includes the field ✓ (FIXED)
  4. Backend saves the selection ✓
  5. Next edit shows saved value ✓

🧪 Testing | 测试

Test Environment | 测试环境

  • OS | 操作系统: macOS Darwin 24.5.0
  • Node Version | Node 版本: Latest stable
  • Browser(s) | 浏览器: Chrome/Safari/Firefox

Manual Testing | 手动测试

  • Tested in development mode | 开发模式测试通过
  • Verified trader edit saves system_prompt_template correctly | 确认交易员编辑正确保存策略模板
  • Verified reopening edit modal displays saved template | 确认重新打开编辑窗口显示保存的模板
  • Verified no existing functionality broke | 确认没有破坏现有功能
  • Code builds successfully | 代码构建成功

🌐 Internationalization | 国际化

  • All user-facing text supports i18n | 所有面向用户的文本支持国际化
  • Both English and Chinese versions provided | 提供了中英文版本
  • N/A | 不适用(此修复仅涉及数据传输,无UI文本变更)

✅ Checklist | 检查清单

Code Quality | 代码质量

  • Code follows project style | 代码遵循项目风格
  • Self-review completed | 已完成代码自查
  • Code builds successfully | 代码构建成功
  • No console errors or warnings | 无控制台错误或警告

Testing | 测试

  • Manually tested edit-save-reopen flow | 手动测试编辑-保存-重新打开流程
  • Verified API request includes system_prompt_template | 确认 API 请求包含 system_prompt_template

Documentation | 文档

  • Updated type definitions (TypeScript) | 已更新类型定义(无需更改,types.ts 已正确定义)

Git

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

📚 Additional Notes | 补充说明

English:
This is a regression fix. The field was working correctly after c1f080f but was lost during the PR #872 refactoring. This affects all users editing traders with custom strategy templates.

中文:
这是一个回归修复。该字段在 c1f080f 之后工作正常,但在 PR #872 重构期间丢失。影响所有使用自定义策略模板编辑交易员的用户。


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 许可证

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

修復編輯交易員時策略模板無法保存的問題。

Issue:
- 用戶編輯交易員時,選擇的策略模板(system_prompt_template)沒有被保存
- 重新打開編輯窗口,總是顯示默認值
- 用戶困惑為什麼策略模板無法持久化

Root Cause:
- PR NoFxAiOS#872 在 UI 重構時遺漏了 system_prompt_template 字段
- handleSaveEditTrader 的 request 對象缺少 system_prompt_template
- 導致更新請求不包含策略模板信息

Fix:
- 在 handleSaveEditTrader 的 request 對象中添加 system_prompt_template 字段
- 位置:override_base_prompt 之後,is_cross_margin 之前
- 與後端 API 和 TraderConfigModal 保持一致

Result:
- 編輯交易員時,策略模板正確保存
- 重新打開編輯窗口,顯示正確的已保存值
- 用戶可以成功切換和保存不同的策略模板

Technical Details:
- web/src/types.ts TraderConfigData 接口已有 system_prompt_template ✓
- Backend handleUpdateTrader 接收並保存 SystemPromptTemplate ✓
- Frontend TraderConfigModal 表單提交包含 system_prompt_template ✓
- Frontend handleSaveEditTrader request 缺失此字段 ✗ → ✓ (已修復)

Related:
- PR NoFxAiOS#872: UI 重構時遺漏
- commit c1f080f: 原始添加 system_prompt_template 支持
- commit e58fc3c: 修復 types.ts 缺失字段

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link

🤖 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 (1 lines: +1 -0)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
decision/prompt_manager_test.go
market/data_test.go
trader/hyperliquid_trader_race_test.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.

補充完整修復:確保 TypeScript 類型定義與 API 使用一致。

Issue:
- AITradersPage.tsx 提交時包含 system_prompt_template 字段
- 但 TraderConfigData 接口缺少此字段定義
- TypeScript 類型不匹配

Fix:
- 在 TraderConfigData 接口添加 system_prompt_template: string
- 位置:override_base_prompt 之後,is_cross_margin 之前
- 與 CreateTraderRequest 保持一致

Result:
- TypeScript 類型完整
- 編輯交易員時正確加載和保存策略模板
- 無類型錯誤

Technical:
- web/src/types.ts Line 200
- 與後端 SystemPromptTemplate 字段對應

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link

🤖 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 (2 lines: +2 -0)

🔧 Backend Checks

Go Formatting: ⚠️ Needs formatting

Files needing formatting
decision/prompt_manager_test.go
market/data_test.go
trader/hyperliquid_trader_race_test.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.

@hzb1115 hzb1115 merged commit cc4522e into NoFxAiOS:dev Nov 12, 2025
16 checks passed
the-dev-z added a commit to the-dev-z/nofx that referenced this pull request Nov 12, 2025
Includes:
- PR NoFxAiOS#931: Fix Go formatting for test files
- PR NoFxAiOS#800: Data staleness detection (Part 2/3) - already in z-dev-v2
- PR NoFxAiOS#918: Improve UX messages for empty states and error feedback
- PR NoFxAiOS#922: Fix missing system_prompt_template field in trader edit
- PR NoFxAiOS#921: Remove duplicate exchange config fields (Aster & Hyperliquid)
- PR NoFxAiOS#917: Fix two-stage private key input validation (0x prefix support)
- PR NoFxAiOS#713: Add backend safety checks for partial_close
- PR NoFxAiOS#908: Web Crypto environment check (0xEmberZz)
- PR NoFxAiOS#638: Decision limit selector with 5/10/20/50 options (xqliu)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

# Conflicts:
#	market/data.go
#	web/src/components/TwoStageKeyModal.tsx
@the-dev-z the-dev-z deleted the fix/system-prompt-template-save branch November 12, 2025 08:36
@the-dev-z
Copy link
Collaborator Author

Verified Fixed

This issue has been resolved by PR #922 (merged to dev on 2025-11-12).

Fix Details:
Restored missing system_prompt_template field in trader edit request.

Recommendation: This issue can be closed.

cc @xqliu @hzb1115

bebest2010 pushed a commit to bebest2010/nofx that referenced this pull request Nov 18, 2025
… request (NoFxAiOS#922)

* fix(web): restore missing system_prompt_template in handleSaveEditTrader

修復編輯交易員時策略模板無法保存的問題。

Issue:
- 用戶編輯交易員時,選擇的策略模板(system_prompt_template)沒有被保存
- 重新打開編輯窗口,總是顯示默認值
- 用戶困惑為什麼策略模板無法持久化

Root Cause:
- PR NoFxAiOS#872 在 UI 重構時遺漏了 system_prompt_template 字段
- handleSaveEditTrader 的 request 對象缺少 system_prompt_template
- 導致更新請求不包含策略模板信息

Fix:
- 在 handleSaveEditTrader 的 request 對象中添加 system_prompt_template 字段
- 位置:override_base_prompt 之後,is_cross_margin 之前
- 與後端 API 和 TraderConfigModal 保持一致

Result:
- 編輯交易員時,策略模板正確保存
- 重新打開編輯窗口,顯示正確的已保存值
- 用戶可以成功切換和保存不同的策略模板

Technical Details:
- web/src/types.ts TraderConfigData 接口已有 system_prompt_template ✓
- Backend handleUpdateTrader 接收並保存 SystemPromptTemplate ✓
- Frontend TraderConfigModal 表單提交包含 system_prompt_template ✓
- Frontend handleSaveEditTrader request 缺失此字段 ✗ → ✓ (已修復)

Related:
- PR NoFxAiOS#872: UI 重構時遺漏
- commit c1f080f: 原始添加 system_prompt_template 支持
- commit e58fc3c: 修復 types.ts 缺失字段

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix(types): add missing system_prompt_template field to TraderConfigData

補充完整修復:確保 TypeScript 類型定義與 API 使用一致。

Issue:
- AITradersPage.tsx 提交時包含 system_prompt_template 字段
- 但 TraderConfigData 接口缺少此字段定義
- TypeScript 類型不匹配

Fix:
- 在 TraderConfigData 接口添加 system_prompt_template: string
- 位置:override_base_prompt 之後,is_cross_margin 之前
- 與 CreateTraderRequest 保持一致

Result:
- TypeScript 類型完整
- 編輯交易員時正確加載和保存策略模板
- 無類型錯誤

Technical:
- web/src/types.ts Line 200
- 與後端 SystemPromptTemplate 字段對應

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: the-dev-z <the-dev-z@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
tinkle-community added a commit that referenced this pull request Nov 26, 2025
… request (#922)

* fix(web): restore missing system_prompt_template in handleSaveEditTrader

修復編輯交易員時策略模板無法保存的問題。

Issue:
- 用戶編輯交易員時,選擇的策略模板(system_prompt_template)沒有被保存
- 重新打開編輯窗口,總是顯示默認值
- 用戶困惑為什麼策略模板無法持久化

Root Cause:
- PR #872 在 UI 重構時遺漏了 system_prompt_template 字段
- handleSaveEditTrader 的 request 對象缺少 system_prompt_template
- 導致更新請求不包含策略模板信息

Fix:
- 在 handleSaveEditTrader 的 request 對象中添加 system_prompt_template 字段
- 位置:override_base_prompt 之後,is_cross_margin 之前
- 與後端 API 和 TraderConfigModal 保持一致

Result:
- 編輯交易員時,策略模板正確保存
- 重新打開編輯窗口,顯示正確的已保存值
- 用戶可以成功切換和保存不同的策略模板

Technical Details:
- web/src/types.ts TraderConfigData 接口已有 system_prompt_template ✓
- Backend handleUpdateTrader 接收並保存 SystemPromptTemplate ✓
- Frontend TraderConfigModal 表單提交包含 system_prompt_template ✓
- Frontend handleSaveEditTrader request 缺失此字段 ✗ → ✓ (已修復)

Related:
- PR #872: UI 重構時遺漏
- commit c1f080f: 原始添加 system_prompt_template 支持
- commit e58fc3c: 修復 types.ts 缺失字段

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: tinkle-community <tinklefund@gmail.com>

* fix(types): add missing system_prompt_template field to TraderConfigData

補充完整修復:確保 TypeScript 類型定義與 API 使用一致。

Issue:
- AITradersPage.tsx 提交時包含 system_prompt_template 字段
- 但 TraderConfigData 接口缺少此字段定義
- TypeScript 類型不匹配

Fix:
- 在 TraderConfigData 接口添加 system_prompt_template: string
- 位置:override_base_prompt 之後,is_cross_margin 之前
- 與 CreateTraderRequest 保持一致

Result:
- TypeScript 類型完整
- 編輯交易員時正確加載和保存策略模板
- 無類型錯誤

Technical:
- web/src/types.ts Line 200
- 與後端 SystemPromptTemplate 字段對應

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: tinkle-community <tinklefund@gmail.com>

---------

Co-authored-by: the-dev-z <the-dev-z@users.noreply.github.com>
Co-authored-by: tinkle-community <tinklefund@gmail.com>
tinkle-community added a commit that referenced this pull request Nov 26, 2025
… request (#922)

* fix(web): restore missing system_prompt_template in handleSaveEditTrader

修復編輯交易員時策略模板無法保存的問題。

Issue:
- 用戶編輯交易員時,選擇的策略模板(system_prompt_template)沒有被保存
- 重新打開編輯窗口,總是顯示默認值
- 用戶困惑為什麼策略模板無法持久化

Root Cause:
- PR #872 在 UI 重構時遺漏了 system_prompt_template 字段
- handleSaveEditTrader 的 request 對象缺少 system_prompt_template
- 導致更新請求不包含策略模板信息

Fix:
- 在 handleSaveEditTrader 的 request 對象中添加 system_prompt_template 字段
- 位置:override_base_prompt 之後,is_cross_margin 之前
- 與後端 API 和 TraderConfigModal 保持一致

Result:
- 編輯交易員時,策略模板正確保存
- 重新打開編輯窗口,顯示正確的已保存值
- 用戶可以成功切換和保存不同的策略模板

Technical Details:
- web/src/types.ts TraderConfigData 接口已有 system_prompt_template ✓
- Backend handleUpdateTrader 接收並保存 SystemPromptTemplate ✓
- Frontend TraderConfigModal 表單提交包含 system_prompt_template ✓
- Frontend handleSaveEditTrader request 缺失此字段 ✗ → ✓ (已修復)

Related:
- PR #872: UI 重構時遺漏
- commit c1f080f: 原始添加 system_prompt_template 支持
- commit e58fc3c: 修復 types.ts 缺失字段

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: tinkle-community <tinklefund@gmail.com>

* fix(types): add missing system_prompt_template field to TraderConfigData

補充完整修復:確保 TypeScript 類型定義與 API 使用一致。

Issue:
- AITradersPage.tsx 提交時包含 system_prompt_template 字段
- 但 TraderConfigData 接口缺少此字段定義
- TypeScript 類型不匹配

Fix:
- 在 TraderConfigData 接口添加 system_prompt_template: string
- 位置:override_base_prompt 之後,is_cross_margin 之前
- 與 CreateTraderRequest 保持一致

Result:
- TypeScript 類型完整
- 編輯交易員時正確加載和保存策略模板
- 無類型錯誤

Technical:
- web/src/types.ts Line 200
- 與後端 SystemPromptTemplate 字段對應

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: tinkle-community <tinklefund@gmail.com>

---------

Co-authored-by: the-dev-z <the-dev-z@users.noreply.github.com>
Co-authored-by: tinkle-community <tinklefund@gmail.com>
tinkle-community pushed a commit that referenced this pull request Dec 7, 2025
… request (#922)

* fix(web): restore missing system_prompt_template in handleSaveEditTrader
修復編輯交易員時策略模板無法保存的問題。
Issue:
- 用戶編輯交易員時,選擇的策略模板(system_prompt_template)沒有被保存
- 重新打開編輯窗口,總是顯示默認值
- 用戶困惑為什麼策略模板無法持久化
Root Cause:
- PR #872 在 UI 重構時遺漏了 system_prompt_template 字段
- handleSaveEditTrader 的 request 對象缺少 system_prompt_template
- 導致更新請求不包含策略模板信息
Fix:
- 在 handleSaveEditTrader 的 request 對象中添加 system_prompt_template 字段
- 位置:override_base_prompt 之後,is_cross_margin 之前
- 與後端 API 和 TraderConfigModal 保持一致
Result:
- 編輯交易員時,策略模板正確保存
- 重新打開編輯窗口,顯示正確的已保存值
- 用戶可以成功切換和保存不同的策略模板
Technical Details:
- web/src/types.ts TraderConfigData 接口已有 system_prompt_template ✓
- Backend handleUpdateTrader 接收並保存 SystemPromptTemplate ✓
- Frontend TraderConfigModal 表單提交包含 system_prompt_template ✓
- Frontend handleSaveEditTrader request 缺失此字段 ✗ → ✓ (已修復)
Related:
- PR #872: UI 重構時遺漏
- commit c1f080f: 原始添加 system_prompt_template 支持
- commit e58fc3c: 修復 types.ts 缺失字段
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
* fix(types): add missing system_prompt_template field to TraderConfigData
補充完整修復:確保 TypeScript 類型定義與 API 使用一致。
Issue:
- AITradersPage.tsx 提交時包含 system_prompt_template 字段
- 但 TraderConfigData 接口缺少此字段定義
- TypeScript 類型不匹配
Fix:
- 在 TraderConfigData 接口添加 system_prompt_template: string
- 位置:override_base_prompt 之後,is_cross_margin 之前
- 與 CreateTraderRequest 保持一致
Result:
- TypeScript 類型完整
- 編輯交易員時正確加載和保存策略模板
- 無類型錯誤
Technical:
- web/src/types.ts Line 200
- 與後端 SystemPromptTemplate 字段對應
Co-Authored-By: tinkle-community <tinklefund@gmail.com>
---------
Co-authored-by: the-dev-z <the-dev-z@users.noreply.github.com>
Co-authored-by: tinkle-community <tinklefund@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants