Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
618fed85
Unverified
提交
618fed85
authored
5月 21, 2025
作者:
Will Chen
提交者:
GitHub
5月 21, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Show promo messages for relevant AI errors (#216)
上级
96153f29
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
134 行增加
和
11 行删除
+134
-11
ChatErrorBox.tsx
src/components/chat/ChatErrorBox.tsx
+128
-0
ChatInput.tsx
src/components/chat/ChatInput.tsx
+6
-11
没有找到文件。
src/components/chat/ChatErrorBox.tsx
0 → 100644
浏览文件 @
618fed85
import
{
IpcClient
}
from
"@/ipc/ipc_client"
;
import
{
X
}
from
"lucide-react"
;
export
function
ChatErrorBox
({
onDismiss
,
error
,
isDyadProEnabled
,
}:
{
onDismiss
:
()
=>
void
;
error
:
string
;
isDyadProEnabled
:
boolean
;
})
{
if
(
error
.
includes
(
"doesn't have a free quota tier"
))
{
return
(
<
ChatErrorContainer
onDismiss=
{
onDismiss
}
>
{
error
}
<
span
className=
"ml-1"
>
<
ExternalLink
href=
"https://dyad.sh/pro"
>
Access with Dyad Pro.
</
ExternalLink
>
</
span
>
</
ChatErrorContainer
>
);
}
// Important, this needs to come after the "free quota tier" check
// because it also includes this URL in the error message
if
(
error
.
includes
(
"https://ai.google.dev/gemini-api/docs/rate-limits"
))
{
return
(
<
ChatErrorContainer
onDismiss=
{
onDismiss
}
>
{
error
}
<
span
className=
"ml-1"
>
<
ExternalLink
href=
"https://dyad.sh/pro"
>
Upgrade to Dyad Pro.
</
ExternalLink
>
</
span
>
</
ChatErrorContainer
>
);
}
if
(
error
.
includes
(
"LiteLLM Virtual Key expected"
))
{
return
(
<
ChatInfoContainer
onDismiss=
{
onDismiss
}
>
<
span
>
Looks like you don't have a valid Dyad Pro key.
{
" "
}
<
ExternalLink
href=
"https://dyad.sh/pro"
>
Upgrade to Dyad Pro
</
ExternalLink
>
{
" "
}
today.
</
span
>
</
ChatInfoContainer
>
);
}
if
(
isDyadProEnabled
&&
error
.
includes
(
"ExceededBudget:"
))
{
return
(
<
ChatInfoContainer
onDismiss=
{
onDismiss
}
>
<
span
>
You have used all of your Dyad AI credits this month.
{
" "
}
<
ExternalLink
href=
"https://academy.dyad.sh/subscription"
>
Upgrade to Dyad Max
</
ExternalLink
>
{
" "
}
and get more AI credits
</
span
>
</
ChatInfoContainer
>
);
}
return
<
ChatErrorContainer
onDismiss=
{
onDismiss
}
>
{
error
}
</
ChatErrorContainer
>;
}
function
ExternalLink
({
href
,
children
,
}:
{
href
:
string
;
children
:
React
.
ReactNode
;
})
{
return
(
<
a
className=
"underline cursor-pointer text-blue-500 hover:text-blue-700"
onClick=
{
()
=>
IpcClient
.
getInstance
().
openExternalUrl
(
href
)
}
>
{
children
}
</
a
>
);
}
function
ChatErrorContainer
({
onDismiss
,
children
,
}:
{
onDismiss
:
()
=>
void
;
children
:
React
.
ReactNode
;
})
{
return
(
<
div
className=
"relative mt-2 bg-red-50 border border-red-200 rounded-md shadow-sm p-2 mx-4"
>
<
button
onClick=
{
onDismiss
}
className=
"absolute top-1 left-1 p-1 hover:bg-red-100 rounded"
>
<
X
size=
{
14
}
className=
"text-red-500"
/>
</
button
>
<
div
className=
"px-6 py-1 text-sm"
>
<
div
className=
"text-red-700 text-wrap"
>
{
children
}
</
div
>
</
div
>
</
div
>
);
}
function
ChatInfoContainer
({
onDismiss
,
children
,
}:
{
onDismiss
:
()
=>
void
;
children
:
React
.
ReactNode
;
})
{
return
(
<
div
className=
"relative mt-2 bg-sky-50 border border-sky-200 rounded-md shadow-sm p-2 mx-4"
>
<
button
onClick=
{
onDismiss
}
className=
"absolute top-1 left-1 p-1 hover:bg-sky-100 rounded"
>
<
X
size=
{
14
}
className=
"text-sky-600"
/>
</
button
>
<
div
className=
"px-6 py-1 text-sm"
>
<
div
className=
"text-sky-800 text-wrap"
>
{
children
}
</
div
>
</
div
>
</
div
>
);
}
src/components/chat/ChatInput.tsx
浏览文件 @
618fed85
...
...
@@ -60,6 +60,7 @@ import { AttachmentsList } from "./AttachmentsList";
import
{
DragDropOverlay
}
from
"./DragDropOverlay"
;
import
{
showError
,
showExtraFilesToast
}
from
"@/lib/toast"
;
import
{
ChatInputControls
}
from
"../ChatInputControls"
;
import
{
ChatErrorBox
}
from
"./ChatErrorBox"
;
const
showTokenBarAtom
=
atom
(
false
);
export
function
ChatInput
({
chatId
}:
{
chatId
?:
number
})
{
...
...
@@ -235,17 +236,11 @@ export function ChatInput({ chatId }: { chatId?: number }) {
return
(
<>
{
error
&&
showError
&&
(
<
div
className=
"relative mt-2 bg-red-50 border border-red-200 rounded-md shadow-sm p-2"
>
<
button
onClick=
{
dismissError
}
className=
"absolute top-1 left-1 p-1 hover:bg-red-100 rounded"
>
<
X
size=
{
14
}
className=
"text-red-500"
/>
</
button
>
<
div
className=
"px-6 py-1 text-sm"
>
<
div
className=
"text-red-700 text-wrap"
>
{
error
}
</
div
>
</
div
>
</
div
>
<
ChatErrorBox
onDismiss=
{
dismissError
}
error=
{
error
}
isDyadProEnabled=
{
settings
.
enableDyadPro
??
false
}
/>
)
}
{
/* Display loading or error state for proposal */
}
{
isProposalLoading
&&
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论