Skip to content

Add battery percentage display to launcher clock panel#4320

Draft
Jack251970 wants to merge 8 commits intodevfrom
copilot/add-battery-percentage-ui
Draft

Add battery percentage display to launcher clock panel#4320
Jack251970 wants to merge 8 commits intodevfrom
copilot/add-battery-percentage-ui

Conversation

@Jack251970
Copy link
Member

@Jack251970 Jack251970 commented Mar 4, 2026

CHANGES

This pull request adds support for displaying battery status in the application's UI, allowing users to toggle its visibility alongside the clock and date. It introduces a new dependency for battery information and updates both the settings and UI to accommodate this feature.

Resolve #3221.

TODO

  • Fix battery text size if only date is displayed.
  • Fix clock, date, battery text size margin.
  • Check memory usage.

TEST

image image image

Summary by cubic

Adds an optional battery percentage next to the clock/date with a toggle in Theme settings, updated via the existing timer using PowerStatus. Resolves #3221.

Summary of changes

  • Changed
    • Clock panel layout: horizontal; clock+date stacked vertically; battery in a separate stack with left margin.
    • Existing timer now also updates BatteryText when UseBattery is on; no new timer added.
  • Added
    • Settings.UseBattery (default false), bound to a new toggle in Theme settings with a “75%” preview.
    • BatteryText and a PowerStatusProvider to read BatteryLifeProportion and format it as an integer percent.
    • New “Battery” i18n string (en.xaml).
    • Dependency: PowerStatus 1.0.3; packages.lock updated (also bumps Flow.Launcher.Plugin to 5.2.0).
  • Removed
    • No existing behavior removed.
  • Memory
    • One PowerStatusProvider instance per MainViewModel; negligible overhead.
    • One extra TextBlock when enabled; no meaningful memory impact.
  • Security
    • Uses local Windows power APIs only; no network calls or elevated permissions. Low risk.
  • Tests
    • No unit tests added. Manually validated in the settings preview and main UI.

Written for commit db03adc. Summary will update on new commits.

Copilot AI and others added 6 commits March 4, 2026 04:39
Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
- Add PowerStatus NuGet package (v1.0.3)
- Add UseBattery setting to Settings.cs
- Add BatteryText property and update periodic timer in MainViewModel
- Add BatteryBox TextBlock to ClockPanel in MainWindow.xaml
- Add BaseBatteryBox and BatteryBox styles to Base.xaml and all theme files
- Add UseBattery toggle and preview to SettingsPaneTheme
- Add Battery localization string to en.xaml

Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
- Remove BaseBatteryBox and BatteryBox style definitions from Base.xaml
- Remove BatteryBox style overrides from all theme files
- Update BatteryBox TextBlock in MainWindow.xaml to use ClockBox style
- Update BatteryBox TextBlock in SettingsPaneTheme.xaml to use ClockBox style

Co-authored-by: Jack251970 <53996452+Jack251970@users.noreply.github.com>
Restructure ClockPanel in MainWindow.xaml by grouping the Clock and Date TextBlocks in a vertical StackPanel and placing the Battery TextBlock in a separate vertical StackPanel with a left margin. This enhances the visual alignment and separation between the clock/date and battery displays.
Copilot AI review requested due to automatic review settings March 4, 2026 05:14
@prlabeler prlabeler bot added the enhancement New feature or request label Mar 4, 2026
@github-actions github-actions bot added this to the 2.2.0 milestone Mar 4, 2026
@Jack251970 Jack251970 enabled auto-merge March 4, 2026 05:14
@gitstream-cm
Copy link

gitstream-cm bot commented Mar 4, 2026

🥷 Code experts: jjw24

jjw24, Jack251970 have most 👩‍💻 activity in the files.
Jack251970, jjw24 have most 🧠 knowledge in the files.

See details

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Activity based on git-commit:

jjw24 Jack251970
MAR
FEB
JAN
DEC
NOV
OCT 31 additions & 52 deletions

Knowledge based on git-blame:
jjw24: 95%
Jack251970: 4%

Flow.Launcher/Flow.Launcher.csproj

Activity based on git-commit:

jjw24 Jack251970
MAR
FEB
JAN 1 additions & 1 deletions
DEC
NOV 1 additions & 1 deletions
OCT 2 additions & 4 deletions

Knowledge based on git-blame:
Jack251970: 100%

Flow.Launcher/Languages/en.xaml

Activity based on git-commit:

jjw24 Jack251970
MAR
FEB 7 additions & 4 deletions
JAN
DEC
NOV
OCT 13 additions & 10 deletions

Knowledge based on git-blame:
jjw24: 96%
Jack251970: 3%

Flow.Launcher/MainWindow.xaml

Activity based on git-commit:

jjw24 Jack251970
MAR
FEB
JAN
DEC 1 additions & 1 deletions
NOV
OCT 1 additions & 1 deletions

Knowledge based on git-blame:
jjw24: 100%

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Activity based on git-commit:

jjw24 Jack251970
MAR
FEB
JAN
DEC
NOV
OCT 8 additions & 5 deletions

