fix(web): agent log refetch and slider percentage rounding (#16344)

This commit is contained in:
chanx
2026-06-25 13:49:25 +08:00
committed by GitHub
parent 17b066e6ae
commit d44359826d
4 changed files with 26 additions and 11 deletions

View File

@@ -25,7 +25,6 @@ const CopyToClipboard = ({
const icon = copied ? <LucideCheck /> : <LucideCopy />;
const trigger = avoidButtonWrapper ? (
<Button
asChild
variant="transparent"
size="icon-sm"
{...buttonProps}

View File

@@ -92,9 +92,11 @@ export const SliderInputFormField = forwardRef<
<FormControl>
<SingleFormSlider
{...field}
value={percentage ? field.value * 100 : field.value}
value={
percentage ? Math.round(field.value * 100) : field.value
}
onChange={(value) =>
field.onChange(percentage ? value / 100 : value)
field.onChange(percentage ? Math.round(value) / 100 : value)
}
max={displayMax}
min={displayMin}
@@ -114,13 +116,13 @@ export const SliderInputFormField = forwardRef<
step={displayStep}
hideIcons
value={
percentage ? (field.value * 100).toFixed(0) : field.value
percentage ? Math.round(field.value * 100) : field.value
}
onChange={(val) => {
const value = Number(val || 0);
if (!isNaN(value)) {
if (value >= 0) {
field.onChange(
percentage ? (value / 100).toFixed(0) : value,
percentage ? Math.round(value) / 100 : value,
);
}
}}

View File

@@ -685,7 +685,11 @@ export const useFetchVersion = (
export const useFetchAgentLog = (searchParams: IAgentLogsRequest) => {
const { id } = useParams();
const { data, isFetching: loading } = useQuery<IAgentLogsResponse>({
const {
data,
isFetching: loading,
refetch,
} = useQuery<IAgentLogsResponse>({
queryKey: [AgentApiAction.FetchAgentLog, id, searchParams],
initialData: {} as IAgentLogsResponse,
gcTime: 0,
@@ -698,7 +702,7 @@ export const useFetchAgentLog = (searchParams: IAgentLogsRequest) => {
},
});
return { data, loading };
return { data, loading, refetch };
};
export const useFetchSessionsByCanvasId = () => {

View File

@@ -126,7 +126,7 @@ const AgentLogPage: React.FC = () => {
},
];
const { data: logData, loading } = useFetchAgentLog(searchParams);
const { data: logData, loading, refetch } = useFetchAgentLog(searchParams);
const { sessions: data, total } = logData || {};
const { handleExport, loading: exportLoading } = useExportAgentLogToCSV();
const [currentDate, setCurrentDate] = useState<DateRange>({
@@ -191,8 +191,18 @@ const AgentLogPage: React.FC = () => {
};
const handleClickSearch = () => {
setPagination((pre) => ({ ...pre, current: 1 }));
handleSearch({ page: 1, keywords });
const sameParams =
pagination.current === 1 &&
searchParams.keywords === keywords &&
searchParams.from_date === currentDate.from &&
searchParams.to_date === currentDate.to;
if (sameParams) {
refetch();
} else {
setPagination((pre) => ({ ...pre, current: 1 }));
handleSearch({ page: 1, keywords });
}
};
useEffect(() => {
handleSearch();