opensumi / core

🚀 A framework helps you quickly build AI Native IDE products. https://preview.opensumi.com
https://opensumi.com
MIT License
2.89k stars 372 forks source link

feat: support multi-line edits rewrite widget #3962

Closed Ricbet closed 1 month ago

Ricbet commented 1 month ago

Types

Background or solution

有三种情况可以隐藏该 widget

  1. 按 esc 主动隐藏
  2. 编辑代码时自动隐藏
  3. 当光标位置超出补全的 range 时自动隐藏

示例

https://github.com/user-attachments/assets/6fcfd39d-c3d7-4d44-809a-1396097e883c

Changelog

Summary by CodeRabbit

Summary by CodeRabbit

railway-app[bot] commented 1 month ago

This PR was not deployed automatically as @Ricbet does not have access to the Railway project.

In order to get automatic PR deploys, please add @Ricbet to the project inside the project settings page.

coderabbitai[bot] commented 1 month ago

Walkthrough

本次变更涉及多个文件的显著修改,包括重命名与多行编辑相关的上下文键,增强智能补全处理程序以更有效地处理文本修改,新增用于管理代码编辑器中添加和删除视觉效果的装饰模型,以及移除智能补全处理程序的依赖,简化了补全处理逻辑。同时,更新了测试用例以反映新的数据结构。

Changes

文件路径 变更摘要
packages/ai-native/src/browser/contextkey/*.ts 重命名上下文键 multiLineCompletionsIsVisiblemultiLineEditsIsVisible
packages/ai-native/src/browser/contrib/intelligent-completions/*.ts 引入 additionsDeletionsDecorationModel 类以管理代码装饰,更新 IntelligentCompletionsHandler 类以处理文本修改,增加新方法以计算字符和单词级别的差异。
packages/ai-native/src/browser/contrib/inline-completions/*.ts 移除对 IntelligentCompletionsHandler 的依赖,简化 InlineCompletionHandler 类的补全处理逻辑。
packages/ai-native/__test__/browser/contrib/intelligent-completions/multi-line.decoration.test.ts 更新测试用例的预期结果结构,从数组改为包含 fullLineModsinlineMods 的对象。
packages/ai-native/src/browser/contrib/intelligent-completions/diff-computer.ts 修改 MultiLineDiffComputer 类,增加 tokenize 方法并将 equals 方法的访问修饰符更改为 protected
packages/ai-native/src/browser/widget/rewrite/*.tsx 新增 RewriteWidget 组件,集成虚拟代码编辑器并管理文本装饰。
packages/theme/src/common/color-tokens/ai-native.ts 新增与多行编辑相关的颜色令牌 designMultiLineEditsDeletionsBackgrounddesignMultiLineEditsAdditionsBackground
packages/startup/entry/sample-modules/ai-native/ai-native.contribution.ts 修改 insertRandomStrings 函数以支持更灵活的字符串插入和删除操作。

Recent review details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between 372748603889b5b3bb963e10b52564be5a915e54 and 5b5f428af22695e37969f6e8c746b8457b260a64.
Files selected for processing (3) * packages/ai-native/src/browser/contrib/intelligent-completions/diff-computer.ts (5 hunks) * packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.handler.ts (5 hunks) * packages/ai-native/src/browser/widget/rewrite/rewrite-widget.module.less (1 hunks)
Files skipped from review due to trivial changes (1) * packages/ai-native/src/browser/widget/rewrite/rewrite-widget.module.less
Files skipped from review as they are similar to previous changes (1) * packages/ai-native/src/browser/contrib/intelligent-completions/diff-computer.ts
Additional context used
Biome
packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.handler.ts
[error] 142-143: Change to an optional chain. Unsafe fix: Change to an optional chain. (lint/complexity/useOptionalChain)
Additional comments not posted (6)
packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.handler.ts (6)
`62-67`: **代码无误。** 代码实现正确。 --- Line range hint `68-87`: **代码无误。** 代码实现正确。 --- `171-212`: **代码无误。** 代码实现正确。 --- `217-221`: **代码无误。** 代码实现正确。 --- `225-244`: **代码无误。** 代码实现正确。 --- `253-290`: **代码无误。** 代码实现正确。
--- 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?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` 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) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 13.31361% with 293 lines in your changes missing coverage. Please review.

Project coverage is 54.72%. Comparing base (1807a2e) to head (5b5f428). Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ent-completions/intelligent-completions.handler.ts 0.00% 88 Missing and 16 partials :warning:
...r/contrib/intelligent-completions/diff-computer.ts 11.50% 83 Missing and 17 partials :warning:
...gent-completions/additions-deletions.decoration.ts 0.00% 38 Missing and 5 partials :warning:
...b/intelligent-completions/multi-line.decoration.ts 41.66% 30 Missing and 12 partials :warning:
...browser/contextkey/ai-native.contextkey.service.ts 0.00% 3 Missing :warning:
packages/core-browser/src/contextkey/ai-native.ts 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3962 +/- ## ========================================== - Coverage 54.86% 54.72% -0.14% ========================================== Files 1569 1570 +1 Lines 95660 95948 +288 Branches 19613 19677 +64 ========================================== + Hits 52486 52510 +24 - Misses 35852 36070 +218 - Partials 7322 7368 +46 ``` | [Flag](https://app.codecov.io/gh/opensumi/core/pull/3962/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensumi) | Coverage Δ | | |---|---|---| | [jsdom](https://app.codecov.io/gh/opensumi/core/pull/3962/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensumi) | `50.20% <13.31%> (-0.13%)` | :arrow_down: | | [node](https://app.codecov.io/gh/opensumi/core/pull/3962/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensumi) | `15.43% <0.59%> (-0.05%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=opensumi#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.