Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
a0165cdf
Unverified
提交
a0165cdf
authored
5月 02, 2025
作者:
Will Chen
提交者:
GitHub
5月 02, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Provide a way to fix dyad-output errors with AI (#67)
上级
b72d1927
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
36 行增加
和
5 行删除
+36
-5
DyadOutput.tsx
src/components/chat/DyadOutput.tsx
+36
-5
没有找到文件。
src/components/chat/DyadOutput.tsx
浏览文件 @
a0165cdf
...
...
@@ -4,8 +4,11 @@ import {
ChevronsUpDown
,
AlertTriangle
,
XCircle
,
Sparkles
,
}
from
"lucide-react"
;
import
{
useAtom
,
useSetAtom
}
from
"jotai"
;
import
{
chatInputValueAtom
,
selectedChatIdAtom
}
from
"@/atoms/chatAtoms"
;
import
{
useStreamChat
}
from
"@/hooks/useStreamChat"
;
interface
DyadOutputProps
{
type
:
"error"
|
"warning"
;
message
?:
string
;
...
...
@@ -18,6 +21,8 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({
children
,
})
=>
{
const
[
isContentVisible
,
setIsContentVisible
]
=
useState
(
false
);
const
[
selectedChatId
,
setSelectedChatId
]
=
useAtom
(
selectedChatIdAtom
);
const
{
streamMessage
}
=
useStreamChat
();
// If the type is not warning, it is an error (in case LLM gives a weird "type")
const
isError
=
type
!==
"warning"
;
...
...
@@ -30,9 +35,19 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({
);
const
label
=
isError
?
"Error"
:
"Warning"
;
const
handleAIFix
=
(
e
:
React
.
MouseEvent
)
=>
{
e
.
stopPropagation
();
if
(
message
&&
selectedChatId
)
{
streamMessage
({
prompt
:
`Fix the error:
${
message
}
`
,
chatId
:
selectedChatId
,
});
}
};
return
(
<
div
className=
{
`relative bg-(--background-lightest) hover:bg-(--background-lighter) rounded-lg px-4 py-2 border my-2 cursor-pointer ${borderColor}`
}
className=
{
`relative bg-(--background-lightest) hover:bg-(--background-lighter) rounded-lg px-4 py-2 border my-2 cursor-pointer
min-h-18
${borderColor}`
}
onClick=
{
()
=>
setIsContentVisible
(
!
isContentVisible
)
}
>
{
/* Top-left label badge */
}
...
...
@@ -43,12 +58,26 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({
{
icon
}
<
span
>
{
label
}
</
span
>
</
div
>
{
/* Fix with AI button - always visible for errors */
}
{
isError
&&
message
&&
(
<
div
className=
"absolute top-9 left-2"
>
<
button
onClick=
{
handleAIFix
}
className=
"cursor-pointer flex items-center justify-center bg-red-600 hover:bg-red-700 dark:bg-red-700 dark:hover:bg-red-800 text-white rounded text-xs p-1 w-24 h-6"
>
<
Sparkles
size=
{
16
}
className=
"mr-1"
/>
<
span
>
Fix with AI
</
span
>
</
button
>
</
div
>
)
}
{
/* Main content, padded to avoid label */
}
<
div
className=
"flex items-center justify-between pl-2
0
"
>
<
div
className=
"flex items-center justify-between pl-2
4 pr-6
"
>
<
div
className=
"flex items-center gap-2"
>
{
message
&&
(
<
span
className=
"text-gray-700 dark:text-gray-300 font-medium text-sm"
>
{
message
.
slice
(
0
,
isContentVisible
?
undefined
:
8
0
)
+
{
message
.
slice
(
0
,
isContentVisible
?
undefined
:
10
0
)
+
(
!
isContentVisible
?
"..."
:
""
)
}
</
span
>
)
}
...
...
@@ -67,8 +96,10 @@ export const DyadOutput: React.FC<DyadOutputProps> = ({
)
}
</
div
>
</
div
>
{
/* Content area */
}
{
isContentVisible
&&
children
&&
(
<
div
className=
"
text-sm mt-2 text-gray-800 dark:text-gray-200 pl-2
0"
>
<
div
className=
"
mt-4 pl-20 text-sm text-gray-800 dark:text-gray-20
0"
>
{
children
}
</
div
>
)
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论