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: remove global from browser #4022

Merged
merged 1 commit into from
Sep 13, 2024
Merged

fix: remove global from browser #4022

merged 1 commit into from
Sep 13, 2024

Conversation

bytemain
Copy link
Member

@bytemain bytemain commented Sep 13, 2024

Types

  • 🐛 Bug Fixes

Background or solution

browser 里没有 global,如果用了 global.setTimeout 就得让用户用 global 的 polyfill

Changelog

Summary by CodeRabbit

  • Bug Fixes
    • 移除了 global 前缀,简化了多个功能的定时器调用(如 setTimeoutclearTimeout),提高了代码可读性。
    • 确保在不同环境中更准确地检查 localStorage 的可用性。

这些更改未影响现有功能,保持了应用的稳定性和性能。

Copy link

railway-app bot commented Sep 13, 2024

🚅 Previously deployed to Railway in the core project. Environment has been deleted.

Copy link
Contributor

coderabbitai bot commented Sep 13, 2024

Walkthrough

此次更改涉及多个文件,主要集中在移除对 setTimeoutclearTimeout 函数的 global 前缀。所有相关类在调用这些定时器函数时,均直接使用它们而不再通过全局对象引用。这一调整未改变原有功能,核心逻辑保持不变,主要是简化了代码,使其更易于阅读。

Changes

文件路径 更改摘要
packages/addons/src/browser/... 移除 global 前缀,直接调用 clearIntervalsetInterval
packages/connection/src/browser/... 移除 global 前缀,直接调用 clearIntervalsetInterval
packages/connection/src/common/... 移除 global 前缀,直接调用 setTimeout
packages/core-browser/src/preferences/... 检查 localStorage 的存在性时,改为使用 typeof localStorage !== 'undefined'
packages/core-browser/src/progress/... 移除 global 前缀,直接调用 setTimeout
packages/core-common/src/node/... 移除 global 前缀,直接调用 setTimeout
packages/extension/src/hosted/api/vscode/... 移除 global 前缀,直接调用 setTimeoutclearTimeout
packages/extension/src/node/... 移除 global 前缀,直接调用 setTimeout
packages/main-layout/__tests__/browser/... 移除 global 前缀,直接调用 setTimeout
packages/terminal-next/src/node/... 移除 global 前缀,直接调用 setTimeoutclearTimeout
packages/terminal-next/src/node/... 移除 global 前缀,直接调用 setTimeoutclearTimeout

Possibly related PRs

  • fix: add pty socket timeout #3834: 此 PR 涉及 PtyServiceManagerRemote 类,同样通过移除 global 前缀来简化 setTimeoutclearTimeout 的使用,与主 PR 的更改类似。

Suggested labels

🐞 bug

Tip

OpenAI O1 model for chat
  • We have deployed OpenAI's latest O1 model for chat.
  • OpenAI claims that this model has superior reasoning capabilities than their GPT-4o model.
  • Please share any feedback with us in the discussions post.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c60c9ce and 0c54fa3.

Files selected for processing (14)
  • packages/addons/src/browser/chrome-devtools.contribution.ts (3 hunks)
  • packages/addons/src/browser/connection-rtt-contribution.ts (2 hunks)
  • packages/connection/src/browser/ws-channel-handler.ts (1 hunks)
  • packages/connection/src/common/server-handler.ts (1 hunks)
  • packages/core-browser/src/preferences/early-preferences.ts (2 hunks)
  • packages/core-browser/src/progress/progress-indicator.ts (2 hunks)
  • packages/core-common/src/node/port.ts (1 hunks)
  • packages/extension/src/hosted/api/vscode/ext.host.output.ts (2 hunks)
  • packages/extension/src/hosted/api/vscode/ext.host.statusbar.ts (2 hunks)
  • packages/extension/src/hosted/ext.host.proxy-base.ts (2 hunks)
  • packages/extension/src/node/extension.service.ts (1 hunks)
  • packages/main-layout/tests/browser/layout.service.test.tsx (1 hunks)
  • packages/terminal-next/src/node/pty.manager.remote.ts (2 hunks)
  • packages/terminal-next/src/node/terminal.service.ts (4 hunks)
Files skipped from review due to trivial changes (13)
  • packages/addons/src/browser/chrome-devtools.contribution.ts
  • packages/addons/src/browser/connection-rtt-contribution.ts
  • packages/connection/src/browser/ws-channel-handler.ts
  • packages/connection/src/common/server-handler.ts
  • packages/core-browser/src/progress/progress-indicator.ts
  • packages/core-common/src/node/port.ts
  • packages/extension/src/hosted/api/vscode/ext.host.output.ts
  • packages/extension/src/hosted/api/vscode/ext.host.statusbar.ts
  • packages/extension/src/hosted/ext.host.proxy-base.ts
  • packages/extension/src/node/extension.service.ts
  • packages/main-layout/tests/browser/layout.service.test.tsx
  • packages/terminal-next/src/node/pty.manager.remote.ts
  • packages/terminal-next/src/node/terminal.service.ts
Additional comments not posted (2)
packages/core-browser/src/preferences/early-preferences.ts (2)

100-100: 改进了对 localStorage 可用性的检查方式。

更新后的代码使用 typeof localStorage !== 'undefined' 来检查 localStorage 是否可用,相比之前检查 global.localStorage 的存在性,这种方式更加健壮。它能够在各种环境中正确识别 localStorage 特性的可用性,特别是在 global 可能未定义或可能不包含 localStorage 的情况下。


109-109: 与之前的评论重复。

此处的更改与之前评论的代码段相同,提供了对 localStorage 可用性更健壮的检查方式。


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>.
    • 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 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 🐞 bug Something isn't working label Sep 13, 2024
Copy link

codecov bot commented Sep 13, 2024

Codecov Report

Attention: Patch coverage is 59.09091% with 9 lines in your changes missing coverage. Please review.

Project coverage is 54.46%. Comparing base (999faff) to head (0c54fa3).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...kages/terminal-next/src/node/pty.manager.remote.ts 0.00% 2 Missing ⚠️
...ackages/terminal-next/src/node/terminal.service.ts 50.00% 2 Missing ⚠️
...es/core-browser/src/progress/progress-indicator.ts 66.66% 1 Missing ⚠️
packages/core-common/src/node/port.ts 0.00% 1 Missing ⚠️
...extension/src/hosted/api/vscode/ext.host.output.ts 50.00% 1 Missing ⚠️
...ension/src/hosted/api/vscode/ext.host.statusbar.ts 50.00% 1 Missing ⚠️
packages/extension/src/node/extension.service.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4022   +/-   ##
=======================================
  Coverage   54.46%   54.46%           
=======================================
  Files        1583     1583           
  Lines       96839    96838    -1     
  Branches    19823    19823           
=======================================
+ Hits        52745    52747    +2     
+ Misses      36625    36623    -2     
+ Partials     7469     7468    -1     
Flag Coverage Δ
jsdom 49.98% <45.45%> (+<0.01%) ⬆️
node 15.61% <27.27%> (+<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.

@bytemain bytemain merged commit 36491e3 into main Sep 13, 2024
14 checks passed
@bytemain bytemain deleted the fix/no-global-in-browser branch September 13, 2024 11:06
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.

2 participants