Skip to content

Restore support for the bar view on the date and time meters. - #2130

Open
lvaschmidt wants to merge 2 commits into
htop-dev:mainfrom
lvaschmidt:main
Open

lvaschmidt wants to merge 2 commits into
htop-dev:mainfrom
lvaschmidt:main

Conversation

@lvaschmidt

Copy link
Copy Markdown

This overturns a little bit of #1387 , restoring the bar type for Time, Date, and Date & Time meters. This addresses this comment by execvpe, which @BenBE seemed open to?

This change restores those meters to the way they were, reusing the code from before the change, so I wasn't writing new code.

Screenshot 2026-10-07 at 4 36 14 PM

^Here's how they look in my testing of this PR.

One tiny additional change is to fix the oversight in the Black Night theme that failed to label the Date and DateTime meters green the way all similar meters are labeled in that theme.

Screenshot 2026-10-07 at 4 36 32 PM

^The date meters in the corrected color.

I also changed the caption of the date meter in the bar mode to "D&T", which seemed appropriate as far as I could tell.

ChatGPT helped make the PR, and I tested it by hand.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

📝 Walkthrough

Walkthrough

The clock, date, and date-time meters now support bar mode and expose progress values. Date and date-time totals account for Gregorian leap years. The date-time meter uses D&T as its bar-mode caption. In the BLACKNIGHT color scheme, DATE and DATETIME now use green on black.


Priority: ⬇️ Low

Change: Bug fix

Merge Risk: 🔵 Low · up to fe8c9

The Date & Time bar may show “Dat” instead of the stated “D&T,” a small but visible labeling mismatch. Confirm the intended caption or restore the short label before merging.

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

The clock marks minutes through the day
The date counts days along its way
Leap years add a day to count
Bar mode shows the changing amount
Green lights DATE and DATETIME
Each meter keeps its time in line

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

@BenBE BenBE added the needs-discussion 🤔 Changes need to be discussed and require consent label Oct 8, 2026
@fasterit

fasterit commented Oct 9, 2026

Copy link
Copy Markdown
Member

@BenBE and me would generally be in favor of merging this.

But: This is AI messy, so please:

  • Clean up the code (no _getCaption etc.)
  • Make two clean commits, one for the color fix and one for the restoration of the bar style functionality
  • Use proper Assisted-by: lines in the commit description
  • Review everything manually. Then force push to this PR.

@fasterit fasterit added needs-AI-cleanup 🧟 Stacks of sequential commits and/or AI noise // Incorrect Assisted-by: // Styleguide violations and removed needs-discussion 🤔 Changes need to be discussed and require consent labels Oct 9, 2026
@lvaschmidt

Copy link
Copy Markdown
Author

When you want no _getCaption, does that mean you want the bar for Date and Time to be labeled "Dat", you don't want it changed to "D&T"? From my understanding, the _getCaption was the way that other meters with variable labels did it. But I can remove that aspect entirely. Sure. Will do the rest.

Restore day and year progress bars while preserving the original captions. Share the year-progress calculation for Date and DateTime and select their text format with a ternary expression.

Assisted-by: ChatGPT
Signed-off-by: Lysander Schmidt <me@LysanderSchmidt.com>
Assisted-by: ChatGPT
Signed-off-by: Lysander Schmidt <me@LysanderSchmidt.com>

@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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ff050669-4428-4600-b079-0b37a3034ed6
📥 Commits

Reviewing files that changed from the base of the PR and between 8311809 and fe8c917.

📒 Files selected for processing (1)
  • DateTimeMeter.c

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread DateTimeMeter.c
.supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE),
.maxItems = 0,
.total = 0.0,
.supportedModes = (1 << BAR_METERMODE) | (1 << TEXT_METERMODE) | (1 << LED_METERMODE),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect caption lookup and any DateTime-specific getter.
rg -n -C 8 '\bMeter_getCaption\b|\.getCaption|DateTimeMeter_class' Meter.c Meter.h DateTimeMeter.c

Repository: htop-dev/htop

Length of output: 4759


🏁 Script executed:

set -euo pipefail
printf '%s\n' '--- DateTimeMeter.c at reviewed head ---'
nl -ba DateTimeMeter.c | sed -n '1,115p'
printf '%s\n' '--- relevant diff from merge base ---'
git diff --no-ext-diff --unified=20 44a59cf1b407df3a1853e9f4f86c3f366808c9e0 fe8c9177bcb451d627339b1a1adf45cf47c11b51 -- DateTimeMeter.c Meter.c Meter.h

Repository: htop-dev/htop

Length of output: 6359


Confirm the intended Date & Time bar caption.

BarMeterMode_draw displays the first three characters from Meter_getCaption(). Because DateTimeMeter_class has no custom getter, its "Date &amp; Time: " caption renders as Dat, not D&amp;T. If D&amp;T remains required, add a Date & Time-specific caption getter that preserves the existing text and LED captions.

@lvaschmidt

Copy link
Copy Markdown
Author

I redid it in two commits as requested. I also reverted the variable caption feature entirely.

Screenshot 2026-10-09 at 2 12 54 PM

I wasn’t sure whether

This is AI messy, so please clean up the code (no _getCaption etc.)

meant I should deduplicate the leap year calculation.

That duplication was human mess from when the feature was implemented the last time, but I did consolidate the if statement there in a way I think is cleaner. But you might consider it less clean if you're against ternary operators, which I know some people are. I'm happy to have it either way. This is your code base, not mine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-AI-cleanup 🧟 Stacks of sequential commits and/or AI noise // Incorrect Assisted-by: // Styleguide violations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants