Skip to content

fix: spell every weekday correctly in the schedule preview - #376

Open
Sma1lboy wants to merge 1 commit into
mainfrom
claude/keen-einstein-5eq5gf
Open

fix: spell every weekday correctly in the schedule preview#376
Sma1lboy wants to merge 1 commit into
mainfrom
claude/keen-einstein-5eq5gf

Conversation

@Sma1lboy

@Sma1lboy Sma1lboy commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Direction

Bugs / correctness — a self-found defect in the automation composer's schedule-preview text.

Problem

describeCron in src/tui/component/cron-segments.ts built the single-weekday phrase by string surgery — uppercase the first letter, lowercase the tail, append "days":

if (/^[A-Z]{3}$/.test(dow)) return `${dow.charAt(0)}${dow.slice(1).toLowerCase()}days ${at}`

That only spells the three abbreviations whose first-letter + lowercased-tail + "days" happens to equal the real word (MON→Mondays, FRI→Fridays, SUN→Sundays). The other four render garbage, and every one of them is reachable straight from the day-of-week stepper (DOW_LADDER):

cron rendered before correct
0 9 * * TUE Tuedays at 09:00 Tuesdays
0 9 * * WED Weddays at 09:00 Wednesdays
0 9 * * THU Thudays at 09:00 Thursdays
0 9 * * SAT Satdays at 09:00 Saturdays

The whole point of the preview is to let a user confirm a cron they can't read back, so 4/7 weekdays showing a nonsense word defeats it.

A second, narrower defect in the same function's helper (describeTimeOfDay): for an hourly schedule (hour === "*") any non-*/n minute fell through to `hourly at :${minute.padStart(2, "0")}`. A list/range minute is not a single clock minute, so 15,45 * * * * rendered every day hourly at :15,45 — a confidently-false fire time — instead of returning null the way every other unmodelled shape does.

Fix

  • Name weekdays from an explicit DOW_NAMES map instead of the slice trick.
  • Guard the hourly-minute path so it only names a plain numeric minute (/^\d+$/) and otherwise returns null, keeping the preview's "silent rather than wrong" contract.

Both changes are confined to cron-segments.ts (still ~127 lines, well under the size cap).

Verification

  • Extended test/tui/cron-segments.test.ts: the existing describeCron block only asserted MON (the one accidentally-correct case), so the bug slipped through. Added all six other weekdays plus the hourly list/range-minute cases. bun run vitest run test/tui/cron-segments.test.ts → 16 passed.
  • bun run lint and bun run typecheck both green across the workspace.

Follow-ups

None required. The bug-hunt also flagged a borderline formatRelative rounding choice (Math.round(minutes / 60) reports 90 min as "in 2h") in automation-composer.ts — left out of scope as an approximation-precision judgement call, not a clear defect.


Generated by Claude Code

The automation composer's schedule preview built a weekday phrase by
uppercasing the first letter and appending "days" to the lowercased
tail, which only spelled MON/FRI/SUN right — TUE/WED/THU/SAT rendered
"Tuedays", "Weddays", "Thudays", "Satdays", all reachable straight from
the day stepper. Name weekdays from an explicit map, and stay silent on
an hourly list/range minute (`15,45`) instead of asserting a `:15,45`
fire time the schedule never has.
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
kobe-landing Error Error Aug 5, 2026 4:33pm

Request Review

@claude

claude Bot commented Aug 5, 2026

Copy link
Copy Markdown

Claude finished @Sma1lboy's task in 1m 57s —— View job


Review in progress

  • Gather context (read CLAUDE.md, diff, changed files)
  • Run specialized review agents (code-reviewer, silent-failure-hunter, pr-test-analyzer, type-design-analyzer, comment-analyzer, code-simplifier)
  • Check kobe house rules (attribution, changeset, file-size cap, regression test)
  • Synthesize and post consolidated review

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.23077% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/kobe/src/tui/component/cron-segments.ts 69.23% 4 Missing ⚠️
Files with missing lines Coverage Δ
packages/kobe/src/tui/component/cron-segments.ts 84.28% <69.23%> (-6.90%) ⬇️

... and 398 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants