Skip to content

fix(ui): reject schedules the parser can't read instead of guessing - #5569

Merged
kovtcharov-amd merged 2 commits into
amd:mainfrom
kovtcharov:kalin/schedule-parser-fail-loudly
Oct 23, 2026
Merged

kovtcharov-amd merged 2 commits into
amd:mainfrom
kovtcharov:kalin/schedule-parser-fail-loudly

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

"tomorrow at noon" silently became a daily job, "daily at 25:00" dropped its time, "on feb 30 at 9am" ran every day, "every tuesday" first ran a week late, and "every 1s" started a full agent turn every second. The schedule parser now reads every word or rejects the schedule with a plain fix, such as "25:00 isn't a time — use 0:00–23:59." The schedule form also gains visible field labels, shows that reason under the field, and stops resetting Delete's "Confirm?" before a slow reader can click it.

Test plan

  • pytest on the scheduler and gaia schedule tests (tests/unit/test_scheduler*.py, tests/unit/test_schedule_*.py, tests/integration/test_scheduler_e2e.py): 338 passed, 1 skipped
  • pytest tests/unit/chat -n 4: 2162 passed, 4 skipped
  • vitest run (webui): 1528 passed; tsc --noEmit clean
  • python util/lint.py --black --isort and --flake8 clean
  • In the Agent UI, open Scheduled tasks > New schedule and type tomorrow at noon, daily at 25:00, every tuesday. The first two show "GAIA didn't understand that schedule." with the reason. The third previews next Tuesday.
🔍 Technical details
  • parse_schedule_input removes each piece it understands (dates and one-off phrasing, at <time>, from X to Y, days, interval) and rejects anything left over. Its return contract is unchanged: interval_seconds=0 plus the reason in description. create_task no longer falls back to the laxer parse_interval, so the API's 400 carries the same reason.
  • There is no one-shot concept to reuse. gaia schedule is cron-only, and the daemon scheduler's KIND_ONE_SHOT isn't wired to the UI scheduler, so one-time phrasing is rejected with a recurring suggestion.
  • Minimum interval: neither scheduler had a floor, so I used 60 s, which matches cron's granularity (MIN_INTERVAL_SECONDS). The timer tests that need 1 s schedules lower it with a monkeypatch fixture.
  • every other <second|minute|hour|day|week> maps to an interval of 2. every other tuesday is rejected because it needs an anchor week the config doesn't store. The same goes for a time of day combined with intervals other than daily/weekly (every 2 days at 9am used to fire daily) and for set days with multi-week intervals.
  • Windows that don't start on the hour (from 9:30am) were silently rounded down. They are now rejected, and the existing test that asserted the rounding is updated.
  • compute_next_run: days-only daily/weekly schedules pick the next listed day at the current clock time. Before, they added the full interval first and then walked forward, landing a week late. Other intervals keep the old path.
  • Saved rows aren't re-parsed on load, so they behave as before. A test loads an every 2 days at 9am row and a 1 s row.
  • ScheduleManager.tsx: the three fields have <label htmlFor> labels. The rejection text is linked to the schedule field with aria-describedby, and the field gets aria-invalid. The Delete confirm window is 8 s (CONFIRM_DELETE_MS), its timer lives in a ref, and the timer is cleared on every toggle and on unmount.

The Agent UI schedule parser silently dropped what it didn't understand:
"tomorrow at noon" became a daily job, "daily at 25:00" lost its time,
"on feb 30 at 9am" ran daily, and "every 1s" ran a full agent turn every
second. It now reads every word or rejects the schedule with a plain fix.

- Invalid times, dates, one-time phrasing, leftover words, and runs more
  often than once a minute are rejected with an actionable message.
- "every other <unit>" is an interval of 2; "every other tuesday" and
  intervals that can't combine with a time or set days are rejected.
- "every tuesday" now first runs on the next Tuesday, not a week later.
- Saved schedules keep their stored config and load unchanged.
- Schedule form: visible field labels, the rejection reason is shown and
  tied to the field, and Delete's confirm window is 8 s with its timer
  cleared on re-arm and unmount.
