Skip to content

Replace blocking alert() with inline validation and warn on imminent Window triggers#240

Merged
ScottMorris merged 3 commits into
mainfrom
fix/edit-alarm-validation-and-imminent-window
Jul 9, 2026
Merged

Replace blocking alert() with inline validation and warn on imminent Window triggers#240
ScottMorris merged 3 commits into
mainfrom
fix/edit-alarm-validation-and-imminent-window

Conversation

@ScottMorris

Copy link
Copy Markdown
Contributor

Summary

  • alert() is silently swallowed by the Tauri desktop webview (confirmed via direct timing measurement — the call returns instantly with no dialog ever shown), so Edit Alarm's "select at least one day" validation never actually reached the user on desktop. Replaced with an inline error message under the day selector, which is also just a better pattern for a required-field error than a transient alert/toast.
  • Window mode's overnight-crossing support (windowEnd <= windowStart, e.g. an 11pm-6am window) is intentional, existing scheduler behaviour, but the UI gives zero indication when it happens — an accidental Start/End mix-up can silently schedule a trigger within minutes with no feedback at all. Added:
    • An inline "This window crosses midnight" hint shown while editing whenever windowEnd <= windowStart.
    • A post-save confirmation dialog when the saved alarm's nextTrigger (already returned by AlarmService.save() — no new Rust command needed) is under 30 minutes away, letting the user go back and adjust before finding out the hard way.

Test plan

  • pnpm --filter threshold exec tsc --noEmit clean
  • pnpm --filter threshold test — 53 tests pass
  • Live-verified via the Tauri MCP bridge against a running desktop dev build:
    • Deselecting all days and saving shows the inline error and stays on the screen (no alert(), no crash)
    • Setting Start Window 11:00 PM / End Window 6:00 AM shows the "crosses midnight" hint
    • Saving a normal, non-imminent window alarm navigates straight to Home with no dialog
    • Saving/editing a window alarm with a next trigger ~10 minutes out shows the confirmation dialog with the correct computed time; "Adjust" stays on the screen, "Keep It" navigates home

🤖 Generated with Claude Code

https://claude.ai/code/session_01MM1S4DNyxhwcbkMcx3hDp2

…nent Window triggers

alert() is silently swallowed by the Tauri desktop webview, so the
no-days-selected validation on Edit Alarm never actually reached the
user. Replace it with an inline error under the day selector instead,
which also reads better for a required-field error than a transient
alert would.

Window mode's overnight-crossing support (end time <= start time is a
deliberate, valid design for windows like 11pm-6am) has no UI
indication when it happens, so an accidental Start/End tap can
silently schedule a trigger within minutes with zero feedback. Add an
inline "crosses midnight" hint while editing, plus a post-save
confirmation dialog when the resulting alarm's next trigger is under
30 minutes away, giving the user a chance to go back and adjust
instead of finding out when the alarm rings.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MM1S4DNyxhwcbkMcx3hDp2
@ScottMorris ScottMorris added bug Something isn't working core Core app logic ui User interface labels Jul 9, 2026
ScottMorris and others added 2 commits July 9, 2026 16:39
…ndow handling

Two issues caught in review of this same change: the save-failure
catch block still called alert(), the exact bug this PR otherwise
removed, so a failed save (e.g. a zero-length window, which the
scheduler rejects outright) was completely silent on desktop. Swapped
it for showToast(), now that desktop toasts actually work. Also guard
handleSave client-side against windowStart === windowEnd so it never
round-trips a request the scheduler will reject, and split the
Window-mode hint text so a zero-length window gets its own accurate
error instead of being mislabelled as "crosses midnight".

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MM1S4DNyxhwcbkMcx3hDp2
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MM1S4DNyxhwcbkMcx3hDp2
@ScottMorris ScottMorris merged commit 2567921 into main Jul 9, 2026
7 checks passed
@ScottMorris ScottMorris deleted the fix/edit-alarm-validation-and-imminent-window branch July 9, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core Core app logic ui User interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant