Skip to content
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

fix: in web ide menu does not display; in web ide shortcut keys are not available #4160

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

eedpublic
Copy link

@eedpublic eedpublic commented Nov 8, 2024

Types

  • 🐛 Bug Fixes

Background or solution

Changelog

Summary by CodeRabbit

  • 新功能

    • 简化了应用程序支持打开文件夹和工作区的逻辑,提高了应用能力的判断效率。
    • 增强了键绑定功能,允许根据应用环境灵活管理命令执行。
  • 修复

    • 修正了在非Electron环境下执行特定命令的逻辑,避免不必要的命令执行。

@CLAassistant
Copy link

CLAassistant commented Nov 8, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ hacke2
❌ weimin2.zhou


weimin2.zhou seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@opensumi opensumi bot added the 🐞 bug Something isn't working label Nov 8, 2024
Copy link
Contributor

coderabbitai bot commented Nov 8, 2024

Walkthrough

此拉取请求对 common.contribution.tskeybinding.ts 文件进行了修改。主要更改包括简化 ClientCommonContribution 类中的属性条件逻辑,以及在 KeybindingRegistryImpl 类中集成 AppConfig 服务。通过调整关键绑定处理逻辑,增强了应用程序环境下的灵活性,确保某些命令在非 Electron 渲染上下文中不会被执行。

Changes

文件路径 更改摘要
packages/core-browser/src/common/common.contribution.ts 修改 ClientCommonContribution 类的构造函数,简化 application.supportsOpenFolderapplication.supportsOpenWorkspace 属性的条件逻辑。
packages/core-browser/src/keybinding/keybinding.ts KeybindingRegistryImpl 类中集成 AppConfig 服务,新增 appConfig 属性,并在 tryKeybindingExecution 方法中添加条件检查以控制命令执行。

Possibly related PRs

  • fix: improve keybinding performance #4126: 此 PR 涉及对关键绑定处理的修改,与主 PR 中 keybinding.ts 文件的更改相关,特别是关于 AppConfig 服务的集成和关键绑定执行逻辑的调整。
  • fix: restored notebook have invalid keybinding #4174: 此 PR 解决了笔记本中关键绑定的问题,与主 PR 的重点在于简化与应用程序能力相关的逻辑相连接,均涉及应用程序上下文中的关键绑定管理和注册。

Suggested reviewers

  • Ricbet

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

