You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c7b0f23
Browse filesBrowse the repository at this point in the historyBrowse files
feat(desktop): notify when a background design run finishes (#472)
## Summary
Long runs, especially on local models (see #411), often finish while the
user is in another app. This shows a system notification when a live run
settles as completed or failed, or when the agent asks a question, while
the Open CoDesign window is unfocused. The notification is titled with
the design name; clicking it focuses the window and opens that design.
Cancelled, interrupted, and replayed runs do not notify. Window focus is
checked after the setting is read, so returning to the app meanwhile
suppresses the notification; a failed read, or a failed focus or design
switch after a click, is logged. The main process installs no permission
handler, so Electron allows the renderer `Notification` API.
Settings → Advanced has a "System notifications" checkbox. It is stored
in `preferences.json`, which moves to schema version 10. New installs
start with it on. Installs upgraded from schema 9 or earlier keep it off
until the user turns it on, so an update does not start sending
notifications nobody asked for; the changeset (and so the release notes)
says this and names the switch, which also turns notifications off.
On Windows the main process sets the AppUserModelID to the
electron-builder `appId` (`ai.opencowork.codesign`, from
`apps/desktop/electron-builder.yml`), which the NSIS Start Menu shortcut
carries; Windows only shows toasts for that ID. This has not been
checked on a Windows machine.
Known limit, left for a follow-up: notifications come from the renderer.
On macOS, closing the last window keeps the app running without a
renderer, so runs that settle after that are not announced until a
window is open again. The settings hint and the changeset both state
this.
## Type of change
- [ ] Bug fix
- [x] New feature
- [ ] Refactor (no behavior change)
- [ ] Documentation
- [ ] Build / CI / tooling
- [ ] Breaking change
## Linked issue
Refs #411 (overnight local runs). It does not change the timeout.
## Checklist
- [x] I checked the linked issue / relevant context before starting
- [x] `pnpm lint && pnpm typecheck && pnpm test` passes locally
- [x] Added/updated tests for the change
- [x] Added a changeset (`pnpm changeset`) if user-visible
- [ ] Updated docs if behavior changed
## Dependency additions (if any)
None.
## Screenshots / recordings (UI changes)
Not attached. Settings → Advanced gains one checkbox row.
## Checks
- Pre-push `pnpm -r typecheck && pnpm lint && pnpm test` with `CI=1`
(the repo's two-worker limit): 10 tasks passed; desktop 179 files, 2,622
tests. `pnpm lint` checked 680 files.
- `useAgentStream.completion.test.ts`: live `run_settled` events notify
for completed and failed runs only (this test fails without the hook
change); outcomes recovered after a refresh do not notify (fails if the
replay check is removed)
- `lib/system-notifications.test.ts`: design title and click behaviour,
focused window, focus regained during the setting read, a failed click
logged, setting off, unknown design
- `preferences-ipc.test.ts`: on for new installs (no file), off for
files from schema 9 and still off after another preference is saved
(both fail without the migration), update round trip at schema 10,
non-boolean values rejected
The notification has not been exercised in a running desktop app or with
a live model. Still to check on an installed Windows build: completed,
failed, and question notifications while the app is in the background; a
click restoring a minimized window and opening that design; nothing
shown while the app is focused, for cancelled runs, for replayed
history, or with the setting off. The unit tests above cover these cases
in the renderer, except the question notification wiring in `App.tsx`;
restoring a minimized window is done by `win.restore()` in the
main-process `codesign:v1:focus-window` handler, which has no unit test.
Send a system notification when a design run completes or fails, or when the agent asks a question, while the window is in the background. Clicking it brings the window back and opens that design. New installs start with notifications on. Installs upgraded from an earlier version keep them off until you turn on Settings → Advanced → System notifications; the same switch turns them off. On macOS, notifications stop after the last window is closed, until it is opened again. Preferences move to schema version 10.
0 commit comments