easystitch-client AutoDigitizeSettings.stitchPreference type drifts from workspace contract #75

Closed
opened 2026-09-14 03:24:15 +00:00 by Mark · 0 comments
Owner

Where: src/lib/easystitch-client.ts:17-19 vs src/components/workspace/types.ts:27.

Bug:

  • Client type: stitchPreference: "balanced" | "quality" | "speed" (easystitch-client.ts:18).
  • Workspace type: StitchPreference = 'balanced' | 'detail' | 'speed' (types.ts:27).
  • Default in workspace state: 'balanced' (useWorkspace.ts:59).

The file's own header (easystitch-client.ts:3-5) says: "The shapes here must match those exactly; drift between these surfaces is a bug."

Why it doesn't crash at runtime: src/lib/digitize-adapters.ts:59-64 mapStitchPreference rewrites "detail" → "quality" before the client type sees it. So today it works by accident — the moment someone calls digitize() with raw settings (or bypasses the adapter), TypeScript will accept "detail" but the service will reject it as not in ["balanced","quality","speed"].

Fix consistent with existing patterns:

  1. Pick one vocabulary. The workspace already uses "detail" in the UI; the service uses "quality". Rename client side to "detail" and update mapStitchPreference to be a no-op (drop the function entirely).
  2. OR rename the workspace side to "quality" and update RightPanel's stitchPreference picker (src/components/workspace/RightPanel.tsx) to match.

Recommended: rename the client to "detail" so the workspace stays the source of truth — mapStitchPreference becomes identity, and the DigitizeAdapters comment about "the service caps at 10" stays accurate.

Acceptance: grep -rn '"quality"\|"detail"' src/ shows one vocabulary; mapStitchPreference either disappears or is a trivial identity; tsc -p tsconfig.json is clean.

**Where:** `src/lib/easystitch-client.ts:17-19` vs `src/components/workspace/types.ts:27`. **Bug:** - Client type: `stitchPreference: "balanced" | "quality" | "speed"` (easystitch-client.ts:18). - Workspace type: `StitchPreference = 'balanced' | 'detail' | 'speed'` (types.ts:27). - Default in workspace state: `'balanced'` (useWorkspace.ts:59). The file's own header (`easystitch-client.ts:3-5`) says: *"The shapes here must match those exactly; drift between these surfaces is a bug."* **Why it doesn't crash at runtime:** `src/lib/digitize-adapters.ts:59-64` `mapStitchPreference` rewrites `"detail"` → `"quality"` before the client type sees it. So today it works by accident — the moment someone calls `digitize()` with raw settings (or bypasses the adapter), TypeScript will accept `"detail"` but the service will reject it as not in `["balanced","quality","speed"]`. **Fix consistent with existing patterns:** 1. Pick one vocabulary. The workspace already uses `"detail"` in the UI; the service uses `"quality"`. Rename client side to `"detail"` and update `mapStitchPreference` to be a no-op (drop the function entirely). 2. OR rename the workspace side to `"quality"` and update `RightPanel`'s stitchPreference picker (`src/components/workspace/RightPanel.tsx`) to match. Recommended: rename the client to `"detail"` so the workspace stays the source of truth — `mapStitchPreference` becomes identity, and the `DigitizeAdapters` comment about "the service caps at 10" stays accurate. Acceptance: `grep -rn '"quality"\|"detail"' src/` shows one vocabulary; `mapStitchPreference` either disappears or is a trivial identity; `tsc -p tsconfig.json` is clean.
Mark 2026-09-14 03:24:15 +00:00
Sign in to join this conversation.
No description provided.