Knowledge based on git-blame:
jjw24: 97%
Jack251970: 3%

Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml

Activity based on git-commit:

jjw24 Jack251970
MAR
FEB
JAN
DEC
NOV
OCT 343 additions & 323 deletions

Knowledge based on git-blame:
jjw24: 58%
Jack251970: 42%

Flow.Launcher/ViewModel/MainViewModel.cs

Activity based on git-commit:

jjw24 Jack251970
MAR
FEB 11 additions & 6 deletions
JAN 50 additions & 35 deletions
DEC
NOV 106 additions & 94 deletions
OCT 125 additions & 88 deletions

Knowledge based on git-blame:
Jack251970: 95%

Flow.Launcher/packages.lock.json

Activity based on git-commit:

jjw24 Jack251970
MAR
FEB
JAN 5 additions & 5 deletions
DEC
NOV 5 additions & 5 deletions
OCT 14 additions & 6 deletions

Knowledge based on git-blame:
Jack251970: 100%

✨ Comment /gs review for LinearB AI review. Learn how to automate it here.

@gitstream-cm
Copy link

gitstream-cm bot commented Mar 4, 2026

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml">

<violation number="1" location="Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml:352">
P2: Battery preview layout does not match the real launcher layout, so the settings preview becomes misleading when battery is enabled.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an optional battery percentage indicator to the launcher’s clock panel, controlled by a new setting, to address the request in #3221.

Changes:

  • Introduces a UseBattery user setting and adds a corresponding toggle in the theme/settings UI.
  • Adds BatteryText to MainViewModel and renders it in MainWindow alongside the clock/date.
  • Adds the PowerStatus NuGet dependency and updates lockfile/localization strings.

Reviewed changes

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

Show a summary per file
File Description
Flow.Launcher/packages.lock.json Locks new PowerStatus dependency and updates resolved package versions.
Flow.Launcher/Flow.Launcher.csproj Adds PowerStatus package reference.
Flow.Launcher.Infrastructure/UserSettings/Settings.cs Adds persisted UseBattery setting.
Flow.Launcher/ViewModel/MainViewModel.cs Polls power status and exposes BatteryText for binding.
Flow.Launcher/MainWindow.xaml Updates clock panel layout and adds battery text binding.
Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml Adds settings toggle and theme preview BatteryBox.
Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs Adds UseBattery binding and preview BatteryText.
Flow.Launcher/Languages/en.xaml Adds Battery localization key (English).

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

📝 Walkthrough

Walkthrough

Adds an optional battery-percentage display beside clock/date: new Settings flag, UI elements and localization, a PowerStatus dependency, ViewModel properties to fetch/format battery percentage, and settings toggle integration.

Changes

Cohort / File(s) Summary
Dependencies
Flow.Launcher/Flow.Launcher.csproj, Flow.Launcher/packages.lock.json
Added PowerStatus NuGet package (v1.0.3); updated Flow.Launcher.Plugin version references in lockfile.
Settings Model
Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Added public bool UseBattery { get; set; } = false;.
Main UI
Flow.Launcher/MainWindow.xaml, Flow.Launcher/Themes/Base.xaml
Reflowed clock/date layout to horizontal grouping; added BatteryBox element and adjusted clock/date margins/styles.
Localization
Flow.Launcher/Languages/en.xaml
Added Battery resource key.
ViewModels
Flow.Launcher/ViewModel/MainViewModel.cs, Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs
Introduced PowerStatusProvider usage, added BatteryText and proxied UseBattery properties for binding.
Settings UI
Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml
Added Battery SettingsCard and ToggleSwitch bound to UseBattery; added Battery display binding to BatteryText.

Sequence Diagram

sequenceDiagram
    participant User
    participant Settings
    participant MainWindow
    participant MainViewModel
    participant PowerStatusProvider

    User->>MainWindow: Toggle "Show Battery" (UI)
    MainWindow->>Settings: Set UseBattery = true/false
    MainWindow->>MainViewModel: Notify setting change / bind update
    MainViewModel->>PowerStatusProvider: Request battery status (if UseBattery)
    PowerStatusProvider-->>MainViewModel: Return battery proportion/value
    MainViewModel->>MainWindow: Update BatteryText (e.g., "75%")
    MainWindow-->>User: Render BatteryBox with BatteryText
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • onesounds
  • jjw24
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding a battery percentage display feature to the launcher's clock panel, which is the primary objective of this PR.
Linked Issues check ✅ Passed The PR successfully implements the core requirement from issue #3221: a toggleable battery percentage display next to the clock and date. All coding aspects are addressed: Settings.UseBattery toggle [#3221], UI elements with visibility binding [#3221], PowerStatusProvider for reading battery info [#3221], and proper localization [#3221].
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the battery feature. Theme margin adjustments and layout restructuring are necessary to accommodate the new battery display element alongside clock/date.
Description check ✅ Passed The pull request description is directly related to the changeset, clearly explaining the battery status feature addition with specifics about layout changes, new settings, dependencies, and testing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch copilot/add-battery-percentage-ui

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 and usage tips.

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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Flow.Launcher/Languages/en.xaml`:
- Line 331: The localized resource dictionaries are missing the "Battery" key
used by SettingsPaneTheme.xaml via {DynamicResource Battery}; add a
<system:String x:Key="Battery">Battery</system:String> entry (translated
appropriately) to each of the other 27 language XAML files (all non-English
resource dictionaries) so the DynamicResource resolves for all locales; ensure
the key name is exactly "Battery" and place it alongside the other top-level
strings in each language file so no locale shows a missing/blank header.

In `@Flow.Launcher/MainWindow.xaml`:
- Around line 302-323: The right-hand StackPanel that holds BatteryBox currently
has a fixed Margin="8 0 0 0" which leaves a gap even when Settings.UseBattery is
false; update the XAML so the left margin is conditional – either remove the
fixed Margin and apply it via a Style/DataTrigger on that StackPanel (targeting
the StackPanel containing BatteryBox) that sets Margin="8 0 0 0" only when
Settings.UseBattery is true, or bind the Margin to Settings.UseBattery using a
converter that returns "8 0 0 0" when true and "0 0 0 0" when false; reference
the StackPanel (the one with Margin currently defined), the BatteryBox TextBlock
and Settings.UseBattery to locate and apply the change.

ℹ️ Review info
Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a8401153-82bd-490e-a3ff-0319593291cc

📥 Commits

Reviewing files that changed from the base of the PR and between dda9000 and db03adc.

📒 Files selected for processing (8)
  • Flow.Launcher.Infrastructure/UserSettings/Settings.cs
  • Flow.Launcher/Flow.Launcher.csproj
  • Flow.Launcher/Languages/en.xaml
  • Flow.Launcher/MainWindow.xaml
  • Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml
  • Flow.Launcher/ViewModel/MainViewModel.cs
  • Flow.Launcher/packages.lock.json

Changed default Margin in Base.xaml styles from "0 0 0 3" or "0 0 0 0" to "0 1.5 0 1.5" for better vertical alignment and spacing in both the main and BaseDateBox styles. Trigger-based margin and font size settings remain unchanged.
Separated BatteryBox into its own StackPanel with margin for improved alignment and spacing in MainWindow.xaml and SettingsPaneTheme.xaml. Updated the battery icon glyph in SettingsPaneTheme.xaml for a refreshed visual appearance.
@Jack251970 Jack251970 marked this pull request as draft March 4, 2026 05:37
auto-merge was automatically disabled March 4, 2026 05:37

Pull request was converted to draft

@prlabeler prlabeler bot added the bug Something isn't working label Mar 4, 2026
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Flow.Launcher/Themes/Base.xaml (1)

134-146: ⚠️ Potential issue | 🟡 Minor

Base margin normalization is currently bypassed by theme overrides

Line 134 and Line 146 standardize spacing in BaseClockBox/BaseDateBox, but Flow.Launcher/Themes/SlimLight.xaml:198-224 still overrides these margins (including trigger margins), so clock/date/battery alignment will remain inconsistent when users switch to SlimLight.

Consider aligning SlimLight’s ClockBox/DateBox margins with this new base spacing model so the battery layout behaves consistently across themes.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Flow.Launcher/Themes/Base.xaml` around lines 134 - 146, The BaseClockBox and
BaseDateBox styles now normalize margins and trigger margins, but SlimLight's
ClockBox/DateBox styles still override those margins (including trigger margins)
causing inconsistent alignment; update the SlimLight theme styles that define
ClockBox and DateBox (the Style entries in SlimLight.xaml around the
ClockBox/DateBox definitions) to either remove the hardcoded Margin/FontSize
trigger overrides or align their Margin and DataTrigger values with the
BaseClockBox/BaseDateBox conventions so they inherit the base spacing model and
produce consistent clock/date/battery alignment across themes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@Flow.Launcher/Themes/Base.xaml`:
- Around line 134-146: The BaseClockBox and BaseDateBox styles now normalize
margins and trigger margins, but SlimLight's ClockBox/DateBox styles still
override those margins (including trigger margins) causing inconsistent
alignment; update the SlimLight theme styles that define ClockBox and DateBox
(the Style entries in SlimLight.xaml around the ClockBox/DateBox definitions) to
either remove the hardcoded Margin/FontSize trigger overrides or align their
Margin and DataTrigger values with the BaseClockBox/BaseDateBox conventions so
they inherit the base spacing model and produce consistent clock/date/battery
alignment across themes.

ℹ️ Review info
Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0fe65895-2577-4a45-93a4-b72e7eab8577

📥 Commits

Reviewing files that changed from the base of the PR and between db03adc and e2d0cf4.

📒 Files selected for processing (3)
  • Flow.Launcher/MainWindow.xaml
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml
  • Flow.Launcher/Themes/Base.xaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • Flow.Launcher/MainWindow.xaml
  • Flow.Launcher/SettingPages/Views/SettingsPaneTheme.xaml

@jjw24
Copy link
Member

jjw24 commented Mar 4, 2026

Please ensure you test that this change does not increase memory usage.

@Jack251970 Jack251970 removed the bug Something isn't working label Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add next to the clock and date the option to see my battery percentage

4 participants