Skip to content

fix(webui): notify when a scheduled task finishes - #7643

Closed
github-actions[bot] wants to merge 1 commit into
mainfrom
autofix/issue-7596
Closed

github-actions[bot] wants to merge 1 commit into
mainfrom
autofix/issue-7596

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

When a scheduled task finished successfully, nothing told you. The bell stayed at "No notifications" and the answer sat unnoticed in the task's chat, because only failed runs raised a notification. Now each run that finishes cleanly adds one unread "Scheduled task "X" finished" notification to the bell. It shows the start of the answer and is linked to the task's chat. A run still in progress, a failed run, a repeat poll and old runs found at launch add nothing.

Closes #7596

Test plan

  • npx vitest run in src/gaia/apps/webui passes (3,793 tests, including 6 new ones in scheduleStore.successes.test.ts)
  • tsc -b is clean
  • Agent UI: open Scheduled tasks, click Run now, close the dialog. When the run ends, the bell shows one unread "Scheduled task "…" finished" with the start of the answer. Waiting through more polls adds no duplicate.
  • Same flow with a run that fails: you get only the existing "failed" notification, not a "finished" one.
  • Reload the app after a run: no "finished" notification for the old run.
  • npm run test:rtl, then look at the bell with the new notification in English and Arabic.

⚠️ Needs manual validation: the automated checks cover the store logic but don't show the bell. A maintainer should run the Agent UI steps above and check the screenshots before merging.

🔍 Technical details
  • stores/scheduleStore.ts: notifyNewSuccesses runs next to notifyNewFailures on every loadSchedules after the first (App-level 30 s poll plus the dialog's 5 s poll). It compares each schedule's clean runs (run_count - error_count, minus one while running) against a snapshot kept in the new cleanRunCounts.
  • The scheduler bumps run_count when a run starts (ui/scheduler.py _execute_task_once), so a poll during a run would otherwise look like a success with the previous run's last_error. While a schedule is running, its snapshot keeps the old value and no notification fires.
  • Id schedule-done-${id}-${run_count} matches the failure pattern. Title goes through getT() (new key schedules.notify.finished, en and ar). The message is last_result cut to 200 characters.
  • Like the failure notification, clicking the bell item only marks it read: NotificationCenter doesn't navigate on sessionId yet. The issue's "No chats yet." sidebar gap is separate and not touched here.
  • python util/lint.py --all reports mypy, Bandit and import-validation errors in Python files this PR doesn't touch, so they are already on main. The Python unit suite couldn't collect on this runner (responses isn't installed). This PR has no Python changes.

A scheduled run that succeeded raised nothing, so the bell stayed empty
and the answer sat unnoticed in the task's chat; only failures notified.
The schedule poll now adds an info notification, linked to the task's
chat, once per run that ends without an error. It waits for a run in
flight to end and stays silent on the first load, as failures do.

Closes #7596
@tylerbea

Copy link
Copy Markdown
Contributor

#7696 fixes the same issue (#7596), with tests and before/after screenshots. Worth comparing the two before merging either one.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Superseded by #7696, which fixes the same issue (#7596) with the same approach, a Run-now race test, and before/after screenshots.

kovtcharov-amd pushed a commit to kovtcharov/gaia that referenced this pull request Nov 12, 2026
Scheduled tasks run while the user is away, but when one finished
nothing told them; only failures reached the bell. Now a run that
finishes cleanly adds an unread "Scheduled task "<name>" finished"
notification with the start of the answer. Runs that were already done
when the app opened stay quiet, and a failed run still raises only its
error.

Closes amd#7596

| Before | After |
| --- | --- |
| <img
src="https://raw.githubusercontent.com/tylerbea/gaia/pr-shots/7596/before.jpg"
width="420"> | <img
src="https://raw.githubusercontent.com/tylerbea/gaia/pr-shots/7596/after.png"
width="420"> |

## Test plan

- [x] New `stores/__tests__/scheduleStore.finished.test.ts` (3 of 5
cases fail on main), plus all store and i18n tests (192) and `npm run
build`
- [x] Built app with the schedule list stubbed to a finished run: the
bell shows 1 unread with the finished notice
- [ ] With a real model: Run now on a task, close the dialog, and see
the notice arrive when it ends

<details>
<summary>🔍 Technical details</summary>

- `scheduleStore.ts` keeps finished-run counts per schedule (`run_count`
minus a run in flight, since the backend counts a run when it starts)
and compares them on each load, the same way it already compared error
counts.
- New string `schedules.finished` in English and Arabic.
- Not in this change: clicking a bell item doesn't open its chat for any
notification type. The notice carries the chat id, so that can follow in
`NotificationCenter`.
- The after shot stubs the schedule list and setup check, because the
empty scratch home can't complete a real run.
</details>

Note: amd#7643 is the auto-fix bot's draft for the same issue. This one
adds tests and before/after shots; keep whichever you prefer. amd#7659
changes when `run_count` goes up, so whichever merges second should
recheck the finished-run count here.
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.

[Bug]: A scheduled task that finishes sends no notification

2 participants