warning [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
warning eslint > @humanwhocodes/[email protected]: Use @eslint/config-array instead
warning eslint > file-entry-cache > flat-cache > [email protected]: Rimraf versions prior to v4 are no longer supported
warning eslint > @humanwhocodes/config-array > @humanwhocodes/[email protected]: Use @eslint/object-schema instead
warning eslint > file-entry-cache > flat-cache > rimraf > [email protected]: Glob versions prior to v9 are no longer supported
warning eslint > file-entry-cache > flat-cache > rimraf > glob > [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
warning eslint-import-resolver-typescript > [email protected]: Glob versions prior to v9 are no longer supported
error Couldn't find any versions for "@opensumi/ide-dev-tool" that matches "workspace:*"


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.

Copy link
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: 0

🧹 Outside diff range and nitpick comments (1)
packages/core-browser/src/keybinding/keybinding.ts (1)

891-894: 优雅处理了环境特定的快捷键!

在 Web 环境下跳过 electron 相关的快捷键绑定,避免与浏览器默认快捷键冲突,实现优雅。建议添加单元测试验证此逻辑。

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between d7142f9 and 4b123dc.

📒 Files selected for processing (2)
  • packages/core-browser/src/common/common.contribution.ts (1 hunks)
  • packages/core-browser/src/keybinding/keybinding.ts (3 hunks)
🔇 Additional comments (2)
packages/core-browser/src/common/common.contribution.ts (1)

63-64: 请验证简化条件的影响范围

条件判断从复杂的组合逻辑简化为仅检查 !this.appConfig.isRemote,这个改动可能会影响到以下场景:

  1. 在非远程但也非 Electron 环境下的行为发生了变化
  2. 可能会在不适合的场景下启用文件夹和工作区打开功能

建议:

  1. 添加详细的注释说明此更改的原因
  2. 考虑添加单元测试验证各种环境组合下的行为
✅ Verification successful

Let me gather more context about the previous implementation and the PR's objective.


移除 isElectronRenderer 检查是合理的改动

从代码历史和使用场景分析,移除 isElectronRenderer 的检查是合理的:

  1. 文件夹和工作区打开功能只需要确保不在远程环境即可,与是否在 Electron 环境中运行无关
  2. window.service.ts 中可以看到,Electron 特定功能都有独立的判断和处理逻辑
  3. 这个改动使得非 Electron 的本地环境(如浏览器)也能支持打开文件夹和工作区的功能

相关的功能使用检查(在 file-tree-next 模块)也仅依赖于这些配置项的布尔值,不会受到实现细节变化的影响。

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# 搜索与这些配置项相关的使用场景
rg "application\.supportsOpenFolder|application\.supportsOpenWorkspace" -A 3

Length of output: 3757


Script:

#!/bin/bash
# Check the previous implementation and related changes
git log -p packages/core-browser/src/common/common.contribution.ts | grep -A 10 "supportsOpen"

# Check if there are any related test files
fd "common.contribution.test" --type f

# Look for any documentation about remote vs electron environments
rg "isRemote|isElectronRenderer" -A 3 packages/core-browser/

Length of output: 11523

packages/core-browser/src/keybinding/keybinding.ts (1)

20-20: 依赖注入实现合理!

通过依赖注入方式集成 AppConfig 服务,符合代码设计规范。

Also applies to: 234-236

@hacke2
Copy link
Member

hacke2 commented Nov 11, 2024

@eedpublic 签署一下 CLA

@hacke2
Copy link
Member

hacke2 commented Nov 11, 2024

commit message 最好改一下,写清楚这段代码的作用

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 54.04%. Comparing base (fc4ad0d) to head (d2f0c28).

Files with missing lines Patch % Lines
packages/core-browser/src/keybinding/keybinding.ts 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4160      +/-   ##
==========================================
- Coverage   54.05%   54.04%   -0.01%     
==========================================
  Files        1616     1616              
  Lines       97963    97967       +4     
  Branches    20055    20048       -7     
==========================================
- Hits        52952    52949       -3     
- Misses      37398    37404       +6     
- Partials     7613     7614       +1     
Flag Coverage Δ
jsdom 49.62% <75.00%> (-0.01%) ⬇️
node 15.56% <50.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.

@eedpublic eedpublic changed the title fix: codefuse ide support web ide fix: in web ide menu does not display; in web ide shortcut keys are not available Nov 12, 2024
@@ -60,8 +60,8 @@ export class ClientCommonContribution

constructor() {
const overridePropertiesDefault = {
'application.supportsOpenFolder': !!this.appConfig.isElectronRenderer && !this.appConfig.isRemote,
'application.supportsOpenWorkspace': !!this.appConfig.isElectronRenderer && !this.appConfig.isRemote,
'application.supportsOpenFolder': !this.appConfig.isRemote,
Copy link
Member

Choose a reason for hiding this comment

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

在 Web 环境下这两个功能的表现是什么样的,贴张图

Copy link
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: 0

🧹 Outside diff range and nitpick comments (1)
packages/core-browser/src/keybinding/keybinding.ts (1)

890-893: 建议重构电子快捷键处理逻辑以提高可维护性

当前实现直接在 tryKeybindingExecution 方法中处理电子快捷键的跳过逻辑。建议将这个逻辑抽取到一个单独的方法中,以提高代码的可维护性和可测试性。

建议应用以下更改:

+private shouldSkipElectronBinding(binding: Keybinding): boolean {
+  return !this.appConfig.isElectronRenderer && binding.command.startsWith('electron.');
+}

protected tryKeybindingExecution(bindings: Keybinding[], event: KeyboardEvent): boolean {
  if (bindings.length === 0) {
    return false;
  }
  for (const binding of bindings) {
-    // 在web下electron绑定的浏览器基础快捷键无法使用,这里跳过,直接使用浏览器的快捷键
-    if (!this.appConfig.isElectronRenderer && binding.command.startsWith('electron.')) {
+    if (this.shouldSkipElectronBinding(binding)) {
      continue;
    }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4b123dc and d2f0c28.

📒 Files selected for processing (1)
  • packages/core-browser/src/keybinding/keybinding.ts (3 hunks)
🔇 Additional comments (1)
packages/core-browser/src/keybinding/keybinding.ts (1)

234-236: 注入配置看起来不错!

AppConfig 的注入实现正确,并且遵循了类中其他依赖注入的模式。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants