Skip to content

Fix the lock message end time, 24:00 ranges, and Wayland resolution detection - #4

Merged
kgrizz-git merged 1 commit into
chore/close-public-repo-planfrom
fix/time-calculation-and-resolution-bugs
Oct 28, 2026
Merged

kgrizz-git merged 1 commit into
chore/close-public-repo-planfrom
fix/time-calculation-and-resolution-bugs

Conversation

@kgrizz-git

@kgrizz-git kgrizz-git commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #3. It needs that PR's tests, so the base is its branch. GitHub retargets it to main when #3 merges.

Summary

The tests in #3 found three bugs. This PR fixes them and one more of the same kind. None of them is a safety invariant, and no restriction, lock, cap, or popup-lifetime check changes. The runtime restricted-time test already handled 16:00-24:00 correctly.

  • Blank lock-message end time. configure.sh printed Lock ends: today for HH:MM configs. calculate_restriction_end_time and show_config_locked_error passed 05:00 to format_hour_12h, which takes a bare hour. They now share a new format_endpoint_12h, so the message reads Lock ends: 5:30 AM today. One _restriction_end_info helper replaces three copy-pasted blocks.
  • Ranges that end at 24. build_weekly_restricted_intervals dropped a range like TUESDAY=16-24, so the popup's next-unrestricted time treated that evening as free. range_endpoint_to_day_minutes now takes an optional end role that accepts 24 and 24:00, as the 16-hour cap code already does. A start of 24 stays invalid. A range that ends at the Saturday week boundary now continues into Sunday in the search.
  • Wrong AM/PM for 24. The same range printed as ending at 12:00 PM in the lock message, in the configure range summary, and in status.sh. All three now print 12:00 AM, and the lock message says it ends on the next day.
  • Wayland detection. get_display_resolution had A || B && C, which Bash reads as (A || B) && C. WAYLAND_DISPLAY alone never selected Wayland detection. It does now.

Tests

  • The new assertions fail on the old code: 36 in test-time-calculations.sh, 2 in the resolution test, and 10 of 14 in the new test-config-locked-message.sh. They pass with the fixes.
  • test-config-locked-message.sh drives the real show_config_locked_error with a stubbed clock and checks the text a user sees.
  • The "known gap" workarounds from Archive the public repo plan, raise test coverage, and fix the bugs the tests found #3 are gone, and the TO_DO entry is removed.

Checks

  • ./scripts/run-tests.sh --tier a: 55 run, 3 skipped on macOS, and the same on Ubuntu 24.04 (arm64 container, non-root)
  • ./scripts/check-quality.sh, ./scripts/run-security-scan.sh --ci, check-doc-drift.sh --strict
  • The changed functions also work under macOS bash 3.2
  • Reviewed read-only by opencode-go/muse-spark-1.3-contributor. It found nothing to change and agreed that no restriction or lock check is weakened.
  • CI on Ubuntu and macOS

lib/time-calculations-append.txt is a tracked leftover that holds an old copy of the buggy function. Nothing references it, and I left it alone.

🤖 Generated with Claude Code

Summary by Sourcery

Correct restriction end-time handling, midnight formatting, and Wayland resolution detection while expanding regression coverage.

Bug Fixes:

  • Fix lock-message end times for HH:MM restrictions and correctly report ranges ending at 24:00 as midnight on the following day.
  • Preserve restrictions ending at 24:00, including ranges crossing the Saturday-to-Sunday week boundary.
  • Correct 24:00 AM/PM formatting in lock messages, configuration summaries, and status output.
  • Detect Wayland displays when WAYLAND_DISPLAY is set, regardless of XDG_SESSION_TYPE.

Enhancements:

  • Consolidate restriction-end calculation and endpoint formatting for consistent lock-time reporting.

Tests:

  • Add coverage for locked-configuration messages, 24:00 range handling, Wayland detection, and midnight formatting.

Chores:

  • Remove the completed bug-tracking entry from the developer to-do list and register the new locked-message test in the test tiers.

…etection.

The configure lock error printed a blank end time for HH:MM values. A range
ending at 24 read as 12:00 PM and was dropped from the next-unrestricted-time
search. WAYLAND_DISPLAY alone did not select Wayland resolution detection.
The runtime restriction, lock, cap, and popup-lifetime checks are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f3ef547b-79ae-4376-8e34-120dded05d59
  • Autofix · 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

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

@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Sorry @kgrizz-git, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 3 days and 4 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sonarqubecloud

Copy link
Copy Markdown

@sourcery-ai

sourcery-ai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR fixes user-facing restriction end-time formatting, adds end-of-day range support through interval construction and next-unrestricted searches, corrects midnight display semantics, and repairs Wayland detection precedence, with focused regression tests and documentation updates.

Sequence diagram for restriction end-time formatting

sequenceDiagram
    participant LockMessage as show_config_locked_error
    participant EndTime as calculate_restriction_end_time
    participant Shared as _restriction_end_info
    participant Formatter as format_endpoint_12h
    participant Parser as range_endpoint_to_day_minutes

    LockMessage->>EndTime: calculate_restriction_end_time()
    EndTime->>Shared: _restriction_end_info(range, current_day)
    Shared->>Formatter: format_endpoint_12h(end_part)
    Shared->>Parser: range_endpoint_to_day_minutes(end_part, end)
    Parser-->>Shared: endpoint minutes
    Formatter-->>Shared: 5:30 AM or 12:00 AM
    Shared-->>EndTime: end time, day, next-day flag
    EndTime-->>LockMessage: formatted lock end information
Loading

Flow diagram for 24:00 restricted-range handling

flowchart LR
    Range["16-24 or 16:00-24:00"] --> Parse[range_endpoint_to_day_minutes with end role]
    Parse --> Interval[build_weekly_restricted_intervals]
    Interval --> Search[get_next_unrestricted_time]
    Search --> Boundary["24:00 becomes week-boundary interval end"]
    Boundary --> Sunday["Search continues at Sunday 00:00"]
Loading

File-Level Changes

Change Details Files
Centralize range-end formatting and restriction-end calculation so lock messages preserve minutes and correctly describe midnight boundaries.
  • Add endpoint formatting for bare hours, HH:MM values, and 24:00 as 12:00 AM.
  • Reuse a shared restriction-end helper across normal, overnight, and fallback paths.
  • Update configure lock-message dependency loading and add end-time/day assertions.
lib/configure-core.sh
lib/configure-ui-errors.sh
lib/time-calculations.sh
tests/test-config-locked-message.sh
tests/test-time-calculations.sh
Support 24:00 as a valid range terminator while preserving 24 as an invalid start and correctly continuing restrictions across day and week boundaries.
  • Add start/end roles to endpoint-to-minutes parsing, allowing only end-of-day 24:00 for end endpoints.
  • Build weekly intervals through minute 1440 and wrap Saturday-ending intervals into Sunday searches.
  • Add coverage for ordinary, overnight, full-day, and week-boundary ranges.
lib/time-parsing.sh
lib/time-calculations.sh
tests/test-time-calculations.sh
Correct midnight AM/PM rendering consistently across status output and range summaries.
  • Treat hour 24 as midnight rather than noon in shared time conversion and status formatting.
  • Verify 24 and 24:00 output as 12:00 AM without changing overnight formatting.
lib/time-parsing.sh
lib/status-config-display.sh
tests/test-status-display.sh
Fix Wayland resolution selection when WAYLAND_DISPLAY is present without a Wayland session-type variable.
  • Correct the conditional precedence so WAYLAND_DISPLAY alone, including alongside a non-Wayland session type, selects Wayland detection.
  • Replace the known-gap test workaround with explicit regression cases.
lib/resolution-detection.sh
tests/test-resolution-detection-stubbed.sh
Align project documentation and test-tier registration with the completed fixes.
  • Remove the resolved bug TODO entry.
  • Document the new locked-message test in the tier assessment and test manifest.
  • Record the lock-message, 24:00, and Wayland fixes in the changelog.
CHANGELOG.md
dev-docs/TO_DO.md
dev-docs/testing-assessments/test-tiers.md
tests/tiers.yaml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@kgrizz-git
kgrizz-git added this pull request to stack #5 October 28, 2026 17:13
@kgrizz-git

Copy link
Copy Markdown
Owner Author

Folded into #3 as requested. The commits are on that branch now (e711735, a720538), so this PR is closed.

@kgrizz-git
kgrizz-git merged commit e711735 into main Oct 28, 2026
9 checks passed
@kgrizz-git
kgrizz-git deleted the fix/time-calculation-and-resolution-bugs branch October 28, 2026 17:16
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.

1 participant