summaryrefslogtreecommitdiffhomepage
AgeCommit message (Collapse)Author
2026-06-02feat: add search_code tool wrapping the cs code-search engineAdam Malczewski
Add a dedicated, permission-gated search_code tool that wraps boyter/cs (code spelunker) — a fast, relevance-ranked, structure-aware code search engine — giving agents a better default than grep/find for exploratory 'where is X / how does Y work' searches (ranked results, snippets, ~5x smaller payloads). - packages/core/src/tools/search-code.ts: createSearchCodeTool factory; -f json invocation, workdir path containment, graceful missing-binary handling (DISPATCH_CS_BIN override), readable per-file formatted output. - Wire-up: export from core; register in agent-manager (both child-whitelist and parent perm paths) behind new perm_search_code; add to summon catalog + tools enum; frontend ToolPermissions + settings. - Docker: build a patched, statically-linked cs (pinned v3.1.0 commit) in a golang builder stage and bundle at /usr/local/bin/cs. - docker/cs/luau-declarations.patch: additive Luau declaration table so --only-declarations / definition ranking works for Roblox .luau files (upstream has Lua but not Luau). Applied during the Docker build. - Tests: new search-code.test.ts (stubbed JSON formatting + live-cs integration, skipped when cs absent); agent-manager/routes mocks + perm-gating assertions; loader pass-through. All tests (596), biome, and tsc (core/api/frontend) pass. cs-builder Docker stage verified to build and produce a working patched binary.
2026-06-02Merge branch 'dev' into feat/plus-button-stickyAdam Malczewski
2026-06-02docs: handoff for perm/fix-user-agent-summon-permissionAdam Malczewski
2026-06-02Merge branch 'dev' into perm/fix-user-agent-summon-permissionAdam Malczewski
# Conflicts: # packages/api/tests/agent-manager.test.ts
2026-06-02docs: handoff for tab/fix-tab-messaging-tool (cross-tab messaging tools ↵Adam Malczewski
usable when granted)
2026-06-02style(tabbar): theme sticky + button like a selected tab, no left borderAdam Malczewski
Apply tab-active so the pinned + button uses the same raised base-100 fill, border and top-corner treatment as a selected tab, and drop its left border (!border-l-0) so it sits flush against the bar's edge. Keep !rounded-ss-none for the square top-left corner.
2026-06-02fix(tabs): say a reply will WAKE you with a new message (clearer than ↵Adam Malczewski
'arrives on its own') Matches actual behavior: a peer's reply wakes this tab with a new message in a later turn. Updated the send_to_tab description (both canReadTab branches), the delivery-result text (both branches), and the system-prompt one-liner; updated the test assertion accordingly.
2026-06-02fix(perm): decouple perm_user_agent from perm_summon for spawning user agentsAdam Malczewski
Granting only the user-agent (top-level) permission without the subagent-summon permission left the agent unable to summon user agents: the whole summon tool was gated behind perm_summon, so perm_user_agent alone produced no summon tool. Register summon when EITHER perm_summon OR perm_user_agent is granted. createSummonTool now takes an independent subagentEnabled flag (mirrors perm_summon) alongside userAgentEnabled (mirrors perm_user_agent): - subagent-only -> ordinary subagents, no top_level - user-agent-only -> spawns ONLY top-level user agents (top_level forced, background/top_level params dropped, user-agent catalog only) - both -> unchanged full behavior retrieve stays bundled with perm_summon (user agents are fire-and-forget). Adds core summon tests (user-agent-only mode + legacy-default regression) and an agent-manager summon/user_agent permission-split suite.
2026-06-02fix(tabbar): flatten top-left corner of sticky + buttonAdam Malczewski
daisyUI tabs-lift rounds both top corners; the pinned + button sits at the bar's left edge, so its top-left (start-start) radius reads as a stray rounded corner. Override with !rounded-ss-none.
2026-06-02fix(tabs): only mention read_tab when the sender actually has it; CAPS on ONLYAdam Malczewski
The send_to_tab guidance previously told the agent it could call read_tab to check for a reply, but the tab-messaging permissions are split — a tab can hold send_to_tab WITHOUT read_tab (the exact case in testing). Advertising a tool the agent wasn't granted is wrong. Thread a canReadTab flag from AgentManager.buildTabCommToolEntries into createSendToTabTool (true iff this tab is also granted read_tab). The tool description and the delivery-result text now only reference read_tab when canReadTab is true; otherwise they say a reply arrives on its own and to end the turn. Drop the read_tab phrasing from the static TOOL_DESCRIPTIONS one-liner (can't be conditional per-tab there). Also uppercase ONLY in the recipient reply-contract footer for emphasis. Tests: cover both canReadTab branches for description + result text; assert ONLY is uppercased.
2026-06-02feat(tabbar): sticky + button & double-clickable trailing padAdam Malczewski
Pin the new-tab + button to the left edge of the user-tab row via position: sticky (!sticky left-0 z-10) with an opaque bg-base-200 and a right-side shadow as a floating cue, so it stays reachable at any horizontal scroll. Add a flex-fill trailing pad after the last tab (flex-1 min-w-12) that opens a new tab on double-click.
2026-06-02fix(tabs): clearer send_to_tab context to stop busy-wait + wrong-recipient ↵Adam Malczewski
replies Two behavioral problems observed once the tools were usable: 1. The SENDER busy-waited for a reply (ran 'sleep 20' / polled) instead of ending its turn. Tool description, the delivery result text, and the system-prompt one-liner now say plainly: do not sleep/poll/run commands to wait; a reply arrives on its own in a later turn (or via read_tab in a future turn); keep working if there's other work, else end your turn. 2. The RECIPIENT replied to its OWN user in plain text instead of routing the answer back through send_to_tab. The provenance wrapper now states the message is from another AGENT (not your user), and that to reply you must use send_to_tab addressed to the sender's handle — and only if asked, since it may just be context. A plain text answer reaches only your own user. Tests updated for the new wording.
2026-06-02fix(tabs): advertise send_to_tab/read_tab in the agent system promptAdam Malczewski
Granted tab-messaging tools were registered in the API tool payload but buildSystemPrompt built its 'You have access to the following tools' list by filtering toolNames through TOOL_DESCRIPTIONS, which had no entries for send_to_tab/read_tab. The model was therefore told it lacked those tools and refused to use them even when explicitly granted. Add the two missing TOOL_DESCRIPTIONS entries so the capability list matches the granted toolset. Add regression tests that capture the constructed Agent's systemPrompt and assert the tab-messaging tools are listed when granted (and omitted when not), locking the prompt list to the schema list so they can't drift again.
2026-06-02chore: remove notes/ plan & report docs; gitignore notes/ (keep wishlist local)Adam Malczewski
2026-06-02docs: handoff for td/todo-fix (declarative todo system)Adam Malczewski
2026-06-02Merge branch 'dev' into td/todo-fixAdam Malczewski
2026-06-02docs: handoff for cr/claude-reset-fix (wake probe body fix)Adam Malczewski
2026-06-02Merge branch 'dev' into cr/claude-reset-fixAdam Malczewski
2026-06-02feat(todo): port opencode's declarative whole-list todo toolAdam Malczewski
Replace the imperative id-based CRUD todo tool (add/update/list/get/remove) with opencode's declarative whole-list design: a single `todos` param that replaces the entire list each call. No model-visible ids, no delta reasoning, no "task not found" spirals. - core: TaskItem { id, content, status }; statuses pending|in_progress| completed|cancelled. TaskList.setTasks/getTasks/onChange. New rich TODO_DESCRIPTION adapted from opencode's todowrite.txt. - api: TASK_MANAGEMENT_GUIDANCE system-prompt section (from anthropic.txt); updated TOOL_DESCRIPTIONS.todo. Reload fix: TabStatusSnapshot now carries per-tab tasks so getAllStatuses rehydrates the panel on reconnect. - frontend: mirror types; hydrate tasks from snapshot in both restore paths; upgrade sidebar Tasks panel to render content + all four statuses + progress. - tests: new core task-list.test.ts (15); updated api TaskList mocks + getAllStatuses task-snapshot coverage. bun run check clean; 569 tests pass; all packages typecheck.
2026-06-02Merge branch 'dev' into tc/tab-controlsAdam Malczewski
# Conflicts: # packages/frontend/src/lib/components/ChatInput.svelte
2026-06-02fix(wake): probe with genuine Claude Code request shape so OAuth wakes succeedAdam Malczewski
The wake probe POSTed a bare { model, messages } body with no system[] identity. Anthropic validates system[] on OAuth (Pro/Max) subscription requests and rejects any that lack the verbatim Claude Code identity, so every scheduled wake (and the manual Wake-now button) failed silently — surfacing as a blank '— failed' status that then burned the retry budget. - Add pure buildWakeProbeBody(model) in @dispatch/core mirroring a genuine Claude Code request (billing header block + identity block + 'hi'), with a unit test for its shape. - wakeAllClaudeAccounts now sends that body plus the CLI session/request-id headers, and records 'HTTP <status>: <message>' on failure so the panel never shows a bare 'failed' and breakage stays debuggable.
2026-06-02feat(tabs): drag-reorder + double-click rename + per-tab chat draftAdam Malczewski
- TabBar: HTML5 drag-and-drop to reorder user tabs (subagent tabs untouched); double-click a tab title to rename (Enter/blur confirm, Escape cancel). - Store: add reorderTabs/renameTab/setDraft; per-tab in-memory `draft` and `manualTitle` fields. Manual rename suppresses first-message auto-title. - ChatInput: bind to the active tab's draft so switching tabs saves/restores unsent text instead of clobbering it. - Backend: updateTabPositions() + PATCH /tabs/reorder persist tab order to the existing `position` column; tabs without a stored position fall to the end then get explicit positions on first reorder. - Tests: store reorder/rename/auto-title-guard/draft coverage; core updateTabPositions coverage (FakeDatabase extended with transaction support).
2026-06-02Add HANDOFF.md for sb/status-barAdam Malczewski
2026-06-02Merge branch 'dev' into sb/status-barAdam Malczewski
2026-06-02Add status bar beneath chat input with send/stop button and context displayAdam Malczewski
Restructure ChatInput into two stacked bars: - Top bar: auto-resizing textarea + fixed-width send/stop button that morphs in place (no layout shift) across idle/generating states. - Bottom bar: agent status icon, context-window fill bar, and compact token count + percent (inert bar when model max is unknown). Wire contextLimit prop from App.svelte into ChatInput, reusing the shared computeContextUsage helper so it agrees with the sidebar.
2026-06-02Add HANDOFF.md for m1/minor-fixesAdam Malczewski
2026-06-02Fix cache req badge wrap, remove cache cost note, pace-aware key usage barsAdam Malczewski
2026-06-02chore: untrack and gitignore notes/wishlist.mdAdam Malczewski
2026-06-02Merge branch 'dev' into u3/agent-effort-levelAdam Malczewski
# Conflicts: # packages/api/tests/agent-manager.test.ts
2026-06-02wishlist: add major Workspaces feature with workspace-scoped agentsAdam Malczewski
2026-06-02test: prove Context Window view gets hydrated cacheStats.last after reloadAdam Malczewski
Cross-branch contract test (u2/context-window-view merged from dev): the Context Window panel derives current context from cacheStats.last via computeContextUsage. This drives the full path — persisted usage aggregate -> hydrateFromBackend -> cacheStats.last -> computeContextUsage -> '48,200 / 200,000' — proving the view shows real context size immediately after a reload on a new device (not 'No context data yet'). Guards the contract so neither persistence nor the view can silently break it.
2026-06-02Merge branch 'dev' into u1/usage-persistenceAdam Malczewski
2026-06-02fix: reconcile live cacheStats to DB truth on turn-sealedAdam Malczewski
Addresses the live-accumulator overshoot a Gemini review surfaced: the frontend adds every streamed usage event to cacheStats, but a rate-limited fallback attempt's usage is discarded server-side (never persisted). Live numbers overshot until a reload re-seeded from the DB aggregate. Fix: turn-sealed (emitted AFTER the atomic usage-row write) now carries the authoritative getUsageStatsForTab aggregate. The store REPLACES (not adds) cacheStats with it every turn — landing the just-sealed turn's usage AND self-healing any live drift, including the discarded-fallback overshoot. No extra round-trip (piggybacks turn-sealed); idempotent in the happy path. - core: add UsageStats type; getUsageStatsForTab returns it; turn-sealed gains optional usageStats field. - api: agent-manager reads getUsageStatsForTab post-flush and attaches it to the turn-sealed emit (try/catch: omit on DB error). - frontend: turn-sealed handler replaces cacheStats (undefined ⇒ untouched back-compat; null ⇒ clear). Tests: frontend reconcile/self-heal/back-compat/null-clear; api turn-sealed carries aggregate. 509 -> 514 passing; typecheck + biome green.
2026-06-02Merge branch 'dev' into u2/context-window-viewAdam Malczewski
2026-06-02wishlist: add new items - tab forking, per-tab input state, image ↵Adam Malczewski
attachments, better tab controls, agent tools isolation, chat settings conflict, backgrounding, tab naming fix, key usage tool, effort level per model/key, search code tool
2026-06-02feat(context-window): show current/max context usage per tab/modelAdam Malczewski
Add a 'Context Window' sidebar view showing the live context occupancy (latest request's input+output) against the model's maximum context window, resolved dynamically from the models.dev catalog. - core: models.dev catalog module (resolveContextLimit) with disk cache, TTL, stale-fallback + offline penalty memo; null for unknown models. - api: GET /models/context-limit?provider=&modelId=. - frontend: ContextWindowPanel + computeContextUsage helper; App resolves + caches the active model's max (anthropic/opencode-anthropic only); percent shown to 2 decimals; degrades to bare token count when max unknown. - tests: core catalog (13), api route (3), frontend helper (6).
2026-06-02fix(frontend): honest effort display in agent UI (gemini review)Adam Malczewski
Address two UI-accuracy issues found in review: - AgentBuilder: the per-model effort select no longer disguises an unset value as 'High'. Adds an explicit 'Inherit' option; choosing it strips the effort key so the saved TOML omits it (and the call site falls back to per-tab → default), matching displayed intent to persisted state. - ModelSelector: effort badges for models without an explicit override now reflect the actual effective effort (per-tab selector → default) instead of always showing the default constant, mirroring backend resolution.
2026-06-02feat: persist per-tab token/cache usage across reloadAdam Malczewski
Persist usage as invisible type:"usage" chunk rows (side channel): - core: add "usage" ChunkType + UsageData; exclude usage rows from getChunksForTab/getTotalChunkCount; add getUsageStatsForTab aggregate (exported from barrel); defensive skip in groupRowsToMessages. - api: agent-manager accumulates per-attempt usageRows and flushes them in the same atomic appendChunks call as the turn's content (discarded on a superseded fallback attempt). GET /tabs enriches rows with usageStats. - frontend: hydrateFromBackend seeds cacheStats from usageStats (reload only; no re-seed on statuses reconnect, so no double-count with live events). Tests: core DB-backed usage persistence/aggregate; api usage-row-per-event + fallback discard; routes GET /tabs usageStats; frontend hydrate seed + no-double-count + live-accumulation-after-seed. 495 -> 509 passing.
2026-06-02feat(agents): per-model reasoning effort levelAdam Malczewski
Add a per-model/key reasoning effort setting to agent definitions, surfaced and editable in the Agent Settings page and displayed at a glance in the model selector views. - core: single source of truth for effort levels (REASONING_EFFORTS, DEFAULT_REASONING_EFFORT='high', labels, isReasoningEffort guard); add 'xhigh' level; AgentModelEntry.effort; xhigh budget=24000 for classic-thinking Claude; default floor 'high'. Persist/parse effort in the agent TOML loader. - api: thread effort through the fallback chain with per-model -> per-tab -> default precedence; validate /chat + agentModels effort from the canonical list. - frontend: effort <select> per model row in AgentBuilder; effort badges in ModelSelector (agent + subagent chains); Thinking dropdown sourced from canonical list; per-tab default raised to 'high'. - tests: +15 (loader round-trip, agent xhigh budget, canonical list + guard, api precedence, route validation).
2026-06-01Add Phosphor icons; replace sidebar text with hamburger buttonAdam Malczewski
- Add phosphor-svelte ^3.1.0 to frontend deps. - Wire phosphor-svelte/vite (sveltePhosphorOptimize) as a fallback so stray named imports still tree-shake correctly. Per-icon imports like 'phosphor-svelte/lib/ListIcon' remain the preferred pattern; see the comment in vite.config.ts. - Replace the 'Sidebar' text in Header.svelte with a Phosphor List icon styled as a square daisyUI button (btn btn-square btn-sm btn-neutral) with aria-label preserved for screen readers.
2026-06-01merge: dev into r1/claude-reset-fixAdam Malczewski
Brings in the n2/ntfy-notifications feature (ntfy.sh push notifications with per-event toggles, subagent-suppression flag, topic-only input, Settings UI, dispatcher + transport + config modules, 12+ new tests), the header declutter (theme picker + Debug panel moved into Settings / sidebar), the shared theme boot-apply module, and an a11y label for the remove-panel button. No code changes from this branch were touched by the merge — the overlap was purely textual. Conflict resolution: 1. HANDOFF.md (add/add conflict). Both branches independently put a single-purpose HANDOFF.md at the repo root for their respective in-flight feature, matching the existing convention (c351719 did the same for this branch; 29bdd00 did the same for ntfy). After this merge both features ship, so neither is in-flight anymore. Archive both into notes/: - notes/wake-schedule-handoff.md (this branch — git tracks as a rename from HANDOFF.md) - notes/ntfy-notifications-handoff.md (dev — recovered from MERGE_HEAD before deletion) The root HANDOFF.md is intentionally absent post-merge; the next in-flight branch will create its own. 2. packages/api/tests/routes.test.ts (auto-merged). dev appended ntfy stubs to the vi.mock('@dispatch/core', ...) factory; this branch appended a 'Wake schedule routes' describe block at the bottom. The two regions don't overlap and the textual auto-merge is correct (verified: 6 describe blocks, both mock-stub regions and the new describe present, no conflict markers). Verification on the merge commit: bun run test → 31 files, 495 / 495 passing (was 431 on the branch + 64 from dev) bun run check → biome clean, 156 files bun run --cwd packages/frontend typecheck → svelte-check 0 errors, 0 warnings dev can now fast-forward to this commit: git checkout dev && git merge --ff-only r1/claude-reset-fix
2026-06-01fix(frontend): ClaudeReset — keep '11 AM' badge on one lineAdam Malczewski
The marked-hour summary badge ('11 AM', '12 PM', etc.) wrapped after the hour number when the trailing 'Probes …' text pushed against it, so '11' sat on the first line and 'AM' dropped to the second — ugly two-line badge. Add 'whitespace-nowrap' (prevents the space between hour and meridiem from breaking) and 'shrink-0' (so the badge never gets compressed narrower than its content) to the badge span.
2026-06-01docs: HANDOFF round-2 review followup + move review 2 into notes/Adam Malczewski
Append a 'Review followup — Round 2' section to HANDOFF.md documenting the round-2 Gemini-review fixes: - Critical: request-reorder desync (SnapshotSequencer assumed client send order == server processing order; not true on the wire). Fixed by promoting the per-hour pendingHours Set to a single global pendingHour mutation lock — serializing toggle POSTs eliminates the reorder window entirely. - High: toggle endpoint guessed user intent from server state, which combined with any desync to invert clicks. Fixed by requiring an explicit action: 'on' | 'off' field on every request. - Low: round-2 R2-3 (retry storm re-probes succeeded accounts) noted as a deliberate trade-off, not fixed. Move the round-2 review report from the project root into notes/claude-reset-review-2.md to match the convention established for the round-1 report. Net delta vs branch base: 431 tests (was 427 after round 1; +4 contract tests for the explicit-action endpoint). Biome and svelte-check clean.
2026-06-01fix(frontend): ClaudeReset — global mutation lock + explicit action intentAdam Malczewski
Round-2 Gemini review found that the SnapshotSequencer's 'most-recent client seq wins' rule only protects against RESPONSE reordering. If the network reorders the REQUESTS themselves (B reaches the server before A), the server's snapshot reflecting the true final state may carry the older client seq and get discarded — UI permanently desyncs. Two related fixes: 1. Replace pendingHours: Set<number> (per-hour lock) with a single pendingHour: number | null (global mutation lock). All 24 toggle buttons go disabled while any POST is in flight. This serializes mutations on the wire, eliminating the request-reorder failure mode entirely. 2. Send the action explicitly. toggleHour now derives 'on' or 'off' from its local state and passes it to postToggle, which sends it on the wire. Pairs with the matching backend contract change — the server no longer guesses from its own state, so even if a stale UI made it through it would just be an idempotent no-op or timestamp refresh instead of an inverted click. The SnapshotSequencer is retained — it still guards the GET-on-mount vs first-click race (where the two requests are NOT both mutations and the global lock doesn't apply). UX note: per-hour 'cursor: wait' visual is preserved for the hour whose request is in flight (so the user can see which click is pending), while the OTHER hours go merely disabled (no cursor change) — a clearer 'busy' signal than dimming everything uniformly. svelte-check: 0 errors, 0 warnings. 431 / 431 tests pass.
2026-06-01fix(api): wake-schedule toggle requires explicit action: 'on' | 'off'Adam Malczewski
Round-2 Gemini review surfaced that the toggle endpoint derived add-vs- remove from its own in-memory state, which combined catastrophically with any UI desync: a user clicking to turn ON an hour the UI showed as off, but the server had as on, would silently get the hour turned OFF. The clicks felt 'inverted' and the only recovery was a full reload. Fix: require an explicit `action` field on every /toggle request. The client must declare its intent; the server is no longer allowed to guess. Idempotency rules: - action: 'off' on an already-off hour → 200, no-op success. - action: 'on' on an already-on hour → 200, REPLACES timestamps (so a recovering UI can re-assert the user's wall-clock intent without a delete-then-add round trip). - Missing or invalid action → 400. The 'off' path no longer reads or requires `timestamps`. The 'on' path still requires all four slot timestamps as finite Unix-ms numbers (the skewed-toggle relaxation from round 1 is preserved). Tests: - toggle() helper auto-derives action from `timestamps` presence, so the existing 12 tests stayed terse. One test that relied on the old 'empty body = add' behavior now passes `action: 'on'` explicitly. - Added 4 new contract tests: * rejects requests missing/with-invalid action * action='off' on an already-off hour is idempotent * action='on' on an already-on hour replaces timestamps (the round-2 desync-recovery scenario) * action='off' ignores stray timestamps payloads 29 / 29 routes tests pass; 431 / 431 across the workspace.
2026-06-01Merge branch 'dev' into n2/ntfy-notificationsAdam Malczewski
Brings in: theme picker consolidation, sidebar Debug panel, header declutter, a11y label on remove-panel button. Conflicts in SettingsPanel.svelte (theme picker insertion site overlaps the ntfy block) and HANDOFF.md (each branch maintains its own). # Conflicts: # HANDOFF.md
2026-06-01feat(notifications): topic-only input (drop URL validation)Adam Malczewski
The Settings field is now a plain topic name (e.g. `my-secret-topic`) instead of a full URL. The transport always posts to `https://ntfy.sh/<topic>` (URL-encoded), and the only server-side check is "non-empty when enabled". Removes the user-visible "string does not match the expected pattern" error people hit when typing a bare topic. - packages/core/src/notifications/ntfy.ts: drop validateTopicUrl; add buildNtfyUrl(topic) + exported NTFY_BASE_URL. - packages/core/src/notifications/types.ts, config.ts: rename topicUrl -> topic; update docs. - packages/api/src/routes/notifications.ts: only validates non-empty topic when enabled. Also fixes a latent bug where notifySubagents was dropped on every PUT (was not passed to normalizeNtfyConfig). - packages/frontend/src/lib/components/SettingsPanel.svelte: relabel field "Topic URL" -> "Topic"; placeholder "your-secret-topic"; updated helper copy. - Tests updated: rewrote validateTopicUrl coverage as buildNtfyUrl coverage + proof that previously-rejected topics (dots, spaces, unicode, "Any Topic Whatsoever") now POST cleanly. - HANDOFF.md: added a short "topic-only input" section.
2026-06-01docs: HANDOFF review followup + move reset review report into notes/Adam Malczewski
Append a 'Review followup' section to HANDOFF.md documenting the three Gemini-review fixes (clock-skew toggle, snapshot race, transactional persist) and the two nits, with file-by-file scope, verification output (427 tests, biome clean, 0 svelte-check errors), and the design-pushback items deliberately deferred (snapshot polling, DST drift). Move the root-level review report (claude-report.md) into notes/claude-reset-review.md to match the existing convention from 4e63651 (root .md files collected under notes/). Renamed from 'claude-report.md' to disambiguate from the unrelated cache-miss notes/claude-report.md.
2026-06-01fix(frontend): ClaudeReset — global snapshot sequencer fixes cross-hour raceAdam Malczewski
Replaces the per-hour inFlightSeq with a single shared SnapshotSequencer used by both loadFromServer() and postToggle() (Gemini #2, High; nit #4). The bug: applySnapshot replaces the *whole* schedule object. The old per-hour counter could not stop request A for hour 9 (knows only about hour 9) from clobbering request B for hour 10 (knows about both) when B returned first and A straggled in — hour 10 would visually vanish. Same race existed between the initial-mount loadFromServer and a quick user toggle: whichever lost the race won the UI. Fix: every request to /models/wake-schedule (GET and POST) bumps a single monotonic seq. On response, sequencer.accept(seq) returns false if any newer request has already won; we drop the snapshot. Also drops the inFlightSeq mechanism entirely — it was redundant with pendingHours for user clicks AND insufficient for the cross-hour and initial-load races, so two mechanisms became one.
2026-06-01feat(frontend): SnapshotSequencer — reusable 'most-recent request wins' ↵Adam Malczewski
race guard Tiny, dependency-free class for the common pattern where a component fans out multiple HTTP calls that each return a full snapshot of shared state, and applying an older snapshot would clobber a newer one. begin() tags a new request, accept(seq) decides whether to apply the response. Pulled out as its own module (rather than inlined in ClaudeReset) because the next consumer of this pattern shouldn't have to re-derive it. The contract is small enough to test exhaustively in isolation: - accepts the first response unconditionally - accepts responses in send order - rejects an older response that arrives AFTER a newer one (the core race that motivated this) - rejects ALL stragglers once a newer one wins - handles the initial-load vs first-click race - equal seq is idempotent accept (defensive) - begin() seqs are monotonic and unique - state inspector reflects the watermark 8 tests, all green. No Svelte dependency — usable from any TS file.