Skip to content

Surface block-level contextual objects in TAE snippets#1160

Open
graygilmore wants to merge 2 commits intomainfrom
gg-tae-snippet-completions
Open

Surface block-level contextual objects in TAE snippets#1160
graygilmore wants to merge 2 commits intomainfrom
gg-tae-snippet-completions

Conversation

@graygilmore
Copy link
Contributor

@graygilmore graygilmore commented Mar 23, 2026

Summary

In a theme app extension, snippets can only be rendered from blocks/*.liquid files, so the ambient context always includes the block-level objects (section, block, recommendations, app). Previously, the completion and diagnostic systems only provided app for snippets regardless of project mode — no autocomplete or hover for section, block, or recommendations in TAE snippet files.

Commit 1: Thread project mode through TypeSystem and UndefinedObject check

Adds an optional getModeForURI callback to TypeSystem, CompletionsProvider, and HoverProvider, and passes context.mode into the UndefinedObject check. No behavior changes — pure plumbing so that downstream code can branch on project mode.

Commit 2: Surface block-level contextual objects in TAE snippets

When mode is app, snippets now get the same contextual objects as blocks: section, block, recommendations, app. This applies to both completions and the UndefinedObject diagnostic.

Closes #346

🎩 Tophatting

  1. Open a theme app extension project in VS Code with the Shopify Liquid extension
  2. Create or open a snippets/*.liquid file
  3. Type {{ section — you should now see section in the autocomplete suggestions
  4. Verify block, recommendations, and app also appear
  5. Verify there are no UndefinedObject warnings for these objects
  6. Open a regular theme project (not a TAE) and confirm snippets still only get appsection, block, and recommendations should NOT appear

@graygilmore graygilmore force-pushed the gg-tae-snippet-completions branch from c09c9c6 to e5870d6 Compare March 23, 2026 18:35
graygilmore and others added 2 commits March 23, 2026 11:46
The contextual objects available in a Liquid file (e.g. section, block, recommendations) are currently determined solely by file path. This makes it impossible to vary behavior based on whether the project is a theme or a theme app extension.

This adds an optional getModeForURI callback to TypeSystem, CompletionsProvider, and HoverProvider, and passes context.mode into the UndefinedObject check's getContextualObjects. No behavior changes yet — mode is accepted but not acted on.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In a theme app extension, snippets can only be rendered from blocks/*.liquid files, so the ambient context always includes the block-level objects (section, block, recommendations, app). Previously, the completion and diagnostic systems only provided 'app' for snippets regardless of project mode, which meant developers got no autocomplete or hover for section, block, or recommendations in TAE snippet files.

Now when mode is 'app', snippets get the same contextual objects as blocks.

Closes #346

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@graygilmore graygilmore force-pushed the gg-tae-snippet-completions branch from e5870d6 to f0de2f8 Compare March 23, 2026 18:46
if (relativePath.startsWith('snippets/')) {
// In a theme app extension, snippets can only be rendered from blocks,
// so they have access to the same contextual objects as blocks.
if (mode === 'app') return BLOCK_CONTEXTUAL_OBJECTS;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of threading mode all the way through we could do something really lazy here but the cost doesn't seem too bad and it sets up a pattern that we might want to use in other areas.

@graygilmore graygilmore marked this pull request as ready for review March 23, 2026 23:21
@graygilmore graygilmore requested a review from a team as a code owner March 23, 2026 23:21
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.

recommendations is an object that is available to the Section Rendering API

1 participant