Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
77e39874
Unverified
提交
77e39874
authored
7月 04, 2025
作者:
Will Chen
提交者:
GitHub
7月 04, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
truly disable check problems (#566)
上级
d0f6e403
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
38 行增加
和
13 行删除
+38
-13
AutoFixProblemsSwitch.tsx
src/components/AutoFixProblemsSwitch.tsx
+10
-1
Problems.tsx
src/components/preview_panel/Problems.tsx
+18
-8
useCheckProblems.ts
src/hooks/useCheckProblems.ts
+3
-1
problems_handlers.ts
src/ipc/handlers/problems_handlers.ts
+7
-3
没有找到文件。
src/components/AutoFixProblemsSwitch.tsx
浏览文件 @
77e39874
...
...
@@ -2,7 +2,13 @@ import { useSettings } from "@/hooks/useSettings";
import
{
Label
}
from
"@/components/ui/label"
;
import
{
Switch
}
from
"@/components/ui/switch"
;
export
function
AutoFixProblemsSwitch
()
{
import
{
showInfo
}
from
"@/lib/toast"
;
export
function
AutoFixProblemsSwitch
({
showToast
=
false
,
}:
{
showToast
?:
boolean
;
})
{
const
{
settings
,
updateSettings
}
=
useSettings
();
return
(
<
div
className=
"flex items-center space-x-2"
>
...
...
@@ -13,6 +19,9 @@ export function AutoFixProblemsSwitch() {
updateSettings
({
enableAutoFixProblems
:
!
settings
?.
enableAutoFixProblems
,
});
if
(
!
settings
?.
enableAutoFixProblems
&&
showToast
)
{
showInfo
(
"You can disable Auto-fix problems in the Settings page."
);
}
}
}
/>
<
Label
htmlFor=
"auto-fix-problems"
>
Auto-fix problems
</
Label
>
...
...
src/components/preview_panel/Problems.tsx
浏览文件 @
77e39874
...
...
@@ -15,6 +15,8 @@ import { useStreamChat } from "@/hooks/useStreamChat";
import
{
useCheckProblems
}
from
"@/hooks/useCheckProblems"
;
import
{
createProblemFixPrompt
}
from
"@/shared/problem_prompt"
;
import
{
showError
}
from
"@/lib/toast"
;
import
{
useSettings
}
from
"@/hooks/useSettings"
;
import
{
AutoFixProblemsSwitch
}
from
"../AutoFixProblemsSwitch"
;
interface
ProblemItemProps
{
problem
:
Problem
;
...
...
@@ -62,6 +64,7 @@ const RecheckButton = ({
variant
=
"outline"
,
className
=
"h-7 px-3 text-xs"
,
}:
RecheckButtonProps
)
=>
{
const
{
settings
}
=
useSettings
();
const
{
checkProblems
,
isChecking
}
=
useCheckProblems
(
appId
);
const
handleRecheck
=
async
()
=>
{
...
...
@@ -71,6 +74,21 @@ const RecheckButton = ({
}
};
if
(
!
settings
?.
enableAutoFixProblems
)
{
return
(
<
div
className=
"flex flex-col items-center justify-center h-full text-center p-8"
>
<
div
className=
"w-16 h-16 rounded-full bg-[var(--background-darkest)] flex items-center justify-center mb-4"
>
<
Wrench
size=
{
24
}
className=
"text-muted-foreground"
/>
</
div
>
<
h3
className=
"text-lg font-medium mb-2"
>
Enable Auto-Fix Problems
</
h3
>
<
p
className=
"text-sm text-muted-foreground max-w-md mb-4"
>
You need to enable autofix problems to use the Problem pane.
</
p
>
<
AutoFixProblemsSwitch
showToast=
{
true
}
/>
</
div
>
);
}
return
(
<
Button
size=
{
size
}
...
...
@@ -179,14 +197,6 @@ export function _Problems() {
if
(
!
problemReport
)
{
return
(
<
div
className=
"flex flex-col items-center justify-center h-full text-center p-8"
>
<
div
className=
"w-16 h-16 rounded-full bg-[var(--background-darkest)] flex items-center justify-center mb-4"
>
<
FileText
size=
{
24
}
className=
"text-muted-foreground"
/>
</
div
>
<
h3
className=
"text-lg font-medium mb-2"
>
No Problems Data
</
h3
>
<
p
className=
"text-sm text-muted-foreground max-w-md mb-4"
>
No TypeScript diagnostics available for this app yet. Problems will
appear here after running type checking.
</
p
>
<
RecheckButton
appId=
{
selectedAppId
}
/>
</
div
>
);
...
...
src/hooks/useCheckProblems.ts
浏览文件 @
77e39874
import
{
useQuery
}
from
"@tanstack/react-query"
;
import
{
IpcClient
}
from
"@/ipc/ipc_client"
;
import
type
{
ProblemReport
}
from
"@/ipc/ipc_types"
;
import
{
useSettings
}
from
"./useSettings"
;
export
function
useCheckProblems
(
appId
:
number
|
null
)
{
const
{
settings
}
=
useSettings
();
const
{
data
:
problemReport
,
isLoading
:
isChecking
,
...
...
@@ -17,7 +19,7 @@ export function useCheckProblems(appId: number | null) {
const
ipcClient
=
IpcClient
.
getInstance
();
return
ipcClient
.
checkProblems
({
appId
});
},
enabled
:
!!
appId
,
enabled
:
!!
appId
&&
settings
?.
enableAutoFixProblems
,
// DO NOT SHOW ERROR TOAST.
});
...
...
src/ipc/handlers/problems_handlers.ts
浏览文件 @
77e39874
import
{
db
}
from
"../../db"
;
import
{
ipcMain
}
from
"electron"
;
import
{
apps
}
from
"../../db/schema"
;
import
{
eq
}
from
"drizzle-orm"
;
import
{
generateProblemReport
}
from
"../processors/tsc"
;
import
{
getDyadAppPath
}
from
"@/paths/paths"
;
import
{
logger
}
from
"./app_upgrade_handlers"
;
import
log
from
"electron-log"
;
import
{
createLoggedHandler
}
from
"./safe_handle"
;
const
logger
=
log
.
scope
(
"problems_handlers"
);
const
handle
=
createLoggedHandler
(
logger
);
export
function
registerProblemsHandlers
()
{
// Handler to check problems using autofix with empty response
ipcMain
.
handle
(
"check-problems"
,
async
(
event
,
params
:
{
appId
:
number
})
=>
{
handle
(
"check-problems"
,
async
(
event
,
params
:
{
appId
:
number
})
=>
{
try
{
// Get the app to find its path
const
app
=
await
db
.
query
.
apps
.
findFirst
({
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论