Conversation
|
/next |
Walkthrough本次变更主要在文件处理逻辑上进行调整。在 ChatContext 组件中,更新函数 Changes
Sequence Diagram(s)sequenceDiagram
participant User as 用户
participant LLM as LLMContextService
participant List as addFileToList
participant Notifier as 事件通知器
User->>LLM: addFileToContext(uri, selection, isManual)
LLM->>LLM: 判断文件类型(已附加 vs 最近浏览)
LLM->>List: 调用 addFileToList 添加文件
List-->>LLM: 返回更新后的列表
LLM->>Notifier: 触发上下文文件更新事件
Notifier-->>LLM: 事件确认
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 ESLint
yarn install v1.22.22 ✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (5)
packages/ai-native/src/common/llm-context.ts (1)
46-46: 将attachedFiles类型替换为AttachFileContext[]原先为行内定义;统一改成接口后,更易维护和扩展。请确保序列化、反序列化逻辑在其他地方也同步更新。
packages/ai-native/src/browser/context/llm-context.service.ts (4)
37-47: 新增私有方法addFileToList封装了插入和裁剪列表逻辑,易于维护;不过
list.shift()会移除最早插入的项,请确认这样处理符合预期,避免误删除较为重要的文件。
62-75: 通知上下文变更与清理附加文件
notifyContextChange统一触发onDidContextFilesChangeEmitter,有助于事件订阅方获取最新文件上下文。cleanFileContext仅清空attachedFiles,保留recentlyViewFiles,避免“最近查看”丢失;如需进一步清理,也需在设计上明确。
161-165: 序列化方法:serializeRecentlyViewFiles与serializeAttachedFiles
map(...).filter(Boolean)可以安全过滤无效项,但如需调试原因,建议记录日志。serializeAttachedFiles显示转换为AttachFileContext[],若后续增添字段,需同步修改此方法。Also applies to: 167-171
191-199: 私有方法getFileErrors
- 根据 MarkerSeverity.Error 查找编辑器标记,可明确获取当前文件的错误信息。
- 若需警告或信息级别的标记,也可扩展此方法以实现更丰富的上下文提示。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
packages/ai-native/src/browser/components/ChatContext/index.tsx(1 hunks)packages/ai-native/src/browser/context/llm-context.service.ts(6 hunks)packages/ai-native/src/common/llm-context.ts(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
- GitHub Check: 🚀🚀🚀 Next Version for pull request
- GitHub Check: unittest (ubuntu-latest, 18.x, jsdom)
- GitHub Check: unittest (ubuntu-latest, 18.x, node)
- GitHub Check: build (ubuntu-latest, 20.x)
- GitHub Check: build (macos-latest, 20.x)
- GitHub Check: unittest (macos-latest, 18.x, jsdom)
- GitHub Check: unittest (macos-latest, 18.x, node)
- GitHub Check: build-windows
- GitHub Check: ubuntu-latest, Node.js 20.x
🔇 Additional comments (12)
packages/ai-native/src/browser/components/ChatContext/index.tsx (1)
42-42: 仅传入files.attached该改动确保
updateAddedFiles只更新已附加文件列表,逻辑更清晰。请确认组件中确实只需要已附加文件数据,不会影响对“最近查看”文件的管理。packages/ai-native/src/common/llm-context.ts (2)
18-18: 改动了上下文事件的载荷结构将原本的
Event<FileContext[]>改为Event<{ viewed: FileContext[]; attached: FileContext[] }>,允许分开处理已附加与最近查看的文件。请确认所有订阅方已同步适配新的事件类型。
37-42: 新增AttachFileContext接口定义了附加文件的内容、错误行、路径及语言等字段。此结构有利于更灵活地处理文件信息,但请验证下游对这些字段的使用场景,以免出现空字段或额外依赖。
packages/ai-native/src/browser/context/llm-context.service.ts (9)
15-15: 导入了新接口AttachFileContext此处仅增加新接口的 import,便于在序列化和上下文管理中使用。
30-34: 配置新上限与数组初始化
maxAttachFilesLimit = 10、maxViewFilesLimit = 20:请确认是否符合业务需求,若数值过小或过大可能导致文件处理受限。- 初始化两个数组
attachedFiles和recentlyViewFiles,分类逻辑更清晰。
49-60: 变更addFileToContext逻辑
- 默认
isManual = false,将文件区分到recentlyViewFiles与attachedFiles。- 若对同一 URI 多次调用,可能覆盖原 selection 信息,请留意需求是否需要保留或合并之前的选区。
78-85:removeFileFromContext基于isManual移除文件与
addFileToContext对应,注意手动与自动收集的文件可能混杂,确保外部调用方都正确传入isManual以免误删文件。
102-103: 自动收集事件:添加文件到查看列表在文档模型创建事件中调用
addFileToContext(..., false),能保证每次打开文件自动进入“最近查看”。如需特殊处理临时文件,请另外判断。
112-113: 自动收集事件:移除文件在文档模型移除事件中调用
removeFileFromContext(..., false),确保不再显示在“最近查看”列表。逻辑简单易懂,暂未发现问题。
134-134: 编辑器选区判断逻辑当选区是单行时(start 行与 end 行相同),会将文件添加到“最近查看”。多行选区则连带区间一起存储。请确认这与实际需求匹配,尤其在大段选区时是否影响性能。
Also applies to: 139-140
153-153: 序列化上下文根路径与文件
- 使用
URI.file(this.appConfig.workspaceDir)作为根目录时,需确保workspaceDir已正确配置。- 分别序列化
recentlyViewFiles与attachedFiles,结构更直观。Also applies to: 156-157
173-189: 私有方法serializeAttachedFile
- 提取文档内容、语言、行级错误信息,整合到
AttachFileContext。- 异常捕获返回
null,不会阻断流程,如需查看具体错误可考虑日志记录。
|
🎉 PR Next publish successful! 3.7.2-next-1740448398.0 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v3.8 #4407 +/- ##
==========================================
- Coverage 53.38% 53.36% -0.03%
==========================================
Files 1657 1657
Lines 102198 102254 +56
Branches 22114 22121 +7
==========================================
+ Hits 54563 54572 +9
- Misses 39627 39664 +37
- Partials 8008 8018 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
/next |
|
🎉 PR Next publish successful! 3.7.2-next-1740450374.0 |
1245846 to
7141eb9
Compare
|
/next |
|
🎉 PR Next publish successful! 3.8.1-next-1740452092.0 |
61bc212 to
6920039
Compare
|
/next |
|
🎉 PR Next publish successful! 3.8.1-next-1740463566.0 |
|
/next |
|
🎉 PR Next publish successful! 3.8.1-next-1740465035.0 |
|
/next |
|
🎉 PR Next publish successful! 3.8.1-next-1740467196.0 |
|
/next |
|
🎉 PR Next publish successful! 3.8.1-next-1740475512.0 |
|
/next |
|
🎉 PR Next publish successful! 3.8.1-next-1740478950.0 |
c7bfeb5 to
0b7e003
Compare
|
/next |
|
🎉 PR Next publish successful! 3.8.1-next-1740725107.0 |
|
/next |
|
🎉 PR Next publish successful! 3.8.1-next-1740726474.0 |
|
/next |
|
🎉 PR Next publish successful! 3.8.1-next-1740965430.0 |
9c06811 to
994f538
Compare
54cca5a to
985cc40
Compare
8dbe60e to
dd705f0
Compare
Types
Background or solution
Changelog
Summary by CodeRabbit
新功能
重构