Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions model/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,6 @@ func TaskGetAllTasks(startIdx int, num int, queryParams SyncTaskQueryParams) []*
return nil
}

for _, task := range tasks {
if cache, err := GetUserCache(task.UserId); err == nil {
task.Username = cache.Username
}
}

return tasks
}

Expand Down
40 changes: 20 additions & 20 deletions web/src/components/table/task-logs/TaskLogsColumnDefs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For commercial licensing, please contact support@quantumnous.com
*/

import React from 'react';
import { Progress, Tag, Typography } from '@douyinfe/semi-ui';
import { Progress, Tag, Tooltip, Typography } from '@douyinfe/semi-ui';
import {
Music,
FileText,
Expand Down Expand Up @@ -240,6 +240,7 @@ export const getTaskLogsColumns = ({
openContentModal,
isAdminUser,
openVideoModal,
showUserInfoFunc,
}) => {
return [
{
Expand Down Expand Up @@ -293,31 +294,30 @@ export const getTaskLogsColumns = ({
{
key: COLUMN_KEYS.USERNAME,
title: t('用户'),
dataIndex: 'username',
render: (text, record, index) => {
dataIndex: 'user_id',
render: (userId, record, index) => {
if (!isAdminUser) {
return <></>;
}
const displayName = record.display_name;
const label = displayName || text || t('未知');
const avatarText =
typeof displayName === 'string' && displayName.length > 0
? displayName[0]
: typeof text === 'string' && text.length > 0
? text[0]
: '?';

const displayText = String(record.username || userId || '?');
return (
<Space>
<Avatar
size='extra-small'
color={stringToColor(label)}
style={{ cursor: 'default' }}
<Tooltip content={displayText}>
<Avatar
size='extra-small'
color={stringToColor(displayText)}
style={{ cursor: 'pointer' }}
onClick={() => showUserInfoFunc && showUserInfoFunc(userId)}
>
{displayText.slice(0, 1)}
</Avatar>
</Tooltip>
Comment thread
coderabbitai[bot] marked this conversation as resolved.
<Typography.Text
ellipsis={{ showTooltip: true }}
style={{ cursor: 'pointer', color: 'var(--semi-color-primary)' }}
onClick={() => showUserInfoFunc && showUserInfoFunc(userId)}
>
{avatarText}
</Avatar>
<Typography.Text ellipsis={{ showTooltip: true }}>
{label}
{userId}
</Typography.Text>
</Space>
);
Expand Down
4 changes: 3 additions & 1 deletion web/src/components/table/task-logs/TaskLogsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const TaskLogsTable = (taskLogsData) => {
copyText,
openContentModal,
openVideoModal,
showUserInfoFunc,
isAdminUser,
t,
COLUMN_KEYS,
Expand All @@ -53,9 +54,10 @@ const TaskLogsTable = (taskLogsData) => {
copyText,
openContentModal,
openVideoModal,
showUserInfoFunc,
isAdminUser,
});
}, [t, COLUMN_KEYS, copyText, openContentModal, openVideoModal, isAdminUser]);
}, [t, COLUMN_KEYS, copyText, openContentModal, openVideoModal, showUserInfoFunc, isAdminUser]);

// Filter columns based on visibility settings
const getVisibleColumns = () => {
Expand Down
2 changes: 2 additions & 0 deletions web/src/components/table/task-logs/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import TaskLogsActions from './TaskLogsActions';
import TaskLogsFilters from './TaskLogsFilters';
import ColumnSelectorModal from './modals/ColumnSelectorModal';
import ContentModal from './modals/ContentModal';
import UserInfoModal from '../usage-logs/modals/UserInfoModal';
import { useTaskLogsData } from '../../../hooks/task-logs/useTaskLogsData';
import { useIsMobile } from '../../../hooks/common/useIsMobile';
import { createCardProPagination } from '../../../helpers/utils';
Expand All @@ -45,6 +46,7 @@ const TaskLogsPage = () => {
modalContent={taskLogsData.videoUrl}
isVideo={true}
/>
<UserInfoModal {...taskLogsData} />

<Layout>
<CardPro
Expand Down
25 changes: 25 additions & 0 deletions web/src/hooks/task-logs/useTaskLogsData.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ export const useTaskLogsData = () => {
const [isVideoModalOpen, setIsVideoModalOpen] = useState(false);
const [videoUrl, setVideoUrl] = useState('');

// User info modal state
const [showUserInfo, setShowUserInfoModal] = useState(false);
const [userInfoData, setUserInfoData] = useState(null);

// Form state
const [formApi, setFormApi] = useState(null);
let now = new Date();
Expand Down Expand Up @@ -273,6 +277,21 @@ export const useTaskLogsData = () => {
setIsVideoModalOpen(true);
};

// 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);
}
};
Comment on lines +280 to +293

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

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.

Suggested change
// 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.


// Initialize data
useEffect(() => {
const localPageSize =
Expand Down Expand Up @@ -319,6 +338,12 @@ export const useTaskLogsData = () => {
compactMode,
setCompactMode,

// User info modal
showUserInfo,
setShowUserInfoModal,
userInfoData,
showUserInfoFunc,

// Functions
loadLogs,
handlePageChange,
Expand Down