refactor: support watch by unrecursive config#4201
Conversation
|
/next |
|
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
warning eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options. Walkthrough该拉取请求引入了一些对文件监控功能的修改,包括在 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant FileService
participant FileSystemProvider
participant DiskFileSystemProvider
User->>FileService: watchFileChanges(uri, options)
FileService->>FileSystemProvider: watch(uri, options)
FileSystemProvider->>DiskFileSystemProvider: watch(uri, options)
DiskFileSystemProvider->>DiskFileSystemProvider: getWatcherServer(recursive)
DiskFileSystemProvider->>DiskFileSystemProvider: initWatcherServer(excludes)
DiskFileSystemProvider-->>FileSystemProvider: return watcher
FileSystemProvider-->>FileService: return watch result
FileService-->>User: return watch result
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
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.
Actionable comments posted: 4
🧹 Outside diff range and nitpick comments (3)
packages/core-browser/src/react-providers/config-provider.tsx (1)
315-319: 属性命名建议修改为nonRecursiveDirectories为更符合命名惯例,建议将属性
unRecursiveDirectories重命名为nonRecursiveDirectories,以提升代码可读性和一致性。packages/file-service/src/node/file-service.ts (1)
98-107: 建议使用可选链操作符优化代码当前代码在处理 options 时可以使用可选链操作符来简化逻辑。
建议修改为:
- recursive: options && options.recursive !== undefined ? options.recursive : this.options.recursive, + recursive: options?.recursive ?? this.options.recursive,🧰 Tools
🪛 Biome (1.9.4)
[error] 105-105: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
packages/file-service/src/browser/file-service-client.ts (1)
Line range hint
342-362: 建议添加功能说明文档新增的非递归目录配置功能缺少相关文档说明。
建议在代码中添加以下注释:
+ // 通过 unRecursiveDirectories 配置控制特定目录的文件监听是否递归 + // 当路径匹配 unRecursiveDirectories 中的目录时,将禁用递归监听 const unRecursiveDirectories = this.appConfig.unRecursiveDirectories || [];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (7)
packages/core-browser/src/react-providers/config-provider.tsx(1 hunks)packages/core-common/src/types/file.ts(1 hunks)packages/file-service/src/browser/file-service-client.ts(2 hunks)packages/file-service/src/node/disk-file-system.provider.ts(6 hunks)packages/file-service/src/node/file-service.ts(1 hunks)packages/file-service/src/node/recursive/file-service-watcher.ts(1 hunks)packages/file-service/src/node/un-recursive/file-service-watcher.ts(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/file-service/src/node/file-service.ts
[error] 105-105: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
🔇 Additional comments (3)
packages/file-service/src/node/disk-file-system.provider.ts (2)
71-75: 属性定义正确
新增的 recursiveFileSystemWatcher 和 unrecursiveFileSystemWatcher 属性定义清晰,类型明确,有助于区分递归和非递归的文件监视器。
105-105: 确保初始化 WatcherServer
在构造函数中调用 this.initWatcherServer();,确保了文件监视器服务器的正确初始化。
packages/core-common/src/types/file.ts (1)
160-160: 更新 watch 方法接口,增加递归选项
在 FileSystemProvider 接口的 watch 方法中新增了 recursive 可选参数,增强了对文件或目录监视的灵活性,允许呼叫者指定是否递归监视子目录。
| if (!watcherServer) { | ||
| return -1; | ||
| } |
There was a problem hiding this comment.
避免在 Promise 中返回错误的数值
当没有可用的 watcherServer 时,watch 方法返回 -1。建议抛出异常或拒绝 Promise,而不是返回特定的错误值,以符合 Promise 的错误处理惯例。
建议修改如下:
if (!watcherServer) {
- return -1;
+ throw new Error('No suitable watcher server found');
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (!watcherServer) { | |
| return -1; | |
| } | |
| if (!watcherServer) { | |
| throw new Error('No suitable watcher server found'); | |
| } |
|
🎉 PR Next publish successful! 3.6.1-next-1733711618.0 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4201 +/- ##
==========================================
- Coverage 54.04% 54.03% -0.02%
==========================================
Files 1616 1616
Lines 98006 98005 -1
Branches 20056 20062 +6
==========================================
- Hits 52966 52954 -12
- Misses 37420 37428 +8
- Partials 7620 7623 +3
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
Summary by CodeRabbit
新功能
unRecursiveDirectories,用于配置不递归处理的目录路径。watchFileChanges方法,允许指定是否递归监视文件变化。改进
FileService和DiskFileSystemProvider类的可配置性。文档