Skip to content

Add theme dev reconciliation strategy flag#7634

Open
gonzaloriestra wants to merge 1 commit into
cli-interactivity/app-dev-flagsfrom
cli-interactivity/theme-dev-reconciliation
Open

Add theme dev reconciliation strategy flag#7634
gonzaloriestra wants to merge 1 commit into
cli-interactivity/app-dev-flagsfrom
cli-interactivity/theme-dev-reconciliation

Conversation

@gonzaloriestra

@gonzaloriestra gonzaloriestra commented May 25, 2026

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Fixes https://github.com/shop/issues-develop/issues/22873

The interactivity audit found that theme dev with --theme-editor-sync could still prompt when JSON files needed reconciliation.

WHAT is this pull request doing?

  • Adds --reconciliation-strategy with keep-local, keep-remote, and abort options.
  • Threads the strategy through theme editor sync reconciliation and refreshes generated command docs.

How to test your changes?

Make a change in a theme file (like templates/404.json) locally and remotely and run:

  • shopify theme dev --theme-editor-sync
  • shopify theme dev --theme-editor-sync --reconciliation-strategy keep-local
  • shopify theme dev --theme-editor-sync --reconciliation-strategy keep-remote
  • shopify theme dev --theme-editor-sync --reconciliation-strategy abort

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing, so I've added a changelog entry with pnpm changeset add

gonzaloriestra commented May 25, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label May 25, 2026
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch 2 times, most recently from bc8df22 to c635c86 Compare May 26, 2026 14:53
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-profile-token branch 2 times, most recently from b73773b to 8f6ca1c Compare May 26, 2026 15:22
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch 2 times, most recently from 17976d9 to a727f50 Compare May 26, 2026 15:31
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-profile-token branch from 8f6ca1c to fee06e6 Compare June 1, 2026 11:43
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch 2 times, most recently from cf17902 to f1bd642 Compare June 1, 2026 11:58
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-profile-token branch from fee06e6 to ad55535 Compare June 1, 2026 11:58
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch from f1bd642 to e4069c5 Compare June 1, 2026 12:20
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-profile-token branch from ad55535 to 8d70823 Compare June 1, 2026 12:20
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/private/node/constants.d.ts
@@ -7,6 +7,7 @@ export declare const environmentVariables: {
     enableCliRedirect: string;
     env: string;
     firstPartyDev: string;
+    hostedApps: string;
     noAnalytics: string;
     optOutInstrumentation: string;
     appAutomationToken: string;
packages/cli-kit/dist/public/common/version.d.ts
@@ -1 +1 @@
-export declare const CLI_KIT_VERSION = "4.1.0";
\ No newline at end of file
+export declare const CLI_KIT_VERSION = "4.0.0";
\ No newline at end of file
packages/cli-kit/dist/public/node/context/local.d.ts
@@ -42,6 +42,13 @@ export declare function isShopify(env?: NodeJS.ProcessEnv): Promise<boolean>;
  * @returns True if the SHOPIFY_UNIT_TEST environment variable is truthy.
  */
 export declare function isUnitTest(env?: NodeJS.ProcessEnv): boolean;
+/**
+ * Returns true if the CLI is running in hosted apps mode.
+ *
+ * @param env - The environment variables from the environment of the current process.
+ * @returns True if the HOSTED_APPS environment variable is truthy.
+ */
+export declare function isHostedAppsMode(env?: NodeJS.ProcessEnv): boolean;
 /**
  * Returns true if reporting analytics is enabled.
  *

@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch from e4069c5 to c5d2d3f Compare June 1, 2026 12:45
@gonzaloriestra gonzaloriestra changed the base branch from cli-interactivity/theme-profile-token to graphite-base/7634 June 15, 2026 10:53
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch from c5d2d3f to 2b45cf7 Compare June 15, 2026 10:53
@gonzaloriestra gonzaloriestra changed the base branch from graphite-base/7634 to cli-interactivity/app-dev-flags June 15, 2026 10:53
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch from 2b45cf7 to 3fcd3c1 Compare June 15, 2026 11:40
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/app-dev-flags branch from c22f504 to 155a4b3 Compare June 15, 2026 11:40
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch from 3fcd3c1 to e4ccca0 Compare June 15, 2026 11:46
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/app-dev-flags branch from 155a4b3 to bc9aaca Compare June 16, 2026 08:58
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch from e4ccca0 to 469f7c2 Compare June 16, 2026 08:58
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/app-dev-flags branch from bc9aaca to b1b95a3 Compare June 16, 2026 11:26
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch 2 times, most recently from 1e5307e to 5a86eaf Compare June 16, 2026 12:03
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/app-dev-flags branch 2 times, most recently from 2237293 to 9471955 Compare June 16, 2026 13:34
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/app-dev-flags branch from 9471955 to 8d194da Compare July 1, 2026 14:10
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch from 5a86eaf to 348790c Compare July 1, 2026 14:10
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/app-dev-flags branch from 8d194da to d849219 Compare July 1, 2026 14:18
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch from 348790c to 0b212e4 Compare July 1, 2026 14:18
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/app-dev-flags branch from c82c565 to aa85d78 Compare July 2, 2026 11:33
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch 2 times, most recently from 1fa107f to 69e1254 Compare July 2, 2026 12:07
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/app-dev-flags branch from aa85d78 to 5f73f48 Compare July 2, 2026 12:07
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch from 69e1254 to bd3c62b Compare July 2, 2026 12:43
@github-actions github-actions Bot added Area: @shopify/theme @shopify/theme package issues and removed no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. labels Jul 2, 2026
@gonzaloriestra gonzaloriestra marked this pull request as ready for review July 2, 2026 13:03
@gonzaloriestra gonzaloriestra requested review from a team as code owners July 2, 2026 13:03
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/app-dev-flags branch from 02fc84c to 278d226 Compare July 2, 2026 13:41
@gonzaloriestra gonzaloriestra force-pushed the cli-interactivity/theme-dev-reconciliation branch from bd3c62b to 1e98f09 Compare July 2, 2026 13:41

@lucyxiang lucyxiang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Review assisted by pair-review

env: 'SHOPIFY_FLAG_STANDARD_EVENTS_INSPECTOR',
default: false,
}),
'reconciliation-strategy': Flags.string({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme dev --reconciliation-strategy keep-local on its own does nothing and emits no warning, shall we add dependency on theme-editor-sync?

Suggestion: Consider declaring the dependency so oclif surfaces an error instead of silently ignoring the flag:

Suggested change
'reconciliation-strategy': Flags.string({
'reconciliation-strategy': Flags.string({
description:
'How to resolve JSON conflicts when --theme-editor-sync is enabled. Use keep-local to keep local files, keep-remote to keep remote files, or abort to fail instead of prompting.',
options: ['keep-local', 'keep-remote', 'abort'],
env: 'SHOPIFY_FLAG_RECONCILIATION_STRATEGY',
dependsOn: ['theme-editor-sync'],
}),

})

describe('files only present on remote developer theme', () => {
test('should download assets from remote theme without prompting when keep-remote strategy is selected', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we check that local files do get deleted

})

describe('files with conflicting checksums', () => {
test('should keep local files without prompting when keep-local strategy is selected', async () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly check than remote files are deleted

Comment on lines +190 to +194
case 'abort':
throw new AbortError(
'Theme JSON files need reconciliation.',
`${title}\n${files.map((file) => `- ${file.key}`).join('\n')}`,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about collecting all files and throwing one AbortError that lists every file needing reconciliation, rather than throwing inside the per-category callback on the first hit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: @shopify/theme @shopify/theme package issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants