Commit 041ae8b
feat(automations): add foundation — types, storage, scheduler, leader election (#323745)
* feat(automations): add foundation — types, storage service, scheduler, leader election
Introduces the Automations subsystem core:
- IAutomation types and IAutomationSchedule (interval-based: manual/hourly/daily/weekly)
- DST-safe computeNextRunAt scheduling logic
- IAutomationService with persistent JSON ledger (StorageScope.APPLICATION)
- Optimistic concurrency via revision counter for cross-window safety
- Leader election to ensure single scheduler instance across windows
- AutomationScheduler: periodic tick loop checking due automations
- Feature gate: chat.automations.enabled setting mirrored to context key
- Unit tests for scheduling logic
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: address Copilot Code Review feedback on PR 1
- Add _unsupportedSchema guard to recordRunStart and updateRun
- Localize CRASH_RECOVERY_REASON string via nls.localize()
- Move imports above registerSingleton call in contribution file
- Fix test comment referencing wrong helper name (buildLocalDate -> localDate)
* fix: address CCR round 2 — schema guards, telemetry cleanup, scope fix
- Add _unsupportedSchema guard to markStaleRunsFailed and advanceNextRunAt
- Replace boolean telemetry flags with actual enum values (permissionLevel, isolationMode)
- Remove hasProviderId, hasSessionTypeId, hasModelId, hasMode, hasPermissionLevel flags
- Add scope: ConfigurationScope.MACHINE to runTimeoutMinutes setting
* fix: gate scheduler construction on chat.automations.enabled
AutomationSchedulerCore (and its leader election heartbeat/storage
writes) are now only constructed when the feature setting is enabled.
Uses MutableDisposable for clean teardown on runtime toggle.
Addresses CCR feedback: avoid 30s heartbeat timer + storage writes
when the feature is disabled.
* fix: isolate per-automation errors in dispatch loop
Wrap advanceNextRunAt + runOneWithTimeout in try/catch so a failure
in one automation does not abort dispatch of remaining due automations.
* fix: register automations path in i18n resources
Adds vs/sessions/contrib/automations to the translation resources
so nls.localize calls pass the eslint translation-remind rule.
* fix: validate enum fields at write boundary and harden persist()
- Normalize permissionLevel/isolationMode in createAutomation and
mergeAutomation: reject unknown values to keep persisted data and
GDPR-classified telemetry low-cardinality.
- Wrap persist() storage read and write in try/catch so storage
failures degrade gracefully instead of breaking the scheduler.
* fix: scheduler to Eventually phase, simplify persist(), document serial dispatch
- Move scheduler registration from AfterRestored to Eventually —
background concern that doesn't need to block workbench restore.
- Remove re-read-before-write in persist() — refreshFromStorage via
onDidChangeValue already handles cross-window sync. Eliminates
redundant JSON.parse on every mutation and the misleading optimistic
concurrency check that overwrote anyway.
- Document that _pendingRuns serializes dispatch intentionally.
* style: remove em dashes and obscure acronyms from comments
Replace all em dashes with periods or semicolons. Remove TOCTOU
acronym. Replace multiplication sign with plain x.
* Signing commit
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent e7bf9e8 commit 041ae8b
18 files changed
Lines changed: 2553 additions & 0 deletions
File tree
- build/lib
- src/vs
- sessions
- contrib/automations
- browser
- test/browser
- workbench/contrib/chat
- common/automations
- test/common/automations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
647 | 651 | | |
648 | 652 | | |
649 | 653 | | |
| |||
Lines changed: 164 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
0 commit comments