Repository navigation
feat(@formatjs/editor): refine localization workflows - #7403
Merged
longlho merged 5 commits intoSep 15, 2026
Merged
Conversation
pgonsolin
marked this pull request as ready for review
September 14, 2026 19:45
longlho
enabled auto-merge (squash)
September 14, 2026 19:58
longlho
force-pushed
the
psi/editor-workflow-refinements
branch
from
September 14, 2026 20:21
062e292 to
f69241c
Compare
longlho
added a commit
that referenced
this pull request
Sep 14, 2026
Fork PR tests fall back to local Bazel execution while main uses RBE, so their action keys differ. The old `disk-Test-` restore prefix also matches examples caches: #7403 restored a 51 MiB examples cache before running roughly 50,000 actions locally. Give the GHA test job a dedicated Ubuntu 24.04 disk cache and run the same local configuration on main and PRs. Main saves a fresh snapshot per run, including completed actions when later tests fail; PRs only restore. The prefix includes architecture and Bazel version and cannot match examples or release caches. BuildBuddy workflows and release jobs retain their existing remote execution setup. Validation: actionlint 1.7.12 and repository commit hooks. End-to-end cache reuse requires a main run to seed the new namespace after merge, followed by a PR restore; no speedup is claimed yet. The initial main run and later cache misses execute locally, so cold runs can still be slow. This changes neither #7403 nor its running workflows.
longlho
force-pushed
the
psi/editor-workflow-refinements
branch
2 times, most recently
from
September 15, 2026 01:34
f89a1f3 to
1543734
Compare
longlho
force-pushed
the
psi/editor-workflow-refinements
branch
2 times, most recently
from
September 15, 2026 02:20
90ab837 to
9291af0
Compare
Merged
4 of 5 tasks
longlho
added a commit
that referenced
this pull request
Oct 27, 2026
… editors (#7706) ## Motivation A consumer can run several independent translation workspaces (for example a web app and two mobile apps) in one editor deployment, and each workspace receives messages from several upload streams (for example a main branch and a release branch). Today `@formatjs/editor` models a single message set with optional per-message `catalogs` and a `catalog` filter, and location links have to be built by every consumer through `renderLocation`. This PR adds: 1. A **project model** so the shell can list and switch workspaces while the consumer loads that project's messages, locales, and save handler. 2. **Per-message source membership**, distinct from catalogs, with a composable filter, a context row, and row badges. 3. Enough **location metadata** plus exported helpers to build source links without consumer-side hardcoding. Default rendering stays plain text. Follows the conventions of #7403 and #7424: flat files under `packages/editor`, tests next to code, exports through `index.ts` / `ui.tsx`, CHANGELOG left to the release tooling, no consumer-specific naming. ## API additions | Area | Addition | Notes | | --- | --- | --- | | `workflow.ts` | `EditorProject {id, label, description?}` | New type | | `workflow.ts` | `TranslationEditorOptions.projects?`, `project?` (controlled), `defaultProject?`, `onProjectChange?` | All optional; the hook never loads data | | `workflow.ts` | `TranslationEditorState.projects`, `project`, `setProject(id, {discardDrafts?})` | Returns `ProjectChangeResult`: `changed` / `unchanged` / `blocked` (`unsaved-drafts` or `unknown-project`). Resets page, selection, and catalog/source filters | | `workflow.ts` | `ProjectChangeResult`, `ProjectChangeOptions` | New types | | `workflow.ts` | `EditorMessage.sources?: readonly string[]` | Upload streams, distinct from `catalogs` | | `workflow.ts` | `TranslationEditorState.sources`, `source`, `setSource` | Empty-string "all" sentinel, same as `catalog`; composes with status, catalog, and search | | `source-location.ts` | `SourceLocation.source?`, `repository?`, `revision?` | `SourceLocation` is still exported from `workflow.ts` | | `source-location.ts` | `formatSourceLocation(location)` | The `file`, `file:start`, `file:start–end` text `MessageContext` already used | | `source-location.ts` | `resolveSourceLocationHref(location, {baseUrl?, repository?, revision?, lineFragment?})`, `SourceLocationHrefOptions` | `baseUrl` is a string with optional `{repository}` / `{revision}` placeholders or a function; returns `undefined` without a base or a placeholder value | | `core.tsx` | `EditorState.clearSelection()` | Lets workflows drop an explicit selection | | `message-context.tsx` | "Sources" row, `copySources`, labels `sources` / `sourceCopy` | Hidden when the message has no sources | | `design-system.tsx` | `ProjectPicker`, `SourceFilter`, `SourceBadge` adapters and their props types | Optional additions to `EditorToolComponents`; native `<select>` / `<select>` / `<span>` implementations | | `ui.tsx` | `TranslationEditorViewProps.projects?`, `sourceFilter?`; `EditorProjectSelection`, `EditorSourceSelection` | Picker renders when more than one project exists, filter when any source exists | | `ui.tsx` | `EditorMessageRenderState.sources`, `EditorViewMessage.sources?` | Default rows render `SourceBadge`s; custom `renderMessage` receives `state.sources` | | `ui.tsx` | Labels `project`, `sources`, `sourceFilter`, `allSources`, `sourceBadge(source)` | Overridable through `labels` | The spec called for `ProjectPicker` and `SourceBadge`; a third `SourceFilter` adapter was added so the composed view can render the source filter through the design system instead of a raw `<select>`. ## Compatibility - Every option, prop, message field, and label is optional; `projects` defaults to an empty list and `project` to `undefined`. - Existing design-system registries keep type-checking: the new adapters sit in `EditorToolComponents`, which is already `Partial` in `EditorComponents`, and fall back to the native implementations. - `TranslationEditorView` passes `filters` through unchanged when no project or source data is supplied. - `SourceLocation` keeps its shape and export path; `MessageContext` default location text is unchanged. - All 57 existing editor tests pass unchanged; 16 tests were added (73 total). ## Test plan Run in this environment (no Bazel available on the machine): - [x] `tsc` over `packages/editor/*.ts(x)` with the root `tsconfig.json` (`isolatedDeclarations`, `strict`) and the `#packages/*` path mapping – clean - [x] `vitest run` for all 7 editor test files with happy-dom – 73 passed (57 on `main`) - [x] `oxfmt --check packages/editor/` and `oxlint packages/editor/` – clean - [x] `codescythe` dead-export check – clean - [ ] `bazel test //packages/editor/...` – not run locally; relies on CI New tests: - `workflow.test.tsx`: source filter composing with status, catalog, and search; uncontrolled switching resets page/selection/filters and reports `unchanged` / `unknown-project`; `unsaved-drafts` blocks until reset or `discardDrafts`; controlled projects wait for the consumer. - `source-location.test.ts`: file-only, `file:start`, `file:start–end`, placeholders with repository/revision present and absent, fallbacks, path encoding, resolver and fragment overrides, no link without a base. - `tools.test.tsx`: `MessageContext` sources row with copy controls and omission without sources; text-only default locations with resolver-built links via `renderLocation`; native `ProjectPicker` (keyboard-focusable `<select>`, labelled options, disabled), `SourceFilter`, and `SourceBadge`. - `ui.test.tsx`: view renders the picker only with more than one project and the filter only with sources, badges only on rows with sources; custom registries without the new adapters still work and `renderMessage` receives `state.sources`. The demo under `packages/editor/demo` and the VRT gallery were left unchanged: wiring new controls into the StyleX demo is not cheap enough to include here, and nothing new renders without project or source data, so existing visual baselines are unaffected. ## Consumer binding This package only models projects, sources, and location metadata. Loading a project's messages, confirming draft discards, and mapping `repository` / `revision` to a specific hosting URL live in the consuming application, outside this package. --------- Co-authored-by: pgonsolin <[email protected]> Co-authored-by: Long Ho <[email protected]>
longlho
added a commit
that referenced
this pull request
Oct 28, 2026
… editors (#7706) ## Motivation A consumer can run several independent translation workspaces (for example a web app and two mobile apps) in one editor deployment, and each workspace receives messages from several upload streams (for example a main branch and a release branch). Today `@formatjs/editor` models a single message set with optional per-message `catalogs` and a `catalog` filter, and location links have to be built by every consumer through `renderLocation`. This PR adds: 1. A **project model** so the shell can list and switch workspaces while the consumer loads that project's messages, locales, and save handler. 2. **Per-message source membership**, distinct from catalogs, with a composable filter, a context row, and row badges. 3. Enough **location metadata** plus exported helpers to build source links without consumer-side hardcoding. Default rendering stays plain text. Follows the conventions of #7403 and #7424: flat files under `packages/editor`, tests next to code, exports through `index.ts` / `ui.tsx`, CHANGELOG left to the release tooling, no consumer-specific naming. ## API additions | Area | Addition | Notes | | --- | --- | --- | | `workflow.ts` | `EditorProject {id, label, description?}` | New type | | `workflow.ts` | `TranslationEditorOptions.projects?`, `project?` (controlled), `defaultProject?`, `onProjectChange?` | All optional; the hook never loads data | | `workflow.ts` | `TranslationEditorState.projects`, `project`, `setProject(id, {discardDrafts?})` | Returns `ProjectChangeResult`: `changed` / `unchanged` / `blocked` (`unsaved-drafts` or `unknown-project`). Resets page, selection, and catalog/source filters | | `workflow.ts` | `ProjectChangeResult`, `ProjectChangeOptions` | New types | | `workflow.ts` | `EditorMessage.sources?: readonly string[]` | Upload streams, distinct from `catalogs` | | `workflow.ts` | `TranslationEditorState.sources`, `source`, `setSource` | Empty-string "all" sentinel, same as `catalog`; composes with status, catalog, and search | | `source-location.ts` | `SourceLocation.source?`, `repository?`, `revision?` | `SourceLocation` is still exported from `workflow.ts` | | `source-location.ts` | `formatSourceLocation(location)` | The `file`, `file:start`, `file:start–end` text `MessageContext` already used | | `source-location.ts` | `resolveSourceLocationHref(location, {baseUrl?, repository?, revision?, lineFragment?})`, `SourceLocationHrefOptions` | `baseUrl` is a string with optional `{repository}` / `{revision}` placeholders or a function; returns `undefined` without a base or a placeholder value | | `core.tsx` | `EditorState.clearSelection()` | Lets workflows drop an explicit selection | | `message-context.tsx` | "Sources" row, `copySources`, labels `sources` / `sourceCopy` | Hidden when the message has no sources | | `design-system.tsx` | `ProjectPicker`, `SourceFilter`, `SourceBadge` adapters and their props types | Optional additions to `EditorToolComponents`; native `<select>` / `<select>` / `<span>` implementations | | `ui.tsx` | `TranslationEditorViewProps.projects?`, `sourceFilter?`; `EditorProjectSelection`, `EditorSourceSelection` | Picker renders when more than one project exists, filter when any source exists | | `ui.tsx` | `EditorMessageRenderState.sources`, `EditorViewMessage.sources?` | Default rows render `SourceBadge`s; custom `renderMessage` receives `state.sources` | | `ui.tsx` | Labels `project`, `sources`, `sourceFilter`, `allSources`, `sourceBadge(source)` | Overridable through `labels` | The spec called for `ProjectPicker` and `SourceBadge`; a third `SourceFilter` adapter was added so the composed view can render the source filter through the design system instead of a raw `<select>`. ## Compatibility - Every option, prop, message field, and label is optional; `projects` defaults to an empty list and `project` to `undefined`. - Existing design-system registries keep type-checking: the new adapters sit in `EditorToolComponents`, which is already `Partial` in `EditorComponents`, and fall back to the native implementations. - `TranslationEditorView` passes `filters` through unchanged when no project or source data is supplied. - `SourceLocation` keeps its shape and export path; `MessageContext` default location text is unchanged. - All 57 existing editor tests pass unchanged; 16 tests were added (73 total). ## Test plan Run in this environment (no Bazel available on the machine): - [x] `tsc` over `packages/editor/*.ts(x)` with the root `tsconfig.json` (`isolatedDeclarations`, `strict`) and the `#packages/*` path mapping – clean - [x] `vitest run` for all 7 editor test files with happy-dom – 73 passed (57 on `main`) - [x] `oxfmt --check packages/editor/` and `oxlint packages/editor/` – clean - [x] `codescythe` dead-export check – clean - [ ] `bazel test //packages/editor/...` – not run locally; relies on CI New tests: - `workflow.test.tsx`: source filter composing with status, catalog, and search; uncontrolled switching resets page/selection/filters and reports `unchanged` / `unknown-project`; `unsaved-drafts` blocks until reset or `discardDrafts`; controlled projects wait for the consumer. - `source-location.test.ts`: file-only, `file:start`, `file:start–end`, placeholders with repository/revision present and absent, fallbacks, path encoding, resolver and fragment overrides, no link without a base. - `tools.test.tsx`: `MessageContext` sources row with copy controls and omission without sources; text-only default locations with resolver-built links via `renderLocation`; native `ProjectPicker` (keyboard-focusable `<select>`, labelled options, disabled), `SourceFilter`, and `SourceBadge`. - `ui.test.tsx`: view renders the picker only with more than one project and the filter only with sources, badges only on rows with sources; custom registries without the new adapters still work and `renderMessage` receives `state.sources`. The demo under `packages/editor/demo` and the VRT gallery were left unchanged: wiring new controls into the StyleX demo is not cheap enough to include here, and nothing new renders without project or source data, so existing visual baselines are unaffected. ## Consumer binding This package only models projects, sources, and location metadata. Loading a project's messages, confirming draft discards, and mapping `repository` / `revision` to a specific hosting URL live in the consuming application, outside this package. --------- Co-authored-by: pgonsolin <[email protected]> Co-authored-by: Long Ho <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Consumers of
@formatjs/editorcurrently have to duplicate controlled editor behavior when they need a description-only search, richly rendered locale labels, exact metadata copy controls, compact autosizing translation fields, a remembered grid/list preference, multi-locale status semantics, or parser-backed preview eligibility. That makes product integrations own behavior that belongs at the reusable editor seam.This was found while simplifying ppl-ai/agi#215483, whose host application should retain locale policy and design-system bindings without parallel editor implementations.
What changed
descriptionQuerystate to the headless editor and a separately controlleddescriptionSearchfield to the composed view. Description and general searches are conjunctive; workflow pagination resets for either query.renderLocaleLabel(locale, label)while preserving plain accessible label text and the picker's existing controlled selection, Select All, and contiguous column ordering.MessageContext, sharingCopyTextButtonfeedback and host clipboard adapters.useTranslationLayout, defaulting to grid and persisting valid grid/list preferences through browser storage or a supplied adapter.hasTranslationForEveryLocale/matchesMessageStatusfor the all-selected translated and any-selected missing contract.hasMeaningfulIcuStructure, which accepts only valid parser output containing non-literal ICU elements; plain literals, escaped braces, and invalid drafts are not previewable.Consumer-owned locale naming, design-system presentation, fetching/debouncing/cancellation, server persistence, and product-specific status help remain outside the package.
Verification
//packages/editor:unit_test: 47 tests pass, including the new workflow utility and adapter regressions.//packages/editor:pkg,:typecheck, and:unit_test_typecheckbuild.