Skip to content

shell: clamp notification toast width to viewport; battery warning auto-expires - #12666

Closed
0xdfi wants to merge 1 commit into
omacom:quattrofrom
0xdfi:fix/toast-scaling-small-screens
Closed

0xdfi wants to merge 1 commit into
omacom:quattrofrom
0xdfi:fix/toast-scaling-small-screens

Conversation

@0xdfi

@0xdfi 0xdfi commented Sep 20, 2026

Copy link
Copy Markdown

What

Two changes so notification toasts scale correctly on small logical viewports and never become undismissable pin walls:

  1. Toast width clamps to the viewport (shell/plugins/notifications/components/NotificationCard.qml)

    • implicitWidth: Math.min(Style.space(380), Math.round(Screen.width * 0.8))
    • Keeps the 380px desktop target when there is room; on small logical screens the card now always fits with margins.
  2. Low-battery warning no longer stacks forever (bin/omarchy-battery-low)

    • -u critical → -u normal, -t 30000 → -t 12000.

Why

Found on a CM5 mini-Linux box (720x720 panel, scale 1.6 → 450 logical px). The fixed Style.space(380) card is 507 logical px wide there (×fontScale 16/12) — literally wider than the screen. Worse: the battery warning is sent as critical urgency, and (a) critical toasts get durationFor() → 0 (no auto-expiry), (b) each threshold flap sends a new notification id (no replaces_id), and (c) popups are mirrored to disk and restored on shell start. Net effect: 12 immortal, screen-wider-than-display toasts covering the desktop, re-appearing after every reboot, with dismissal only on right-click/long-press.

Verified locally

  • Test toast with the new urgency/timeout auto-expired to history after 12s (files moved from popupStateDir → history).
  • Width math: 380 × 1.333 fontScale = 507 px vs 450 available pre-fix; post-fix min(507, 0.8·450=360) fits.

Happy to split this into two PRs (scaling vs battery urgency) if preferred — they just shipped together because they fixed the same incident.

…to-expires

On small logical viewports (HiDPI panels) the fixed 380px toast width
exceeds the screen: on a 720x720 panel at scale 1.6 only 450 logical px
remain, so critical battery toasts stack across the whole screen and
persist (restored criticals never expire). Clamp toast width to 80% of
the logical screen width (keeping the 380px target when there is room)
and demote the low-battery warning to normal urgency with a 12s expiry
so it auto-expires like any transient toast.
@llstrk

llstrk commented Sep 23, 2026

Copy link
Copy Markdown

No code defect found in the inspected scope. One documentation update is suggested.

Verified (source inspection): the popup layout uses the card’s clamped width, and newly issued low-battery warnings receive a finite lifetime without losing their notification-silencing bypass.

Source-derived behavior Before This PR
Card width in the reported 450-logical-pixel, 16px-font example 507px 360px
New low-battery toast lifetime No automatic expiry 12 seconds, paused while hovered

Documentation note: docs/notifications.md:168-169 still calls the low-battery toast “critical.” Suggested change: describe its normal urgency and 12-second timeout.

Existing-state limitation: previously saved critical battery warnings retain their old urgency and still need dismissal; this change prevents persistence of new warnings rather than cleaning up old ones.


Review information

Test scope: Source-only review at 703ebfa7adc1; no QML rendering, fractional-scale desktop, physical battery, or measured expiry tests. The width comparison is calculated from source, not a screenshot measurement; unusually large side-bar clearances or gaps are outside the demonstrated fit.

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Automated AI review: Astra Medium performed initial inspection and synthesis, with independent Opus 5.5 High and GPT 6 Sol Xhigh technical reviews. Public claims were checked against pinned source; a fresh Astra Medium check assessed presentation and privacy only.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Oct 2, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 703ebfa and run on an Omarchy worker VM, with this branch merged into current quattro (821ae58). Both problems are real and both changes fix them, but each half has an open alternative, so this waits on the maintainer to choose.

What ran. The output was set to scale 4 (320 logical px), and the real omarchy-battery-low 7 sent the warning:

  • On quattro, the card is wider than the screen and runs off the left edge, so the border and icon are cut off. The critical warning is still on screen 15 s later.
  • With this PR, the card is 256 px wide and fits with room to spare. The warning moves to history within 15 s.
  • At scale 1 the card is still 380 px, so desktop screens are unchanged.
  • test/shell.d/notifications-test.sh (142), notification-send-test.sh (17), battery-test.sh (7) and battery-status-test.sh pass. ./test/cli has one failure, vscode generated theme references current theme file, which fails the same way on quattro.
  • Do Not Disturb is unaffected. omarchy-notification-send sends as omarchy-action, which bypasses it whatever the urgency (shouldBypassDnd in NotificationLogic.js).

Competing fixes.

If the urgency change is kept, docs/notifications.md:168 still calls this a critical toast and needs to follow. Warnings already saved as critical stay until dismissed, because only new ones get the timeout.

Who checked it. Reviewed by Claude Opus 5.5. No second opinion ran: the configured reviewer, Codex Medium, answered, but omabot's daily review allowance was already spent. So this rests on one model's reading and the worker run above.

Waiting on the maintainer to choose between this PR, #11034 and #11415.

@jandrusk

Copy link
Copy Markdown

Two useful nits in one PR (toast width clamp + shorter battery-warning timeout / lower urgency).

For the battery half, also see open PRs that dismiss the warning when AC is plugged in (#14739, #14218, #11415) and storm reports #9670/#10939 — a timeout alone doesn’t clear a sticky critical toast if the shell treats critical as persistent.

Toast clamp looks straightforward and still needed on small logical viewports. Might be cleaner to split clamp vs battery policy so the dismiss-on-AC work can land independently.

@omarchybot

Copy link
Copy Markdown
Collaborator

The head is unchanged at 703ebfa, so the worker run from the earlier comment still stands. This pass asked the second opinion that did not run last time to compare this PR with the fixes it competes with. Both halves have an older open fix, and neither of those has a defect that this PR avoids, so the older ones are the ones to take.

Toast width: #11034. It is older, and it clamps the card to the room the popup column actually has: the window width minus the popupPlacement margins. With the bar on the right, NotificationLogic.js:441 makes the right margin the bar clearance, which 0.8 * Screen.width does not account for. When the margins take more than a fifth of the screen, the card here can still overflow. #11034 has already been verified on a worker.

Battery warning: #11415. It is older, and it fixes the stale warning by dismissing it once the battery stops being low. This PR instead lets the warning expire after 12 s while the battery is still low. Critical toasts never expiring is intentional (durationFor in notifications/Service.qml:108), so that is a policy choice rather than a fix #11415 lacks. Lowering the urgency also leaves warnings already saved as critical on screen. #14739 and #14218, which @jandrusk pointed to, dismiss the warning when the charger is plugged in. Both were opened after #11415 and take the same approach.

Who checked it. Claude Opus 5.5 and Codex Medium each compared the three diffs against current quattro, without seeing the other's answer, and both reached the same result for both halves. That review read the source and ran nothing new.

Waiting on the maintainer. The recommendation is #11034 for the width and #11415 for the battery warning, which would make this PR one to close.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 14, 2026
@ryanrhughes

Copy link
Copy Markdown
Collaborator

Thanks @0xdfi! Two things in here. The battery change: in the new notification engine (#15932), criticals stay until dismissed on purpose, and dismissing the low-battery warning on AC connect is being handled in #14218. The width clamp is still a real issue on the new engine, and it overlaps #11034, which is still open. Closing this one, but thanks for testing it on the CM5.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants