Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
52205be9
Unverified
提交
52205be9
authored
7月 01, 2025
作者:
Will Chen
提交者:
GitHub
7月 01, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow toggling pro in pro mode selector (#539)
Fixes #512
上级
eee087fc
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
38 行增加
和
18 行删除
+38
-18
ProModeSelector.tsx
src/components/ProModeSelector.tsx
+33
-14
schemas.ts
src/lib/schemas.ts
+5
-4
没有找到文件。
src/components/ProModeSelector.tsx
浏览文件 @
52205be9
...
@@ -14,6 +14,7 @@ import { Label } from "@/components/ui/label";
...
@@ -14,6 +14,7 @@ import { Label } from "@/components/ui/label";
import
{
Sparkles
,
Info
}
from
"lucide-react"
;
import
{
Sparkles
,
Info
}
from
"lucide-react"
;
import
{
useSettings
}
from
"@/hooks/useSettings"
;
import
{
useSettings
}
from
"@/hooks/useSettings"
;
import
{
IpcClient
}
from
"@/ipc/ipc_client"
;
import
{
IpcClient
}
from
"@/ipc/ipc_client"
;
import
{
hasDyadProKey
}
from
"@/lib/schemas"
;
export
function
ProModeSelector
()
{
export
function
ProModeSelector
()
{
const
{
settings
,
updateSettings
}
=
useSettings
();
const
{
settings
,
updateSettings
}
=
useSettings
();
...
@@ -30,7 +31,14 @@ export function ProModeSelector() {
...
@@ -30,7 +31,14 @@ export function ProModeSelector() {
});
});
};
};
const
proEnabled
=
Boolean
(
settings
?.
enableDyadPro
);
const
toggleProEnabled
=
()
=>
{
updateSettings
({
enableDyadPro
:
!
settings
?.
enableDyadPro
,
});
};
const
hasProKey
=
settings
?
hasDyadProKey
(
settings
)
:
false
;
const
proModeTogglable
=
hasProKey
&&
Boolean
(
settings
?.
enableDyadPro
);
return
(
return
(
<
Popover
>
<
Popover
>
...
@@ -58,7 +66,7 @@ export function ProModeSelector() {
...
@@ -58,7 +66,7 @@ export function ProModeSelector() {
</
h4
>
</
h4
>
<
div
className=
"h-px bg-gradient-to-r from-primary/50 via-primary/20 to-transparent"
/>
<
div
className=
"h-px bg-gradient-to-r from-primary/50 via-primary/20 to-transparent"
/>
</
div
>
</
div
>
{
!
proEnabled
&&
(
{
!
hasProKey
&&
(
<
div
className=
"text-sm text-center text-muted-foreground"
>
<
div
className=
"text-sm text-center text-muted-foreground"
>
<
a
<
a
className=
"inline-flex items-center justify-center gap-2 rounded-md border border-primary/30 bg-primary/10 px-3 py-2 text-sm font-medium text-primary shadow-sm transition-colors hover:bg-primary/20 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
className=
"inline-flex items-center justify-center gap-2 rounded-md border border-primary/30 bg-primary/10 px-3 py-2 text-sm font-medium text-primary shadow-sm transition-colors hover:bg-primary/20 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
...
@@ -72,25 +80,36 @@ export function ProModeSelector() {
...
@@ -72,25 +80,36 @@ export function ProModeSelector() {
</
a
>
</
a
>
</
div
>
</
div
>
)
}
)
}
<
div
className=
"flex flex-col gap-5"
>
<
SelectorRow
id=
"pro-enabled"
label=
"Enable Dyad Pro"
description=
"Use Dyad Pro AI credits"
tooltip=
"Uses Dyad Pro AI credits for the main AI model and Pro modes."
isTogglable=
{
hasProKey
}
settingEnabled=
{
Boolean
(
settings
?.
enableDyadPro
)
}
toggle=
{
toggleProEnabled
}
/>
<
SelectorRow
<
SelectorRow
id=
"lazy-edits"
id=
"lazy-edits"
label=
"Turbo Edits"
label=
"Turbo Edits"
description=
"Makes editing files faster and cheaper.
"
description=
"Makes file edits faster and cheaper
"
tooltip=
"Uses a faster, cheaper model to generate full file updates."
tooltip=
"Uses a faster, cheaper model to generate full file updates."
proEnabled=
{
proEnabled
}
isTogglable=
{
proModeTogglable
}
settingEnabled=
{
Boolean
(
settings
?.
enableProLazyEditsMode
)
}
settingEnabled=
{
Boolean
(
settings
?.
enableProLazyEditsMode
)
}
toggle=
{
toggleLazyEdits
}
toggle=
{
toggleLazyEdits
}
/>
/>
<
SelectorRow
<
SelectorRow
id=
"smart-context"
id=
"smart-context"
label=
"Smart Context"
label=
"Smart Context"
description=
"Automatically detects the most relevant files for your cha
t"
description=
"Optimizes your AI's code contex
t"
tooltip=
"Improve efficiency and save credits working on large codebases."
tooltip=
"Improve efficiency and save credits working on large codebases."
proEnabled=
{
proEnabled
}
isTogglable=
{
proModeTogglable
}
settingEnabled=
{
Boolean
(
settings
?.
enableProSmartFilesContextMode
)
}
settingEnabled=
{
Boolean
(
settings
?.
enableProSmartFilesContextMode
)
}
toggle=
{
toggleSmartContext
}
toggle=
{
toggleSmartContext
}
/>
/>
</
div
>
</
div
>
</
div
>
</
PopoverContent
>
</
PopoverContent
>
</
Popover
>
</
Popover
>
);
);
...
@@ -101,7 +120,7 @@ function SelectorRow({
...
@@ -101,7 +120,7 @@ function SelectorRow({
label
,
label
,
description
,
description
,
tooltip
,
tooltip
,
proEnabled
,
isTogglable
,
settingEnabled
,
settingEnabled
,
toggle
,
toggle
,
}:
{
}:
{
...
@@ -109,16 +128,16 @@ function SelectorRow({
...
@@ -109,16 +128,16 @@ function SelectorRow({
label
:
string
;
label
:
string
;
description
:
string
;
description
:
string
;
tooltip
:
string
;
tooltip
:
string
;
proEnabled
:
boolean
;
isTogglable
:
boolean
;
settingEnabled
:
boolean
;
settingEnabled
:
boolean
;
toggle
:
()
=>
void
;
toggle
:
()
=>
void
;
})
{
})
{
return
(
return
(
<
div
className=
"flex items-center justify-between"
>
<
div
className=
"flex items-center justify-between"
>
<
div
className=
"space-y-
2
"
>
<
div
className=
"space-y-
1.5
"
>
<
Label
<
Label
htmlFor=
{
id
}
htmlFor=
{
id
}
className=
{
!
proEnabled
?
"text-muted-foreground/50"
:
""
}
className=
{
!
isTogglable
?
"text-muted-foreground/50"
:
""
}
>
>
{
label
}
{
label
}
</
Label
>
</
Label
>
...
@@ -126,7 +145,7 @@ function SelectorRow({
...
@@ -126,7 +145,7 @@ function SelectorRow({
<
Tooltip
>
<
Tooltip
>
<
TooltipTrigger
asChild
>
<
TooltipTrigger
asChild
>
<
Info
<
Info
className=
{
`h-4 w-4 cursor-help ${!
proEnabled
? "text-muted-foreground/50" : "text-muted-foreground"}`
}
className=
{
`h-4 w-4 cursor-help ${!
isTogglable
? "text-muted-foreground/50" : "text-muted-foreground"}`
}
/>
/>
</
TooltipTrigger
>
</
TooltipTrigger
>
<
TooltipContent
side=
"right"
className=
"max-w-72"
>
<
TooltipContent
side=
"right"
className=
"max-w-72"
>
...
@@ -134,7 +153,7 @@ function SelectorRow({
...
@@ -134,7 +153,7 @@ function SelectorRow({
</
TooltipContent
>
</
TooltipContent
>
</
Tooltip
>
</
Tooltip
>
<
p
<
p
className=
{
`text-xs ${!
proEnabled
? "text-muted-foreground/50" : "text-muted-foreground"} max-w-55`
}
className=
{
`text-xs ${!
isTogglable
? "text-muted-foreground/50" : "text-muted-foreground"} max-w-55`
}
>
>
{
description
}
{
description
}
</
p
>
</
p
>
...
@@ -142,9 +161,9 @@ function SelectorRow({
...
@@ -142,9 +161,9 @@ function SelectorRow({
</
div
>
</
div
>
<
Switch
<
Switch
id=
{
id
}
id=
{
id
}
checked=
{
proEnabled
?
settingEnabled
:
false
}
checked=
{
isTogglable
?
settingEnabled
:
false
}
onCheckedChange=
{
toggle
}
onCheckedChange=
{
toggle
}
disabled=
{
!
proEnabled
}
disabled=
{
!
isTogglable
}
/>
/>
</
div
>
</
div
>
);
);
...
...
src/lib/schemas.ts
浏览文件 @
52205be9
...
@@ -170,10 +170,11 @@ export const UserSettingsSchema = z.object({
...
@@ -170,10 +170,11 @@ export const UserSettingsSchema = z.object({
export
type
UserSettings
=
z
.
infer
<
typeof
UserSettingsSchema
>
;
export
type
UserSettings
=
z
.
infer
<
typeof
UserSettingsSchema
>
;
export
function
isDyadProEnabled
(
settings
:
UserSettings
):
boolean
{
export
function
isDyadProEnabled
(
settings
:
UserSettings
):
boolean
{
return
(
return
settings
.
enableDyadPro
===
true
&&
hasDyadProKey
(
settings
);
settings
.
enableDyadPro
===
true
&&
}
!!
settings
.
providerSettings
?.
auto
?.
apiKey
?.
value
);
export
function
hasDyadProKey
(
settings
:
UserSettings
):
boolean
{
return
!!
settings
.
providerSettings
?.
auto
?.
apiKey
?.
value
;
}
}
// Define interfaces for the props
// Define interfaces for the props
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论