Skip to content

feat(ui-core): useProjectReadiness — one answer to the journey's where-am-I (#288) - #294

Merged
JArmandoAnaya merged 1 commit into
mainfrom
journey/pr1-readiness
Aug 4, 2026
Merged

feat(ui-core): useProjectReadiness — one answer to the journey's where-am-I (#288)#294
JArmandoAnaya merged 1 commit into
mainfrom
journey/pr1-readiness

Conversation

@JArmandoAnaya

Copy link
Copy Markdown
Contributor

Closes #288.

First of the five journey-navigation PRs (#288#292). Queries only — no UI consumes the hook yet.

What

useProjectReadiness(projectId) in frontend/ui-core/src/screens/queries.ts, exported from index.ts, composing the three queries the project header already runs:

  • hasSchema via useActiveSchema, reading SCHEMA_NOT_FOUND off the error the way ProjectScreen's SchemaSection does — that 404 is an answer (hasSchema: false), any other failure means the hook answers null. This is now the single spelling of "has a schema"; the three existing sites are deliberately untouched (new code uses the hook, old sites migrate as touched).
  • hasAssets / hasAnnotations / annotatedPct from useProjectStats.
  • hasBatchInAnnotation from useBatches, the header's own filter.
  • currentStep: labelsimagesannotate (nothing annotated or any batch not yet completed) → export. "done" is declared but not yet derivable — a TODO records that hasReleases (two-hop dataset → releases) and ingest-in-flight (no project-scoped ingest-jobs hook on the wire client) are deliberately out of v1.

The hook returns null until every source has answered — a checklist drawn from half an answer says something false with confidence.

What it costs

Zero requests on the project screen: all three queries share their keys with the header's. Asserted, not claimed — the new test renders a header stand-in beside the hook and counts exactly three requests, none of them /schema/versions (the history tab's fetch-on-open pin in screens.test.tsx holds).

Tests

New frontend/ui-core/src/screens/readiness.test.tsx (7): one per step transition, the SCHEMA_NOT_FOUND branch, the real-failure-answers-null branch, and the request-count assertion. No existing test touched.

bash scripts/check.sh frontend: All checks passed (ui-core 381 tests / 26 files, annotator + scripts suites included).

useProjectReadiness composes the three queries the project header already
runs — active schema, project stats, batches — so it costs zero requests
on the project screen, and it is the single spelling of "has a schema"
from here on: the schema-less 404 is an answer, any other failure means
the hook answers null rather than guessing. currentStep walks
labels -> images -> annotate -> export; "done" is declared and waits on
hasReleases and an ingest-in-flight signal, both recorded as out of v1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add useProjectReadiness hook and normalize the has-schema question

1 participant