Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
672bd790
Unverified
提交
672bd790
authored
4月 29, 2025
作者:
Will Chen
提交者:
GitHub
4月 29, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add heuristic to suggest fix code output (#45)
Add heuristic to fix code output
上级
37928a90
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
72 行增加
和
3 行删除
+72
-3
ChatInput.tsx
src/components/chat/ChatInput.tsx
+38
-0
ChatMessage.tsx
src/components/chat/ChatMessage.tsx
+9
-2
DyadMarkdownParser.tsx
src/components/chat/DyadMarkdownParser.tsx
+11
-0
proposal_handlers.ts
src/ipc/handlers/proposal_handlers.ts
+8
-0
schemas.ts
src/lib/schemas.ts
+6
-1
没有找到文件。
src/components/chat/ChatInput.tsx
浏览文件 @
672bd790
...
...
@@ -385,12 +385,50 @@ function RefactorFileButton({ path }: { path: string }) {
);
}
function
WriteCodeProperlyButton
()
{
const
chatId
=
useAtomValue
(
selectedChatIdAtom
);
const
{
streamMessage
}
=
useStreamChat
();
return
(
<
TooltipProvider
>
<
Tooltip
>
<
TooltipTrigger
asChild
>
<
Button
variant=
"outline"
size=
"sm"
onClick=
{
()
=>
{
if
(
!
chatId
)
{
console
.
error
(
"No chat id found"
);
return
;
}
streamMessage
({
prompt
:
`Write the code in the previous message in the correct format using \`<dyad-write>\` tags!`
,
chatId
,
redo
:
false
,
});
}
}
>
Write code properly
</
Button
>
</
TooltipTrigger
>
<
TooltipContent
>
<
p
>
Write code properly (useful when AI generates the code in the wrong
format)
</
p
>
</
TooltipContent
>
</
Tooltip
>
</
TooltipProvider
>
);
}
function
mapActionToButton
(
action
:
SuggestedAction
)
{
switch
(
action
.
id
)
{
case
"summarize-in-new-chat"
:
return
<
SummarizeInNewChatButton
/>;
case
"refactor-file"
:
return
<
RefactorFileButton
path=
{
action
.
path
}
/>;
case
"write-code-properly"
:
return
<
WriteCodeProperlyButton
/>;
default
:
console
.
error
(
`Unsupported action:
${
action
.
id
}
`
);
return
(
...
...
src/components/chat/ChatMessage.tsx
浏览文件 @
672bd790
import
{
memo
}
from
"react"
;
import
type
{
Message
}
from
"@/ipc/ipc_types"
;
import
{
DyadMarkdownParser
}
from
"./DyadMarkdownParser"
;
import
{
DyadMarkdownParser
,
VanillaMarkdownParser
,
}
from
"./DyadMarkdownParser"
;
import
{
motion
}
from
"framer-motion"
;
import
{
useStreamChat
}
from
"@/hooks/useStreamChat"
;
import
{
CheckCircle
,
XCircle
}
from
"lucide-react"
;
...
...
@@ -64,7 +67,11 @@ const ChatMessage = ({ message }: ChatMessageProps) => {
className=
"prose dark:prose-invert prose-headings:mb-2 prose-p:my-1 prose-pre:my-0 max-w-none"
suppressHydrationWarning
>
<
DyadMarkdownParser
content=
{
message
.
content
}
/>
{
message
.
role
===
"assistant"
?
(
<
DyadMarkdownParser
content=
{
message
.
content
}
/>
)
:
(
<
VanillaMarkdownParser
content=
{
message
.
content
}
/>
)
}
</
div
>
)
}
{
message
.
approvalState
&&
(
...
...
src/components/chat/DyadMarkdownParser.tsx
浏览文件 @
672bd790
...
...
@@ -29,6 +29,17 @@ type ContentPiece =
|
{
type
:
"markdown"
;
content
:
string
}
|
{
type
:
"custom-tag"
;
tagInfo
:
CustomTagInfo
};
export
const
VanillaMarkdownParser
=
({
content
}:
{
content
:
string
})
=>
{
return
(
<
ReactMarkdown
rehypePlugins=
{
[
rehypeRaw
]
}
components=
{
{
code
:
CodeHighlight
}
as
any
}
>
{
content
}
</
ReactMarkdown
>
);
};
/**
* Custom component to parse markdown content with Dyad-specific tags
*/
...
...
src/ipc/handlers/proposal_handlers.ts
浏览文件 @
672bd790
...
...
@@ -239,6 +239,14 @@ const getProposalHandler = async (
path
:
refactorTarget
.
path
,
});
}
if
(
writeTags
.
length
===
0
&&
latestAssistantMessage
.
content
.
includes
(
"```"
)
)
{
actions
.
push
({
id
:
"write-code-properly"
,
});
}
}
// Get all chat messages to calculate token usage
...
...
src/lib/schemas.ts
浏览文件 @
672bd790
...
...
@@ -159,7 +159,8 @@ export interface CodeProposal {
export
type
SuggestedAction
=
|
RestartAppAction
|
SummarizeInNewChatAction
|
RefactorFileAction
;
|
RefactorFileAction
|
WriteCodeProperlyAction
;
export
interface
RestartAppAction
{
id
:
"restart-app"
;
...
...
@@ -169,6 +170,10 @@ export interface SummarizeInNewChatAction {
id
:
"summarize-in-new-chat"
;
}
export
interface
WriteCodeProperlyAction
{
id
:
"write-code-properly"
;
}
export
interface
RefactorFileAction
{
id
:
"refactor-file"
;
path
:
string
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论