Skip to content

feat: support grayscale mode to save bandwidth (partial)#568

Draft
foresee-io wants to merge 1 commit into
rustdesk:mainfrom
foresee-io:feat/gray-v1
Draft

feat: support grayscale mode to save bandwidth (partial)#568
foresee-io wants to merge 1 commit into
rustdesk:mainfrom
foresee-io:feat/gray-v1

Conversation

@foresee-io

@foresee-io foresee-io commented Jul 6, 2026

Copy link
Copy Markdown

Associated with:

Summary by CodeRabbit

  • New Features
    • Added support for a new color mode option in user defaults.
    • Improved compatibility so some existing color settings may now map to a higher-fidelity mode when available.

Signed-off-by: Zhenyu FU <ysfcore@outlook.com>
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds an I400 value to the Chroma protobuf enum and introduces a color-mode configuration option. The config logic maps a stored i420 color-mode value to i444 when the i444 option is enabled, otherwise leaving values unchanged.

Changes

Color-mode configuration and chroma enum

Layer / File(s) Summary
Chroma enum extension
protos/message.proto
Adds a new I400 = 2 member to the Chroma enum.
Color-mode config key and resolution logic
src/config.rs
Adds public constant OPTION_COLOR_MODE and a match arm in UserDefaultConfig::get() that rewrites "i420" to "i444" when OPTION_I444 is set to "Y", otherwise passing values through unchanged.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Related Issues: None specified.

Related PRs: None specified.

Suggested labels: enhancement, config

Suggested reviewers: rustdesk maintainers familiar with config.rs and message.proto

🐰 A whisper of chroma, a new mode in sight,
i420 slips quietly into i444's light,
One tiny enum, one constant small,
Backward compatible, handling it all.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the PR’s main goal of adding grayscale/color-mode support to reduce bandwidth.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@foresee-io

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/config.rs (1)

2882-2883: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Misplaced comment.

// i444 is for backward compatibility sits directly above the OPTION_COLOR_MODE constant, but the constant itself has nothing to do with backward compatibility — the compatibility logic lives in UserDefaultConfig::get() (Lines 2385-2390). This is confusing when read in isolation.

✏️ Suggested fix
     pub const OPTION_I444: &str = "i444";
-    // i444 is for backward compatibility
+    // color-mode superseded OPTION_I444; kept for backward compatibility with old configs
     pub const OPTION_COLOR_MODE: &str = "color-mode";
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/config.rs` around lines 2882 - 2883, The backward-compatibility note is
attached to the wrong symbol, since OPTION_COLOR_MODE is just a constant and the
compatibility behavior is implemented in UserDefaultConfig::get(). Move or
rewrite the comment so it sits with the actual compatibility handling in
UserDefaultConfig::get(), and keep the OPTION_COLOR_MODE constant comment
focused only on the constant itself.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/config.rs`:
- Around line 2882-2883: The backward-compatibility note is attached to the
wrong symbol, since OPTION_COLOR_MODE is just a constant and the compatibility
behavior is implemented in UserDefaultConfig::get(). Move or rewrite the comment
so it sits with the actual compatibility handling in UserDefaultConfig::get(),
and keep the OPTION_COLOR_MODE constant comment focused only on the constant
itself.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c6d2d021-3ad9-45f3-b41f-e78132cabfcc

📥 Commits

Reviewing files that changed from the base of the PR and between 7e1c392 and 82ffd3a.

📒 Files selected for processing (2)
  • protos/message.proto
  • src/config.rs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new configurable “color mode” setting (including a grayscale option) intended to reduce bandwidth usage, and extends the protocol chroma enum to represent grayscale.

Changes:

  • Added a color-mode user default option with logic intended to map legacy i444 settings to the new mode.
  • Added I400 (grayscale) to the Chroma enum in the protobuf schema.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/config.rs Adds OPTION_COLOR_MODE and getter logic to migrate/interpret legacy i444 settings.
protos/message.proto Extends Chroma enum with I400 for grayscale support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/config.rs
Comment on lines +2383 to +2394
keys::OPTION_COLOR_MODE => {
let v = self.get_string(key, "i420", vec!["i444", "i400"]);
if v == "i420" {
if self.options.get(keys::OPTION_I444) == Some(&"Y".to_string()) {
"i444".to_string()
} else {
"i420".to_string()
}
} else {
v
}
}
Comment thread src/config.rs
Comment on lines 2881 to +2883
pub const OPTION_I444: &str = "i444";
// i444 is for backward compatibility
pub const OPTION_COLOR_MODE: &str = "color-mode";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants