Skip to content

feat: support intelligent completions always visible#4039

Merged
bytemain merged 1 commit intomainfrom
feat/suppoter-intelligent-completion-alwaysVisible
Sep 24, 2024
Merged

feat: support intelligent completions always visible#4039
bytemain merged 1 commit intomainfrom
feat/suppoter-intelligent-completion-alwaysVisible

Conversation

@Ricbet
Copy link
Copy Markdown
Member

@Ricbet Ricbet commented Sep 24, 2024

Types

  • 🎉 New Features

Background or solution

registerIntelligentCompletionProvider API 新增 alwaysVisible 属性
在同时出现内联补全和下拉补全时,能一直保持显示,不会受下拉补全的 “内联字符” 影响

sametime_visible.mp4

Changelog

Summary by CodeRabbit

  • 新功能
    • 增强智能补全功能,避免重复请求,并优化了内联补全的可见性管理。
    • 新增属性 alwaysVisible,确保相关UI元素始终可见,提升可访问性和可用性。
  • 改进
    • 简化依赖,移除了不再需要的导入项。

@Ricbet Ricbet requested review from bytemain and erha19 September 24, 2024 06:44
@Ricbet Ricbet self-assigned this Sep 24, 2024
@railway-app
Copy link
Copy Markdown

railway-app Bot commented Sep 24, 2024

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
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 24, 2024

Walkthrough

本次更改涉及多个文件的修改,主要集中在简化依赖关系和增强智能补全功能。inline-completions.handler.ts文件中移除了不再需要的IEditor导入,intelligent-completions.controller.ts文件中添加了多个重要导入,并对智能补全控制器进行了逻辑增强。ai-native.contribution.ts文件中新增了alwaysVisible属性,以提高用户界面的可见性和可用性。

Changes

文件路径 更改摘要
packages/ai-native/src/browser/contrib/inline-completions/inline-completions.handler.ts 移除了对IEditor的导入,简化了依赖。
packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts 更新了多个导入,增强了智能补全控制器的功能,添加了对重复请求的检查。
packages/startup/entry/sample-modules/ai-native/ai-native.contribution.ts AINativeContribution类的配置对象中新增了alwaysVisible属性,设置为true

Possibly related PRs

Suggested labels

🎨 feature, ⚙️ refactor

Suggested reviewers

  • bytemain

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
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@opensumi opensumi Bot added the 🎨 feature feature required label Sep 24, 2024
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range and nitpick comments (1)
packages/ai-native/src/browser/contrib/inline-completions/inline-completions.handler.ts (1)

PR 目标与实际代码更改不符

根据脚本结果,未发现 alwaysVisible 属性的相关更改。请确认是否遗漏了该属性的实现,或者是否在其他文件中进行了相关修改。确保所有与 PR 目标相关的更改均已包含,并更新 PR 描述以准确反映实际的代码变更。

Analysis chain

Line range hint 1-164: PR 目标与实际代码更改不符

PR 的目标提到了添加 alwaysVisible 属性来增强 registerIntelligentCompletionProvider API 的功能,但在提供的代码中没有看到相关的更改。这可能表明:

  1. 代码更改可能在其他未提供的文件中。
  2. 可能遗漏了实现这个新功能的代码。
  3. PR 描述可能与实际更改不一致。

建议运行以下脚本来验证是否有其他相关更改:

请确保所有与 PR 目标相关的更改都已包含在内,并更新 PR 描述以准确反映实际的代码更改。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 描述:搜索与 alwaysVisible 属性和 registerIntelligentCompletionProvider API 相关的更改

# 测试:搜索包含 alwaysVisible 的新增或修改行
echo "搜索 alwaysVisible 相关更改:"
rg -t ts -g '!**/node_modules/**' -n '^\+.*alwaysVisible'

# 测试:搜索 registerIntelligentCompletionProvider 的使用或定义
echo "搜索 registerIntelligentCompletionProvider 相关更改:"
rg -t ts -g '!**/node_modules/**' -n 'registerIntelligentCompletionProvider'

Length of output: 1009

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between acc8715 and d86f6a6.

Files selected for processing (3)
  • packages/ai-native/src/browser/contrib/inline-completions/inline-completions.handler.ts (1 hunks)
  • packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts (6 hunks)
  • packages/startup/entry/sample-modules/ai-native/ai-native.contribution.ts (1 hunks)
Additional comments not posted (10)
packages/ai-native/src/browser/contrib/inline-completions/inline-completions.handler.ts (1)

14-14: 导入语句的更改看起来是正确的

移除了 IEditor 的导入,这表明该接口在此文件中不再被使用。这种清理无用导入的做法有助于保持代码的整洁性。

packages/startup/entry/sample-modules/ai-native/ai-native.contribution.ts (3)

497-497: 新属性 alwaysVisible 成功实现了PR的目标。

这个改动通过添加 alwaysVisible: true 属性,成功实现了使智能补全始终可见的功能。这与PR的目标完全一致,能够确保智能补全在内联补全和下拉补全同时显示时保持可见。

代码变更:

+          alwaysVisible: true,

这个改动简洁明了,直接实现了所需的功能。


Line range hint 1-524: 总体评估:改动简洁有效,与现有代码结构协调一致

这个改动虽小,但有效地实现了PR的目标。它保持了文件的整体结构和风格一致性,同时引入了新的功能。主要观察如下:

  1. 改动位于 registerIntelligentCompletionFeature 方法中,这是一个合适的位置。
  2. 新添加的 alwaysVisible: true 属性与方法返回的对象中的其他属性风格一致。
  3. 这个改动没有引入新的依赖或复杂逻辑,降低了引入bug的风险。

建议:

  1. 确保这个改动在不同场景下都能正常工作,特别是在有多种补全同时出现的情况下。
  2. 考虑添加注释解释这个属性的作用,以增强代码的可维护性。

497-497: 建议验证此更改对代码库其他部分的影响

虽然这个改动很简单,但它可能会影响到使用智能补全功能的其他部分。建议进行以下验证:

  1. 检查是否有任何依赖于智能补全可见性行为的代码需要更新。
  2. 更新相关文档,以反映智能补全现在始终可见的新行为。
  3. 考虑是否需要添加任何新的单元测试或更新现有测试,以覆盖这个新行为。

可以运行以下脚本来检查可能受影响的区域:

packages/ai-native/src/browser/contrib/intelligent-completions/intelligent-completions.controller.ts (6)

8-8: 导入语句更新良好

新增的 isDefinedrunWhenIdle 导入在后续代码中被正确使用,有助于功能的实现。


13-15: 正确添加必要的导入

导入了 IObservableautorunGhostTextWidgetInlineCompletionsController,这些在后续代码中被有效使用,增强了代码的可读性和功能性。


48-50: 新增类属性定义合理

添加了 multiLineDecorationModeladditionsDeletionsDecorationModelaiNativeContextKey 属性,这些属性在类中被正确初始化和使用,支持新的功能需求。


56-58: mount 方法中初始化成员变量

成员变量在 mount 方法中初始化,确保在编辑器挂载时正确设置,有利于资源管理和生命周期控制。


76-80: 优化性能:避免重复请求

通过检查 multiLineEditsIsVisible 的状态,避免在上一次补全结果仍可见时重复发送请求,提升了性能并减少了不必要的资源消耗。


97-97: 正确解构新属性 alwaysVisible

completionModel 中解构出 alwaysVisible 属性,为后续逻辑中对该属性的判断提供了支持。

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 19 lines in your changes missing coverage. Please review.

Project coverage is 54.41%. Comparing base (acc8715) to head (d86f6a6).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...-completions/intelligent-completions.controller.ts 0.00% 14 Missing and 4 partials ⚠️
...b/inline-completions/inline-completions.handler.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #4039       +/-   ##
===========================================
+ Coverage   15.58%   54.41%   +38.82%     
===========================================
  Files        1584     1584               
  Lines       97014    97028       +14     
  Branches    19860    19864        +4     
===========================================
+ Hits        15120    52796    +37676     
+ Misses      68788    36738    -32050     
+ Partials    13106     7494     -5612     
Flag Coverage Δ
jsdom 49.94% <0.00%> (?)
node 15.58% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎨 feature feature required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] 下拉补全和内联补全支持同时展示(不受 insertText 限制)

2 participants