Repository navigation
feat(warmup): add per-account daily first warm-up start time - #64
Conversation
Allow setting an optional daily start time per account so automatic five-hour window warm-ups begin at the chosen time of day (in the Mac's timezone), continue auto-scheduling until midnight (while avoiding late-night warm-ups within five hours of tomorrow's start time), and wait until the next day's start time overnight. If a five-hour window is already active or fully depleted at the configured start time, Tally waits for it to reset and resumes auto-scheduling from there.
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
Pull Request Review
Confidence Score: 6/10
Editing the time can resume an Account after an ambiguous send, and a late time the picker accepts can repeatedly miss the warm-up even while Tally is awake. Three other findings cover midnight DST, a queued start after a timezone change, and a stale web form overwriting a separate edit.
Before merging, decide how close to midnight the picker should allow a start. Full 1-second to 20-minute jitter, a post-schedule quota reading, and a hard midnight cutoff cannot all fit for every minute the picker accepts. Keep one explicit save for a finished time edit; the web write queue and native save revisions only exist because intermediate picker values are written to the owner.
Reviewed 82f4e28543daeb4cae43c48d1ded795a743044cc. git diff --check passed. I ran a Swift stdin check against the pinned scheduler with synthetic quota readings for the timing cases; I did not run the full suite, send provider warm-ups, or use reset credits.
Originally created in OpenCode session ID: ses_df47d891effeeQTw9sJJJgS9Hx using model: openai/gpt-6.2-sol-fast
| let previous = store.state.namespaces[namespace]?.warmups | ||
| var value = previous?[accountID] ?? WarmupStatus() | ||
| value.enabled = enabled; value.model = model | ||
| if case let .some(nextStartTime) = startTime { value.startTime = nextStartTime } |
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
P2: Changing the clock time silently resumes paused warm-ups
A first-warm-up edit takes the same path as an explicit Resume. It clears suspended, changes the attempt revision, and cancels any in-flight send. On an Account paused after an interrupted or unconfirmed request, selecting a time can therefore restart automatic sends without the user clicking Resume. If a send is already in flight, the revision change also makes finishWarmup discard its result. Treat a time-only edit as a future-schedule change: preserve suspension, the attempt revision and any in-flight send, and reserve resuming for an explicit action. Add a mocked-owner test that edits only the time after a failed send.
Originally created in OpenCode session ID: ses_df47d891effeeQTw9sJJJgS9Hx using model: openai/gpt-6.2-sol-fast
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. Added TallyOwner.setWarmupStartTime plus partial {"startTime": ...} support on PUT /api/v1/accounts/{id}/warmup, and guarded start-time-only updateWarmup calls so editing the start time preserves suspended, revision, message, enabled, and any in-flight warm-up task while explicit Resume still clears suspension.
| let candidate = allowed.addingTimeInterval(delay) | ||
| if candidate < window.cutoff { return candidate } | ||
| if allowed == window.start { | ||
| let maxOffset = max(0, window.cutoff.timeIntervalSince(window.start) - 1) |
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
P2: A valid late start can miss the warm-up every day
With a 23:59 start and a 10-minute jitter sample, the scheduler clamps nextAt to 23:59:59. prepare then needs a quota reading observed at or after 23:59:59 and a scheduler tick before midnight. Normal quota polling runs every two minutes, so an idle Account with a reading at 23:59:01 misses the send; a new reading at midnight only schedules tomorrow. I reproduced this with the pinned scheduler. The late-start test checks the displayed timestamp without checking whether the send can happen. Either constrain the supported times to leave room for jitter and a fresh read, or agree on different late-start jitter/collection behavior and exercise the actual send in the test.
Originally created in OpenCode session ID: ses_df47d891effeeQTw9sJJJgS9Hx using model: openai/gpt-6.2-sol-fast
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. WarmupStatus.setScheduledTime now reserves 180s of quota-poll headroom (pollHeadroom) before daily cutoffs across both regular and narrow late-night windows, backed by an owner-level 23:55 test under 120s polling with max jitter and a 23:59 rollover check.
|
|
||
| private static func activeWindow(for date: Date, hour: Int, minute: Int, calendar: Calendar) -> (start: Date, cutoff: Date, nextStart: Date) { | ||
| let dayStart = calendar.startOfDay(for: date) | ||
| let nextDayStart = calendar.date(byAdding: .day, value: 1, to: dayStart)! |
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
P3: A midnight DST transition uses the wrong tomorrow cutoff
In America/Havana on March 8, 2026, startOfDay is 01:00. Adding a calendar day produces March 9 at 01:00 rather than 00:00; searching from there for a configured 00:30 returns March 10. The scheduler allows March 8 at 21:00 even though the real cutoff for March 9 at 00:30 is March 8 at 19:30. Use the current local day interval’s end for the next day boundary and add a midnight-transition fixture.
Originally created in OpenCode session ID: ses_df47d891effeeQTw9sJJJgS9Hx using model: openai/gpt-6.2-sol-fast
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. WarmupStatus.activeWindow now uses calendar.dateInterval(of: .day, for: date) for exact local day start/end boundaries, with a regression test for America/Havana on March 8, 2026.
| } | ||
| let earliest = Self.earliestAllowedStart(at: now, startTime: startTime, timezone: timezone) | ||
| if earliest > now { | ||
| if nextAt == nil || nextAt! < earliest || !Self.isAllowedStart(nextAt!, startTime: startTime, timezone: timezone) { |
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
P3: A timezone change can delay the first warm-up by hours
nextAt is an absolute timestamp. If the Mac changes from Los Angeles to New York after pre-scheduling 04:10 Pacific, it becomes a valid daytime instant at 07:10 Eastern. This branch holds onto it even when it runs at 03:01 Eastern, so a 04:00 local start misses its intended jitter interval. Invalidate or recompute the pending schedule when the Mac timezone changes, while retaining the actual attempt and quota-reset timestamps. Cover the case where the old time is still allowed in the new timezone.
Originally created in OpenCode session ID: ses_df47d891effeeQTw9sJJJgS9Hx using model: openai/gpt-6.2-sol-fast
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. Added optional scheduleTimeZone on WarmupStatus (cleared when startTime == nil or nextAt == nil) so pending schedules recompute when the Mac timezone changes, verified with a Pacific-to-Eastern test.
| <label className="warmup-model"><span>Model</span> | ||
| <select value={selected} disabled={disabled || saving || loading || !models.length || !!unavailable} aria-label={`Warm-up model for ${providerName(account.provider)} ${account.name}`} | ||
| onChange={event => { setSelected(event.target.value); void change(true, event.target.value) }}> | ||
| onChange={event => { setSelected(event.target.value); void change(true, event.target.value, startTime) }}> |
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
P3: A model-only web edit can clear another client’s schedule
The web client always sends the form’s copy of startTime. If the browser still shows Any time, the Mac sets 04:00, and someone changes the model before the browser’s next poll, the model PUT includes startTime: null and silently restores 24/7 warm-ups. The API already knows how to distinguish omission from clearing. Omit the field on changes to model, toggle, or Resume unless the user is also saving a new or cleared time.
Originally created in OpenCode session ID: ses_df47d891effeeQTw9sJJJgS9Hx using model: openai/gpt-6.2-sol-fast
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. Both web and macOS Settings now omit startTime on model, toggle, and Resume writes unless locally dirtied before initial enable, and send time-only patches for start-time edits through a per-account single-flight coalescing writer.
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using Claude Opus 5.5
Pull Request Review
Council review of 82f4e28 against Max's three design decisions (resume after an active or depleted window, 5-hour overlap guard before tomorrow's start, normal 1s to 20m jitter, optional per-account "Any time" default).
Scheduler. I traced earliestAllowedStart, activeWindow, and scheduledTime through every prepare branch. Each one honors the start time: active and depleted windows defer via scheduledTime(from: reset), which clamps into the next allowed window; the idle path refuses to fire once now passes the cutoff (the late-wake case at 23:02 is covered by the "Waiting for daily start time" branch, not only by the nextAt check); the cutoff min(midnight, nextStart - 5h) is always after start because 19 hours separate them on every day, including 23-hour DST days; and every nextAt that scheduledTime returns passes isAllowedStart, so the new !isAllowedStart(nextAt!) conditions do not cause jitter re-rolls on each tick. Legacy accounts (startTime == nil) take the unchanged path except that the "Scheduled after the current window" branch now also recomputes when nextAt == nil, which only fills a gap. Legacy JSON decodes with startTime == nil, and older builds ignore the new key, so rollback is safe.
Findings. No blocking defects. Two P3 issues are in the editing path, not the scheduler: clearing one segment of the web time input persists "Any time" and unmounts the field mid-edit, and every start-time save clears the suspended latch and cancels an in-flight warm-up, so the new high-frequency control acts as an implicit Resume. Two P4 items: README and docs/verification/window-warmup.md still describe the warm-up API and behavior without the start time, and the web time input gives no hint that the time is in the Mac's timezone even though the component already receives timezone.
Checks run locally (Command Line Tools Swift 6.4 with the MacOSX26 SDK, not CI-equivalent): bash scripts/test-swift.sh --build-system native --filter 'warmup|routesEnforcePolicy' passed 21 tests; tsc --noEmit in web/ passed; npm --prefix web test passed 21 tests. No live provider sends.
Confidence Score: 8/10
Originally created in OpenCode session ID: ses_df47d8ea9ffeulc4eYSDYh24cp using model: anthropic/claude-opus-5-5
| <input id={timeID} type="time" value={startTime} disabled={disabled || !!unavailable} | ||
| aria-label={`First warm-up time for ${providerName(account.provider)} ${account.name}`} | ||
| onChange={event => { | ||
| const next = event.target.value || null |
There was a problem hiding this comment.
Code Review by OpenCode using Claude Opus 5.5
P3: Clearing one segment of the time input persists "Any time"
<input type="time"> reports value === "" whenever the field is incomplete, for example after Backspace in the hour segment in Chrome or Edge, or the Clear button in iOS Safari's picker. This handler turns that into null, immediately PUTs startTime: null, and the startTime !== null branch unmounts the input and shows "Any time". A user retyping the hour loses the field and silently reverts the account to 24/7 warming, which is the opposite of what they were doing. The dedicated "Any time" button already covers the clear case.
Ignore incomplete values here and keep the button as the only way to clear:
| const next = event.target.value || null | |
| const next = event.target.value | |
| if (!next) return |
Originally created in OpenCode session ID: ses_df47d8ea9ffeulc4eYSDYh24cp using model: anthropic/claude-opus-5-5
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. WarmupPreferences.tsx now ignores empty or incomplete <input type="time"> values (requiring /^\d{2}:\d{2}$/) so clearing a segment never unmounts the input or saves null, keeping clearing exclusively on the Any time button.
| value.enabled = enabled; value.model = model | ||
| if case let .some(nextStartTime) = startTime { value.startTime = nextStartTime } | ||
| value.revision = UUID().uuidString | ||
| value.nextAt = nil; value.resetAt = nil; value.suspended = false |
There was a problem hiding this comment.
Code Review by OpenCode using Claude Opus 5.5
P3: Start-time edits act as an implicit Resume and cancel in-flight sends
Every updateWarmup call clears suspended and, two lines down, cancels warmupTask when this account is warming. That was tolerable when the only callers were the toggle, the model picker, and Resume, all deliberate acknowledgments. This PR adds a control that saves on every change: each macOS DatePicker step and each web <input type="time"> input event issues a separate save. Two consequences:
- An account paused after an ambiguous or failed send (
needsAttention) resumes as soon as the user nudges the start time. The README tells users to toggle off and on, or press Resume, after resolving the cause; adjusting the time is not that acknowledgment. - Editing the time while a warm-up request is in flight cancels it.
finishWarmupthen drops the result on the revision mismatch,lastAttemptAtstays set, and the next automatic attempt waits 5 hours, so a time tweak can quietly cost a window.lastAttemptAtdoes prevent a double send.
When only startTime changes (same enabled and model), keep suspended and do not cancel the running task; only recompute nextAt/resetAt. A small let scheduleOnly = previous?[accountID].map { $0.enabled == enabled && $0.model == model } ?? false guard around the suspended = false and the cancel is enough.
Originally created in OpenCode session ID: ses_df47d8ea9ffeulc4eYSDYh24cp using model: anthropic/claude-opus-5-5
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. Added TallyOwner.setWarmupStartTime plus partial {"startTime": ...} support on PUT /api/v1/accounts/{id}/warmup, and guarded start-time-only updateWarmup calls so editing the start time preserves suspended, revision, message, enabled, and any in-flight warm-up task while explicit Resume still clears suspension.
| <label htmlFor={startTime !== null ? timeID : undefined}>First warm-up</label> | ||
| <div className="warmup-time-control"> | ||
| {startTime !== null ? <> | ||
| <input id={timeID} type="time" value={startTime} disabled={disabled || !!unavailable} |
There was a problem hiding this comment.
Code Review by OpenCode using Claude Opus 5.5
P4: The time input does not say which timezone it uses
The scheduler interprets startTime in the Mac's timezone, and this component already receives timezone and uses it for the "Next warm-up" timestamp. The input shows a bare clock time, so from a phone in another timezone "04:00" reads as local time. Show the zone next to the control, for example a <small> with timezone or a title on the input, so the value is unambiguous.
Originally created in OpenCode session ID: ses_df47d8ea9ffeulc4eYSDYh24cp using model: anthropic/claude-opus-5-5
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. WarmupPreferences.tsx now displays the Mac's timezone next to the time picker whenever it differs from the browser's timezone, and README.md documents daily start times and late-minute best-effort behavior.
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using Gemini 4 Neon
Pull Request Review
Reviewed PR #64 at commit 82f4e28543daeb4cae43c48d1ded795a743044cc across Sources/TallyCore/Warmup.swift, Sources/TallyCore/TallyOwner.swift, Sources/TallyHTTP/TallyHTTP.swift, Sources/TallyApp/TallySettings.swift, web/src/WarmupPreferences.tsx, web/src/api.ts, web/src/style.css, and the added Swift tests. Local checks ran SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk bash scripts/test-swift.sh --build-system native (105 tests passed; Command Line Tools Swift 6.4, not CI-equivalent Xcode) and npm --prefix web test (21 tests passed).
The core scheduling rules in Warmup.swift match the confirmed requirements: DST-aware min(midnight, tomorrowStart - 5h) cutoff, quiet-hours deferral, active/depleted window resume after reset, preserved jitter, legacy JSON decoding, and omitted-vs-null HTTP semantics. Five concrete defects should be addressed before merge (3 P2, 2 P3): editing startTime clears the suspended safety lock, macOS DatePicker saves can race out of order onto disk, clearing <input type="time"> in the web UI unmounts the field mid-edit and saves null, late start times clamp to 23:59:59 and starve behind the 120s quota poll window, and Next warm-up disappears for up to 15 seconds in the web UI after editing start time.
Confidence Score: 7/10
Originally created in OpenCode session ID: ses_df47d8471ffeDZZV4L22pW0Jhk using model: github-copilot/gemini-4-neon
| value.enabled = enabled; value.model = model | ||
| if case let .some(nextStartTime) = startTime { value.startTime = nextStartTime } | ||
| value.revision = UUID().uuidString | ||
| value.nextAt = nil; value.resetAt = nil; value.suspended = false | ||
| value.message = enabled ? "Waiting for quota information" : "Off" |
There was a problem hiding this comment.
Code Review by OpenCode using Gemini 4 Neon
P2: Editing startTime silently clears suspended and cancels in-flight warm-ups
updateWarmup unconditionally sets value.suspended = false, rotates value.revision, resets value.message, and cancels warmupTask (line 297) on every save. Both Sources/TallyApp/TallySettings.swift:204 and web/src/WarmupPreferences.tsx:139 set canSaveEnabled = status.enabled || ... and leave the First warm-up controls enabled while status.needsAttention is true. Changing startTime on a suspended account therefore bypasses the crash/interruption pause lock and wipes out the error banner without an explicit Resume or toggle off/on. Worse, when a warm-up failed with warmup_model_unavailable (TallyOwner.swift:344 clears lastAttemptAt), the Resume button is intentionally disabled because the saved model is absent from models, yet editing startTime clears suspended = false and immediately triggers a new send with that broken model. Similarly, changing startTime while a warm-up send is in flight cancels warmupTask and causes finishWarmup (TallyOwner.swift:340) to discard the send result on revision mismatch.
Treat a start-time-only change (enabled == value.enabled && model == value.model && nextStartTime != value.startTime) separately: persist value.startTime without clearing value.suspended, value.message, or value.revision, and without cancelling an in-flight warmupTask. Only clear nextAt and resetAt when the account is not suspended and not currently sending.
Originally created in OpenCode session ID: ses_df47d8471ffeDZZV4L22pW0Jhk using model: github-copilot/gemini-4-neon
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. Added TallyOwner.setWarmupStartTime plus partial {"startTime": ...} support on PUT /api/v1/accounts/{id}/warmup, and guarded start-time-only updateWarmup calls so editing the start time preserves suspended, revision, message, enabled, and any in-flight warm-up task while explicit Resume still clears suspension.
| private func save() async { | ||
| saveRevision += 1 | ||
| let revision = saveRevision | ||
| let nextEnabled = enabled | ||
| let nextModel = selected | ||
| let nextStartTime = startTime | ||
| saving = true | ||
| defer { saving = false } | ||
| defer { if saveRevision == revision { saving = false } } | ||
| do { | ||
| try await runtime.owner.setWarmup(accountID: account.id, enabled: enabled, model: selected) | ||
| runtime.warmups = await runtime.owner.warmupStatuses() | ||
| error = nil | ||
| } catch let fault as Fault { error = fault.message; enabled = status.enabled } | ||
| catch { self.error = "Could not save warm-up preferences."; enabled = status.enabled } | ||
| try await runtime.owner.setWarmup(accountID: account.id, enabled: nextEnabled, model: nextModel, startTime: nextStartTime) | ||
| if saveRevision == revision { | ||
| runtime.warmups = await runtime.owner.warmupStatuses() | ||
| error = nil | ||
| } |
There was a problem hiding this comment.
Code Review by OpenCode using Gemini 4 Neon
P2: Unserialized DatePicker saves can execute out of order and persist a stale startTime
DatePicker is intentionally left enabled while saving (TallySettings.swift:251), and every keystroke or stepper tick spawns a fresh unstructured Task { await save() } (TallySettings.swift:315). Unstructured Task creation does not guarantee FIFO execution across the hop from @MainActor to the TallyOwner actor: a newer edit (06:00) can enter owner.setWarmup before an older edit (05:00), letting the older task overwrite accounts.json with 05:00. saveRevision only suppresses UI updates from older tasks; it does not stop the older actor call from persisting stale state, which displayTask then pulls back into the UI a second later. web/src/WarmupPreferences.tsx:24,51 added a promise queue for this exact concurrency problem, but the native macOS view does not serialize writes.
Serialize (or coalesce to the latest pending (enabled, selected, startTime)) saves inside WarmupSettings using a single active save loop/task so actor writes execute in order and rapid picker edits collapse into one final disk write.
Originally created in OpenCode session ID: ses_df47d8471ffeDZZV4L22pW0Jhk using model: github-copilot/gemini-4-neon
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. Replaced unstructured per-edit Task writes in TallySettings.swift with a single-flight coalescing save loop (enqueueSave/drainSaves) and moved the DatePicker reference date to Jan 1 so spring-forward DST hours do not shift.
| {startTime !== null ? <> | ||
| <input id={timeID} type="time" value={startTime} disabled={disabled || !!unavailable} | ||
| aria-label={`First warm-up time for ${providerName(account.provider)} ${account.name}`} | ||
| onChange={event => { | ||
| const next = event.target.value || null | ||
| setStartTime(next) | ||
| if (canSaveEnabled) void change(true, selected, next) | ||
| }} /> |
There was a problem hiding this comment.
Code Review by OpenCode using Gemini 4 Neon
P2: Clearing <input type="time"> unmounts the input mid-edit and immediately saves Any time
When a user deletes digits with Backspace/Delete on desktop browsers or taps Clear/Reset in the iOS Safari time picker, <input type="time"> emits an onChange event with event.target.value === "". Line 178 converts "" to null, calls setStartTime(null), and fires change(true, selected, null). Because line 174 conditionally mounts the <input> on startTime !== null, clearing the field while typing a new time immediately unmounts the input out from under the user, drops keyboard focus, dismisses the mobile wheel picker, and persists startTime: null to the server. In addition, every intermediate wheel tick or arrow press queues a separate sequential PUT request in useWarmups.save without coalescing.
Keep the time input mounted while editing: ignore empty intermediate values in onChange (reserving clearing to null for the explicit Any time button), and commit on blur/debounce or coalesce pending per-account writes in useWarmups.save so scrolling the picker does not fire a burst of sequential PUTs.
Originally created in OpenCode session ID: ses_df47d8471ffeDZZV4L22pW0Jhk using model: github-copilot/gemini-4-neon
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. WarmupPreferences.tsx now ignores empty or incomplete <input type="time"> values (requiring /^\d{2}:\d{2}$/) so clearing a segment never unmounts the input or saves null, keeping clearing exclusively on the Any time button.
| if candidate < window.cutoff { return candidate } | ||
| if allowed == window.start { | ||
| let maxOffset = max(0, window.cutoff.timeIntervalSince(window.start) - 1) | ||
| return window.start.addingTimeInterval(min(delay, maxOffset)) | ||
| } | ||
| let nextWindow = Self.activeWindow(for: window.nextStart, hour: hour, minute: minute, calendar: calendar) | ||
| let maxOffset = max(0, nextWindow.cutoff.timeIntervalSince(nextWindow.start) - 1) | ||
| return nextWindow.start.addingTimeInterval(min(delay, maxOffset)) |
There was a problem hiding this comment.
Code Review by OpenCode using Gemini 4 Neon
P3: Clamping overflow jitter to window.cutoff - 1 starves late start times behind the 120s quota poll
When startTime is within 20 minutes of midnight (for example 23:55, where window.cutoff - window.start is 300s while warmupJitter draws uniformly from 1...1200s), 75% of random draws hit candidate >= window.cutoff and clamp to window.cutoff - 1 (23:59:59). At 23:59:59, prepare (Warmup.swift:200) refuses to fire until a post-schedule quota reading arrives (observed >= nextAt). Because routine quota collection polls every 120 seconds (Sources/TallyCore/Collection.swift:92), there is a less than 1% chance a poll lands inside [23:59:59, 00:00:00); once the clock crosses 00:00:00, earliestAllowedStart advances to the next day and skips the warm-up entirely. The test at Tests/TallyTests/RuntimeTests.swift:225-232 only checks nextAt < midnight and misses this starvation (in that test, nextAt is 23:59:59).
Instead of pinning every overflow draw to cutoff - 1, fit jitter into the available window with headroom for a quota poll (for example max(0, windowLength - 180) scaled or clamped, or window.start directly when the remaining window is narrower than one poll cycle), and add a test proving prepare actually fires for a late start time under a 120s poll interval.
Originally created in OpenCode session ID: ses_df47d8471ffeDZZV4L22pW0Jhk using model: github-copilot/gemini-4-neon
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. WarmupStatus.setScheduledTime now reserves 180s of quota-poll headroom (pollHeadroom) before daily cutoffs across both regular and narrow late-night windows, backed by an owner-level 23:55 test under 120s polling with max jitter and a 23:59 rollover check.
| } else { | ||
| try await owner.setWarmup(accountID: String(parts[4]), enabled: input.enabled, model: input.model) | ||
| } | ||
| return try json(await owner.warmupReadings()) |
There was a problem hiding this comment.
Code Review by OpenCode using Gemini 4 Neon
P3: PUT /api/v1/accounts/{id}/warmup returns nextAt: null, hiding Next warm-up for up to 15 seconds in the web UI
TallyOwner.updateWarmup clears value.nextAt = nil and persists without recomputing the schedule, and TallyHTTP immediately returns owner.warmupReadings(). In web/src/WarmupPreferences.tsx:57,63, setReadings(next) removes the Next warm-up timestamp row, and the immediate tally:operation poll fires before TallyApp's 1-second pollingTask runs owner.tick(), so nextAt stays null in the web UI until the next 15-second poll interval.
When enabled is true and the account is not suspended, compute the next scheduled time via value.prepare(...) (without claiming/sending) inside updateWarmup before store.save() so both PUT responses and native saves immediately display the updated Next warm-up time in a single disk write.
Originally created in OpenCode session ID: ses_df47d8471ffeDZZV4L22pW0Jhk using model: github-copilot/gemini-4-neon
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 4d416a1. updateWarmup and setWarmupStartTime now call prepareWarmupSchedule (invoking prepare without claiming or sending) before store.save() when the account is enabled, not suspended, and not mid-send, so the PUT response immediately returns the updated nextAt.
…and DST
Preserve suspended state, attempt revision, and in-flight sends on start-time-only updates via dedicated `setWarmupStartTime` and partial `{"startTime": ...}` PUT support, recompute `nextAt` immediately before returning, reserve 180s quota-poll headroom before daily cutoffs, use exact local day intervals for midnight DST transitions, track `scheduleTimeZone` for timezone changes, serialize and coalesce native and web saves, ignore incomplete `<input type="time">` edits, show the Mac timezone on web when it differs, and document daily start times in `README.md`.
|
Follow-up by OpenCode using Gemini 4 Neon Review Follow-upReviewed 13 inline findings (9 deduplicated ledger items across Council Rounds 1 and 2): 9 accepted, 0 rejected, 0 deferred. All fixes were pushed in
|
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
Follow-up Review
Confidence Score: 7/10. The normal clock-time path is fixed, but retrying a full start-time PUT can still clear the safety pause, and simultaneous web saves can roll back another Account's displayed settings.
I reviewed the full PR and the delta from 82f4e28543daeb4cae43c48d1ded795a743044cc. L1 still has the retry case below; L7 still has the response-ordering case below. The remaining ledger items are addressed: the 23:55 send gate has room for a 120-second poll, 23:59 rolls over as documented, native writes serialize and the picker uses a reference date, incomplete browser values don't clear the setting, the Havana day boundary and timezone change recalculate the schedule, eligible saves calculate nextAt without sending, and the README and web picker explain the Mac timezone.
Both pinned diffs passed git diff --check. A Swift stdin check ran the pinned scheduler with synthetic quota readings for the cutoff, rollover, DST, and timezone cases. A separate Swift fixture reproduced the repeated PUT state transition using the pinned owner methods; a Node fixture reproduced the concurrent response race using the pinned hook and mocked fetch. No live provider sends or reset credits were used. GitHub's web and companion checks passed; Swift CI had not finished when checked.
Originally created in OpenCode session ID: ses_df468f4acffeQcvcb1tIq96gEr using model: openai/gpt-6.2-sol-fast
| guard case let .some(nextStartTime) = startTime else { return false } | ||
| return nextStartTime != value.startTime | ||
| }() | ||
| let startTimeOnly = value.enabled == enabled && value.model == model && startTimeChanged |
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
P2: Repeating a start-time PUT clears the safety pause
On a paused Account, a full PUT with unchanged enabled and model and a new startTime preserves the pause on the first call. If its response is lost and the caller retries the identical PUT, startTimeChanged is now false. The retry takes the Resume path, clears suspended, changes the attempt revision, and can cancel an in-flight send. I reproduced the state transition with the pinned owner logic in a synthetic Swift fixture. Classify unchanged enabled/model plus an explicitly supplied time as schedule-only even when that time is already saved. Make a same-value schedule write a no-op and keep Resume on the request that omits startTime.
Originally created in OpenCode session ID: ses_df468f4acffeQcvcb1tIq96gEr using model: openai/gpt-6.2-sol-fast
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 72cd494. updateWarmup now treats unchanged enabled/model with an explicitly supplied startTime as a schedule-only edit and returns immediately as a no-op when startTime matches the stored value, reserving explicit Resume for requests that omit startTime. Added an idempotent retry assertion in warmupStartTimeEditPreservesPauseDisabledAndInFlightSend.
| const updated = await request<Readings>(`/api/v1/accounts/${encodeURIComponent(accountID)}/warmup`, { | ||
| method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(next.patch), signal: AbortSignal.timeout(10_000), | ||
| }) | ||
| setReadings(updated) |
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
P3: A delayed save response rolls back another Account's displayed settings
Each Account now has its own active PUT, but each response replaces the entire readings map. If A's response captures B at 04:00 and arrives after B's successful 06:00 response, the browser displays 04:00 again until a fresh poll finishes. This also affects the displayed pause state and model. I reproduced the ordering against the pinned hook with mocked fetch. Merge only the written Account's reading from each PUT response and use the follow-up GET to refresh the full map; alternatively, keep the writes globally serialized while still coalescing pending edits per Account.
Originally created in OpenCode session ID: ses_df468f4acffeQcvcb1tIq96gEr using model: openai/gpt-6.2-sol-fast
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Accepted: Fixed in 72cd494. useWarmups.drain now merges only updated[accountID] into the existing readings map so concurrent saves for different accounts do not overwrite each other's newer readings.
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using Claude Opus 5.5
Follow-up Review
Council round 3 of 4d416a17cff9deacefd713da201f3a09d484b87c, covering git diff 82f4e28..4d416a1 and the full PR at the new head. All nine prior findings (L1 to L9) are resolved, and I found no regressions that block merge. No new inline findings.
L1, pause and in-flight safety. setWarmupStartTime and the startTimeOnly branch of updateWarmup change only startTime and, when enabled, not suspended, and not mid-send, recompute nextAt. They leave suspended, revision, message, enabled, and model untouched, and warmupTask is cancelled only on the non-time path. finishWarmup re-reads the stored value and checks only revision, so a time edit during a send keeps both the new startTime and the send's outcome. warmupStartTimeEditPreservesPauseDisabledAndInFlightSend covers in-flight, suspended, Resume, and disabled cases. A full PUT that repeats enabled/model with a changed startTime does not resume; the test asserts that deliberately, and neither client can produce that body for a Resume because Resume is disabled while a save is in flight.
L2, poll headroom. setScheduledTime keeps every same-day nextAt at or before cutoff - 180s, except where the window is shorter than the headroom (23:58 to 23:59), which the README now calls best effort. Late wakes stay safe because the idle branch derives earliestAllowedStart from now, not from nextAt. The 23:55 owner test and the 23:59 rollover test pin both behaviors.
L3, L4, L7, client writes. Native enqueueSave/drainSaves runs one save at a time on the main actor and merges field by field (String?? keeps "Any time" distinct from "omitted"). The web client's per-account pendingByAccount does the same and rejects incomplete <input type="time"> values with /^\d{2}:\d{2}$/. Both clients send startTime on toggle, model, or Resume writes only when it was set locally before the first enable, so a stale form no longer overwrites a time set elsewhere. The HTTP route accepts {enabled, model[, startTime]} or {startTime} alone and returns 400 for anything else, which HTTPTests covers.
L5, L6, L8, L9. activeWindow uses dateInterval(of: .day) (Havana test passes). scheduleTimeZone is set by every setScheduledTime call with a start time and cleared on every nextAt = nil path, so hasValidSchedule reschedules after a timezone change; legacy JSON decodes it as nil and reschedules once. prepareWarmupSchedule runs before store.save() so the PUT response carries nextAt. The web picker shows the Mac timezone when it differs from the browser's.
Non-blocking observations (no change required). Web writes for different accounts now run concurrently instead of through one global queue, so a response for account A can briefly replace account B's newer reading; the tally:operation poll fired by the last finished drain corrects it within one request. For start times within about 23 minutes of midnight, the narrow-window branch (cutoff - start < delay + 180) means a small jitter draw after a mid-window reset defers to tomorrow while a larger draw fires at cutoff - 180s. The window is narrow enough that this only matters for those late settings.
Checks run. SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk bash scripts/test-swift.sh --build-system native on an archive of 4d416a1: 107 tests passed (Command Line Tools Swift 6.4, not CI-equivalent Xcode). npm --prefix web test: 21 passed. tsc --noEmit passed. git diff --check 82f4e28 4d416a1 passed. No provider warm-ups were sent and no reset credits were used.
Confidence Score: 9/10
Originally created in OpenCode session ID: ses_df468f9eeffeTy0qFKSDxQODrg using model: anthropic/claude-opus-5-5
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using Gemini 4 Neon
Follow-up Review
Reviewed commit 4d416a17cff9deacefd713da201f3a09d484b87c and the full PR #64 diff against main. All nine prior council findings (L1-L9) are resolved with no regressions found across the scheduler, owner persistence, HTTP API, macOS Settings, web UI, tests, and documentation.
- Pause, in-flight, and partial-PUT safety (L1, L8):
TallyOwner.setWarmupStartTime, thestartTimeOnlyguard inupdateWarmup, and partial{"startTime": ...}handling inSources/TallyHTTP/TallyHTTP.swiftpreservesuspended,revision,message,enabled,model, and any in-flightwarmupTask, while explicit Resume still clears suspension. BothupdateWarmupandsetWarmupStartTimecomputenextAtviaprepareWarmupSchedulebefore saving so API and native reads immediately show the updated schedule. - Scheduler headroom, midnight DST, and timezone changes (L2, L5, L6):
WarmupStatus.setScheduledTimereservespollHeadroom(180s) before daily cutoffs across regular and late-night windows,activeWindowusescalendar.dateInterval(of: .day, for: date)for exact local day boundaries, andscheduleTimeZonerecomputes pending schedules when the Mac timezone changes. - Native and web editing, coalescing, and docs (L3, L4, L7, L9):
TallySettings.swiftuses a single-flight coalescing save loop (enqueueSave/drainSaves) and a Jan 1 non-DSTDatePickerreference date.WarmupPreferences.tsxignores incomplete<input type="time">values, coalesces per-account writes with field-level merging, omitsstartTimeon non-time writes unless locally dirtied before initial enable, and displays the Mactimezonewhen it differs from the browser timezone.README.mddocuments daily start times and late-minute (23:58-23:59) best-effort behavior.
Local checks run (Command Line Tools Swift 6.4 with MacOSX26 SDK, not CI-equivalent Xcode): bash scripts/test-swift.sh --build-system native passed 107 tests; npm --prefix web test passed 21 tests; tsc --noEmit in web/ passed; git diff --check main..4d416a17cff9deacefd713da201f3a09d484b87c was clean. No live provider sends or reset credits were used.
Confidence Score: 9/10
Originally created in OpenCode session ID: ses_df468efbdffefvEJhtmSoZD9Sv using model: github-copilot/gemini-4-neon
…b readings per account Treat any `updateWarmup` call with unchanged `enabled` and `model` and an explicitly supplied `startTime` as a schedule-only edit (returning immediately as a no-op when `startTime` is unchanged) so retried full PUT requests never clear `suspended` or cancel in-flight sends while explicit Resume (omitting `startTime`) continues to resume. Merge only the saved account's entry in `useWarmups` so concurrent saves for different accounts do not overwrite newer state, and compare narrow late-night window width against `1200 + pollHeadroom` for monotonic clamping.
|
Follow-up by OpenCode using Gemini 4 Neon Review Follow-upReviewed 2 follow-up findings from Council Round 3: 2 accepted, 0 rejected, 0 deferred. Fixes pushed in
|
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
Follow-up Review
Confidence Score: 9/10. Repeated full start-time PUTs preserve the safety pause and leave in-flight sends intact, and the late-window clamp now behaves monotonically. The web fix handles out-of-order saves during normal operation; one non-blocking stale-response case remains when the saved Account ID disappears during the PUT.
Reviewed 4d416a17cff9deacefd713da201f3a09d484b87c..72cd494e4a36d3e2f64d49918230e86eec3ed6e8. The HTTP decoder distinguishes an omitted startTime (explicit Resume with unchanged enabled/model) from an explicit value or null. The owner returns before changing the attempt revision or cancelling an in-flight send when an explicit time already matches. The updated regression test covers retry while paused and Resume after the retry.
git diff --check passed for the pinned range. Six synthetic Swift assertions passed against the pinned scheduler. A Node fixture confirmed both the normal out-of-order web save and the remaining missing-ID case. No full suite was run locally, no live provider send was triggered, and no reset credit was used.
Originally created in OpenCode session ID: ses_df462429dffeyHzKqqGmf3dObp using model: openai/gpt-6.2-sol-fast
| const updated = await request<Readings>(`/api/v1/accounts/${encodeURIComponent(accountID)}/warmup`, { | ||
| method: 'PUT', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(next.patch), signal: AbortSignal.timeout(10_000), | ||
| }) | ||
| setReadings(previous => previous && accountID in updated ? { ...previous, [accountID]: updated[accountID] } : updated) |
There was a problem hiding this comment.
Code Review by OpenCode using GPT-6.2 Sol Fast
P3: A PUT response missing its Account ID can still roll back another Account
The HTTP route saves settings and takes its readings snapshot in separate owner calls. If inventory reconciliation removes or replaces A's ID between those calls, A's PUT can succeed with a snapshot that has B's old settings and no A. If that response arrives after B's newer PUT response, this fallback replaces the whole map and rolls B back until a fresh GET succeeds. A mocked response against this exact updater reproduced B's display reverting from 06:00 to 04:00. When updated has no entry for the saved ID, keep the existing map and let the follow-up GET reconcile inventory.
Originally created in OpenCode session ID: ses_df462429dffeyHzKqqGmf3dObp using model: openai/gpt-6.2-sol-fast
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Deferred: Real edge case when an account disappears from inventory mid-PUT while another account saves concurrently, but the tally:operation poll dispatched right after drain reconciles the map immediately with no persistence impact. Keeping 72cd494 as-is.
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using anthropic/claude-opus-5-5
Follow-up Review
Scope: 4d416a1..72cd494 (12-line fix commit), checked against the Round 3 findings.
TallyOwner.updateWarmup now classifies any request with an explicit startTime and unchanged enabled/model as schedule-only, and returns early when that startTime already matches the stored value. A retried full PUT therefore no longer clears suspended, resets revision, or cancels the in-flight send, and Resume without startTime still takes the full path. The early return sits after every validation guard and before any store mutation, so a no-op retry persists nothing and still validates input. The new double-PUT assertion in warmupStartTimeEditPreservesPauseDisabledAndInFlightSend covers this.
useWarmups now merges only updated[accountID] into readings and falls back to the full response on first load. Together with the existing revision guard on polls, a slow PUT for one Account can no longer roll back another Account's newer state.
setScheduledTime now decides the narrow-window clamp from 1200 + pollHeadroom instead of the per-draw delay, so the decision is independent of jitter and matches the production jitter ceiling (1...1200). The ceiling is still repeated as a literal in three places, but the values agree today.
Ran locally (Command Line Tools toolchain, not CI-equivalent): SDKROOT=.../MacOSX26.sdk bash scripts/test-swift.sh --build-system native --filter warmup, 22 tests passed.
One P4 is posted inline: both clients' Resume buttons attach startTime when it is locally dirty, and under the new semantics that request is schedule-only and does not resume. Reaching this state takes a cross-client edit, so it does not block merge.
Confidence Score: 9/10
Originally created in OpenCode session ID: ses_df46247aaffePdEnimZ43zt0Ll using model: anthropic/claude-opus-5-5
| if case .some = startTime { return true } | ||
| return false | ||
| }() | ||
| let startTimeOnly = value.enabled == enabled && value.model == model && explicitStartTime |
There was a problem hiding this comment.
Code Review by OpenCode using anthropic/claude-opus-5-5
P4: Resume with a dirty start time is now treated as schedule-only and does not resume
With this rule, any request that carries an explicit startTime and unchanged enabled/model skips the resume branch. Both Resume buttons still attach startTime when it is locally dirty: web/src/WarmupPreferences.tsx sends { enabled: true, model, startTime } when startTimeDirty, and TallySettings enqueues PendingSave(full: (true, selected), startTime: startTimeDirty ? .some(startTime) : nil). Each client sets startTimeDirty only while status.enabled is false, and the status-sync effects leave it set when another client enables the Account. A cross-client enable followed by a pause can therefore leave Resume with a dirty startTime. The click then only updates the time (or no-ops), suspended stays true, and Resume works on the second click after startTimeDirty clears. Low likelihood, but the fix is small: have Resume always omit startTime (send the dirty time as a separate start-time-only save), or clear startTimeDirty when status.enabled flips to true.
Originally created in OpenCode session ID: ses_df46247aaffePdEnimZ43zt0Ll using model: anthropic/claude-opus-5-5
There was a problem hiding this comment.
Follow-up by OpenCode using Gemini 4 Neon
Deferred: Reachable only if a user sets a local start time before picking a model on client A, then enables the account and hits a warm-up failure on client B while client A stays open, and even then the second click succeeds cleanly. Keeping 72cd494 as-is.
MaxAnderson95
left a comment
There was a problem hiding this comment.
Code Review by OpenCode using Gemini 4 Neon
Follow-up Review
Reviewed commit 72cd494e4a36d3e2f64d49918230e86eec3ed6e8 (4d416a1..72cd494). All Round 3 items are resolved cleanly with no new defects found:
Sources/TallyCore/TallyOwner.swift: CheckingexplicitStartTime(case .some = startTime) with an early return whennextStartTime == value.startTimemakes retried full start-time PUTs strictly idempotent, so retries do not clearsuspended, reset schedules, or cancel in-flight sends, while explicit Resume (omittedstartTime,.none) still clearssuspendedand preserves the storedstartTime.web/src/WarmupPreferences.tsx: Merging onlyupdated[accountID]intopreviouswhen present avoids clobbering concurrent saves for other accounts while keeping the full-map fallback whenpreviousis uninitialized.Sources/TallyCore/Warmup.swift: Comparingwindow.cutoff.timeIntervalSince(window.start)against1200 + Self.pollHeadroomremoves thedelaydependency from the narrow-window branch, making late-night clamping monotonic indelayand matching the1...1200jitter bound.Tests/TallyTests/RuntimeTests.swift: Added the idempotent retry assertion inwarmupStartTimeEditPreservesPauseDisabledAndInFlightSend.
Verified locally with SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk bash scripts/test-swift.sh --build-system native --filter "warmupStartTimeEditPreservesPauseDisabledAndInFlightSend|warmupLateStart2355FiresUnder120sPollingWithMaxJitter" (2/2 passed) and npx --prefix web tsc --noEmit -p web/tsconfig.json (passed).
Confidence Score: 10/10
Originally created in OpenCode session ID: ses_df4623e1cffeUOUm6DNcSWuPab using model: github-copilot/gemini-4-neon
|
Follow-up by OpenCode using Gemini 4 Neon Review Follow-upReviewed 2 non-blocking findings from Council Round 4 (Opus 9/10, Sol 9/10, Neon 10/10; 0 P1/P2 findings): 2 deferred (transient display fallback when an account disappears mid-PUT, and two-click Resume when an unsaved pre-enable local edit survives a cross-client enable+failure). No further commits needed on |
Automatic warm-ups previously ran 24/7 whenever a five-hour window became idle, with no way to control when the first warm-up of the day should fire. This adds an optional per-account daily start time picker in both macOS Settings and the web/mobile Settings dialog so warm-ups can start at a chosen morning time (for example 4:00 AM) and auto-schedule through the day until overnight quiet hours.
Summary of changes
Sources/TallyCore/Warmup.swift,Sources/TallyCore/TallyOwner.swift): Added an optionalstartTime("HH:MM"in the Mac's timezone,nil= Any time) toWarmupStatusandWarmupReading, plusscheduleTimeZoneto recompute pending schedules if the Mac changes timezones. Accounts with no start time keep 24/7 behavior and legacy saved settings decode withstartTime == nil. When configured, warm-ups wait untilstartTimeafter midnight and stop atmin(dayEnd, tomorrowStart - 5h)using exact local day intervals (handling midnight DST transitions and DST spring-forward/fall-back) so late-night auto warm-ups do not overlap the next morning's start time. If a five-hour window is already active or fully depleted atstartTime(or a weekly window is depleted), Tally waits for the reset and resumes auto-scheduling after it. Normal random jitter is preserved while reserving 180 seconds of quota-poll headroom before cutoffs (deferring to tomorrow'sstartTimewhen jitter near the cutoff would cross that headroom). Start-time-only updates (setWarmupStartTimeor unchangedenabled/model) preservesuspended,revision, and in-flight sends, andupdateWarmup/setWarmupStartTimerecomputenextAtimmediately when eligible.Sources/TallyHTTP/TallyHTTP.swift): ExtendedPUT /api/v1/accounts/{id}/warmupto accept full{enabled, model, startTime?}payloads as well as time-only{startTime}patches ("HH:MM"to set,nullto clear back to Any time, omitted to preserve the saved value, invalid format returns HTTP 400warmup_start_time).Sources/TallyApp/TallySettings.swift,web/src/WarmupPreferences.tsx,web/src/api.ts,web/src/style.css): Added a per-account First warm-up control (Any time+Set timeswitching to a nativeDatePickeron macOS using a non-DST reference date and<input type="time">on web/mobile, plus anAny timebutton to clear and a Mac timezone hint on web when the browser timezone differs). Both clients use single-flight coalescing saves, send time-only patches for start-time edits, omitstartTimeon non-time edits unless dirty, and ignore incomplete<input type="time">edits so backspacing never unmounts the field.README.md,Tests/TallyTests/RuntimeTests.swift,Tests/TallyTests/HTTPTests.swift): Documented daily start times and late-minute best-effort behavior inREADME.md, and added unit, owner persistence, pause/in-flight safety, 23:55 120s-poll send, midnight DST, timezone travel, overlap-guard, active/depleted-at-start-time, and HTTP API tests.