fix: honor language changes on clean updates - #548
Open
Gautam Sharma (GautamSharma99) wants to merge 1 commit into
Open
fix: honor language changes on clean updates#548Gautam Sharma (GautamSharma99) wants to merge 1 commit into
Gautam Sharma (GautamSharma99) wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 918ec7f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Summary
Fixes #538.
Clean repository updates now treat an explicit primary-language change as meaningful work. A command such as:
will no longer return through the clean-tree no-op path when the persisted wiki language is English. It proceeds through provider setup and reaches the existing whole-wiki translation pass.
This PR also keeps the no-op optimization for equivalent language variants, wires the same decision into the pre-credential startup shortcut, centralizes primary-language comparison, adds regression tests, and includes a patch changeset.
Problem
The update flow checked for a clean-tree no-op before creating run context or resolving the translation plan:
getUpdateNoopStatus()considered metadata, git HEAD, worktree changes, ignored paths, and interrupted runs, but received no language intent. On a clean tree it returnedshouldSkip: trueeven whenoptions.languagerequested a full language switch.The same bug existed one layer earlier in
resolveStartupCommand(). A credential-less--printrun could use the clean-update shortcut and return successfully without requiring credentials, even though translation needed a model call.Implementation
Language-aware no-op status
getUpdateNoopStatus()now accepts the requested language and compares it with the persisted.last-update.jsonlanguage before evaluating git state.When their primary language subtags differ it returns:
An absent persisted language is treated as English, matching the existing translation behavior for metadata written by older OpenWiki versions.
The requested language is validated and canonicalized through
resolveLanguage()before comparison. Invalid programmatic values therefore do not create a false language switch; the CLI already drops them with its existing warning.Same semantics as translation
The translation middleware already intentionally compares primary subtags so region-only changes do not trigger a whole-wiki rewrite—for example,
enanden-GBare considered equivalent.That comparison is now centralized in
getPrimaryLanguageSubtag()and shared by:resolveTranslationPlan().This prevents the optimization and translation pass from drifting into different definitions of a language switch.
Both early-return paths updated
The requested language is passed into no-op evaluation from:
runOpenWikiAgent(), which owns the actual clean-tree early return;canSkipCleanUpdateBeforeCredentials(), which lets genuine print-mode no-ops exit without configured provider credentials.A real language change can therefore no longer be skipped at either layer.
Behavior matrix
frfrdeenenenen-GBpt-BRpt-PTTests
No-op regression coverage
test/update-noop.test.tsnow verifies that:output language changed;en-GBrequest remains a no-op.Startup regression coverage
test/startup.test.tsnow verifies that a clean--printupdate requesting French does not use the credential-free no-op shortcut. With no provider key configured, startup correctly reports the missing credential because model-backed translation must run.Shared language comparison
test/language.test.tscovers:Existing translation tests continue to verify full-pass versus region-only behavior through the same shared helper.
Validation
corepack pnpm test— 67 files, 797 tests passedcorepack pnpm exec vitest run test/update-noop.test.ts test/startup.test.ts test/translation-middleware.test.ts test/language.test.ts— 48 tests passedcorepack pnpm run typecheckcorepack pnpm run lint:checkcorepack pnpm run format:checkcorepack pnpm exec changeset statusgit diff --check