Skip to content

[docs] test#1042

Open
aspire-repo-bot[bot] wants to merge 1 commit into
release/13.4from
docs/polyglot-resource-snapshot-command-state-2-ee58dcc78d697e78
Open

[docs] test#1042
aspire-repo-bot[bot] wants to merge 1 commit into
release/13.4from
docs/polyglot-resource-snapshot-command-state-2-ee58dcc78d697e78

Conversation

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

test

Generated by PR Documentation Check for issue #17328 · ● 42.6M ·

… support

TypeScript AppHosts can now gate command state using ctx.resourceSnapshot()
on UpdateCommandStateContext, exposed via the new UpdateCommandStateResourceSnapshot
DTO added in microsoft/aspire#17328. Remove the outdated caution note that said
TypeScript had no resourceSnapshot equivalent, and replace it with a working
example that mirrors the C# health-gated command pattern.

Also update the Japanese (ja) localization of the same page.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aspire-repo-bot aspire-repo-bot Bot added the docs-from-code Copilot initiated issue from dotnet/aspire repo label May 21, 2026
@aspire-repo-bot aspire-repo-bot Bot requested a review from davidfowl May 21, 2026 21:26
@IEvangelist IEvangelist marked this pull request as ready for review May 21, 2026 22:04
@IEvangelist IEvangelist self-requested a review as a code owner May 21, 2026 22:04
Copilot AI review requested due to automatic review settings May 21, 2026 22:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the “Update command state logic” documentation to describe TypeScript updateState as supporting resource-snapshot-based gating (mirroring the C# pattern), and applies the same change to the Japanese translation.

Changes:

  • Replaces the previous TypeScript caution/limitations guidance with a resourceSnapshot()-based approach.
  • Adds a TypeScript example that imports HealthStatus/ResourceCommandState and gates command enablement on health.
  • Updates accompanying explanatory bullets in both English and Japanese docs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/frontend/src/content/docs/fundamentals/custom-resource-commands.mdx Updates TypeScript updateState docs and example to use resourceSnapshot() + health gating.
src/frontend/src/content/docs/ja/fundamentals/custom-resource-commands.mdx Japanese translation of the same TypeScript updateState docs and example updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +290 to 294
In TypeScript the `updateState` field on `CommandOptions` is an async callback that receives an `UpdateCommandStateContext`. The context exposes:

- `serviceProvider` — used to resolve services.
- `resourceSnapshot()` — an async function that returns a curated snapshot of the resource instance, including `healthStatus` and `state` (lifecycle state).

Comment on lines 297 to +312
```typescript title="apphost.ts"
import { HealthStatus, ResourceCommandState } from './.modules/aspire.js';

await cache.withCommand(
"clear-cache",
"Clear Cache",
executeClearCache,
{
commandOptions: {
iconName: "AnimalRabbitOff",
updateState: async (ctx) => {
const snapshot = await ctx.resourceSnapshot();

return snapshot.healthStatus === HealthStatus.Healthy
? ResourceCommandState.Enabled
: ResourceCommandState.Disabled;
Comment on lines +289 to +292
TypeScript では `CommandOptions` の `updateState` フィールドは非同期コールバックで、`UpdateCommandStateContext` を受け取ります。コンテキストは以下を公開します。

TypeScript では `CommandOptions` の `updateState` フィールドが緩い型(`any`)であり、SDK はまだ `ResourceCommandState` 列挙体をエクスポートしていません。現時点の TypeScript AppHost で最も単純な方法は、`updateState` を完全に省略することです。コマンドは既定で有効になり、リソース到達後にのみコマンド登録します。
- `serviceProvider` — サービスを解決するために使用します。
- `resourceSnapshot()` — リソース インスタンスのスナップショット(`healthStatus` とライフサイクル状態の `state` を含む)を返す非同期関数。
Comment on lines 296 to +312
```typescript title="apphost.ts"
import { HealthStatus, ResourceCommandState } from './.modules/aspire.js';

await cache.withCommand(
"clear-cache",
"Clear Cache",
executeClearCache,
{
commandOptions: {
iconName: "AnimalRabbitOff",
updateState: async (ctx) => {
const snapshot = await ctx.resourceSnapshot();

return snapshot.healthStatus === HealthStatus.Healthy
? ResourceCommandState.Enabled
: ResourceCommandState.Disabled;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-from-code Copilot initiated issue from dotnet/aspire repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant