Skip to content

feat(extension): run Timer in API v2 background runtime - #2

Merged
Juliusolsson05 merged 1 commit into
mainfrom
feat/extension-api-v2
Sep 13, 2026
Merged

Juliusolsson05 merged 1 commit into
mainfrom
feat/extension-api-v2

Conversation

@Juliusolsson05

Copy link
Copy Markdown
Owner

Timer promises a focus timer that keeps running when its panel closes, but API v1 activates the extension inside each view document. Closing the panel destroyed the engine, its commands, the reminder schedule and the notification path.

Behavior

  • One API v2 runtime (dist/runtime.js, onStartupFinished) owns timing, commands, wall-clock persistence and reminders. The panel (dist/view.js) is an independent subscriber over published JSON state; user actions return as named runtime requests with validated input.
  • Completion and reminders use the permissioned notifications.show API, so they surface as an attributed Agent Code toast with no panel open. The chime stays in the view, where autoplay applies.
  • timer.defaultMinutes and timer.inheritTheme settings are read by the runtime. A setting change never rewrites an active deadline; a viewless Start Timer command honors the latest default.
  • Persisted state moves to version 2, which records the active reminder. Previously an app restart while a reminder awaited dismissal silently reset the session. Version 1 saved sessions remain readable.
  • An expired running session is announced once on restore and persisted as finished, so later restarts do not repeat the notification.
  • Timer publishes state once per visible second rather than on every 250 ms check.

Verification

  • npm test: 12 behavioral tests — wall-clock timing, pause/resume, delayed reminder firing, reminder restore, expiry announced once, long-sleep correction, publication rate, invalid mutations, runtime settings, active-deadline protection, viewless start, malformed actions.
  • npm run typecheck, NODE_ENV=production npm run build, and npm run test:extension (independent runtime/view entries; audio only in the view bundle).
  • Agent Code's production Electron journey installs this committed bundle through the real installer and custom scheme, mounts/closes/reopens the panel into a fresh sandbox document, starts the timer with a cold command while no view exists, and verifies the countdown advanced while the panel was closed.

Dependencies

Merge after both dependencies. The installed extension requires an Agent Code build containing API v2.

Fixes #1

🤖 Generated with Claude Code

https://claude.ai/code/session_01SnzR4ggdHfDfmFcTA7H8kw

Move timer ownership out of the disposable panel and into one startup runtime so commands, wall-clock deadlines, settings, reminders, and app notifications survive with zero views. Preserve v1 saved data and add a v2 state shape that restores an in-progress reminder instead of silently resetting it.\n\nRefs #1\nRefs Juliusolsson05/agent-code#934
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.

feat(extension): migrate Timer to API v2 background runtime

1 participant