Skip to content

Commit 869ff17

Browse files
[autofix.ci] apply automated fixes
1 parent 59f86b0 commit 869ff17

File tree

8 files changed

+72
-45
lines changed

8 files changed

+72
-45
lines changed

backend/src/project/project.resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class ProjectsResolver {
103103
const { buffer, mimetype } = await validateAndBufferFile(file);
104104

105105
// Call the service with the extracted buffer and mimetype
106-
const project1= await this.projectService.updateProjectPhotoUrl(
106+
const project1 = await this.projectService.updateProjectPhotoUrl(
107107
userId,
108108
projectId,
109109
buffer,

backend/src/project/project.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
ForbiddenException,
88
} from '@nestjs/common';
99
import { InjectRepository } from '@nestjs/typeorm';
10-
import { Between, In, IsNull, Not, Repository } from 'typeorm';
10+
import { Between, In, Not, Repository } from 'typeorm';
1111
import { Project } from './project.model';
1212
import { ProjectPackages } from './project-packages.model';
1313
import {
@@ -857,4 +857,4 @@ export class ProjectService {
857857
project.isSyncedWithGitHub = true;
858858
return this.projectsRepository.save(project);
859859
}
860-
}
860+
}

frontend/src/app/api/runProject/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,4 +563,4 @@ export async function GET(req: Request) {
563563
} finally {
564564
processingRequests.delete(projectPath);
565565
}
566-
}
566+
}

frontend/src/app/api/screenshot/route.ts

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,41 @@ export async function GET(req: Request) {
5151
await page.setViewport({ width: 1600, height: 900 });
5252
logger.info(`[SCREENSHOT] Viewport set successfully`);
5353

54-
// Navigate to URL with increased timeout and more reliable wait condition
55-
await page.goto(url, {
56-
waitUntil: 'networkidle2', // 更改为等待网络空闲状态,确保页面完全加载
57-
timeout: 90000, // 增加超时时间到90秒
58-
});
59-
60-
// 等待额外的时间让页面完全渲染
61-
await page.waitForTimeout(8000); // 增加等待时间到8秒
54+
// Navigate to URL with increased timeout and more reliable wait condition
55+
await page.goto(url, {
56+
waitUntil: 'networkidle2', // 更改为等待网络空闲状态,确保页面完全加载
57+
timeout: 90000, // 增加超时时间到90秒
58+
});
6259

63-
// 尝试等待页面上的内容加载,如果失败也继续处理
64-
try {
65-
// 等待页面上可能存在的主要内容元素
66-
await Promise.race([
67-
page.waitForSelector('main', { timeout: 5000 }),
68-
page.waitForSelector('#root', { timeout: 5000 }),
69-
page.waitForSelector('.app', { timeout: 5000 }),
70-
page.waitForSelector('h1', { timeout: 5000 }),
71-
page.waitForSelector('div', { timeout: 5000 }), // 添加更通用的选择器
72-
]);
73-
} catch (waitError) {
74-
// 忽略等待选择器的错误,继续截图
75-
logger.info('Unable to find common page elements, continuing with screenshot');
76-
}
60+
// 等待额外的时间让页面完全渲染
61+
await page.waitForTimeout(8000); // 增加等待时间到8秒
62+
63+
// 尝试等待页面上的内容加载,如果失败也继续处理
64+
try {
65+
// 等待页面上可能存在的主要内容元素
66+
await Promise.race([
67+
page.waitForSelector('main', { timeout: 5000 }),
68+
page.waitForSelector('#root', { timeout: 5000 }),
69+
page.waitForSelector('.app', { timeout: 5000 }),
70+
page.waitForSelector('h1', { timeout: 5000 }),
71+
page.waitForSelector('div', { timeout: 5000 }), // 添加更通用的选择器
72+
]);
73+
} catch (waitError) {
74+
// 忽略等待选择器的错误,继续截图
75+
logger.info(
76+
'Unable to find common page elements, continuing with screenshot'
77+
);
78+
}
7779

7880
// Take screenshot
7981
logger.info(`[SCREENSHOT] Taking screenshot`);
8082
const screenshot = await page.screenshot({
8183
type: 'png',
8284
fullPage: true,
8385
});
84-
logger.info(`[SCREENSHOT] Screenshot captured successfully, size: ${screenshot.length} bytes`);
86+
logger.info(
87+
`[SCREENSHOT] Screenshot captured successfully, size: ${screenshot.length} bytes`
88+
);
8589

8690
// Clean up
8791
if (page) {
@@ -95,12 +99,15 @@ export async function GET(req: Request) {
9599
headers: {
96100
'Content-Type': 'image/png',
97101
'Cache-Control': 'no-cache, no-store, must-revalidate',
98-
'Pragma': 'no-cache',
99-
'Expires': '0'
102+
Pragma: 'no-cache',
103+
Expires: '0',
100104
},
101105
});
102106
} catch (error: any) {
103-
logger.error(`[SCREENSHOT] Error capturing screenshot: ${error.message}`, error);
107+
logger.error(
108+
`[SCREENSHOT] Error capturing screenshot: ${error.message}`,
109+
error
110+
);
104111
logger.error(`[SCREENSHOT] Error stack: ${error.stack}`);
105112

106113
if (page) {
@@ -120,13 +127,17 @@ export async function GET(req: Request) {
120127
) {
121128
try {
122129
if (browserInstance) {
123-
logger.warn(`[SCREENSHOT] Resetting browser instance due to protocol error`);
130+
logger.warn(
131+
`[SCREENSHOT] Resetting browser instance due to protocol error`
132+
);
124133
await browserInstance.close();
125134
browserInstance = null;
126135
logger.warn(`[SCREENSHOT] Browser instance reset successfully`);
127136
}
128137
} catch (closeBrowserError) {
129-
logger.error(`[SCREENSHOT] Error closing browser: ${closeBrowserError.message}`);
138+
logger.error(
139+
`[SCREENSHOT] Error closing browser: ${closeBrowserError.message}`
140+
);
130141
}
131142
}
132143

frontend/src/components/chat/code-engine/code-engine.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,10 @@ export function CodeEngine({
332332
setProjectCompleted(true);
333333
isProjectLoadedRef.current = true;
334334
try {
335-
localStorage.setItem(getUserStorageKey(`project-completed-${chatId}`), 'true');
335+
localStorage.setItem(
336+
getUserStorageKey(`project-completed-${chatId}`),
337+
'true'
338+
);
336339
} catch (e) {
337340
logger.error('Failed to save project completion status:', e);
338341
}
@@ -390,7 +393,10 @@ export function CodeEngine({
390393
isProjectLoadedRef.current = true;
391394

392395
try {
393-
localStorage.setItem(getUserStorageKey(`project-completed-${chatId}`), 'true');
396+
localStorage.setItem(
397+
getUserStorageKey(`project-completed-${chatId}`),
398+
'true'
399+
);
394400
} catch (e) {
395401
logger.error('Failed to save project completion status:', e);
396402
}

frontend/src/components/root/expand-card.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ import { URL_PROTOCOL_PREFIX } from '@/utils/const';
99
import { logger } from '@/app/log/logger';
1010
import { Button } from '@/components/ui/button';
1111

12-
export function ExpandableCard({ projects, isGenerating = false, onOpenChat, isCommunityProject = false }) {
12+
export function ExpandableCard({
13+
projects,
14+
isGenerating = false,
15+
onOpenChat,
16+
isCommunityProject = false,
17+
}) {
1318
const [active, setActive] = useState(null);
1419
const [iframeUrl, setIframeUrl] = useState('');
1520
const ref = useRef<HTMLDivElement>(null);

frontend/src/components/sidebar-item.tsx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ import {
1414
DropdownMenuContent,
1515
DropdownMenuTrigger,
1616
} from '@/components/ui/dropdown-menu';
17-
import { DELETE_CHAT, DELETE_PROJECT, GET_CHAT_DETAILS } from '@/graphql/request';
17+
import {
18+
DELETE_CHAT,
19+
DELETE_PROJECT,
20+
GET_CHAT_DETAILS,
21+
} from '@/graphql/request';
1822
import { cn } from '@/lib/utils';
1923
import { useMutation, useLazyQuery } from '@apollo/client';
2024
import { MoreHorizontal, Trash2 } from 'lucide-react';
@@ -44,13 +48,14 @@ function SideBarItemComponent({
4448
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
4549
const [isDialogOpen, setIsDialogOpen] = useState(false);
4650
const router = useRouter();
47-
const { recentlyCompletedProjectId, setPendingProjects } = useContext(ProjectContext);
51+
const { recentlyCompletedProjectId, setPendingProjects } =
52+
useContext(ProjectContext);
4853
const isGenerating = id === recentlyCompletedProjectId;
4954
const isSelected = currentChatId === id;
5055
const variant = isSelected ? 'secondary' : 'ghost';
5156

5257
const [getChatDetails] = useLazyQuery(GET_CHAT_DETAILS);
53-
58+
5459
const [deleteProject] = useMutation(DELETE_PROJECT, {
5560
onCompleted: () => {
5661
logger.info('Project deleted successfully');
@@ -84,11 +89,11 @@ function SideBarItemComponent({
8489
const handleDeleteChat = async () => {
8590
try {
8691
const chatDetailsResult = await getChatDetails({
87-
variables: { chatId: id }
92+
variables: { chatId: id },
8893
});
89-
94+
9095
const projectId = chatDetailsResult?.data?.getChatDetails?.project?.id;
91-
96+
9297
await deleteChat({
9398
variables: {
9499
chatId: id,
@@ -99,7 +104,7 @@ function SideBarItemComponent({
99104
cache.gc();
100105
},
101106
});
102-
107+
103108
if (projectId) {
104109
try {
105110
await deleteProject({
@@ -108,13 +113,13 @@ function SideBarItemComponent({
108113
// Clear project cache
109114
cache.evict({ id: `Project:${projectId}` });
110115
cache.gc();
111-
}
116+
},
112117
});
113118
} catch (projectError) {
114119
logger.error('Error deleting associated project:', projectError);
115120
}
116121
}
117-
122+
118123
setIsDialogOpen(false);
119124
} catch (error) {
120125
logger.error('Error deleting chat:', error);

frontend/src/graphql/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export const DELETE_CHAT = gql`
100100
export const GET_USER_INFO = gql`
101101
query me {
102102
me {
103-
id,
103+
id
104104
username
105105
email
106106
avatarUrl

0 commit comments

Comments
 (0)