优化: 任务日志查询速度并显示用户详情 - #2905
Conversation
WalkthroughRemoved per-task Username population in backend TaskGetAllTasks and updated task-logs UI to display user info by Changes
Sequence DiagramsequenceDiagram
participant User
participant UI as Task Logs UI
participant Hook as useTaskLogsData
participant API as Backend API
participant Modal as UserInfoModal
User->>UI: Click avatar / username cell
UI->>Hook: showUserInfoFunc(userId)
Hook->>Hook: verify admin?
alt is admin
Hook->>API: GET /api/user/{userId}
API-->>Hook: user data
Hook->>Hook: setUserInfoData(userData)
Hook->>Hook: setShowUserInfoModal(true)
Hook-->>UI: modal state updated
UI->>Modal: render with userInfoData
Modal-->>User: display user info
else not admin
Hook-->>UI: no-op / early return
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@web/src/components/table/task-logs/TaskLogsColumnDefs.jsx`:
- Around line 305-314: The Tooltip component is referenced in the
TaskLogsColumnDefs JSX (wrapping Avatar) but not imported, causing a runtime
ReferenceError; fix this by adding Tooltip to the existing Semi UI import that
currently brings in Avatar (i.e., include Tooltip alongside Avatar in the import
statement), then verify Tooltip is used as <Tooltip> around Avatar (which uses
displayText, userId, stringToColor, showUserInfoFunc) so the USERNAME column
renders without crashing.
In `@web/src/hooks/task-logs/useTaskLogsData.js`:
- Around line 280-293: The showUserInfoFunc currently calls
API.get(`/api/user/${userId}`) without catching network errors; wrap the body of
showUserInfoFunc in a try/catch, await API.get inside the try, and in catch call
showError with the caught error (handle AxiosError similarly to other hooks) so
network failures show a user-facing message; keep existing success handling that
calls setUserInfoData(data) and setShowUserInfoModal(true) and preserve the
non-admin early return.
| // User info function | ||
| const showUserInfoFunc = async (userId) => { | ||
| if (!isAdminUser) { | ||
| return; | ||
| } | ||
| const res = await API.get(`/api/user/${userId}`); | ||
| const { success, message, data } = res.data; | ||
| if (success) { | ||
| setUserInfoData(data); | ||
| setShowUserInfoModal(true); | ||
| } else { | ||
| showError(message); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Missing error handling for network failures.
API.get can throw on network errors (timeout, connection refused, etc.), which would result in an unhandled promise rejection with no user feedback. Wrap in try/catch, consistent with how showError already handles AxiosError.
Proposed fix
const showUserInfoFunc = async (userId) => {
if (!isAdminUser) {
return;
}
- const res = await API.get(`/api/user/${userId}`);
- const { success, message, data } = res.data;
- if (success) {
- setUserInfoData(data);
- setShowUserInfoModal(true);
- } else {
- showError(message);
+ try {
+ const res = await API.get(`/api/user/${userId}`);
+ const { success, message, data } = res.data;
+ if (success) {
+ setUserInfoData(data);
+ setShowUserInfoModal(true);
+ } else {
+ showError(message);
+ }
+ } catch (error) {
+ showError(error);
}
};📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // User info function | |
| const showUserInfoFunc = async (userId) => { | |
| if (!isAdminUser) { | |
| return; | |
| } | |
| const res = await API.get(`/api/user/${userId}`); | |
| const { success, message, data } = res.data; | |
| if (success) { | |
| setUserInfoData(data); | |
| setShowUserInfoModal(true); | |
| } else { | |
| showError(message); | |
| } | |
| }; | |
| // User info function | |
| const showUserInfoFunc = async (userId) => { | |
| if (!isAdminUser) { | |
| return; | |
| } | |
| try { | |
| const res = await API.get(`/api/user/${userId}`); | |
| const { success, message, data } = res.data; | |
| if (success) { | |
| setUserInfoData(data); | |
| setShowUserInfoModal(true); | |
| } else { | |
| showError(message); | |
| } | |
| } catch (error) { | |
| showError(error); | |
| } | |
| }; |
🤖 Prompt for AI Agents
In `@web/src/hooks/task-logs/useTaskLogsData.js` around lines 280 - 293, The
showUserInfoFunc currently calls API.get(`/api/user/${userId}`) without catching
network errors; wrap the body of showUserInfoFunc in a try/catch, await API.get
inside the try, and in catch call showError with the caught error (handle
AxiosError similarly to other hooks) so network failures show a user-facing
message; keep existing success handling that calls setUserInfoData(data) and
setShowUserInfoModal(true) and preserve the non-admin early return.
* main: (21 commits) fix: normalize search pagination params to avoid [object Object] fix: ignore header passthrough during channel tests fix(token-search): use TrimPrefix for sk- token normalization fix: rename bulk test action to skip manually disabled channels fix: support numeric status code mapping in ResetStatusCode 优化: 任务日志查询速度并显示用户详情 (QuantumNous#2905) Merge pull request QuantumNous#2916 from worryzyy/feature/add-quota-amount-input feat: Improve backend multilingual support feat: add OpenRouter pricing support to upstream ratio sync feat: refactor request body handling to use BodyStorage for improved efficiency feat(xai): 为xAI渠道添加/v1/responses支持 (QuantumNous#2897) chore: remove deprecated Docker badge from README feat: refactor extra_body handling for improved configuration parsing Update README feat: logs cache field (QuantumNous#2920) feat(localization): added zh_TW (QuantumNous#2913) fix: update README files to improve link formatting and readability feat: add Aion UI link to README files chore(deps): bump axios from 1.12.0 to 1.13.5 in /web simplify language selector display to use text-only labels ... # Conflicts: # web/src/components/layout/headerbar/LanguageSelector.jsx
* perf: task log show userinfo * feat: add Tooltip component to TaskLogsColumnDefs
Summary by CodeRabbit
New Features
Improvements