Skip to content

feat: support the <context> core tag#558

Open
DylanPiercey wants to merge 1 commit into
mainfrom
claude/marko-context-tag-review-ukuhm3
Open

feat: support the <context> core tag#558
DylanPiercey wants to merge 1 commit into
mainfrom
claude/marko-context-tag-review-ukuhm3

Conversation

@DylanPiercey

Copy link
Copy Markdown
Contributor

Adds editor support for the new <context> core tag (marko-js/marko#3336):

  • from= completion: tag-name shorthand ("<my-tag>") completes like an import shorthand (shared machinery), and relative paths complete through the existing file completion. Both forms also get document links.
  • Typed tag variables: a consumer's variable is typed as exactly the provided value of the template from= resolves to. A provide-mode <context> threads its value's type out through the template's return type, so conditional and nested provide sites still type exactly (reading an unprovided context is a runtime error, not a valid undefined), and writable consumer assignments check against the provided type.

Includes a changeset, completion tests, and a hover/diagnostics fixture.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SsZZbkMsjMbDCQLxkrbqE9


Generated by Claude Code

@changeset-bot

changeset-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 73eb83a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@marko/language-tools Minor
@marko/language-server Minor

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

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a859f60d-4d34-4951-9ee1-7514b00c94e5

📥 Commits

Reviewing files that changed from the base of the PR and between 25a8edb and 73eb83a.

⛔ Files ignored due to path filters (21)
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/labeled-region.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/labeled-region.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/labeled-region.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/mode-provider.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/mode-provider.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/mode-provider.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-mode.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-mode.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-mode.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme-relative.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme-relative.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme-relative.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/theme-provider.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/theme-provider.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/theme-provider.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/index.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/index.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/index.ts is excluded by !**/__snapshots__/** and included by **
📒 Files selected for processing (16)
  • .changeset/context-tag-support.md
  • packages/language-server/src/__tests__/context-from-complete.test.ts
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/labeled-region.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/mode-provider.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/show-mode.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/show-theme-relative.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/show-theme.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/theme-provider.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/index.marko
  • packages/language-server/src/service/marko/complete/AttrValue.ts
  • packages/language-server/src/service/marko/complete/Import.ts
  • packages/language-server/src/service/marko/document-links.ts
  • packages/language-server/src/service/marko/util/context-from-attr.ts
  • packages/language-server/src/service/marko/util/tag-shorthand-completions.ts
  • packages/language-tools/marko.internal.d.ts
  • packages/language-tools/src/extractors/script/index.ts

Walkthrough

This pull request adds support for the Marko <context> core tag. New type declarations (withContext, contextTag, contextValue) enable typing of context-provided values. The script extractor is updated to detect context providers and consumers, wrapping template returns with withContext and generating typed consumer bindings, including handling for from= imports and mutable context values. Language server completion logic gains shared shorthand-tag completion generation used by both <context from="..."> and <import> tags, and document-link resolution is extended to resolve <context from="..."> targets. New fixture components and a test suite validate completion behavior, and a changeset documents the feature as a minor version bump for @marko/language-tools and @marko/language-server.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding support for the <context> core tag.
Description check ✅ Passed The description is directly related to the changeset and accurately describes the new <context> support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/marko-context-tag-review-ukuhm3

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/language-tools/src/extractors/script/index.ts`:
- Around line 416-424: The nested `<context>` capture from
`#getContextProvideTag` is being treated as if it were declared in the outer
template scope, which makes `withContext(context, ...)` reference an
out-of-scope identifier when the provider is emitted inside a generated
callback. Update `packages/language-tools/src/extractors/script/index.ts` so
`didProvide` only reflects providers in the current function scope, or hoist a
template-scope capture variable and assign to it from the nested provider path
in the `didProvide`/`didReturn` flow around `#extractor.write`,
`varShared("withContext")`, and `varLocal("context")`. Ensure the nested
callback code at the provider generation sites uses the hoisted capture instead
of a local `var context`.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f4d58d01-01dc-4eb3-b2ad-48819a64cbad

📥 Commits

Reviewing files that changed from the base of the PR and between 64cb1b0 and 25a8edb.

⛔ Files ignored due to path filters (18)
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/mode-provider.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/mode-provider.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/mode-provider.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-mode.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-mode.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-mode.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme-relative.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme-relative.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme-relative.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/show-theme.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/theme-provider.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/theme-provider.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/components/theme-provider.ts is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/index.html is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/index.md is excluded by !**/__snapshots__/** and included by **
  • packages/language-server/src/__tests__/fixtures/script/context-tag/__snapshots__/context-tag.expected/index.ts is excluded by !**/__snapshots__/** and included by **
📒 Files selected for processing (15)
  • .changeset/context-tag-support.md
  • packages/language-server/src/__tests__/context-from-complete.test.ts
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/mode-provider.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/show-mode.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/show-theme-relative.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/show-theme.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/components/theme-provider.marko
  • packages/language-server/src/__tests__/fixtures/script/context-tag/index.marko
  • packages/language-server/src/service/marko/complete/AttrValue.ts
  • packages/language-server/src/service/marko/complete/Import.ts
  • packages/language-server/src/service/marko/document-links.ts
  • packages/language-server/src/service/marko/util/context-from-attr.ts
  • packages/language-server/src/service/marko/util/tag-shorthand-completions.ts
  • packages/language-tools/marko.internal.d.ts
  • packages/language-tools/src/extractors/script/index.ts

Comment thread packages/language-tools/src/extractors/script/index.ts
The from= attribute gets tag-name ("<my-tag>") and relative path
completions plus document links, and a consumer's tag variable is
typed as exactly the provided value of the template from= resolves
to (a provide threads its value's type out through the template's
return type; conditional and nested provide sites still type
exactly, and writable assignments check against the provided type).
@DylanPiercey
DylanPiercey force-pushed the claude/marko-context-tag-review-ukuhm3 branch from 25a8edb to 73eb83a Compare July 9, 2026 00:08
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