Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit f78eb96

Browse files
committed
Merge origin/main (f6fb83f) into claude/issue-10981-silence-clause-closure
Picks up PR #11020 (objectui#9256), whose metric-card refusal texts the merge queue ran this branch's closure walk against. Claude-Session: https://claude.ai/code/session_012UwY3ahMixEFkfTUxMVkYm Co-authored-by: Claude <noreply@anthropic.com>
2 parents 6230156 + f6fb83f commit f78eb96

30 files changed

Lines changed: 1309 additions & 46 deletions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@object-ui/app-shell': minor
3+
'@object-ui/types': minor
4+
'@object-ui/i18n': patch
5+
'@object-ui/cli': patch
6+
---
7+
8+
New SDUI widget `cloud:plan-status`: a "Current plan" badge for one plan card on the Cloud pricing page, shown when that card's plan is the organization's plan (objectui#10919).
9+
10+
**Clause-②: yes** — the accept set of `AnyComponentSchema`, and so of `safeValidateSchema` and `objectui validate`, widens by one `type` literal, `cloud:plan-status`, and `@object-ui/types/zod` exports one new schema, `CloudPlanStatusSchema`. Nothing that parsed before is refused now.
11+
12+
**Why.** The pricing page is static metadata, and nothing in a page's expression scope carries the organization's plan, so the page could not tell which of its cards the organization is already on. The plan is available only from the org-scoped `GET /cloud/environment-entitlements` summary.
13+
14+
**What changed, in observable terms.**
15+
16+
- `@object-ui/app-shell` registers `cloud:plan-status`. A page places one node on each plan card and names that card's plan code in `properties.plan`: `{ "type": "cloud:plan-status", "properties": { "plan": "free" } }`. The widget reads the summary through the hook the environment list already uses, and renders the badge when the summary's `plan` equals `properties.plan`. The comparison is exact, so `Free` does not match `free`.
17+
- The widget renders nothing on every other card, while the summary loads, when the request fails, and when the body is not the `{ success, data }` envelope. It never guesses a plan.
18+
- The node's `className` and `responsiveStyles` reach the badge. Each node reads the summary itself, so a page with three cards makes three requests.
19+
- The widget is registered under one key, `cloud:plan-status`. There is no bare `plan-status` fallback and no `app-shell:`-prefixed twin.
20+
- `@object-ui/types/zod` exports `CloudPlanStatusSchema`, a member of `AnyComponentSchema`. `properties` is required and must be exactly `{ plan }`, with `plan` a non-empty string. A missing bag, a missing or empty `plan`, and any other key in the bag are each refused at that path.
21+
- `body` and `children` are refused by name on this node, because the widget reads neither.
22+
- `plan` is not an enum: the plan catalog belongs to the control plane, and ObjectUI does not list its codes.
23+
- `@object-ui/i18n` adds `cloudPlanStatus.current` ("Current plan") to all ten locale packs.
24+
- `@object-ui/cli`: `objectui check` knows `cloud:plan-status` as a registered type.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
'@object-ui/types': minor
3+
---
4+
5+
**BREAKING (shipped as `minor` — see below):** nineteen ADR-0080 public-block
6+
arms and the dashboard widget slot's `metric-card` node now refuse an authored
7+
`children` by name. None of these renderers reads the node's child list, so the
8+
key rendered nothing, with no render-time error or warning and no element
9+
(objectui#9256).
10+
11+
- `page:header`, `page:tabs`, `page:accordion`, `record:details`,
12+
`record:highlights`, `record:related_list`, `record:path`, `record:activity`,
13+
`record:discussion`, `record:history`, `record:quick_actions`,
14+
`record:reference_rail`, `element:text`, `element:number`, `element:button`,
15+
`element:divider`, `object-metric` and `object-master-detail-form`: `children`
16+
and `body` are declared as by-name refusals on the zod arm, each kept a member.
17+
This package has no TypeScript declaration of these nodes, so the zod face is
18+
the only one that changes.
19+
- `record:alert`: `children` only. Its `body` is the alert's message text, not a
20+
content channel, and is left as it was.
21+
- `page:tabs` and `page:accordion`: the node's own `children` only. Each item's
22+
`children` in `items` stays live — that is what these blocks render.
23+
- `metric-card` in a dashboard's `widgets`: `children?: never` and `body?: never`
24+
on the TypeScript face (`DashboardWidgetSlotComponentSchema`), and both keys
25+
refused by name on its zod twin. That twin is the first arm of the widget
26+
slot's union, so the refusal reaches the author inside the union's
27+
`invalid_union` issue at the widget's path, beside the strict widget schema's
28+
`unrecognized_keys`; `objectui validate` prints it as one arm of two.
29+
30+
What moves for an author:
31+
32+
- `children` on any of these nodes parsed green (and, on `metric-card`, also
33+
type-checked). It is now refused at `safeParse` time at its own path — on
34+
`metric-card`, under the widget's `invalid_union` — and on
35+
`DashboardWidgetSlotComponentSchema` at authoring time.
36+
- `body` was already refused on all of them, by `BaseSchema`. Everywhere except
37+
`record:alert`, the zod refusal message now names what the node renders
38+
instead, where it used to point at `children`, which these nodes do not read
39+
either.
40+
41+
No render behaviour changes: nothing read these keys, which is the whole reason
42+
they could be refused.
43+
44+
Migration: each of these nodes renders from its own keys, so there is no channel
45+
to move the content to. Put it in the key the node does render
46+
(`element:text`'s `properties.content`, the item-level `children` of a
47+
`page:tabs` or `page:accordion` item, `record:alert`'s `properties.body`), place
48+
it beside the node in a container that reads `children` (`page:section`,
49+
`page:card`), or drop it.
50+
51+
Also, text only: `CodeEditorSchema.children`'s docblock now names `onChange`
52+
among the keys `CodeEditorRenderer` forwards to Monaco.
53+
54+
`minor` rather than `major` because this repo's version policy forbids `major`
55+
in any changeset — one `fixed` group — and records `minor` plus an explicit
56+
breaking note as the spelling for a breaking change here.

‎packages/app-shell/package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"./dist/console/connect/ConnectAgentWidget.js",
1010
"./dist/console/diagnostics/CloudAiModelStatus.js",
1111
"./dist/console/home/CloudOnboardingNext.js",
12+
"./dist/console/home/CloudPlanStatus.js",
1213
"./dist/console/marketplace/InstalledListWidget.js",
1314
"./dist/services/builtinComponents.js",
1415
"./dist/views/global-notifications-renderer.js",
@@ -24,6 +25,7 @@
2425
"./src/console/connect/ConnectAgentWidget.tsx",
2526
"./src/console/diagnostics/CloudAiModelStatus.tsx",
2627
"./src/console/home/CloudOnboardingNext.tsx",
28+
"./src/console/home/CloudPlanStatus.tsx",
2729
"./src/console/marketplace/InstalledListWidget.tsx",
2830
"./src/services/builtinComponents.tsx",
2931
"./src/views/global-notifications-renderer.tsx",
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* CloudPlanStatus — the "current plan" marker for one plan card on the Cloud
5+
* control plane's pricing page, registered as the SDUI widget
6+
* `cloud:plan-status` (objectui#10919).
7+
*
8+
* The pricing page is static metadata: nothing in its expression scope carries
9+
* the organization's plan, so a page cannot tell which of its cards is the one
10+
* the organization is already on. The plan is only available from the
11+
* org-scoped `GET /cloud/environment-entitlements` summary (`data.plan`). This
12+
* widget reads that summary and answers one question for the card it is placed
13+
* on: is this card's plan the organization's plan?
14+
*
15+
* • the summary names this card's plan → a localized "Current plan" badge;
16+
* • the summary names another plan → nothing;
17+
* • loading, failed, or no summary → nothing. The plan is never guessed:
18+
* only the authoritative summary (`source: 'summary'`) can mark a card, and
19+
* the row-derived fallback carries no plan at all.
20+
*
21+
* ## One node per card, and the page names the card
22+
*
23+
* The plan code a card stands for is the page's, not this widget's: the plan
24+
* catalog belongs to the control plane, so the page passes its own code in
25+
* `properties.plan` (the `properties` bag is the spelling every page component
26+
* is authored in) and the widget compares it VERBATIM with `data.plan`. No
27+
* code is listed, normalized or defaulted here.
28+
*
29+
* ## The summary is read through `useEnvironmentEntitlements`
30+
*
31+
* The same hook the environment list uses — one reading of the endpoint and its
32+
* strict `{ success, data }` envelope, not a third copy of the fetch. It is
33+
* enabled unconditionally here because this widget exists only to read it.
34+
*/
35+
36+
import { useState } from 'react';
37+
import { Badge, cn } from '@object-ui/components';
38+
import { createAuthenticatedFetch } from '@object-ui/auth';
39+
import { ComponentRegistry } from '@object-ui/core';
40+
import { useObjectTranslation } from '@object-ui/i18n';
41+
import { useAdapter } from '../../providers/AdapterProvider.js';
42+
import { useEnvironmentEntitlements } from '../../environment/useEnvironmentEntitlements.js';
43+
44+
export interface CloudPlanStatusProps {
45+
properties?: {
46+
/**
47+
* The plan code of the card this node sits on, exactly as the control
48+
* plane's entitlements summary spells it (for example `free`).
49+
*/
50+
plan?: string;
51+
};
52+
/** Carries the scope class of the node's `responsiveStyles`. */
53+
className?: string;
54+
}
55+
56+
export function CloudPlanStatus({ properties, className }: CloudPlanStatusProps) {
57+
const { t } = useObjectTranslation();
58+
const dataSource = useAdapter();
59+
// `useState`, not `useMemo`: the hook keys its fetch effect on this function,
60+
// so its identity has to be one React guarantees to keep (AGENTS.md #10).
61+
const [authFetch] = useState(() => createAuthenticatedFetch());
62+
const entitlements = useEnvironmentEntitlements({
63+
enabled: true,
64+
dataSource,
65+
authFetch,
66+
apiBase: (import.meta.env.VITE_SERVER_URL as string | undefined) || '',
67+
});
68+
69+
const plan = properties?.plan;
70+
const isCurrent =
71+
typeof plan === 'string'
72+
&& plan !== ''
73+
&& entitlements?.source === 'summary'
74+
&& entitlements.plan === plan;
75+
if (!isCurrent) return null;
76+
77+
return (
78+
<Badge variant="secondary" className={cn(className)} data-plan-status="current">
79+
{t('cloudPlanStatus.current')}
80+
</Badge>
81+
);
82+
}
83+
84+
// SDUI registration — the Cloud pricing page places one node per plan card.
85+
// Registered under the `cloud` namespace with no bare fallback, so the one key
86+
// is `cloud:plan-status`: the spelling the page authors, and the one literal
87+
// its `@object-ui/types` arm claims (`CloudPlanStatusSchema`).
88+
ComponentRegistry.register('plan-status', (props: CloudPlanStatusProps) => (
89+
<CloudPlanStatus {...props} />
90+
), {
91+
namespace: 'cloud',
92+
skipFallback: true,
93+
label: 'Cloud Plan Status',
94+
category: 'plugin',
95+
inputs: [],
96+
});
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* CloudPlanStatus (`cloud:plan-status`, objectui#10919) marks ONE plan card on
5+
* the Cloud pricing page: a "Current plan" badge when the organization's plan,
6+
* read from the authoritative entitlements summary, equals the card's
7+
* `properties.plan` — and nothing in every other state, so a plan is never
8+
* guessed.
9+
*/
10+
11+
import { describe, it, expect, vi, afterEach } from 'vitest';
12+
import { render, screen, waitFor, cleanup } from '@testing-library/react';
13+
import React from 'react';
14+
15+
let fetchImpl: (url: string, init?: RequestInit) => Promise<unknown>;
16+
const fetchedUrls: string[] = [];
17+
18+
vi.mock('@object-ui/auth', async (importOriginal) => ({
19+
...(await importOriginal<Record<string, unknown>>()),
20+
useAuth: () => ({ activeOrganization: { id: 'org_1' } }),
21+
createAuthenticatedFetch: () => (url: string, init?: RequestInit) => {
22+
fetchedUrls.push(url);
23+
return fetchImpl(url, init);
24+
},
25+
}));
26+
27+
import { I18nProvider } from '@object-ui/i18n';
28+
import { ComponentRegistry } from '@object-ui/core';
29+
import { AdapterCtx, SchemaRenderer } from '@object-ui/react';
30+
import { CloudPlanStatus } from '../CloudPlanStatus';
31+
32+
/**
33+
* The badge text resolves from the locale packs, so a real i18n context is
34+
* needed — without one `t()` returns the raw key and a text assertion would
35+
* pass against nothing. The adapter is the row-derived fallback's data source;
36+
* its rows name a production env, so the fallback resolves `derived` for real
37+
* rather than failing.
38+
*/
39+
const adapter = { find: vi.fn().mockResolvedValue([{ id: 'env_1', environment_type: 'production' }]) };
40+
41+
const renderInShell = (ui: React.ReactElement) =>
42+
render(
43+
<I18nProvider config={{ defaultLanguage: 'en', detectBrowserLanguage: false }}>
44+
<AdapterCtx.Provider value={adapter as never}>{ui}</AdapterCtx.Provider>
45+
</I18nProvider>,
46+
);
47+
48+
/** The control plane's `{ success, data }` envelope around a summary naming `plan`. */
49+
function summary(plan: string) {
50+
return {
51+
ok: true,
52+
status: 200,
53+
json: async () => ({ success: true, data: { plan, hasProductionEnv: true } }),
54+
};
55+
}
56+
57+
afterEach(() => {
58+
cleanup();
59+
fetchedUrls.length = 0;
60+
adapter.find.mockClear();
61+
});
62+
63+
describe('CloudPlanStatus (objectui#10919)', () => {
64+
it('marks the card whose plan is the organization\'s plan', async () => {
65+
fetchImpl = async () => summary('free');
66+
const { container } = renderInShell(<CloudPlanStatus properties={{ plan: 'free' }} />);
67+
68+
expect(await screen.findByText('Current plan')).toBeTruthy();
69+
expect(container.querySelector('[data-plan-status="current"]')).toBeTruthy();
70+
});
71+
72+
it('reads the org-scoped summary endpoint', async () => {
73+
fetchImpl = async () => summary('free');
74+
renderInShell(<CloudPlanStatus properties={{ plan: 'free' }} />);
75+
76+
await screen.findByText('Current plan');
77+
expect(fetchedUrls).toEqual(['/api/v1/cloud/environment-entitlements?organizationId=org_1']);
78+
});
79+
80+
it('renders nothing on a card whose plan is not the organization\'s', async () => {
81+
fetchImpl = async () => summary('team');
82+
const { container } = renderInShell(<CloudPlanStatus properties={{ plan: 'free' }} />);
83+
84+
// Wait until the summary was actually read, so the empty render is a
85+
// verdict on it and not the loading state.
86+
await waitFor(() => expect(fetchedUrls).toHaveLength(1));
87+
await new Promise((r) => setTimeout(r, 0));
88+
expect(container.innerHTML).toBe('');
89+
});
90+
91+
it('compares the plan code verbatim — no case folding', async () => {
92+
fetchImpl = async () => summary('free');
93+
const { container } = renderInShell(<CloudPlanStatus properties={{ plan: 'Free' }} />);
94+
95+
await waitFor(() => expect(fetchedUrls).toHaveLength(1));
96+
await new Promise((r) => setTimeout(r, 0));
97+
expect(container.innerHTML).toBe('');
98+
});
99+
100+
it('renders nothing while the summary is loading', () => {
101+
fetchImpl = () => new Promise(() => {});
102+
const { container } = renderInShell(<CloudPlanStatus properties={{ plan: 'free' }} />);
103+
104+
expect(container.innerHTML).toBe('');
105+
});
106+
107+
it('renders nothing when the summary fails — the row-derived fallback carries no plan', async () => {
108+
fetchImpl = async () => ({ ok: false, status: 500, json: async () => null });
109+
const { container } = renderInShell(<CloudPlanStatus properties={{ plan: 'free' }} />);
110+
111+
// The hook fell through to the rows, which resolve (source `derived`) but
112+
// name no plan — so the card is left unmarked instead of guessed.
113+
await waitFor(() => expect(adapter.find).toHaveBeenCalledTimes(1));
114+
await new Promise((r) => setTimeout(r, 0));
115+
expect(container.innerHTML).toBe('');
116+
});
117+
118+
it('renders nothing for a bare (un-enveloped) body that names the plan', async () => {
119+
// A bare body is a producer contract violation (cloud#1046): it yields no
120+
// summary, so even a `plan` that matches must not mark the card.
121+
fetchImpl = async () => ({ ok: true, status: 200, json: async () => ({ plan: 'free' }) });
122+
const { container } = renderInShell(<CloudPlanStatus properties={{ plan: 'free' }} />);
123+
124+
await waitFor(() => expect(adapter.find).toHaveBeenCalledTimes(1));
125+
await new Promise((r) => setTimeout(r, 0));
126+
expect(container.innerHTML).toBe('');
127+
});
128+
129+
it('renders nothing when the node names no plan', async () => {
130+
fetchImpl = async () => summary('free');
131+
const { container } = renderInShell(<CloudPlanStatus />);
132+
133+
await waitFor(() => expect(fetchedUrls).toHaveLength(1));
134+
await new Promise((r) => setTimeout(r, 0));
135+
expect(container.innerHTML).toBe('');
136+
});
137+
});
138+
139+
describe('`cloud:plan-status` registration (objectui#10919)', () => {
140+
it('is registered under the one key the page authors, with no second spelling', () => {
141+
expect(ComponentRegistry.has('cloud:plan-status')).toBe(true);
142+
// `skipFallback: true` — no bare `plan-status` fallback …
143+
expect(ComponentRegistry.has('plan-status')).toBe(false);
144+
// … and no `app-shell:`-prefixed twin.
145+
expect(ComponentRegistry.has('app-shell:cloud:plan-status')).toBe(false);
146+
});
147+
148+
it('renders from a page node through SchemaRenderer, reading `properties.plan`', async () => {
149+
fetchImpl = async () => summary('team');
150+
const { container } = renderInShell(
151+
<SchemaRenderer
152+
schema={{
153+
type: 'cloud:plan-status',
154+
id: 'plan_team_current',
155+
responsiveStyles: { large: { alignSelf: 'flex-start' } },
156+
properties: { plan: 'team' },
157+
} as never}
158+
/>,
159+
);
160+
161+
expect(await screen.findByText('Current plan')).toBeTruthy();
162+
// The node's `responsiveStyles` scope class reaches the badge through
163+
// `className`, so the page can place it inside its card.
164+
const scope = container.querySelector('style[data-os-scope]')?.getAttribute('data-os-scope');
165+
expect(scope).toBeTruthy();
166+
const badge = container.querySelector('[data-plan-status="current"]');
167+
expect(badge?.classList.contains(scope as string)).toBe(true);
168+
});
169+
});

‎packages/app-shell/src/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ import './console/marketplace/InstalledListWidget.js';
313313
import './console/connect/ConnectAgentWidget.js';
314314
// SDUI widget for the Cloud Welcome page's state-aware onboarding next-step.
315315
import './console/home/CloudOnboardingNext.js';
316+
// SDUI widget for the Cloud pricing page's "current plan" marker (objectui#10919).
317+
import './console/home/CloudPlanStatus.js';
316318
// SDUI widget: read-only admin diagnostic for the env's effective AI model
317319
// (cloud#797) — fetches GET /api/v1/ai/effective-model.
318320
import './console/diagnostics/CloudAiModelStatus.js';

‎packages/cli/src/__tests__/registered-types-validate-ratchet-10859.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,14 @@ describe('registered NAMESPACED component types refused at `type` — a ratchet
196196
expect(refusedAtType(key), key).toBe(false);
197197
}
198198
});
199+
200+
it('counts `cloud:plan-status` armed — it registered WITH its arm (objectui#10919)', () => {
201+
// One registry key (`skipFallback: true`, so no bare `plan-status`), armed in
202+
// `@object-ui/types/zod` in the same change, so the pin above did not move.
203+
expect(NAMESPACED_KEYS).toContain('cloud:plan-status');
204+
expect(BARE_KEYS).not.toContain('plan-status');
205+
expect(refusedAtType('cloud:plan-status')).toBe(false);
206+
});
199207
});
200208

201209
/* ── End to end: the README document through `objectui validate` ─────────── */

‎packages/cli/src/utils/known-schema-types.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const KNOWN_SCHEMA_TYPES: readonly string[] = [
8686
'cloud-connection:panel',
8787
'cloud:ai-model-status',
8888
'cloud:onboarding-next',
89+
'cloud:plan-status',
8990
'code',
9091
'code-editor',
9192
'collapsible',

0 commit comments

Comments
 (0)