summaryrefslogtreecommitdiffhomepage
path: root/src/features/concurrency/index.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-28 13:18:25 +0900
committerAdam Malczewski <[email protected]>2026-06-28 14:41:47 +0900
commit0f1b04bd7976ea416f11d83e4b7b78cf537bfdf3 (patch)
treeb198da2719987ffd58e9c2633fc36684cf2ad316 /src/features/concurrency/index.ts
parenta59200e786f7d97d7ba5b9cd2bee9ffef531dac2 (diff)
downloaddispatch-web-0f1b04bd7976ea416f11d83e4b7b78cf537bfdf3.tar.gz
dispatch-web-0f1b04bd7976ea416f11d83e4b7b78cf537bfdf3.zip
feat(concurrency): configurable cooldown + adaptive-headroom auto-reduce banner
Consumes the backend's concurrency-fixes (commit 2d27666) — additive to [email protected], NO version bump. ConcurrencyStatusEntry gains cooldownMs / autoReduced / autoReducedFrom? / notice?; new ConcurrencyCooldownResponse / SetConcurrencyCooldownRequest + GET/PUT /concurrency/cooldown/:providerId. FE: - Pure core (logic/view-model.ts): DEFAULT_COOLDOWN_MS; parseCooldownInput (non-negative int — 0 is valid, unlike the limit); normalizeCooldown; cooldownLabel ("350ms"/"1.2s"/"0ms (off)"); viewConcurrencyStatus extended (cooldown + autoReduce fields; auto-reduce → warning badge, not busy); viewAutoReduce/autoReduceNotices (banner view — prefers backend notice, synthesizes a fallback); summarizeStatus "N auto-reduced" fragment; normalizeConcurrencyStatus coerces new fields (immutable readonly build; autoReducedFrom/notice only when autoReduced===true); normalizeConcurrencyCooldown. - Types (logic/types.ts): re-export the 2 new contract types + ConcurrencyCooldownResult + Get/SaveConcurrencyCooldown ports. - UI: ConcurrencyCooldownRow.svelte (inline-edit cooldown + Save → PUT, seeded via the ChatLimitField pattern); AutoReduceBanner.svelte (dismissible banner — backend notice + "Was N, now M." + "Restore to N"); ConcurrencyView renders the cooldown per status card + the banner section. The banner persists while autoReduced===true, is dismissible, and clears automatically once a poll shows autoReduced===false after a restore PUT. - Store (store.svelte.ts): getConcurrencyCooldown + setConcurrencyCooldown (surface 400/404/503 as ok:false; normalize at the seam) + interface decls. - App.svelte: saveConcurrencyCooldown adapter → ConcurrencyView. - Tests: +47 (view-model cooldown/auto-reduce/normalizers; component banner render, cooldown PUT, restore clears banner, dismiss; store cooldown GET/PUT). Re-synced the file: dep (bun install) + re-mirrored .dispatch/transport-contract. reference.md. typecheck 0/0, 1048 tests green (run twice), biome clean, build OK. Worktree env: an untracked dispatch-backend → backend symlink was created in the worktree parent so the canonical file:../dispatch-backend/... paths resolve (NOT committed — per the §2d/§2j worktree convention).
Diffstat (limited to 'src/features/concurrency/index.ts')
-rw-r--r--src/features/concurrency/index.ts23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/features/concurrency/index.ts b/src/features/concurrency/index.ts
index 151acb8..95eb5ed 100644
--- a/src/features/concurrency/index.ts
+++ b/src/features/concurrency/index.ts
@@ -1,7 +1,9 @@
export type {
+ // Contract shapes re-exported for a single import surface.
+ ConcurrencyCooldownResponse,
+ ConcurrencyCooldownResult,
ConcurrencyDeleteResult,
ConcurrencyLimitEntry,
- // Contract shapes re-exported for a single import surface.
ConcurrencyLimitResponse,
ConcurrencyLimitResult,
ConcurrencyLimitsResponse,
@@ -10,30 +12,47 @@ export type {
ConcurrencyStatusResponse,
ConcurrencyStatusResult,
DeleteConcurrencyLimit,
+ GetConcurrencyCooldown,
GetConcurrencyLimit,
LoadConcurrencyLimits,
LoadConcurrencyStatus,
+ RestoreOutcome,
+ SaveConcurrencyCooldown,
SaveConcurrencyLimit,
+ SetConcurrencyCooldownRequest,
SetConcurrencyLimitRequest,
} from "./logic/types";
-export type { Badge, ConcurrencyLimitView, ConcurrencyStatusView } from "./logic/view-model";
+export type {
+ AutoReduceNotice,
+ Badge,
+ ConcurrencyLimitView,
+ ConcurrencyStatusView,
+} from "./logic/view-model";
export {
+ autoReduceNotices,
+ cooldownLabel,
+ DEFAULT_COOLDOWN_MS,
formatPauseDuration,
+ normalizeConcurrencyCooldown,
normalizeConcurrencyLimit,
normalizeConcurrencyLimits,
normalizeConcurrencyStatus,
normalizeLimit,
+ parseCooldownInput,
parseLimitInput,
pauseLabel,
providerFromModel,
providerOptions,
summarizeLimits,
summarizeStatus,
+ viewAutoReduce,
viewConcurrencyLimit,
viewConcurrencyLimits,
viewConcurrencyStatus,
viewConcurrencyStatuses,
} from "./logic/view-model";
+export { default as AutoReduceBanner } from "./ui/AutoReduceBanner.svelte";
+export { default as ConcurrencyCooldownRow } from "./ui/ConcurrencyCooldownRow.svelte";
export { default as ConcurrencyLimitRow } from "./ui/ConcurrencyLimitRow.svelte";
export { default as ConcurrencyView } from "./ui/ConcurrencyView.svelte";