@lobehub/chat 0.119.8 → 0.119.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/1_bug_report.yml +22 -9
- package/.github/ISSUE_TEMPLATE/1_bug_report_cn.yml +59 -0
- package/.github/ISSUE_TEMPLATE/2_feature_request.yml +6 -6
- package/.github/ISSUE_TEMPLATE/2_feature_request_cn.yml +21 -0
- package/.github/ISSUE_TEMPLATE/config.yml +4 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +1 -0
- package/CHANGELOG.md +50 -0
- package/docs/Deployment/Common-Error.md +70 -0
- package/docs/Deployment/Common-Error.zh-CN.md +69 -0
- package/docs/Home.md +2 -1
- package/docs/_Sidebar.md +2 -1
- package/package.json +3 -3
- package/src/app/chat/(desktop)/features/ChatInput/__tests__/useAutoFocus.test.ts +23 -1
- package/src/app/chat/(desktop)/features/ChatInput/useAutoFocus.ts +5 -2
- package/src/features/Conversation/index.tsx +2 -2
- package/src/store/tool/slices/store/action.test.ts +4 -6
- package/.github/ISSUE_TEMPLATE/3_question.yml +0 -15
- package/.github/ISSUE_TEMPLATE/4_other.md +0 -7
|
@@ -1,22 +1,35 @@
|
|
|
1
|
-
name: '🐛
|
|
2
|
-
description: '
|
|
1
|
+
name: '🐛 Bug Report'
|
|
2
|
+
description: 'Report an bug'
|
|
3
3
|
title: '[Bug] '
|
|
4
|
-
labels: '🐛 Bug'
|
|
4
|
+
labels: ['🐛 Bug']
|
|
5
5
|
body:
|
|
6
6
|
- type: dropdown
|
|
7
7
|
attributes:
|
|
8
|
-
label: '💻
|
|
8
|
+
label: '💻 Operating System'
|
|
9
9
|
options:
|
|
10
10
|
- Windows
|
|
11
11
|
- macOS
|
|
12
12
|
- Ubuntu
|
|
13
13
|
- Other Linux
|
|
14
|
+
- iOS
|
|
15
|
+
- Android
|
|
14
16
|
- Other
|
|
15
17
|
validations:
|
|
16
18
|
required: true
|
|
17
19
|
- type: dropdown
|
|
18
20
|
attributes:
|
|
19
|
-
label: '
|
|
21
|
+
label: '📦 Environment'
|
|
22
|
+
options:
|
|
23
|
+
- Official Preview
|
|
24
|
+
- Vercel / Zeabur / Sealos
|
|
25
|
+
- Docker
|
|
26
|
+
- Other
|
|
27
|
+
validations:
|
|
28
|
+
required: true
|
|
29
|
+
|
|
30
|
+
- type: dropdown
|
|
31
|
+
attributes:
|
|
32
|
+
label: '🌐 Browser'
|
|
20
33
|
options:
|
|
21
34
|
- Chrome
|
|
22
35
|
- Edge
|
|
@@ -27,19 +40,19 @@ body:
|
|
|
27
40
|
required: true
|
|
28
41
|
- type: textarea
|
|
29
42
|
attributes:
|
|
30
|
-
label: '🐛
|
|
43
|
+
label: '🐛 Bug Description'
|
|
31
44
|
description: A clear and concise description of the bug.
|
|
32
45
|
validations:
|
|
33
46
|
required: true
|
|
34
47
|
- type: textarea
|
|
35
48
|
attributes:
|
|
36
|
-
label: '🚦
|
|
49
|
+
label: '🚦 Expected Behavior'
|
|
37
50
|
description: A clear and concise description of what you expected to happen.
|
|
38
51
|
- type: textarea
|
|
39
52
|
attributes:
|
|
40
|
-
label: '📷
|
|
53
|
+
label: '📷 Recurrence Steps'
|
|
41
54
|
description: A clear and concise description of how to recurrence.
|
|
42
55
|
- type: textarea
|
|
43
56
|
attributes:
|
|
44
|
-
label: '📝
|
|
57
|
+
label: '📝 Additional Information'
|
|
45
58
|
description: If your problem needs further explanation, or if the issue you're seeing cannot be reproduced in a gist, please add more information here.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: '🐛 反馈缺陷'
|
|
2
|
+
description: '反馈一个问题缺陷'
|
|
3
|
+
title: '[Bug] '
|
|
4
|
+
labels: ['🐛 Bug']
|
|
5
|
+
body:
|
|
6
|
+
- type: dropdown
|
|
7
|
+
attributes:
|
|
8
|
+
label: '💻 系统环境'
|
|
9
|
+
options:
|
|
10
|
+
- Windows
|
|
11
|
+
- macOS
|
|
12
|
+
- Ubuntu
|
|
13
|
+
- Other Linux
|
|
14
|
+
- iOS
|
|
15
|
+
- Android
|
|
16
|
+
- Other
|
|
17
|
+
validations:
|
|
18
|
+
required: true
|
|
19
|
+
|
|
20
|
+
- type: dropdown
|
|
21
|
+
attributes:
|
|
22
|
+
label: '📦 部署环境'
|
|
23
|
+
options:
|
|
24
|
+
- Official Preview
|
|
25
|
+
- Vercel / Zeabur / Sealos
|
|
26
|
+
- Docker
|
|
27
|
+
- Other
|
|
28
|
+
validations:
|
|
29
|
+
required: true
|
|
30
|
+
|
|
31
|
+
- type: dropdown
|
|
32
|
+
attributes:
|
|
33
|
+
label: '🌐 浏览器'
|
|
34
|
+
options:
|
|
35
|
+
- Chrome
|
|
36
|
+
- Edge
|
|
37
|
+
- Safari
|
|
38
|
+
- Firefox
|
|
39
|
+
- Other
|
|
40
|
+
validations:
|
|
41
|
+
required: true
|
|
42
|
+
- type: textarea
|
|
43
|
+
attributes:
|
|
44
|
+
label: '🐛 问题描述'
|
|
45
|
+
description: 请提供一个清晰且简洁的问题描述。
|
|
46
|
+
validations:
|
|
47
|
+
required: true
|
|
48
|
+
- type: textarea
|
|
49
|
+
attributes:
|
|
50
|
+
label: '🚦 期望结果'
|
|
51
|
+
description: 请提供一个清晰且简洁的描述,说明您期望发生什么。
|
|
52
|
+
- type: textarea
|
|
53
|
+
attributes:
|
|
54
|
+
label: '📷 复现步骤'
|
|
55
|
+
description: 请提供一个清晰且简洁的描述,说明如何复现问题。
|
|
56
|
+
- type: textarea
|
|
57
|
+
attributes:
|
|
58
|
+
label: '📝 补充信息'
|
|
59
|
+
description: 如果您的问题需要进一步说明,或者您遇到的问题无法在一个简单的示例中复现,请在这里添加更多信息。
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
name: '🌠
|
|
2
|
-
description: '
|
|
1
|
+
name: '🌠 Feature Request'
|
|
2
|
+
description: 'Suggest an idea'
|
|
3
3
|
title: '[Request] '
|
|
4
|
-
labels: '🌠 Feature Request'
|
|
4
|
+
labels: ['🌠 Feature Request']
|
|
5
5
|
body:
|
|
6
6
|
- type: textarea
|
|
7
7
|
attributes:
|
|
8
|
-
label: '🥰
|
|
8
|
+
label: '🥰 Feature Description'
|
|
9
9
|
description: Please add a clear and concise description of the problem you are seeking to solve with this feature request.
|
|
10
10
|
validations:
|
|
11
11
|
required: true
|
|
12
12
|
- type: textarea
|
|
13
13
|
attributes:
|
|
14
|
-
label: '🧐
|
|
14
|
+
label: '🧐 Proposed Solution'
|
|
15
15
|
description: Describe the solution you'd like in a clear and concise manner.
|
|
16
16
|
validations:
|
|
17
17
|
required: true
|
|
18
18
|
- type: textarea
|
|
19
19
|
attributes:
|
|
20
|
-
label: '📝
|
|
20
|
+
label: '📝 Additional Information'
|
|
21
21
|
description: Add any other context about the problem here.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
name: '🌠 功能需求'
|
|
2
|
+
description: '提出需求或建议'
|
|
3
|
+
title: '[Request] '
|
|
4
|
+
labels: ['🌠 功能需求']
|
|
5
|
+
body:
|
|
6
|
+
- type: textarea
|
|
7
|
+
attributes:
|
|
8
|
+
label: '🥰 需求描述'
|
|
9
|
+
description: 请添加一个清晰且简洁的问题描述,阐述您希望通过这个功能需求解决的问题。
|
|
10
|
+
validations:
|
|
11
|
+
required: true
|
|
12
|
+
- type: textarea
|
|
13
|
+
attributes:
|
|
14
|
+
label: '🧐 解决方案'
|
|
15
|
+
description: 请清晰且简洁地描述您想要的解决方案。
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
- type: textarea
|
|
19
|
+
attributes:
|
|
20
|
+
label: '📝 补充信息'
|
|
21
|
+
description: 在这里添加关于问题的任何其他背景信息。
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
### [Version 0.119.10](https://github.com/lobehub/lobe-chat/compare/v0.119.9...v0.119.10)
|
|
6
|
+
|
|
7
|
+
<sup>Released on **2024-01-08**</sup>
|
|
8
|
+
|
|
9
|
+
#### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
- **misc**: Debug information cannot be selected.
|
|
12
|
+
|
|
13
|
+
<br/>
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
17
|
+
|
|
18
|
+
#### What's fixed
|
|
19
|
+
|
|
20
|
+
- **misc**: Debug information cannot be selected, closes [#980](https://github.com/lobehub/lobe-chat/issues/980) ([f02612d](https://github.com/lobehub/lobe-chat/commit/f02612d))
|
|
21
|
+
|
|
22
|
+
</details>
|
|
23
|
+
|
|
24
|
+
<div align="right">
|
|
25
|
+
|
|
26
|
+
[](#readme-top)
|
|
27
|
+
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
### [Version 0.119.9](https://github.com/lobehub/lobe-chat/compare/v0.119.8...v0.119.9)
|
|
31
|
+
|
|
32
|
+
<sup>Released on **2024-01-08**</sup>
|
|
33
|
+
|
|
34
|
+
#### 💄 Styles
|
|
35
|
+
|
|
36
|
+
- **misc**: Fix ChatInput fullscreen display not correct.
|
|
37
|
+
|
|
38
|
+
<br/>
|
|
39
|
+
|
|
40
|
+
<details>
|
|
41
|
+
<summary><kbd>Improvements and Fixes</kbd></summary>
|
|
42
|
+
|
|
43
|
+
#### Styles
|
|
44
|
+
|
|
45
|
+
- **misc**: Fix ChatInput fullscreen display not correct, closes [#982](https://github.com/lobehub/lobe-chat/issues/982) ([e4012c4](https://github.com/lobehub/lobe-chat/commit/e4012c4))
|
|
46
|
+
|
|
47
|
+
</details>
|
|
48
|
+
|
|
49
|
+
<div align="right">
|
|
50
|
+
|
|
51
|
+
[](#readme-top)
|
|
52
|
+
|
|
53
|
+
</div>
|
|
54
|
+
|
|
5
55
|
### [Version 0.119.8](https://github.com/lobehub/lobe-chat/compare/v0.119.7...v0.119.8)
|
|
6
56
|
|
|
7
57
|
<sup>Released on **2024-01-07**</sup>
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Frequently Asked Questions
|
|
2
|
+
|
|
3
|
+
## When using a proxy(e.g. Surge), I encounter the `UNABLE_TO_VERIFY_LEAF_SIGNATURE` error
|
|
4
|
+
|
|
5
|
+
### Problem Description
|
|
6
|
+
|
|
7
|
+
When making network requests during private deployment, certificate validation errors may occur. The error messages may be as follows:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
[TypeError: fetch failed] {
|
|
11
|
+
cause: [Error: unable to verify the first certificate] {
|
|
12
|
+
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
{
|
|
21
|
+
"endpoint": "https://api.openai.com/v1",
|
|
22
|
+
"error": {
|
|
23
|
+
"cause": {
|
|
24
|
+
"code": "UNABLE_TO_VERIFY_LEAF_SIGNATURE"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
This problem typically occurs when using a proxy server with a self-signed certificate or a man-in-the-middle certificate that is not trusted by Node.js by default.
|
|
31
|
+
|
|
32
|
+
### Solution
|
|
33
|
+
|
|
34
|
+
To resolve this issue, you can add an environment variable to bypass Node.js certificate validation when starting the application. The specific approach is to include `NODE_TLS_REJECT_UNAUTHORIZED=0` in the startup command. For example:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
NODE_TLS_REJECT_UNAUTHORIZED=0 npm run start
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Alternatively, when running in a Docker container, you can set the environment variable in the Dockerfile or docker-compose.yml:
|
|
41
|
+
|
|
42
|
+
```dockerfile
|
|
43
|
+
# In the Dockerfile
|
|
44
|
+
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
# In the docker-compose.yml
|
|
49
|
+
environment:
|
|
50
|
+
- NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Example Docker run command:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
docker run -e NODE_TLS_REJECT_UNAUTHORIZED=0 <other parameters> <image name>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Please note that this method reduces security because it allows Node.js to accept unverified certificates. Therefore, it is only recommended for use in private deployments with fully trusted network environments, and the default certificate validation settings should be restored after resolving the certificate issue.
|
|
60
|
+
|
|
61
|
+
### More Secure Alternatives
|
|
62
|
+
|
|
63
|
+
If possible, it is recommended to address certificate issues using the following methods:
|
|
64
|
+
|
|
65
|
+
1. Ensure that all man-in-the-middle certificates are correctly installed on the proxy server and the corresponding clients.
|
|
66
|
+
2. Replace self-signed or man-in-the-middle certificates with valid certificates issued by trusted certificate authorities.
|
|
67
|
+
3. Properly configure the certificate chain in the code to ensure that Node.js can validate to the root certificate.
|
|
68
|
+
|
|
69
|
+
Implementing these methods can resolve certificate validation issues without sacrificing security.
|
|
70
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# 常见问题
|
|
2
|
+
|
|
3
|
+
## 使用代理中转请求时(例如:Surge),报 `UNABLE_TO_VERIFY_LEAF_SIGNATURE` 错误
|
|
4
|
+
|
|
5
|
+
### 问题描述
|
|
6
|
+
|
|
7
|
+
在私有化部署时,进行网络请求可能会遇到证书验证错误。错误信息可能如下:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
[TypeError: fetch failed] {
|
|
11
|
+
cause: [Error: unable to verify the first certificate] {
|
|
12
|
+
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
或者是:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
{
|
|
21
|
+
"endpoint": "https://api.openai.com/v1",
|
|
22
|
+
"error": {
|
|
23
|
+
"cause": {
|
|
24
|
+
"code": "UNABLE_TO_VERIFY_LEAF_SIGNATURE"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
这个问题通常出现在使用代理服务器时,代理服务器使用的自签名证书或中间人证书不被 Node.js 默认信任。
|
|
31
|
+
|
|
32
|
+
### 解决方案
|
|
33
|
+
|
|
34
|
+
要解决这个问题,可以在启动应用时添加环境变量,跳过 Node.js 的证书验证。具体做法是在启动命令中加入 `NODE_TLS_REJECT_UNAUTHORIZED=0`。例如:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
NODE_TLS_REJECT_UNAUTHORIZED=0 npm run start
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
或者在 Docker 容器中运行时,可以在 Dockerfile 或者 docker-compose.yml 中设置环境变量:
|
|
41
|
+
|
|
42
|
+
```dockerfile
|
|
43
|
+
# 在 Dockerfile 中
|
|
44
|
+
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```yaml
|
|
48
|
+
# 在 docker-compose.yml 中
|
|
49
|
+
environment:
|
|
50
|
+
- NODE_TLS_REJECT_UNAUTHORIZED=0
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Docker 运行命令示例:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
docker run -e NODE_TLS_REJECT_UNAUTHORIZED=0 <其他参数> <镜像名>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
请注意,这种方法会降低安全性,因为它允许 Node.js 接受未经验证的证书。因此,仅建议在完全信任网络环境的私有化部署中使用,且需要在解决证书问题后恢复默认的证书验证设置。
|
|
60
|
+
|
|
61
|
+
### 更安全的替代方案
|
|
62
|
+
|
|
63
|
+
如果可能,建议通过以下方法解决证书问题:
|
|
64
|
+
|
|
65
|
+
1. 确保所有的中间人证书都被正确地安装在代理服务器和相应的客户端上。
|
|
66
|
+
2. 使用有效的、由受信任的证书颁发机构签发的证书替换自签名或中间人证书。
|
|
67
|
+
3. 在代码中正确配置证书链,确保 Node.js 可以验证到根证书。
|
|
68
|
+
|
|
69
|
+
采用这些方法可以在不牺牲安全性的前提下解决证书验证问题。
|
package/docs/Home.md
CHANGED
|
@@ -25,10 +25,11 @@ LobeChat is a open-source, extensible ([Function Calling][fc-url]), high-perform
|
|
|
25
25
|
|
|
26
26
|
### 🛳 Self-Hosting
|
|
27
27
|
|
|
28
|
-
- [Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable) | [环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN)
|
|
29
28
|
- [Docker Deployment Guide](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment) | [Docker 部署指引](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment.zh-CN)
|
|
30
29
|
- [Deploying with Azure OpenAI](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI) | [使用 Azure OpenAI 部署](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI.zh-CN)
|
|
30
|
+
- [Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable) | [环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN)
|
|
31
31
|
- [Upstream Sync](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync) | [自部署保持更新](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN)
|
|
32
|
+
- [Common Error](https://github.com/lobehub/lobe-chat/wiki/Common-Error) | [常见问题](https://github.com/lobehub/lobe-chat/wiki/Common-Error.zh-CN)
|
|
32
33
|
- [Data Statistics](https://github.com/lobehub/lobe-chat/wiki/Analytics) | [数据统计](https://github.com/lobehub/lobe-chat/wiki/Analytics.zh-CN)
|
|
33
34
|
|
|
34
35
|
<br/>
|
package/docs/_Sidebar.md
CHANGED
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
|
|
16
16
|
#### 🛳 Self-Hosting
|
|
17
17
|
|
|
18
|
-
- [Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable) | [中文](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN)
|
|
19
18
|
- [Docker Deployment Guide](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment) | [Docker 部署指引](https://github.com/lobehub/lobe-chat/wiki/Docker-Deployment.zh-CN)
|
|
20
19
|
- [Deploying with Azure OpenAI](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI) | [使用 Azure OpenAI 部署](https://github.com/lobehub/lobe-chat/wiki/Deploy-with-Azure-OpenAI.zh-CN)
|
|
20
|
+
- [Environment Variables](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable) | [环境变量](https://github.com/lobehub/lobe-chat/wiki/Environment-Variable.zh-CN)
|
|
21
21
|
- [Upstream Sync](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync) | [自部署保持更新](https://github.com/lobehub/lobe-chat/wiki/Upstream-Sync.zh-CN)
|
|
22
|
+
- [Common Error](https://github.com/lobehub/lobe-chat/wiki/Common-Error) | [常见问题](https://github.com/lobehub/lobe-chat/wiki/Common-Error.zh-CN)
|
|
22
23
|
- [Data Statistics](https://github.com/lobehub/lobe-chat/wiki/Analytics) | [数据统计](https://github.com/lobehub/lobe-chat/wiki/Analytics.zh-CN)
|
|
23
24
|
|
|
24
25
|
#### ⌨️ Development
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/chat",
|
|
3
|
-
"version": "0.119.
|
|
3
|
+
"version": "0.119.10",
|
|
4
4
|
"description": "Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"framework",
|
|
@@ -153,7 +153,7 @@
|
|
|
153
153
|
"@types/ua-parser-js": "^0.7",
|
|
154
154
|
"@types/uuid": "^9",
|
|
155
155
|
"@umijs/lint": "^4",
|
|
156
|
-
"@vitest/coverage-v8": "1.1.
|
|
156
|
+
"@vitest/coverage-v8": "^1.1.3",
|
|
157
157
|
"commitlint": "^18",
|
|
158
158
|
"consola": "^3",
|
|
159
159
|
"dpdm": "^3",
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
"typescript": "^5",
|
|
178
178
|
"unified": "^11",
|
|
179
179
|
"unist-util-visit": "^5",
|
|
180
|
-
"vitest": "1.1.
|
|
180
|
+
"vitest": "^1.1.3",
|
|
181
181
|
"vitest-canvas-mock": "^0.3.3"
|
|
182
182
|
},
|
|
183
183
|
"publishConfig": {
|
|
@@ -7,6 +7,7 @@ enum ElType {
|
|
|
7
7
|
div,
|
|
8
8
|
input,
|
|
9
9
|
markdown,
|
|
10
|
+
debug,
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
// 模拟elementFromPoint方法
|
|
@@ -19,6 +20,10 @@ document.elementFromPoint = function (x) {
|
|
|
19
20
|
return document.createElement('input');
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
if (x === ElType.debug) {
|
|
24
|
+
return document.createElement('pre');
|
|
25
|
+
}
|
|
26
|
+
|
|
22
27
|
if (x === ElType.markdown) {
|
|
23
28
|
const markdownEl = document.createElement('article');
|
|
24
29
|
const markdownChildEl = document.createElement('p');
|
|
@@ -68,7 +73,7 @@ describe('useAutoFocus', () => {
|
|
|
68
73
|
const inputRef = { current: { focus: vi.fn() } } as RefObject<any>;
|
|
69
74
|
renderHook(() => useAutoFocus(inputRef));
|
|
70
75
|
|
|
71
|
-
// Simulate a mousedown event on
|
|
76
|
+
// Simulate a mousedown event on a markdown element
|
|
72
77
|
act(() => {
|
|
73
78
|
document.dispatchEvent(
|
|
74
79
|
new MouseEvent('mousedown', { bubbles: true, clientX: ElType.markdown }),
|
|
@@ -82,4 +87,21 @@ describe('useAutoFocus', () => {
|
|
|
82
87
|
|
|
83
88
|
expect(inputRef.current?.focus).not.toHaveBeenCalled();
|
|
84
89
|
});
|
|
90
|
+
|
|
91
|
+
it('should not focus inputRef when mouseup event happens inside of debug element', () => {
|
|
92
|
+
const inputRef = { current: { focus: vi.fn() } } as RefObject<any>;
|
|
93
|
+
renderHook(() => useAutoFocus(inputRef));
|
|
94
|
+
|
|
95
|
+
// Simulate a mousedown event on a debug element
|
|
96
|
+
act(() => {
|
|
97
|
+
document.dispatchEvent(new MouseEvent('mousedown', { bubbles: true, clientX: ElType.debug }));
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Simulate a mouseup event
|
|
101
|
+
act(() => {
|
|
102
|
+
document.dispatchEvent(new MouseEvent('mouseup', { bubbles: true }));
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
expect(inputRef.current?.focus).not.toHaveBeenCalled();
|
|
106
|
+
});
|
|
85
107
|
});
|
|
@@ -11,9 +11,12 @@ export const useAutoFocus = (inputRef: RefObject<TextAreaRef>) => {
|
|
|
11
11
|
if (!element) return;
|
|
12
12
|
let currentElement: Element | null = element;
|
|
13
13
|
// 因为点击 Markdown 元素时,element 会是 article 标签的子元素
|
|
14
|
-
//
|
|
14
|
+
// Debug 信息时,element 会是 pre 标签
|
|
15
|
+
// 所以向上查找全局点击对象是否是 Markdown 或者 Input 或者 Debug 元素
|
|
15
16
|
while (currentElement && !isInputOrMarkdown) {
|
|
16
|
-
isInputOrMarkdown = ['TEXTAREA', 'INPUT', 'ARTICLE'].includes(
|
|
17
|
+
isInputOrMarkdown = ['TEXTAREA', 'INPUT', 'ARTICLE', 'PRE'].includes(
|
|
18
|
+
currentElement.tagName,
|
|
19
|
+
);
|
|
17
20
|
currentElement = currentElement.parentElement;
|
|
18
21
|
}
|
|
19
22
|
};
|
|
@@ -47,11 +47,11 @@ const Conversation = memo<ConversationProps>(({ chatInput, mobile }) => {
|
|
|
47
47
|
const fontSize = useGlobalStore((s) => settingsSelectors.currentSettings(s).fontSize);
|
|
48
48
|
const { styles } = useStyles(fontSize);
|
|
49
49
|
|
|
50
|
-
// init conversation
|
|
51
50
|
const init = useInitConversation();
|
|
52
51
|
|
|
53
52
|
return (
|
|
54
|
-
|
|
53
|
+
// relative is required, ChatInput's absolute position needs it
|
|
54
|
+
<Flexbox flex={1} style={{ position: 'relative' }}>
|
|
55
55
|
<div className={styles}>
|
|
56
56
|
{init ? <ChatList mobile={mobile} /> : <SkeletonList mobile={mobile} />}
|
|
57
57
|
</div>
|
|
@@ -19,12 +19,6 @@ vi.mock('@/services/plugin', () => ({
|
|
|
19
19
|
},
|
|
20
20
|
}));
|
|
21
21
|
|
|
22
|
-
// Mock necessary modules and functions
|
|
23
|
-
vi.mock('antd', () => ({
|
|
24
|
-
notification: {
|
|
25
|
-
error: vi.fn(),
|
|
26
|
-
},
|
|
27
|
-
}));
|
|
28
22
|
// Mock i18next
|
|
29
23
|
vi.mock('i18next', () => ({
|
|
30
24
|
t: vi.fn((key) => key),
|
|
@@ -179,6 +173,8 @@ describe('useToolStore:pluginStore', () => {
|
|
|
179
173
|
|
|
180
174
|
describe('installPlugin', () => {
|
|
181
175
|
it('should install a plugin with valid manifest', async () => {
|
|
176
|
+
vi.spyOn(notification, 'error');
|
|
177
|
+
|
|
182
178
|
const pluginIdentifier = 'plugin1';
|
|
183
179
|
|
|
184
180
|
const originalUpdateInstallLoadingState = useToolStore.getState().updateInstallLoadingState;
|
|
@@ -253,6 +249,8 @@ describe('useToolStore:pluginStore', () => {
|
|
|
253
249
|
|
|
254
250
|
const error = new TypeError('noManifest');
|
|
255
251
|
|
|
252
|
+
// Mock necessary modules and functions
|
|
253
|
+
vi.spyOn(notification, 'error');
|
|
256
254
|
(pluginService.getPluginManifest as Mock).mockRejectedValue(error);
|
|
257
255
|
|
|
258
256
|
useToolStore.setState({
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
name: '😇 疑问或帮助 Help Wanted'
|
|
2
|
-
description: '疑问或需要帮助 | Need help'
|
|
3
|
-
title: '[Question] '
|
|
4
|
-
labels: '😇 Help Wanted'
|
|
5
|
-
body:
|
|
6
|
-
- type: textarea
|
|
7
|
-
attributes:
|
|
8
|
-
label: '🧐 问题描述 | Proposed Solution'
|
|
9
|
-
description: A clear and concise description of the proplem.
|
|
10
|
-
validations:
|
|
11
|
-
required: true
|
|
12
|
-
- type: textarea
|
|
13
|
-
attributes:
|
|
14
|
-
label: '📝 补充信息 | Additional Information'
|
|
15
|
-
description: Add any other context about the problem here.
|