Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
7041525c
提交
7041525c
authored
4月 21, 2025
作者:
Will Chen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle rename & deletes in proposal
上级
b07defc9
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
59 行增加
和
18 行删除
+59
-18
ChatInput.tsx
src/components/chat/ChatInput.tsx
+21
-4
proposal_handlers.ts
src/ipc/handlers/proposal_handlers.ts
+37
-14
schemas.ts
src/lib/schemas.ts
+1
-0
没有找到文件。
src/components/chat/ChatInput.tsx
浏览文件 @
7041525c
...
...
@@ -10,6 +10,8 @@ import {
Check
,
Loader2
,
Package
,
FileX
,
SendToBack
,
}
from
"lucide-react"
;
import
type
React
from
"react"
;
import
{
useCallback
,
useEffect
,
useRef
,
useState
}
from
"react"
;
...
...
@@ -32,6 +34,7 @@ import {
Proposal
,
SuggestedAction
,
ProposalResult
,
FileChange
,
}
from
"@/lib/schemas"
;
import
type
{
Message
}
from
"@/ipc/ipc_types"
;
import
{
isPreviewOpenAtom
}
from
"@/atoms/viewAtoms"
;
...
...
@@ -461,10 +464,7 @@ function ChatInputActions({
<
ul
className=
"space-y-1"
>
{
proposal
.
filesChanged
.
map
((
file
,
index
)
=>
(
<
li
key=
{
index
}
className=
"flex items-center space-x-2"
>
<
FileText
size=
{
16
}
className=
"text-muted-foreground flex-shrink-0"
/>
{
getIconForFileChange
(
file
)
}
<
span
title=
{
file
.
path
}
className=
"truncate cursor-default"
>
{
file
.
name
}
</
span
>
...
...
@@ -481,3 +481,20 @@ function ChatInputActions({
</
div
>
);
}
function
getIconForFileChange
(
file
:
FileChange
)
{
switch
(
file
.
type
)
{
case
"write"
:
return
(
<
FileText
size=
{
16
}
className=
"text-muted-foreground flex-shrink-0"
/>
);
case
"rename"
:
return
(
<
SendToBack
size=
{
16
}
className=
"text-muted-foreground flex-shrink-0"
/>
);
case
"delete"
:
return
(
<
FileX
size=
{
16
}
className=
"text-muted-foreground flex-shrink-0"
/>
);
}
}
src/ipc/handlers/proposal_handlers.ts
浏览文件 @
7041525c
import
{
ipcMain
,
type
IpcMainInvokeEvent
}
from
"electron"
;
import
type
{
CodeProposal
,
ProposalResult
}
from
"@/lib/schemas"
;
import
type
{
CodeProposal
,
FileChange
,
ProposalResult
,
}
from
"../../lib/schemas"
;
import
{
db
}
from
"../../db"
;
import
{
messages
}
from
"../../db/schema"
;
import
{
desc
,
eq
,
and
,
Update
}
from
"drizzle-orm"
;
...
...
@@ -8,6 +12,8 @@ import path from "node:path"; // Import path for basename
import
{
getDyadAddDependencyTags
,
getDyadChatSummaryTag
,
getDyadDeleteTags
,
getDyadRenameTags
,
getDyadWriteTags
,
processFullResponseActions
,
}
from
"../processors/response_processor"
;
...
...
@@ -65,34 +71,51 @@ const getProposalHandler = async (
);
const
messageContent
=
latestAssistantMessage
.
content
;
// Parse tags directly from message content
const
proposalTitle
=
getDyadChatSummaryTag
(
messageContent
);
const
proposalFiles
=
getDyadWriteTags
(
messageContent
);
// Gets { path: string, content: string }[]
const
proposalWriteFiles
=
getDyadWriteTags
(
messageContent
);
const
proposalRenameFiles
=
getDyadRenameTags
(
messageContent
);
const
proposalDeleteFiles
=
getDyadDeleteTags
(
messageContent
);
const
packagesAdded
=
getDyadAddDependencyTags
(
messageContent
);
const
filesChanged
=
[
...
proposalWriteFiles
.
map
((
tag
)
=>
({
name
:
path
.
basename
(
tag
.
path
),
path
:
tag
.
path
,
summary
:
tag
.
description
??
"(no change summary found)"
,
// Generic summary
type
:
"write"
as
const
,
})),
...
proposalRenameFiles
.
map
((
tag
)
=>
({
name
:
path
.
basename
(
tag
.
to
),
path
:
tag
.
to
,
summary
:
`Rename from
${
tag
.
from
}
to
${
tag
.
to
}
`
,
type
:
"rename"
as
const
,
})),
...
proposalDeleteFiles
.
map
((
tag
)
=>
({
name
:
path
.
basename
(
tag
),
path
:
tag
,
summary
:
`Delete file`
,
type
:
"delete"
as
const
,
})),
];
// Check if we have enough information to create a proposal
if
(
proposalTitle
||
proposalFiles
.
length
>
0
||
packagesAdded
.
length
>
0
)
{
if
(
filesChanged
.
length
>
0
||
packagesAdded
.
length
>
0
)
{
const
proposal
:
CodeProposal
=
{
type
:
"code-proposal"
,
// Use parsed title or a default title if summary tag is missing but write tags exist
title
:
proposalTitle
??
"Proposed File Changes"
,
securityRisks
:
[],
// Keep empty
filesChanged
:
proposalFiles
.
map
((
tag
)
=>
({
name
:
path
.
basename
(
tag
.
path
),
path
:
tag
.
path
,
summary
:
tag
.
description
??
"(no change summary found)"
,
// Generic summary
})),
filesChanged
,
packagesAdded
,
};
logger
.
log
(
"Generated code proposal. title="
,
proposal
.
title
,
"files="
,
proposal
.
filesChanged
.
length
proposal
.
filesChanged
.
length
,
"packages="
,
proposal
.
packagesAdded
.
length
);
return
{
proposal
,
chatId
,
messageId
};
// Return proposal and messageId
}
else
{
...
...
src/lib/schemas.ts
浏览文件 @
7041525c
...
...
@@ -111,6 +111,7 @@ export interface FileChange {
name
:
string
;
path
:
string
;
summary
:
string
;
type
:
"write"
|
"rename"
|
"delete"
;
}
export
interface
CodeProposal
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论