fix: prevent selected file from entering loading state when new files are added

This commit is contained in:
sw3205933776 2025-09-16 19:58:19 +08:00
parent 1774581034
commit d3401a3ee2
2 changed files with 27 additions and 25 deletions

View file

@ -331,7 +331,7 @@ export default function Folder({ data }: { data?: Agent }) {
(item: any) => item.name === chatStoreSelectedFile.name
);
console.log("file", file);
if (file) {
if (file && selectedFile?.path !== chatStoreSelectedFile?.path) {
selectedFileChange(file as FileInfo, isShowSourceCode);
}
}
@ -353,7 +353,7 @@ export default function Folder({ data }: { data?: Agent }) {
const file = fileGroups[0].files.find(
(item: any) => item.path === chatStoreSelectedFile.path
);
if (file) {
if (file && selectedFile?.path !== chatStoreSelectedFile?.path) {
selectedFileChange(file as FileInfo, isShowSourceCode);
}
}
@ -361,7 +361,7 @@ export default function Folder({ data }: { data?: Agent }) {
chatStore.tasks[chatStore.activeTaskId as string]?.selectedFile?.path,
fileGroups,
isShowSourceCode,
chatStore.activeTaskId
chatStore.activeTaskId,
]);
const handleBack = () => {
@ -456,7 +456,7 @@ export default function Folder({ data }: { data?: Agent }) {
{fileGroups.map((group) =>
group.files.map((file) => (
<button
key={file.name}
key={file.path}
onClick={() => selectedFileChange(file, isShowSourceCode)}
className={`w-full flex items-center justify-center p-2 rounded-md hover:bg-fill-fill-primary-hover transition-colors ${
selectedFile?.name === file.name

View file

@ -102,30 +102,32 @@ export const TaskState = ({
</div>
{/* Reassigned */}
{reAssignTo && <div
className={`group hover:bg-tag-surface flex gap-xs items-center px-0.5 py-0.5 transition-all duration-200 ${
isSelected("reassigned") && "bg-tag-surface"
} ${
clickable && "cursor-pointer hover:opacity-80 transition-opacity"
}`}
onClick={() => handleStateClick("reassigned")}
>
<CircleSlash2
className={`w-[10px] h-[10px] text-icon-secondary group-hover:text-icon-warning ${
isSelected("reassigned") && "text-icon-warning"
}`}
/>
<span
className={`transition-all duration-200 text-xs leading-tight font-normal text-text-label group-hover:text-text-warning ${
isSelected("reassigned") && "text-text-warning"
{reAssignTo ? (
<div
className={`group hover:bg-tag-surface flex gap-xs items-center px-0.5 py-0.5 transition-all duration-200 ${
isSelected("reassigned") && "bg-tag-surface"
} ${
clickable && "cursor-pointer hover:opacity-80 transition-opacity"
}`}
onClick={() => handleStateClick("reassigned")}
>
Reassigned{" "}
<span className={fadeWidthClass(isSelected("reassigned"))}>
{reAssignTo}
<CircleSlash2
className={`w-[10px] h-[10px] text-icon-secondary group-hover:text-icon-warning ${
isSelected("reassigned") && "text-icon-warning"
}`}
/>
<span
className={`transition-all duration-200 text-xs leading-tight font-normal text-text-label group-hover:text-text-warning ${
isSelected("reassigned") && "text-text-warning"
}`}
>
Reassigned{" "}
<span className={fadeWidthClass(isSelected("reassigned"))}>
{reAssignTo}
</span>
</span>
</span>
</div>}
</div>
) : null}
{/* Ongoing */}
<div