---
epic: 13
story: 13.3
title: "Web Worker Offloading (Web Only)"
status: draft
---

## Epic 13 — Performance & Reliability
**Goal:** Instant evaluation, never lose work.

### Story 13.3: Web Worker Offloading (Web Only)

As a web CalcPad user,
I want the calculation engine to run in a Web Worker,
So that the main thread remains free for rendering and the UI never freezes during heavy computation.

**Acceptance Criteria:**

**Given** the web version of CalcPad is loaded in a browser
**When** the application initializes
**Then** the calcpad-engine WASM module is instantiated inside a dedicated Web Worker
**And** the main thread contains no evaluation logic

**Given** a user types an expression on the main thread
**When** the input is sent to the Web Worker for evaluation
**Then** the result is returned via postMessage to the main thread
**And** the main thread renders the result without blocking on computation

**Given** the Web Worker is processing a large sheet (500+ lines)
**When** the user continues typing on the main thread
**Then** keystrokes are captured and rendered with zero perceptible lag
**And** pending evaluation requests are queued or debounced so the latest input is always processed

**Given** the Web Worker crashes or becomes unresponsive
**When** the main thread detects the worker has not responded within 5 seconds
**Then** the worker is terminated and a new worker is spawned
**And** the current sheet state is re-sent to the new worker for evaluation
**And** the user sees a brief non-blocking notification that the engine was restarted