@github-actions github-actions Bot added documentation Documentation changes tests Test changes electron Electron app changes labels Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Request changes. The code is sound; the only thing missing is proof from the real app.

The scheduler used to quietly guess at schedules it couldn't fully read. tomorrow at noon became a daily job, daily at 25:00 lost its time, and every tuesday first ran a week late. Now every word has to be understood or the schedule is rejected with a plain fix, and the form gets labels and a Delete confirm that waits long enough to click. I ran about 50 common phrasings through the new parser and every one gave the right result or a clear, fixable rejection. I found no correctness bugs.

Blocking:

  • Show it working in the Agent UI. This changes what users see in the New schedule form, but the PR has no screenshot and no captured /api/schedules request and response. The only manual check is still unticked. Add before→after screenshots of a rejected schedule (e.g. daily at 25:00) and an accepted one (every tuesday). If that has to wait for the Strix Halo lane, the real request and response with the rejection text would do for now.

Worth knowing (not blocking): weekly at 9am and every 7d at 9am used to be accepted and are now rejected with "Say which day to run on." That's arguably right, but it is a behaviour change for anyone typing those forms.

Real-world evidence

N/A: no evidence bundle was produced for this run, and the PR shows none for the UI or the API. The verdict rests on static review, plus the parser probe described under Technical details. No Agent UI or HTTP path was exercised here.

🔍 Technical details

Parser probe. I loaded src/gaia/ui/scheduler.py directly, because the full gaia import needs openai and dotenv, which this runner lacks. All of these parsed correctly: every 30m, every hour from 8am to 6pm on weekdays, mon-fri at noon, every mon, wed and fri at 9am, from 10pm to 2am every hour, every hour between 9am and 5pm, every 5 m from 9 am to 5 pm, every 24 hours at 9am, every 168 hours, daily at noon on sun, every friday at 5pm.. Rejections came back with usable hints: every 30 seconds, noon daily (suggests "Put 'at' before the time"), every 2 weeks on monday, every monday at 9am, wednesday at 9am.

🟡 No UI or API evidence for a user-visible change. See the blocking item above. The rubric asks for a screenshot for Agent UI changes, or at least the underlying HTTP route evidence.

🟢 weekly at 9am is now rejected (scheduler.py:951). Before, it was accepted. The rejection message is clear. If it's intended, consider listing it in the "It rejects" section of docs/guides/agent-ui.mdx alongside the other combinations.

🟢 parse_interval is now dead in production (scheduler.py:92). With the fallback gone from create_task, only tests/unit/test_scheduler.py calls it, and it still accepts every 30s, which the real path now refuses. Consider removing it, or marking it legacy so nobody wires it back in as a lax path.

🟢 Leftover string concatenation (scheduler.py:778). This is an artifact of a black reflow:

            "Give one time per schedule — for two times a day, create two schedules."

Strengths

  • Each recognised phrase is consumed and anything left over is rejected. That removes the whole class of half-read schedules, and create_task no longer falls back to the laxer parser, so the API's 400 carries the same reason the preview shows.
  • The compute_next_run fix for schedules with days but no time is narrowly scoped to daily and weekly intervals. Saved rows aren't re-parsed, and there's a test proving legacy every 2 days at 9am and 1 s rows still load.
  • The form work is done properly: htmlFor labels, aria-invalid and aria-describedby on the field, and a ref-held confirm timer cleared on unmount. The vitest coverage checks the accessible description rather than just the text.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Merge note: #5538, #5539 and #5569 all touch the schedule form, so the second and third to merge need two small test updates (no product-code conflict beyond one message).

🔍 Technical details

Found while building all three together:

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Checked live in the Agent UI's New schedule form: impossible schedules are refused with the reason, and weekly ones get the right next run.

Schedule rejected with a reason

🔍 Technical details
  • "tomorrow at noon" → "One-time tasks aren't supported yet — a schedule repeats. Try … 'daily at 9am' …" (before: saved as a daily job)
  • "daily at 25:00" → "25:00 isn't a time — use 0:00–23:59." (before: daily, time dropped)
  • "every tuesday at 9am" → "Every Tuesday at 9:00 AM · Next run 10/27/2026 9:00 AM" (before: next run a week late)

