-
Notifications
You must be signed in to change notification settings - Fork 403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support trigger source code edits #4389
Conversation
Walkthrough本次提交在智能补全功能中引入了新的触发代码编辑逻辑。改动包括更新接口以支持触发数据、调整按键绑定注册以限定用户作用域、修改控制器以使用新的触发源替换旧的 observable 信号、改进代码编辑源集合的封装,并新增了用于处理触发事件的文件。同时,相关枚举也新增了对应的值,以支持细化代码编辑来源的标识。 Changes
Sequence Diagram(s)sequenceDiagram
participant U as 用户
participant IC as IntelligentCompletionsController
participant TS as TriggerCodeEditsSource
participant E as 编辑器
U->>IC: 发起代码编辑触发请求
IC->>TS: 调用 trigger() 方法
TS->>E: 通过 runOnChangeWithStore 获取当前编辑位置
E-->>TS: 返回当前位置数据
TS->>IC: 更新状态 (触发数据更新)
Possibly related PRs
Suggested labels
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts (2)
164-180
: 请谨慎使用私有属性与方法。
该处通过访问suggestWidgetAdaptor
的私有字段'_currentSuggestItemInfo'
、'_onDidSelectedItemChange'
来强制重置收起逻辑,可能因内部实现变动导致 fragility。建议在原生 API 允许的情况下使用公共方法或事件触发机制,避免因升级依赖或内部逻辑变化而导致不兼容。
419-422
: 优雅处理 triggerSource 不存在的场景。
当前仅在triggerSource
存在时才调用triggerSignal
,若不存在则直接跳过,可能令调用者不易排查具体原因。可考虑增加日志记录或提示,例如:
public trigger(tx: ITransaction): void { const triggerSource = this.codeEditsSourceCollection.getSource(TriggerCodeEditsSource) as TriggerCodeEditsSource; if (triggerSource) { triggerSource.triggerSignal.trigger(tx); } else { + this.logger.debug('No TriggerCodeEditsSource found, trigger skipped.'); } }
packages/ai-native/src/browser/contrib/intelligent-completions/source/trigger.source.ts (1)
1-44
: 新增触发来源逻辑整体可行,但建议补充安全检查。
priority = Number.MAX_SAFE_INTEGER
能确保该触发源优先度最高,可满足需求。- 若
position
始终为null
,可能造成后续的编辑上下文无法正常建立,建议在setBean
前后增添必要的判断或日志,以提高可维护性。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/ai-native/src/browser/contrib/intelligent-completions/index.ts
(2 hunks)packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts
(1 hunks)packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts
(5 hunks)packages/ai-native/src/browser/contrib/intelligent-completions/source/base.ts
(3 hunks)packages/ai-native/src/browser/contrib/intelligent-completions/source/trigger.source.ts
(1 hunks)packages/core-common/src/types/ai-native/index.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- 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-windows
- GitHub Check: unittest (macos-latest, 18.x, jsdom)
- GitHub Check: unittest (macos-latest, 18.x, node)
- GitHub Check: build (macos-latest, 20.x)
- GitHub Check: ubuntu-latest, Node.js 20.x
🔇 Additional comments (10)
packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts (3)
39-39
: 导入适配器的更改看起来合理。
该导入为后续选项重置和阴影字符控制提供了基础,不存在明显风险。
60-60
: 成功引入 TriggerCodeEditsSource。
这是对主动触发编辑逻辑的有效扩展,能够提升代码编辑的可控性。
108-108
: 在 codeEditsSourceCollection 中添加新的来源。
此处将主动触发源纳入集合,优先级由TriggerCodeEditsSource
内部的Number.MAX_SAFE_INTEGER
决定,无需额外调整顺序即可保持其最高优先。packages/ai-native/src/browser/contrib/intelligent-completions/index.ts (2)
4-4
: 导入 ITriggerData 符合新的触发逻辑需求。
该改动与TriggerCodeEditsSource
对应,逻辑上无冲突。
30-30
: 在 ICodeEditsContextBean 中新增 Trigger 字段。
此扩展为代码补全上下文注入了触发位置信息,有助于更灵活地管理触发事件。packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts (1)
77-84
:❓ Verification inconclusive
代码变更看起来不错!
新增的快捷键绑定正确地使用了
KeybindingScope.USER
作用域,并且与配置项codeEdits.triggerKeybinding
关联。建议验证配置项
codeEdits.triggerKeybinding
是否已在配置文件中正确定义:
🏁 Script executed:
#!/bin/bash # 搜索配置项定义 rg -l "codeEdits.triggerKeybinding"Length of output: 138
请注意:请确认配置项定义的范围
代码变更看起来不错!
新增的快捷键绑定正确地使用了KeybindingScope.USER
作用域,并且在当前文件中出现了codeEdits.triggerKeybinding
的引用。
- 搜索结果显示,此配置项仅在
packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.contribution.ts
中存在。请确认该配置项是否需要在全局配置或其他相关文件中正确定义,以确保功能按预期工作。
packages/ai-native/src/browser/contrib/intelligent-completions/source/base.ts (3)
75-75
: 很好的改进!将属性标记为
readonly
可以防止意外修改,提高代码的安全性。Also applies to: 78-78
146-146
: 代码结构优化得很好!新增的
sources
私有数组和getSource
方法提供了更好的源管理机制,使得代码更加模块化和可维护。Also applies to: 149-151
159-161
: 初始化逻辑简化得很好!将源的初始化和挂载逻辑分离得更清晰。
packages/core-common/src/types/ai-native/index.ts (1)
428-430
: 枚举值添加合理!新增的
Trigger
枚举值有清晰的注释说明,并且符合现有的命名模式。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4389 +/- ##
==========================================
- Coverage 53.86% 53.85% -0.02%
==========================================
Files 1650 1651 +1
Lines 101648 101670 +22
Branches 21983 21984 +1
==========================================
- Hits 54755 54754 -1
- Misses 38994 39015 +21
- Partials 7899 7901 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Types
Background or solution
Changelog
code edits 支持 trigger source 类型
Summary by CodeRabbit
新特性
重构