fix(presentation): show a disabled query as idle instead of empty (R3-4)

A disabled query (no data, no error, not fetching) fell through
deriveAsyncState to "empty", so AsyncSurface rendered the
"no items" copy before the query had even started.

- AsyncState.base gains "idle" for "not started / waiting on a
  precondition". A completed empty result (`[]`, `""`, `null`) stays
  "empty"; a real first load stays "initial-loading".
- AsyncSurface renders an optional `idle` slot for idle, else nothing
  (no skeleton, no aria-busy, no empty copy, no children).

Consumer-facing: AsyncState["base"] union adds "idle" (additive);
AsyncSurface gains an optional `idle` prop. No in-repo exhaustive
switch over base needed changes.

RED (before the fix, node scripts/run-vitest.ts on the two files):
  application-query-bridge > disabled query: expected 'empty' to be 'idle'
  async-surface > derives base state 4 ({}): expected 'empty' to be 'idle'
  async-surface > idle renders neither loading nor empty:
    toBeEmptyDOMElement() received the empty-copy section
  Tests 3 failed | 25 passed (pins for first load, [] and null empty passed)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-24 15:14:11 +09:00
co-authored by Claude Opus 5.5
parent d66ae19ad0
commit 5848493580
4 changed files with 57 additions and 5 deletions
@@ -91,6 +91,8 @@ export function TerminalErrorSurface({
export type AsyncSurfaceProps = Readonly<{
state: AsyncState;
children?: ReactNode;
/** Shown while the query has not started (e.g. disabled); nothing if omitted. */
idle?: ReactNode;
onAction?: () => void;
onRetry?: () => void;
onResolveConflict?: () => void;
@@ -102,12 +104,14 @@ export type AsyncSurfaceProps = Readonly<{
export function AsyncSurface({
state,
children,
idle,
onAction,
onRetry,
onResolveConflict,
onReconcileUnknownEffect,
}: AsyncSurfaceProps) {
const { message } = useLocale();
if (state.base === "idle") return idle ?? null;
if (state.base === "initial-loading") return <LoadingSurface />;
if (state.base === "empty") return <EmptySurface />;
if (state.base === "terminal-error" && state.failure) {