parse_interval had no production caller once create_task stopped falling
back to it, and it still accepted forms the real parser refuses, so it is
removed with its tests. The ReDoS digit-run check now targets
parse_schedule_input. Joins an implicitly concatenated string that failed
pylint W1404, and documents that a weekly time needs a day.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Fixed the red Code Quality check and took the three cleanup suggestions. The Agent UI evidence the review asked for is in this comment: a refused daily at 25:00 and an accepted weekly schedule in the live New schedule form.

🔍 Technical details
  • CI root cause: pylint W1404 (implicit string concatenation) at scheduler.py:518, the black-reflow leftover the review flagged. Joined into one literal.
  • parse_interval removed. No production caller remained and it still accepted every 30s. Its tests went with it; the >9-digit ReDoS check now runs against parse_schedule_input.
  • weekly at 9am / every 7d at 9am: the rejection is intended. Added to the "It rejects" list in docs/guides/agent-ui.mdx, plus an every 7d at 9am case in the strict-parse table.
  • Tests: scheduler unit/API/e2e + tests/unit/chat -n 4 pass (2283). One chat test fails only when GAIA_HOME is set, because it patches HOME itself, and passes without it. util/lint.py --all is clean. Webui tsc, vitest (1528) and build pass.
  • Commit: fc90244

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 23, 2026
Merged via the queue into amd:main with commit 6185144 Oct 23, 2026
41 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/schedule-parser-fail-loudly branch October 23, 2026 07:15
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Oct 23, 2026
Tab could walk out of an open dialog and onto the page hidden behind it.
In Settings, 26 presses landed on the sidebar's resize handle under the
overlay, so a keyboard or screen-reader user ended up operating a page
they couldn't see. Now Tab and Shift+Tab wrap inside every modal in the
Agent UI, including when its content changes while open. Escape and
returning focus to the opener work exactly as before.

- **Covered:** Settings, Document library, Scheduled tasks, File
browser, Mobile access, Version picker, Context panel, both change
reviews, the commit/PR dialog, the folder picker, and the Memory
beta-confirm dialog (same behaviour, now through the shared hook).
- **Session panel:** trapped only in its narrow-window overlay form,
where it has a backdrop and already sets `aria-modal`. Docked, it sits
alongside the page and sets no `aria-modal`, so it is left alone. No
`aria-modal` attribute needed correcting.
- **Merge conflicts:** each component change is an import, a ref and one
hook call. That keeps it light against the open PRs on DocumentLibrary
(amd#5605) and ScheduleManager (amd#5538, amd#5569).

## Test plan

- [x] `npx vitest run src/hooks/__tests__/useFocusTrap.test.tsx`: wraps
forward and back, skips disabled and hidden elements, re-reads changed
content, pulls focus in from outside, only the innermost of nested traps
acts, inactive does nothing
- [x] `npx vitest run
src/components/settings/__tests__/SettingsDialogFocus.test.tsx`: Tab
from the last control in Settings returns to the first section button
- [x] `MemoryDashboard.a11y.test.tsx` still passes on the shared hook
- [x] Disabling the hook makes all 8 trap tests fail
- [x] Full `npx vitest run` (146 files, 1532 tests) and `npx tsc
--noEmit` pass
- [ ] Electron jest size check (`reasonably sized component files`):
none of the touched files is close to the cap. On a Windows CRLF
checkout the check fails on main for `ChatView.tsx` (101,751 bytes in
git, 103,725 on disk), which this PR doesn't touch. Confirm it is green
in CI.
- [x] Desktop app: open Settings (Ctrl+,) and hold Tab. Focus cycles
inside the dialog and never reaches the sidebar. Esc still closes it and
returns focus to the opener.
kovtcharov-amd added a commit that referenced this pull request Oct 23, 2026
#5539 made Schedule.last_error required and #5569's fixture predates it, so
the frontend typecheck failed once both were on main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes electron Electron app changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants