Skip to content

Commit 6403930

Browse files
committed
feat(app-shell,i18n): draw the DEPENDENCY_MISSING install refusal in the author's terms
ADR-0141 D2 refuses an install whose declared dependencies the environment does not satisfy (422 DEPENDENCY_MISSING, details.unmet[]). The Console showed the envelope's English sentence. The package page's Install, the catalog page's organization install on a self-hosted runtime and Setup -> Packages -> Import now draw a heading plus one line per unmet entry from the refusal's own facts (dependency, range, found, installed version), in all ten locale packs. installLocal() and the Packages page's request helper carry the envelope's details (and code) on the error they throw. A refusal whose facts cannot be read in full keeps the server's message. Claude-Session: https://claude.ai/code/session_01NndsH9Qm7k6AS2i2fWbjNA Co-authored-by: Claude <noreply@anthropic.com>
1 parent be78977 commit 6403930

20 files changed

Lines changed: 733 additions & 9 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@object-ui/app-shell': minor
3+
'@object-ui/i18n': minor
4+
---
5+
6+
feat(app-shell,i18n): the Console draws the install refusal `DEPENDENCY_MISSING` in the author's terms, one line per unmet dependency
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
ADR-0141 D2 refuses to install a package whose declared `dependencies` the environment does not satisfy (`422 DEPENDENCY_MISSING`, `details.unmet[]` naming each entry's `dependency`, `range`, what was `found` and the `installedVersion`). The Console showed the envelope's English sentence, the same in every locale and without the ranges.
12+
13+
- **`@object-ui/app-shell`:** the three install surfaces that go through `install-local` (the package page's Install, the catalog page's organization install on a self-hosted runtime, and Setup → Packages → Import) draw the refusal from its facts: a heading saying nothing was installed, then one line per unmet entry, such as 「请先安装 app.objectstack.hotcrm 6.x。」 or "Install com.acme.billing ^2.1.0 first. Version 1.4.0 is installed." `installLocal()` now carries the envelope's `details` on the error it throws, and the Packages page's request helper carries `code` and `details`. A refusal whose facts the Console cannot read in full (an older runtime, or a `found` value it does not know) keeps the server's message.
14+
- **`@object-ui/i18n`:** `marketplace.install.dependencyMissing.*` (a heading and one line for each `found` value) in all ten locale packs.
15+
16+
What to do: nothing.

‎ui/packages/app-shell/src/console/marketplace/MarketplacePackagePage.tsx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ import {
8080
type LocalInstallStrippedLock,
8181
type CloudInstallationInfo,
8282
} from './marketplaceApi.js';
83+
import { useDependencyMissingText } from './dependencyMissing.js';
8384
import { getCloudBase, getRuntimeConfig, isMarketplaceEnabled } from '../../runtime-config.js';
8485
import { emitMetadataRefresh } from '../../assistant/assistantBus.js';
8586
import { useMetadata } from '../../providers/MetadataProvider.js';
@@ -144,6 +145,7 @@ export function MarketplacePackagePage() {
144145
const { packageId, appName } = useParams<{ packageId?: string; appName?: string }>();
145146
const { isAdmin, isResolved } = useWorkspaceAdminStatus();
146147
const { t, language } = useObjectTranslation();
148+
const dependencyMissingText = useDependencyMissingText();
147149
// Dates and numbers on this surface read the display locale; a bare
148150
// `toLocale*()` call used the MACHINE's locale (objectui#9909).
149151
const displayLocale = useDisplayLocale();
@@ -637,7 +639,13 @@ export function MarketplacePackagePage() {
637639
// remedy, and the page has nothing to add to it.
638640
const code = e?.code;
639641
let msg = e?.message ?? String(e);
640-
if (errorCodeIs(e, 'MANIFEST_CONFLICT')) {
642+
// ADR-0141 D2 — an unsatisfied declared dependency, drawn from the
643+
// refusal's facts in the reader's locale; without facts the envelope's
644+
// message stands.
645+
const dependencyMissing = dependencyMissingText(e);
646+
if (dependencyMissing) {
647+
msg = dependencyMissing;
648+
} else if (errorCodeIs(e, 'MANIFEST_CONFLICT')) {
641649
msg = t('marketplace.install.localManifestConflict', { message: msg });
642650
} else if (errorCodeIs(e, 'UNAUTHENTICATED')) {
643651
msg = t('marketplace.install.localUnauthorized');

‎ui/packages/app-shell/src/console/marketplace/MarketplacePage.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { emitMetadataRefresh } from '../../assistant/assistantBus.js';
4545
import { appRouteSegment, filterActiveApps, resolveKeyedI18nLabel } from '../../utils/index.js';
4646
import { waitForServedApp, type ServedApp } from './waitForServedApp.js';
4747
import { splitPackageSuffix } from './middleTruncate.js';
48+
import { useDependencyMissingText } from './dependencyMissing.js';
4849
import { packagesHref } from '../../views/metadata-admin/packageSource.js';
4950

5051
/**
@@ -214,6 +215,7 @@ export function MarketplacePage() {
214215
const { appName } = useParams();
215216
const { isAdmin, isResolved } = useWorkspaceAdminStatus();
216217
const { t, language } = useObjectTranslation();
218+
const dependencyMissingText = useDependencyMissingText();
217219
const { appLabel } = useObjectLabel();
218220
// The adapter `MetadataProvider` reads through: the deploy wait asks the
219221
// same `GET /meta/app` the cache would, without the cache persisting it.
@@ -412,7 +414,9 @@ export function MarketplacePage() {
412414
await load();
413415
}
414416
} catch (e: any) {
415-
setOrgMsg({ ok: false, text: e?.message ?? String(e) });
417+
// ADR-0141 D2 — a `DEPENDENCY_MISSING` refusal reads one line per unmet
418+
// dependency, from its own facts; anything else keeps its message.
419+
setOrgMsg({ ok: false, text: dependencyMissingText(e) ?? e?.message ?? String(e) });
416420
} finally {
417421
setOrgInstalling(null);
418422
}
@@ -623,7 +627,7 @@ export function MarketplacePage() {
623627
</div>
624628
{orgDeployNote}
625629
{orgMsg && (
626-
<div className={`rounded-md border p-3 text-sm ${orgMsg.ok ? 'border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400' : 'border-destructive/30 bg-destructive/5 text-destructive'}`}>
630+
<div className={`whitespace-pre-wrap rounded-md border p-3 text-sm ${orgMsg.ok ? 'border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400' : 'border-destructive/30 bg-destructive/5 text-destructive'}`}>
627631
{orgMsg.text}
628632
</div>
629633
)}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The package page draws the `422 DEPENDENCY_MISSING` install refusal
5+
* (ADR-0141 D2) in the author's terms — 「请先安装 HotCRM 6.x」 — one line per
6+
* unmet entry, from the refusal's own facts (objectstack#25792 item 3).
7+
*
8+
* `marketplaceApi` is NOT mocked: one stubbed `fetch` answers by path, so the
9+
* facts the page draws are the ones that crossed the wire. `t` echoes the KEY
10+
* and the interpolated facts: the claim is WHICH line each entry gets and that
11+
* it carries that entry's id, range and version.
12+
*/
13+
14+
import '@testing-library/jest-dom/vitest';
15+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
16+
import { act, cleanup, fireEvent, render, screen } from '@testing-library/react';
17+
18+
vi.mock('react-router-dom', () => ({
19+
useNavigate: () => vi.fn(),
20+
useParams: () => ({ packageId: 'pkg_psa' }),
21+
}));
22+
23+
vi.mock('@object-ui/auth', async (importOriginal) => ({
24+
...(await importOriginal<Record<string, unknown>>()),
25+
useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }),
26+
}));
27+
28+
vi.mock('@object-ui/i18n', async (importOriginal) => ({
29+
...(await importOriginal<Record<string, unknown>>()),
30+
useObjectTranslation: () => ({
31+
t: (key: string, o?: Record<string, unknown>) => {
32+
const facts = ['dependency', 'range', 'installedVersion'].filter((k) => o?.[k] !== undefined).map((k) => `${k}=${String(o?.[k])}`);
33+
return facts.length > 0 ? `«${key}|${facts.join('|')}»` : `«${key}»`;
34+
},
35+
language: 'en',
36+
}),
37+
}));
38+
39+
vi.mock('../../../assistant/assistantBus', () => ({ emitMetadataRefresh: () => {} }));
40+
vi.mock('../../../providers/MetadataProvider', () => ({ useMetadata: () => ({ refresh: async () => {} }) }));
41+
vi.mock('../../../components/SuggestedBindingsPanel', () => ({
42+
SuggestedBindingsPanel: () => <div data-testid="suggested-bindings" />,
43+
}));
44+
45+
import { initRuntimeConfig, resetRuntimeConfigForTesting } from '../../../runtime-config';
46+
import { MarketplacePackagePage } from '../MarketplacePackagePage';
47+
48+
const INSTALL_PATH = '/api/v1/marketplace/install-local';
49+
const MANIFEST_PATH = '/api/v1/marketplace/packages/pkg_psa/versions/latest/manifest';
50+
const CATALOG_PACKAGE = {
51+
package: { id: 'pkg_psa', manifest_id: 'com.acme.psa', display_name: 'PSA', latest_version: { id: 'ver_1', version: '1.0.0' } },
52+
versions: [{ id: 'ver_1', version: '1.0.0' }],
53+
};
54+
const SERVER_MESSAGE = 'SERVER-ENGLISH sentinel: Install refused: a declared dependency is not satisfied in this environment.';
55+
56+
let installBody: unknown;
57+
58+
const answer = (status: number, body: unknown) => ({
59+
ok: status >= 200 && status < 300,
60+
status,
61+
statusText: '',
62+
headers: new Headers({ 'content-type': 'application/json' }),
63+
json: async () => body,
64+
text: async () => JSON.stringify(body),
65+
});
66+
67+
async function boot() {
68+
resetRuntimeConfigForTesting();
69+
vi.stubGlobal('fetch', vi.fn(async (input: unknown, init?: { method?: string }) => {
70+
const path = new URL(String(input), 'http://console.test').pathname;
71+
const method = (init?.method ?? 'GET').toUpperCase();
72+
if (path === '/api/v1/runtime/config') {
73+
return answer(200, {
74+
cloudUrl: '', singleEnvironment: true,
75+
features: { installLocal: true, marketplace: true, aiStudio: true, autoPublishAiBuilds: true },
76+
branding: { productName: 'ObjectOS', productShortName: 'ObjectOS' },
77+
});
78+
}
79+
if (path === INSTALL_PATH && method === 'GET') return answer(200, { success: true, data: { items: [], total: 0 } });
80+
if (path === INSTALL_PATH && method === 'POST') return answer(422, installBody);
81+
if (path === MANIFEST_PATH) {
82+
return answer(200, { success: true, data: { manifest: { id: 'com.acme.psa', version: '1.0.0', type: 'app' }, version: '1.0.0', version_id: 'ver_1' } });
83+
}
84+
if (path === '/api/v1/marketplace/packages/pkg_psa') return answer(200, { success: true, data: CATALOG_PACKAGE });
85+
return answer(404, { success: false, error: { code: 'NOT_FOUND', message: `no route ${method} ${path}` } });
86+
}));
87+
await initRuntimeConfig();
88+
}
89+
90+
async function install() {
91+
render(<MarketplacePackagePage />);
92+
const button = await screen.findByRole('button', { name: '«marketplace.action.install»' });
93+
await act(async () => {});
94+
fireEvent.click(button);
95+
}
96+
97+
const refusal = (details: unknown) => ({
98+
success: false,
99+
error: { code: 'DEPENDENCY_MISSING', httpStatus: 422, message: SERVER_MESSAGE, details },
100+
});
101+
102+
beforeEach(() => { installBody = undefined; });
103+
afterEach(() => {
104+
cleanup();
105+
vi.unstubAllGlobals();
106+
resetRuntimeConfigForTesting();
107+
});
108+
109+
describe('the package page draws DEPENDENCY_MISSING from its facts (objectstack#25792)', () => {
110+
it('one line per unmet entry under the heading, in place of the server\'s English sentence', async () => {
111+
installBody = refusal({
112+
compatible: false,
113+
issues: [
114+
{ severity: 'error', category: 'dependency_missing', message: 'not installed' },
115+
{ severity: 'error', category: 'dependency_missing', message: 'out of range' },
116+
],
117+
unmet: [
118+
{ packageId: 'com.acme.psa', dependency: 'app.objectstack.hotcrm', range: '6.x', found: 'absent' },
119+
{ packageId: 'com.acme.psa', dependency: 'com.acme.billing', range: '^2.1.0', found: 'out-of-range', installedVersion: '1.4.0' },
120+
],
121+
});
122+
await boot();
123+
await install();
124+
125+
const note = await screen.findByText(/marketplace\.install\.dependencyMissing\.heading/);
126+
expect(note.textContent!.split('\n')).toEqual([
127+
'«marketplace.install.dependencyMissing.heading»',
128+
'• «marketplace.install.dependencyMissing.absent|dependency=app.objectstack.hotcrm|range=6.x|installedVersion=—»',
129+
'• «marketplace.install.dependencyMissing.outOfRange|dependency=com.acme.billing|range=^2.1.0|installedVersion=1.4.0»',
130+
]);
131+
expect(screen.queryByText(SERVER_MESSAGE)).not.toBeInTheDocument();
132+
});
133+
134+
it('CONTROL: a refusal without facts it can read keeps the envelope\'s own message', async () => {
135+
installBody = refusal({ compatible: false, issues: [] });
136+
await boot();
137+
await install();
138+
139+
expect(await screen.findByText(SERVER_MESSAGE)).toBeInTheDocument();
140+
expect(screen.queryByText(/dependencyMissing/)).not.toBeInTheDocument();
141+
});
142+
});
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The catalog page's org install on a self-hosted runtime (`installLocal`)
5+
* draws the `422 DEPENDENCY_MISSING` refusal (ADR-0141 D2) in the author's
6+
* terms, one line per unmet entry, from the refusal's own facts
7+
* (objectstack#25792 item 3).
8+
*
9+
* The catalog lists are stubbed; `installLocal` is the REAL client, so the
10+
* facts the strip draws are the ones that crossed the wire. `t` echoes the KEY
11+
* and the interpolated facts: the claim is WHICH line each entry gets and that
12+
* it carries that entry's id, range and version.
13+
*/
14+
15+
import '@testing-library/jest-dom/vitest';
16+
import { afterEach, describe, expect, it, vi } from 'vitest';
17+
import { cleanup, fireEvent, render, screen, within } from '@testing-library/react';
18+
19+
vi.mock('react-router-dom', () => ({
20+
useNavigate: () => vi.fn(),
21+
useParams: () => ({}),
22+
}));
23+
24+
vi.mock('@object-ui/auth', async (importOriginal) => ({
25+
...(await importOriginal<Record<string, unknown>>()),
26+
useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }),
27+
useAuth: () => ({ activeOrganization: { id: 'org_1' } }),
28+
}));
29+
30+
vi.mock('@object-ui/i18n', async (importOriginal) => ({
31+
...(await importOriginal<Record<string, unknown>>()),
32+
useObjectTranslation: () => ({
33+
t: (key: string, o?: Record<string, unknown>) => {
34+
const facts = ['dependency', 'range', 'installedVersion'].filter((k) => o?.[k] !== undefined).map((k) => `${k}=${String(o?.[k])}`);
35+
return facts.length > 0 ? `«${key}|${facts.join('|')}»` : `«${key}»`;
36+
},
37+
language: 'en',
38+
}),
39+
}));
40+
41+
const PKG = 'com.acme.psa';
42+
const ORG_ROW = {
43+
id: 'pkg_psa',
44+
manifest_id: PKG,
45+
display_name: 'Acme PSA',
46+
description: 'A PSA.',
47+
category: null,
48+
icon_url: null,
49+
visibility: 'org',
50+
latest_version: '1.0.0',
51+
};
52+
53+
vi.mock('../marketplaceApi', async (importOriginal) => ({
54+
...(await importOriginal<Record<string, unknown>>()),
55+
listMarketplacePackages: async () => ({ items: [] }),
56+
listLocalInstalls: async () => [],
57+
listOrgPackages: async () => ({ connected: true, items: [ORG_ROW] }),
58+
listInstalledPackages: async () => ({ connected: true, items: [] }),
59+
}));
60+
61+
import { ActiveOrganizationStorage } from '@object-ui/auth';
62+
import { initRuntimeConfig, resetRuntimeConfigForTesting } from '../../../runtime-config';
63+
import { MarketplacePage } from '../MarketplacePage';
64+
65+
const INSTALL_PATH = '/api/v1/marketplace/install-local';
66+
const SERVER_MESSAGE = 'SERVER-ENGLISH sentinel: Install refused: a declared dependency is not satisfied in this environment.';
67+
68+
const answer = (status: number, body: unknown) => ({
69+
ok: status >= 200 && status < 300,
70+
status,
71+
statusText: '',
72+
headers: new Headers({ 'content-type': 'application/json' }),
73+
json: async () => body,
74+
text: async () => JSON.stringify(body),
75+
});
76+
77+
async function boot(installBody: unknown) {
78+
resetRuntimeConfigForTesting();
79+
ActiveOrganizationStorage.set('org_1');
80+
vi.stubGlobal('fetch', vi.fn(async (input: unknown, init?: { method?: string }) => {
81+
const path = new URL(String(input), 'http://console.test').pathname;
82+
const method = (init?.method ?? 'GET').toUpperCase();
83+
if (path === INSTALL_PATH && method === 'POST') return answer(422, installBody);
84+
if (path === '/api/v1/runtime/config') {
85+
return answer(200, {
86+
cloudUrl: 'https://cloud.example', singleEnvironment: true, defaultEnvironmentId: 'env_1',
87+
features: { installLocal: true, marketplace: true, aiStudio: true, autoPublishAiBuilds: true },
88+
branding: { productName: 'ObjectOS', productShortName: 'ObjectOS' },
89+
});
90+
}
91+
return answer(404, { success: false, error: { code: 'NOT_FOUND', message: `no route ${method} ${path}` } });
92+
}));
93+
await initRuntimeConfig();
94+
}
95+
96+
async function installFromOrgCard() {
97+
render(<MarketplacePage />);
98+
const card = await screen.findByTestId(`org-card-${PKG}`);
99+
fireEvent.click(within(card).getByRole('button', { name: '«marketplace.org.install»' }));
100+
}
101+
102+
const refusal = (details: unknown) => ({
103+
success: false,
104+
error: { code: 'DEPENDENCY_MISSING', httpStatus: 422, message: SERVER_MESSAGE, details },
105+
});
106+
107+
afterEach(() => {
108+
cleanup();
109+
vi.unstubAllGlobals();
110+
resetRuntimeConfigForTesting();
111+
});
112+
113+
describe('the catalog page draws DEPENDENCY_MISSING from its facts (objectstack#25792)', () => {
114+
it('one line per unmet entry under the heading, in place of the server\'s English sentence', async () => {
115+
await boot(refusal({
116+
compatible: false,
117+
issues: [
118+
{ severity: 'error', category: 'dependency_missing', message: 'not installed' },
119+
{ severity: 'error', category: 'dependency_missing', message: 'version unreadable' },
120+
],
121+
unmet: [
122+
{ packageId: PKG, dependency: 'app.objectstack.hotcrm', range: '6.x', found: 'absent' },
123+
{ packageId: PKG, dependency: 'com.acme.billing', range: '^2.1.0', found: 'unreadable-version', installedVersion: 'nightly' },
124+
],
125+
}));
126+
await installFromOrgCard();
127+
128+
const strip = await screen.findByText(/marketplace\.install\.dependencyMissing\.heading/);
129+
expect(strip.textContent!.split('\n')).toEqual([
130+
'«marketplace.install.dependencyMissing.heading»',
131+
'• «marketplace.install.dependencyMissing.absent|dependency=app.objectstack.hotcrm|range=6.x|installedVersion=—»',
132+
'• «marketplace.install.dependencyMissing.unreadableVersion|dependency=com.acme.billing|range=^2.1.0|installedVersion=nightly»',
133+
]);
134+
// The lines stay lines on screen.
135+
expect(strip).toHaveClass('whitespace-pre-wrap');
136+
expect(screen.queryByText(SERVER_MESSAGE)).not.toBeInTheDocument();
137+
});
138+
139+
it('CONTROL: another refusal keeps the envelope\'s own message', async () => {
140+
await boot({ success: false, error: { code: 'MANIFEST_CONFLICT', httpStatus: 409, message: SERVER_MESSAGE } });
141+
await installFromOrgCard();
142+
143+
expect(await screen.findByText(SERVER_MESSAGE)).toBeInTheDocument();
144+
expect(screen.queryByText(/dependencyMissing/)).not.toBeInTheDocument();
145+
});
146+
});

0 commit comments

Comments
 (0)