Skip to content

fix(agentic-localization): harden translation inspector writes#7

Merged
nkgentile merged 5 commits intomainfrom
harden-translation-inspector
Mar 3, 2026
Merged

fix(agentic-localization): harden translation inspector writes#7
nkgentile merged 5 commits intomainfrom
harden-translation-inspector

Conversation

@nkgentile
Copy link
Copy Markdown
Contributor

Summary

  • Fix double-append bug@sanity/client's Patch stores insert as a single slot; chaining two .append() calls silently overwrites the first. Split metadata transaction into two patches so both translations and workflowStates persist.
  • Deterministic metadata IDsgetTranslationMetadataId() using @sanity/id-utils with createIfNotExists prevents race-condition duplicates from concurrent tabs.
  • Studio operations for approve/dismiss/applydocumentStore.pair.editOperations() replaces raw client.patch() for permission-aware, lifecycle-correct writes. RBAC gating via useDocumentPairPermissions.
  • Fix draft-only language detectionuseDocumentLanguage switched from preview store (useDocumentValues) to documentStore.listenQuery with raw perspective, fixing "no language set" on newly translated docs.
  • Remove legacy typesLegacyDocumentStatus, deprecated summary/materialityExplanation fields, and isPublished removed. Dashboard-only lifecycle statuses moved to TranslationStatusBadge.
  • Fix writeReviewProgress race — atomic array patches replace read-modify-write pattern.
  • Seed realistic workflow states into sample metadata docs.
  • Unit tests for ids, staleAnalysisCache, types, and getStatusDisplay.

Test plan

  • Open base-language article → inspector shows mix of approved/needsReview/stale/missing
  • Translate a missing locale → status transitions to "Needs Review", metadata persists both translation ref and workflow state
  • Open newly translated doc → inspector shows language correctly (no "doesn't have a language set")
  • Approve a locale → status transitions to "Approved"
  • pnpm --filter l10n test — 158 tests pass
  • pnpm generate-sample-data — only expected draft-reference warnings

…ence

Enables purple presence indicators in Studio when Agent Actions
(translate, prompt, generate) are processing documents.
…tadata lifecycle

- Fix double-append bug: @sanity/client's Patch stores insert as a single
  slot, so chaining two .append() calls overwrites the first. Split metadata
  transaction into two patches (translations + workflowStates).
- Deterministic metadata IDs via getTranslationMetadataId() using
  @sanity/id-utils, with createIfNotExists to prevent race-condition
  duplicates from concurrent tabs.
- Validate result._id from translate API before using it.
- Use Studio's documentStore.pair.editOperations() for approve, dismiss,
  and apply-pre-translation actions (permission-aware, proper doc lifecycle).
- Add useDocumentPairPermissions RBAC gating on metadata writes.
- Fix writeReviewProgress read-modify-write race with atomic array patches.
- Fix useDocumentLanguage for draft-only docs by switching from preview
  store (useDocumentValues) to documentStore.listenQuery with raw perspective.
- Don't clear locale selection until translation succeeds.
- Seed realistic workflowStates and staleAnalysis into sample metadata docs.
- Add unit tests for ids, staleAnalysisCache, types, and getStatusDisplay.
…ated fields

- Remove LegacyDocumentStatus and TranslationDataStatus types from l10n
  package — dashboard-only lifecycle statuses (published, draft, inRelease,
  missingWithFallback) now live in the dashboard's TranslationStatusBadge.
- Remove deprecated summary/materialityExplanation fields from
  StaleAnalysisResult and schema; consolidate on single explanation field.
- Remove deprecated isPublished from LocaleTranslation (use documentState).
- Use KeyedObject from sanity instead of manual _key: string on
  WorkflowStateEntry, ReviewProgress, and dashboard types.
- Simplify parseAnalysisResponse in both function and hook to drop
  legacy field fallback logic.
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ai-shopping-assistant Ready Ready Preview, Comment Mar 3, 2026 5:22pm

Request Review

…ctual script

Add missing "consolidates env files" step and a collapsed manual-steps
section listing the individual CLI commands for each bootstrap step.
@nkgentile nkgentile temporarily deployed to ai-shopping-assistant March 3, 2026 17:21 — with GitHub Actions Inactive
@nkgentile nkgentile temporarily deployed to agentic-localization March 3, 2026 17:21 — with GitHub Actions Inactive
@nkgentile nkgentile merged commit 75ed91d into main Mar 3, 2026
4 checks passed
@nkgentile nkgentile deleted the harden-translation-inspector branch March 3, 2026 17:23
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.

1 participant