Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
19d1e890
Unverified
提交
19d1e890
authored
4月 29, 2025
作者:
Will Chen
提交者:
GitHub
4月 29, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Create Upload Chat Session help feature (#48)
上级
74003b90
全部展开
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
179 行增加
和
16 行删除
+179
-16
HelpDialog.tsx
src/components/HelpDialog.tsx
+0
-0
debug_handlers.ts
src/ipc/handlers/debug_handlers.ts
+79
-15
upload_handlers.ts
src/ipc/handlers/upload_handlers.ts
+59
-0
ipc_client.ts
src/ipc/ipc_client.ts
+30
-1
ipc_host.ts
src/ipc/ipc_host.ts
+2
-0
ipc_types.ts
src/ipc/ipc_types.ts
+7
-0
preload.ts
src/preload.ts
+2
-0
没有找到文件。
src/components/HelpDialog.tsx
浏览文件 @
19d1e890
差异被折叠。
点击展开。
src/ipc/handlers/debug_handlers.ts
浏览文件 @
19d1e890
import
{
ipcMain
,
app
}
from
"electron"
;
import
{
ipcMain
,
app
}
from
"electron"
;
import
{
platform
,
arch
}
from
"os"
;
import
{
platform
,
arch
}
from
"os"
;
import
{
SystemDebugInfo
}
from
"../ipc_types"
;
import
{
SystemDebugInfo
,
ChatLogsData
}
from
"../ipc_types"
;
import
{
readSettings
}
from
"../../main/settings"
;
import
{
readSettings
}
from
"../../main/settings"
;
import
{
execSync
}
from
"child_process"
;
import
{
execSync
}
from
"child_process"
;
import
log
from
"electron-log"
;
import
log
from
"electron-log"
;
import
path
from
"path"
;
import
path
from
"path"
;
import
fs
from
"fs"
;
import
fs
from
"fs"
;
import
{
runShellCommand
}
from
"../utils/runShellCommand"
;
import
{
runShellCommand
}
from
"../utils/runShellCommand"
;
import
{
extractCodebase
}
from
"../../utils/codebase"
;
import
{
db
}
from
"../../db"
;
import
{
chats
,
apps
}
from
"../../db/schema"
;
import
{
eq
}
from
"drizzle-orm"
;
import
{
getDyadAppPath
}
from
"../../paths/paths"
;
export
function
registerDebugHandlers
()
{
// Shared function to get system debug info
ipcMain
.
handle
(
async
function
getSystemDebugInfo
():
Promise
<
SystemDebugInfo
>
{
"get-system-debug-info"
,
console
.
log
(
"Getting system debug info"
);
async
():
Promise
<
SystemDebugInfo
>
=>
{
console
.
log
(
"IPC: get-system-debug-info called"
);
// Get Node.js and pnpm versions
// Get Node.js and pnpm versions
let
nodeVersion
:
string
|
null
=
null
;
let
nodeVersion
:
string
|
null
=
null
;
...
@@ -41,17 +44,10 @@ export function registerDebugHandlers() {
...
@@ -41,17 +44,10 @@ export function registerDebugHandlers() {
}
}
// Get Dyad version from package.json
// Get Dyad version from package.json
const
packageJsonPath
=
path
.
resolve
(
const
packageJsonPath
=
path
.
resolve
(
__dirname
,
".."
,
".."
,
"package.json"
);
__dirname
,
".."
,
".."
,
"package.json"
);
let
dyadVersion
=
"unknown"
;
let
dyadVersion
=
"unknown"
;
try
{
try
{
const
packageJson
=
JSON
.
parse
(
const
packageJson
=
JSON
.
parse
(
fs
.
readFileSync
(
packageJsonPath
,
"utf8"
));
fs
.
readFileSync
(
packageJsonPath
,
"utf8"
)
);
dyadVersion
=
packageJson
.
version
;
dyadVersion
=
packageJson
.
version
;
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
error
(
"Failed to read package.json:"
,
err
);
console
.
error
(
"Failed to read package.json:"
,
err
);
...
@@ -87,6 +83,74 @@ export function registerDebugHandlers() {
...
@@ -87,6 +83,74 @@ export function registerDebugHandlers() {
architecture
:
arch
(),
architecture
:
arch
(),
logs
,
logs
,
};
};
}
export
function
registerDebugHandlers
()
{
ipcMain
.
handle
(
"get-system-debug-info"
,
async
():
Promise
<
SystemDebugInfo
>
=>
{
console
.
log
(
"IPC: get-system-debug-info called"
);
return
getSystemDebugInfo
();
}
);
ipcMain
.
handle
(
"get-chat-logs"
,
async
(
_
,
chatId
:
number
):
Promise
<
ChatLogsData
>
=>
{
console
.
log
(
`IPC: get-chat-logs called for chat
${
chatId
}
`
);
try
{
// Get system debug info using the shared function
const
debugInfo
=
await
getSystemDebugInfo
();
// Get chat data from database
const
chatRecord
=
await
db
.
query
.
chats
.
findFirst
({
where
:
eq
(
chats
.
id
,
chatId
),
with
:
{
messages
:
{
orderBy
:
(
messages
,
{
asc
})
=>
[
asc
(
messages
.
createdAt
)],
},
},
});
if
(
!
chatRecord
)
{
throw
new
Error
(
`Chat with ID
${
chatId
}
not found`
);
}
// Format the chat to match the Chat interface
const
chat
=
{
id
:
chatRecord
.
id
,
title
:
chatRecord
.
title
||
"Untitled Chat"
,
messages
:
chatRecord
.
messages
.
map
((
msg
)
=>
({
id
:
msg
.
id
,
role
:
msg
.
role
,
content
:
msg
.
content
,
approvalState
:
msg
.
approvalState
,
})),
};
// Get app data from database
const
app
=
await
db
.
query
.
apps
.
findFirst
({
where
:
eq
(
apps
.
id
,
chatRecord
.
appId
),
});
if
(
!
app
)
{
throw
new
Error
(
`App with ID
${
chatRecord
.
appId
}
not found`
);
}
// Extract codebase
const
appPath
=
getDyadAppPath
(
app
.
path
);
const
codebase
=
await
extractCodebase
(
appPath
);
return
{
debugInfo
,
chat
,
codebase
,
};
}
catch
(
error
)
{
console
.
error
(
`Error in get-chat-logs:`
,
error
);
throw
error
;
}
}
}
);
);
...
...
src/ipc/handlers/upload_handlers.ts
0 → 100644
浏览文件 @
19d1e890
import
{
ipcMain
}
from
"electron"
;
import
log
from
"electron-log"
;
import
fetch
from
"node-fetch"
;
const
logger
=
log
.
scope
(
"upload_handlers"
);
interface
UploadToSignedUrlParams
{
url
:
string
;
contentType
:
string
;
data
:
any
;
}
export
function
registerUploadHandlers
()
{
ipcMain
.
handle
(
"upload-to-signed-url"
,
async
(
_
,
params
:
UploadToSignedUrlParams
)
=>
{
const
{
url
,
contentType
,
data
}
=
params
;
logger
.
debug
(
"IPC: upload-to-signed-url called"
);
try
{
// Validate the signed URL
if
(
!
url
||
typeof
url
!==
"string"
||
!
url
.
startsWith
(
"https://"
))
{
throw
new
Error
(
"Invalid signed URL provided"
);
}
// Validate content type
if
(
!
contentType
||
typeof
contentType
!==
"string"
)
{
throw
new
Error
(
"Invalid content type provided"
);
}
// Perform the upload to the signed URL
const
response
=
await
fetch
(
url
,
{
method
:
"PUT"
,
headers
:
{
"Content-Type"
:
contentType
,
},
body
:
JSON
.
stringify
(
data
),
});
if
(
!
response
.
ok
)
{
throw
new
Error
(
`Upload failed with status
${
response
.
status
}
:
${
response
.
statusText
}
`
);
}
logger
.
debug
(
"Successfully uploaded data to signed URL"
);
return
{
success
:
true
};
}
catch
(
error
)
{
logger
.
error
(
"Failed to upload to signed URL:"
,
error
);
return
{
success
:
false
,
error
:
error
instanceof
Error
?
error
.
message
:
String
(
error
),
};
}
}
);
logger
.
debug
(
"Registered upload IPC handlers"
);
}
src/ipc/ipc_client.ts
浏览文件 @
19d1e890
...
@@ -21,6 +21,7 @@ import type {
...
@@ -21,6 +21,7 @@ import type {
LocalModelListResponse
,
LocalModelListResponse
,
TokenCountParams
,
TokenCountParams
,
TokenCountResult
,
TokenCountResult
,
ChatLogsData
,
}
from
"./ipc_types"
;
}
from
"./ipc_types"
;
import
type
{
CodeProposal
,
ProposalResult
}
from
"@/lib/schemas"
;
import
type
{
CodeProposal
,
ProposalResult
}
from
"@/lib/schemas"
;
import
{
showError
}
from
"@/lib/toast"
;
import
{
showError
}
from
"@/lib/toast"
;
...
@@ -749,7 +750,35 @@ export class IpcClient {
...
@@ -749,7 +750,35 @@ export class IpcClient {
public
async
getSystemDebugInfo
():
Promise
<
SystemDebugInfo
>
{
public
async
getSystemDebugInfo
():
Promise
<
SystemDebugInfo
>
{
try
{
try
{
const
data
=
await
this
.
ipcRenderer
.
invoke
(
"get-system-debug-info"
);
const
data
=
await
this
.
ipcRenderer
.
invoke
(
"get-system-debug-info"
);
return
data
;
return
data
as
SystemDebugInfo
;
}
catch
(
error
)
{
showError
(
error
);
throw
error
;
}
}
public
async
getChatLogs
(
chatId
:
number
):
Promise
<
ChatLogsData
>
{
try
{
const
data
=
await
this
.
ipcRenderer
.
invoke
(
"get-chat-logs"
,
chatId
);
return
data
as
ChatLogsData
;
}
catch
(
error
)
{
showError
(
error
);
throw
error
;
}
}
public
async
uploadToSignedUrl
(
url
:
string
,
contentType
:
string
,
data
:
any
):
Promise
<
{
success
:
boolean
;
error
?:
string
}
>
{
try
{
const
result
=
await
this
.
ipcRenderer
.
invoke
(
"upload-to-signed-url"
,
{
url
,
contentType
,
data
,
});
return
result
as
{
success
:
boolean
;
error
?:
string
};
}
catch
(
error
)
{
}
catch
(
error
)
{
showError
(
error
);
showError
(
error
);
throw
error
;
throw
error
;
...
...
src/ipc/ipc_host.ts
浏览文件 @
19d1e890
...
@@ -12,6 +12,7 @@ import { registerSupabaseHandlers } from "./handlers/supabase_handlers";
...
@@ -12,6 +12,7 @@ import { registerSupabaseHandlers } from "./handlers/supabase_handlers";
import
{
registerLocalModelHandlers
}
from
"./handlers/local_model_handlers"
;
import
{
registerLocalModelHandlers
}
from
"./handlers/local_model_handlers"
;
import
{
registerTokenCountHandlers
}
from
"./handlers/token_count_handlers"
;
import
{
registerTokenCountHandlers
}
from
"./handlers/token_count_handlers"
;
import
{
registerWindowHandlers
}
from
"./handlers/window_handlers"
;
import
{
registerWindowHandlers
}
from
"./handlers/window_handlers"
;
import
{
registerUploadHandlers
}
from
"./handlers/upload_handlers"
;
export
function
registerIpcHandlers
()
{
export
function
registerIpcHandlers
()
{
// Register all IPC handlers by category
// Register all IPC handlers by category
...
@@ -29,4 +30,5 @@ export function registerIpcHandlers() {
...
@@ -29,4 +30,5 @@ export function registerIpcHandlers() {
registerLocalModelHandlers
();
registerLocalModelHandlers
();
registerTokenCountHandlers
();
registerTokenCountHandlers
();
registerWindowHandlers
();
registerWindowHandlers
();
registerUploadHandlers
();
}
}
src/ipc/ipc_types.ts
浏览文件 @
19d1e890
...
@@ -106,6 +106,7 @@ export interface TokenCountParams {
...
@@ -106,6 +106,7 @@ export interface TokenCountParams {
chatId
:
number
;
chatId
:
number
;
input
:
string
;
input
:
string
;
}
}
export
interface
TokenCountResult
{
export
interface
TokenCountResult
{
totalTokens
:
number
;
totalTokens
:
number
;
messageHistoryTokens
:
number
;
messageHistoryTokens
:
number
;
...
@@ -114,3 +115,9 @@ export interface TokenCountResult {
...
@@ -114,3 +115,9 @@ export interface TokenCountResult {
systemPromptTokens
:
number
;
systemPromptTokens
:
number
;
contextWindow
:
number
;
contextWindow
:
number
;
}
}
export
interface
ChatLogsData
{
debugInfo
:
SystemDebugInfo
;
chat
:
Chat
;
codebase
:
string
;
}
src/preload.ts
浏览文件 @
19d1e890
...
@@ -14,6 +14,7 @@ const validInvokeChannels = [
...
@@ -14,6 +14,7 @@ const validInvokeChannels = [
"create-app"
,
"create-app"
,
"get-chat"
,
"get-chat"
,
"get-chats"
,
"get-chats"
,
"get-chat-logs"
,
"list-apps"
,
"list-apps"
,
"get-app"
,
"get-app"
,
"edit-app-file"
,
"edit-app-file"
,
...
@@ -53,6 +54,7 @@ const validInvokeChannels = [
...
@@ -53,6 +54,7 @@ const validInvokeChannels = [
"window:maximize"
,
"window:maximize"
,
"window:close"
,
"window:close"
,
"window:get-platform"
,
"window:get-platform"
,
"upload-to-signed-url"
,
]
as
const
;
]
as
const
;
// Add valid receive channels
// Add valid receive channels
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论