-
-
Notifications
You must be signed in to change notification settings - Fork 462
fix: Unable to obtain Windows server information #963
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
base: main
Are you sure you want to change the base?
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds SSH-safe execution helpers with UTF‑8/GBK decoding fallbacks, refactors Windows PowerShell command generation and dividers to UTF‑8/WMI variants, and updates parsing and TimeSeq models to support multi-processor CPU data and two-sample network/disk deltas with stronger guards. Changes
Sequence DiagramsequenceDiagram
participant Caller as Caller (detector/provider)
participant SSHExt as SSHClientX (runSafe / execSafe)
participant SSHClient as SSH Client
participant Decoder as SSHDecoder
participant Parser as Windows Parser / Provider
rect rgba(200,230,255,0.6)
note right of SSHExt: runSafe flow
Caller->>SSHExt: runSafe(command, systemType?, context?)
SSHExt->>SSHClient: execute command (bytes)
SSHClient-->>SSHExt: raw bytes
SSHExt->>Decoder: decode(bytes, isWindows, context)
Decoder->>Decoder: try UTF‑8 (allowMalformed)
alt Windows & replacement chars or failure
Decoder->>Decoder: fallback GBK
end
Decoder-->>SSHExt: decoded string
SSHExt-->>Caller: decoded string or throw (context)
end
rect rgba(220,255,220,0.6)
note right of SSHExt: execSafe flow (stdout/stderr)
Caller->>SSHExt: execSafe(callback, entry, systemType?, context?)
SSHExt->>SSHClient: start exec and collect streams
SSHClient-->>SSHExt: stdout bytes / stderr bytes
SSHExt->>Decoder: decode(stdout bytes, isWindows, context + " stdout")
SSHExt->>Decoder: decode(stderr bytes, isWindows, context + " stderr")
Decoder-->>SSHExt: decoded stdout / stderr
SSHExt-->>Caller: (stdout, stderr)
end
rect rgba(255,245,210,0.6)
note right of Parser: Windows data flow
Caller->>SSHExt: execSafe(uptime/net/disk commands)
SSHExt->>Decoder: decode outputs
Decoder-->>Parser: decoded strings
Parser->>Parser: parse CPU (WindowsCpuResult), net/disk two-sample deltas, uptime
Parser-->>Caller: structured server status updates
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Areas requiring extra attention:
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (2)lib/data/model/**/*.dart📄 CodeRabbit inference engine (CLAUDE.md)
Files:
lib/data/model/server/**/*.dart📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-10-08T09:36:41.682ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (12)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (10)
lib/core/extension/ssh_client.dart(2 hunks)lib/data/helper/ssh_decoder.dart(1 hunks)lib/data/helper/system_detector.dart(3 hunks)lib/data/model/app/scripts/cmd_types.dart(3 hunks)lib/data/model/app/scripts/script_consts.dart(2 hunks)lib/data/model/server/cpu.dart(1 hunks)lib/data/model/server/server_status_update_req.dart(4 hunks)lib/data/model/server/time_seq.dart(1 hunks)lib/data/model/server/windows_parser.dart(2 hunks)lib/data/provider/server/single.dart(6 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
lib/data/model/**/*.dart
📄 CodeRabbit inference engine (CLAUDE.md)
After modifying annotated model files, run: dart run build_runner build --delete-conflicting-outputs
Files:
lib/data/model/server/time_seq.dartlib/data/model/server/cpu.dartlib/data/model/server/windows_parser.dartlib/data/model/server/server_status_update_req.dartlib/data/model/app/scripts/cmd_types.dartlib/data/model/app/scripts/script_consts.dart
lib/data/model/server/**/*.dart
📄 CodeRabbit inference engine (CLAUDE.md)
Place server management models under lib/data/model/server/
Files:
lib/data/model/server/time_seq.dartlib/data/model/server/cpu.dartlib/data/model/server/windows_parser.dartlib/data/model/server/server_status_update_req.dart
lib/data/provider/**/*.dart
📄 CodeRabbit inference engine (CLAUDE.md)
Organize Riverpod providers by feature under lib/data/provider/
Files:
lib/data/provider/server/single.dart
🧠 Learnings (4)
📚 Learning: 2025-10-08T09:36:41.682Z
Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-08T09:36:41.682Z
Learning: Applies to lib/data/model/ssh/**/*.dart : Place SSH models under lib/data/model/ssh/
Applied to files:
lib/data/helper/ssh_decoder.dartlib/data/helper/system_detector.dartlib/core/extension/ssh_client.dartlib/data/provider/server/single.dart
📚 Learning: 2025-10-08T09:36:41.682Z
Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-08T09:36:41.682Z
Learning: Applies to lib/data/model/sftp/**/*.dart : Place SFTP models under lib/data/model/sftp/
Applied to files:
lib/data/helper/ssh_decoder.dartlib/data/helper/system_detector.dartlib/core/extension/ssh_client.dartlib/data/provider/server/single.dart
📚 Learning: 2025-10-08T09:36:41.682Z
Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-08T09:36:41.682Z
Learning: Applies to lib/data/model/server/**/*.dart : Place server management models under lib/data/model/server/
Applied to files:
lib/data/helper/system_detector.dartlib/core/extension/ssh_client.dartlib/data/provider/server/single.dart
📚 Learning: 2025-10-08T09:36:41.682Z
Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-08T09:36:41.682Z
Learning: Applies to lib/view/**/*.dart : Prefer widgets/utilities from fl_lib for common UI (e.g., CustomAppBar, context.showRoundDialog, Input, Btnx.cancelOk)
Applied to files:
lib/core/extension/ssh_client.dart
🔇 Additional comments (7)
lib/data/model/server/time_seq.dart (1)
59-70: Data loss confirmed:preis replaced with empty list whensizeDiff > 1, discarding historical state information.When 2+ items are added or removed (sizeDiff > 1), the code replaces
_list[length - 2]with an empty list. Tracing through an example:
- If
pre = [device_A, device_B]andnow = [device_A, device_B, device_C, device_D](2 devices added)- Result:
_list[length - 2]becomes[], losing the record that A and B existed previously- The alternate branch (sizeDiff ≤ 1) would reconcile and preserve this information
The threshold of
sizeDiff > 1is not documented. Why should a single item change be reconciled while 2+ changes result in data erasure? This distinction needs clarification.Type safety issues confirmed:
- Line 64:
<TimeSeqIface>[] as Tand line 69:newPre as Tuse unsafe casts whenTis a more specific list typeVerify the following with the developer:
- Is the empty-list replacement intentional when multiple items change, or is this a bug?
- What is the business rationale for the
sizeDiff > 1threshold?- In the context of network adapters (NetSpeed), CPU cores (Cpus), or disk I/O (DiskIO), when does this trigger and why is historical data loss acceptable?
lib/data/model/app/scripts/script_consts.dart (2)
32-33: LGTM! Windows-specific divider method is well implemented.The method correctly uses
Write-Hostfor PowerShell output and maintains consistent formatting with the existinggetCmdDividermethod.
108-108: Excellent fix for Chinese Windows encoding issues.Setting the console output encoding to UTF-8 directly addresses the PR objective of handling Chinese Windows environments where outputs may be returned in GBK encoding.
lib/data/model/app/scripts/cmd_types.dart (4)
169-180: Correct use of two-sample approach for performance counters.The change to WMI-based performance counters with two samples is the proper way to calculate network rates, as these are cumulative counters. The timestamps will allow accurate rate calculation on the client side.
Note: The 1-second sleep will add to overall script execution time. Since both
netanddiskiocommands use this pattern, the total additional latency will be at least 2 seconds if executed sequentially.
184-185: Good addition of core count information.Adding
NumberOfCoresandNumberOfLogicalProcessorsprovides useful CPU topology information and aligns with the PR's goal of improving Windows data collection.
227-240: Consistent two-sample approach for disk I/O counters.The implementation correctly mirrors the network command's two-sample pattern for cumulative performance counters. This ensures accurate disk I/O rate calculations.
301-301: Correct use of Windows-specific divider.The change to
getWindowsCmdDividerensures Windows commands use PowerShell'sWrite-Hostinstead ofecho, maintaining proper command formatting for Windows environments.
There was a problem hiding this 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
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
lib/data/model/app/scripts/cmd_types.dart(3 hunks)lib/data/model/server/cpu.dart(1 hunks)lib/data/model/server/disk.dart(1 hunks)lib/data/model/server/net_speed.dart(1 hunks)lib/data/model/server/server_status_update_req.dart(4 hunks)lib/data/model/server/time_seq.dart(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
lib/data/model/**/*.dart
📄 CodeRabbit inference engine (CLAUDE.md)
After modifying annotated model files, run: dart run build_runner build --delete-conflicting-outputs
Files:
lib/data/model/server/disk.dartlib/data/model/server/cpu.dartlib/data/model/server/time_seq.dartlib/data/model/app/scripts/cmd_types.dartlib/data/model/server/net_speed.dartlib/data/model/server/server_status_update_req.dart
lib/data/model/server/**/*.dart
📄 CodeRabbit inference engine (CLAUDE.md)
Place server management models under lib/data/model/server/
Files:
lib/data/model/server/disk.dartlib/data/model/server/cpu.dartlib/data/model/server/time_seq.dartlib/data/model/server/net_speed.dartlib/data/model/server/server_status_update_req.dart
🧠 Learnings (1)
📚 Learning: 2025-10-08T09:36:41.682Z
Learnt from: CR
Repo: lollipopkit/flutter_server_box PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-10-08T09:36:41.682Z
Learning: Applies to lib/data/model/server/**/*.dart : Place server management models under lib/data/model/server/
Applied to files:
lib/data/model/server/net_speed.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: check
🔇 Additional comments (5)
lib/data/model/app/scripts/cmd_types.dart (5)
187-196: LGTM! Past review concern has been addressed.The uptime calculation correctly uses
ToString('00')with single quotes. In PowerShell, single quotes inside double-quoted strings within$(...)subexpressions are literal and don't require escaping, so this syntax is correct.The approach of pre-formatting the uptime string in PowerShell avoids the date format parsing issues mentioned in the PR objectives.
299-299: Appropriate use of Windows-specific divider.The switch to
getWindowsCmdDivideraligns with the PR's goal of handling Windows-specific encoding requirements (UTF-8/GBK fallback). This separation enables Windows commands to have different divider formatting or encoding handling compared to Linux/BSD.
225-238: Parsing implementation verified and correct.The disk I/O parsing in
_parseWindowsDiskIO(lib/data/model/server/server_status_update_req.dart:597) correctly handles:
- Nested JSON structure: extracts the last 2 samples from the array, unwraps the optional 'value' wrapper
- Delta calculations: computes
readDelta = read2 - read1andwriteDelta = write2 - write1for cumulative counters- Rate calculation: converts
Timestamp_Sys100NSby dividing by 10,000,000 to get seconds, then uses timeDelta for accurate rates- Validation: ensures timeDelta > 0 and deltas are non-negative before creating DiskIOPiece entries
182-185: Parsing logic already handles both single and multiple CPU objects.Verification of
WindowsParser.parseCpu()inlib/data/model/server/windows_parser.dartconfirms the method correctly handles both scenarios:
- Array case (line 111): Explicitly checks
if (jsonData is List)for multiple physical processors- Single object case (line 156): Explicitly checks
else if (jsonData is Map)for single processorBoth branches properly extract and use the new
NumberOfCoresandNumberOfLogicalProcessorsfields (lines 119-120 and 159-160). The implementation distributes load evenly across logical processors and maintains cumulative counters as documented in the comments.
169-180: Well-structured two-sample network I/O collection with robust parsing.The WMI-based approach with two samples taken 1 second apart enables accurate network rate calculations. The parsing implementation at
_parseWindowsNetwork()correctly:
- Extracts the 2 most recent samples from the JSON array
- Handles nested structures and validates sample alignment
- Computes rate deltas between samples
- Converts
Timestamp_Sys100NS(100-nanosecond units) to seconds with proper divisor (10,000,000)- Filters out invalid entries (_Total, empty names) and negative deltas
本pr修复了以下问题:
Warning
本pr已知问题:
1.无法获取温度信息,这个可能要依赖Open Hardware Monitor等来获取,需要安装Open Hardware Monitor才行,至少在我的服务器>上无法仅通过powershell获取温度
Summary by CodeRabbit
Bug Fixes
New Features
Improvements
Refactor