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

Commit 63b4e0e

Browse files
authored
fix(app-shell,plugin-chatbot): repair the three breaks at the AI paywall moment (#7273)
The upgrade CTA opened a client-composed control-plane path that guessed the console mount, the app slug and the route, and landed on the API's ENDPOINT_NOT_FOUND JSON. Replace both deep-link helpers with cloudConsoleUrl(): the runtime-supplied cloud origin, no path appended, empty when the runtime named no upstream cloud (callers then render no link at all, instead of the old hardcoded vendor host). On a quota refusal the confirm card now holds an explicit blocked state carrying the server's own next step plus the upgrade action, rather than rolling back to "Confirm / Adjust" as though nothing had happened; transient failures keep the rollback, since retrying is the right next step there. Restoring composer text is now limited to text the user actually typed. Card buttons send canned messages, so the previous handler left the "restore" slot pointing at the user's earlier, already-answered prompt and refilled it.
1 parent ef1ffc2 commit 63b4e0e

14 files changed

Lines changed: 560 additions & 50 deletions
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
'@object-ui/app-shell': minor
3+
'@object-ui/plugin-chatbot': minor
4+
---
5+
6+
Fix the three breaks at the AI paywall moment (#7253), measured on a free plan's
7+
second build iteration when the cloud guardrail refuses "Confirm changes" with a
8+
429 `AI_DESIGN_QUOTA_EXHAUSTED`.
9+
10+
- **The upgrade CTA no longer opens a 404.** It used to open a client-composed
11+
`${cloudBase}/apps/cloud-control/sys_environment`, which guessed the control
12+
plane's console mount, app slug and route — all three wrong — and landed on
13+
the API's `ENDPOINT_NOT_FOUND` JSON. `cloudInstallDeepLink` /
14+
`cloudPricingDeepLink` are replaced by `cloudConsoleUrl()`, the
15+
runtime-supplied cloud origin with no path appended; the control plane's own
16+
root redirect decides the landing page. The former
17+
`|| 'https://cloud.objectos.app'` default is gone: a runtime with no upstream
18+
cloud now renders no upgrade link at all rather than pointing a self-hosted
19+
user at the vendor's SaaS.
20+
- **The confirm card gets an explicit failure state.** A quota refusal parks the
21+
card on "not applied" with the server's own next step (reset tomorrow /
22+
upgrade) plus the upgrade action, instead of silently rolling back to
23+
"Confirm / Adjust" as though the click had never happened. Transient failures
24+
(offline, per-minute rate limit) still roll back, because retrying is the
25+
right next step there.
26+
- **The composer is no longer refilled with an already-delivered message.**
27+
Only text typed into the composer is restorable now; card-driven sends
28+
(confirm, approve, suggestion chips) send canned text the user never typed and
29+
no longer leave the previous prompt staged as if it needed resending.

‎packages/app-shell/src/console/ai/AiChatPage.tsx‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ import { emitMetadataRefresh } from '../../assistant/assistantBus.js';
107107
import { getRuntimeConfig, isAiStudioEnabled } from '../../runtime-config.js';
108108
import { makerConvergedOnBuild, makerVisibleAgents } from '../../hooks/surfaceAgent.js';
109109
import { useCanAuthorMetadata } from '../../hooks/useCanAuthorMetadata.js';
110-
import { cloudPricingDeepLink } from '../marketplace/marketplaceApi.js';
110+
import { cloudConsoleUrl } from '../marketplace/marketplaceApi.js';
111111
import { useNavigationContext } from '../../context/NavigationContext.js';
112112
import {
113113
fetchConversation,
@@ -2242,7 +2242,15 @@ export function ChatPane({
22422242
>
22432243
<ChatbotEnhanced
22442244
className="min-h-0 flex-1 bg-background md:max-w-5xl"
2245-
onUpgrade={() => window.open(cloudPricingDeepLink(), '_blank', 'noopener,noreferrer')}
2245+
// The paywall exit. Wired only when this runtime named an upstream
2246+
// cloud — an undefined `onUpgrade` renders NO upgrade button, which is
2247+
// the honest state for a runtime with no control plane behind it
2248+
// (objectui#7253).
2249+
onUpgrade={
2250+
cloudConsoleUrl()
2251+
? () => window.open(cloudConsoleUrl(), '_blank', 'noopener,noreferrer')
2252+
: undefined
2253+
}
22462254
onOpenBuilder={openBuilder}
22472255
onOpenRecord={openRecord}
22482256
surface="plain"

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {
5151
listLocalInstalls,
5252
listCloudEnvironments,
5353
listInstallableOrgIds,
54-
cloudInstallDeepLink,
54+
cloudConsoleUrl,
5555
getCloudInstallationInfo,
5656
reseedSampleData,
5757
purgeSampleData,
@@ -900,12 +900,17 @@ export function MarketplacePackagePage() {
900900
<AlertCircle className="h-4 w-4 mt-0.5 text-amber-600" aria-hidden="true" />
901901
<div className="flex-1">{envsError}</div>
902902
</div>
903-
<a href={cloudInstallDeepLink(pkg.id)} target="_blank" rel="noopener noreferrer">
904-
<Button variant="outline" size="sm" className="w-full">
905-
<ExternalLink className="h-4 w-4 mr-1.5" aria-hidden="true" />
906-
{t('marketplace.action.openOnCloud')}
907-
</Button>
908-
</a>
903+
{/* Only when the runtime named an upstream cloud. An empty base
904+
used to fall back to a composed vendor URL that 404'd
905+
(objectui#7253); an `href=""` would reload this page. */}
906+
{cloudConsoleUrl() ? (
907+
<a href={cloudConsoleUrl()} target="_blank" rel="noopener noreferrer">
908+
<Button variant="outline" size="sm" className="w-full">
909+
<ExternalLink className="h-4 w-4 mr-1.5" aria-hidden="true" />
910+
{t('marketplace.action.openOnCloud')}
911+
</Button>
912+
</a>
913+
) : null}
909914
</div>
910915
) : getRuntimeConfig().defaultEnvironmentId ? (
911916
<div className="flex items-center gap-2">

‎packages/app-shell/src/console/marketplace/__tests__/MarketplacePackagePage-5620.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ vi.mock('../marketplaceApi', () => ({
8484
uninstallLocal: async () => ({}),
8585
listCloudEnvironments: async () => [],
8686
listInstallableOrgIds: async () => [],
87-
cloudInstallDeepLink: () => '',
87+
cloudConsoleUrl: () => '',
8888
reseedSampleData: async () => ({ ok: true }),
8989
purgeSampleData: async () => ({ ok: true }),
9090
reseedLocalSampleData: async () => ({ ok: true }),

‎packages/app-shell/src/console/marketplace/__tests__/MarketplacePackagePage.disabledState.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ vi.mock('../marketplaceApi', () => ({
7171
uninstallLocal: async () => ({}),
7272
listCloudEnvironments: async () => [],
7373
listInstallableOrgIds: async () => [],
74-
cloudInstallDeepLink: () => '',
74+
cloudConsoleUrl: () => '',
7575
reseedSampleData: async () => ({ ok: true }),
7676
purgeSampleData: async () => ({ ok: true }),
7777
reseedLocalSampleData: async () => ({ ok: true }),

‎packages/app-shell/src/console/marketplace/__tests__/MarketplacePackagePage.guardOrder.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ vi.mock('../marketplaceApi', () => ({
9898
uninstallLocal: async () => ({}),
9999
listCloudEnvironments: async () => [],
100100
listInstallableOrgIds: async () => [],
101-
cloudInstallDeepLink: () => '',
101+
cloudConsoleUrl: () => '',
102102
reseedSampleData: async () => ({ ok: true }),
103103
purgeSampleData: async () => ({ ok: true }),
104104
reseedLocalSampleData: async () => ({ ok: true }),

‎packages/app-shell/src/console/marketplace/__tests__/MarketplacePage.guardOrder.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ vi.mock('../marketplaceApi', () => ({
9797
uninstallLocal: async () => ({}),
9898
listCloudEnvironments: async () => [],
9999
listInstallableOrgIds: async () => [],
100-
cloudInstallDeepLink: () => '',
100+
cloudConsoleUrl: () => '',
101101
reseedSampleData: async () => ({ ok: true }),
102102
purgeSampleData: async () => ({ ok: true }),
103103
reseedLocalSampleData: async () => ({ ok: true }),

‎packages/app-shell/src/console/marketplace/__tests__/MarketplaceRefusalResolution-5619.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ vi.mock('../marketplaceApi', () => ({
7676
uninstallLocal: async () => ({}),
7777
listCloudEnvironments: async () => [],
7878
listInstallableOrgIds: async () => [],
79-
cloudInstallDeepLink: () => '',
79+
cloudConsoleUrl: () => '',
8080
reseedSampleData: async () => ({ ok: true }),
8181
purgeSampleData: async () => ({ ok: true }),
8282
reseedLocalSampleData: async () => ({ ok: true }),
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* objectui#7253 — the paywall exit's destination.
5+
*
6+
* The AI quota refusal's "Upgrade plan" CTA used to open
7+
* `${cloudBase}/apps/cloud-control/sys_environment`, a path this repo composed
8+
* from three guesses about the CONTROL PLANE's console — its mount (`/_console`,
9+
* injected by that host), its app slug (`cloud_control`, not `cloud-control`)
10+
* and its route. All three were wrong, so the button landed on the control
11+
* plane's API 404 — `{"success":false,"error":{"code":"ENDPOINT_NOT_FOUND"}}` —
12+
* measured on the local rig.
13+
*
14+
* The fix is negative and that is the point: the only thing the runtime tells a
15+
* tenant SPA about the control plane is its ORIGIN, so the origin is all we may
16+
* name. These assertions pin the absence of a composed path, not a particular
17+
* page — a future "improvement" that appends one is the bug coming back.
18+
*/
19+
20+
import { describe, it, expect, vi } from 'vitest';
21+
22+
// `vi.hoisted`, not a plain const: `vi.mock` is hoisted above module-body
23+
// statements, so a bare const is still in TDZ when the factory runs. The
24+
// default is a CANARY, not '': a case that forgets to set a base then fails
25+
// loudly instead of agreeing with the "no cloud configured" assertion.
26+
const { cloudBase } = vi.hoisted(() => ({ cloudBase: vi.fn(() => 'MOCK_UNSET') }));
27+
vi.mock('../../../runtime-config', () => ({
28+
getCloudBase: () => cloudBase(),
29+
}));
30+
31+
/**
32+
* Import the helper FRESH under the mock.
33+
*
34+
* The `unit` project runs with `isolate: false` (one module graph per worker),
35+
* so a sibling file that imported `marketplaceApi` unmocked — `readApiError`
36+
* does — leaves a cached copy bound to the REAL `getCloudBase`, and a
37+
* top-of-file import here silently reads through to it. Measured: the same
38+
* assertions passed alone and returned `''` in a multi-file run. `resetModules`
39+
* + a dynamic import inside the test is the supported way to re-evaluate under
40+
* this file's own mock.
41+
*/
42+
async function urlFor(base: string): Promise<string> {
43+
cloudBase.mockReturnValue(base);
44+
vi.resetModules();
45+
const { cloudConsoleUrl } = await import('../marketplaceApi');
46+
return cloudConsoleUrl();
47+
}
48+
49+
describe('cloudConsoleUrl (objectui#7253)', () => {
50+
it('is the runtime-supplied cloud origin, verbatim', async () => {
51+
expect(await urlFor('https://cloud.objectos.app')).toBe('https://cloud.objectos.app');
52+
});
53+
54+
it('appends no control-plane path — not the app slug, not an object route', async () => {
55+
const url = await urlFor('https://cloud.objectos.app');
56+
// The exact shape that produced the dead link.
57+
expect(url).not.toContain('/apps/');
58+
expect(url).not.toContain('cloud-control');
59+
expect(url).not.toContain('sys_environment');
60+
expect(url).not.toContain('sys_package');
61+
// …and nothing else either: path-free, so the console mount's own root
62+
// redirect (`/` → `/_console/`) decides where the user lands.
63+
expect(new URL(url).pathname).toBe('/');
64+
});
65+
66+
it('honours a base that already carries a prefix (reverse-proxied control plane)', async () => {
67+
expect(await urlFor('https://acme.example/cloud')).toBe('https://acme.example/cloud');
68+
});
69+
70+
it('is empty when the runtime named no upstream cloud — callers render no link', async () => {
71+
// NOT the former `|| 'https://cloud.objectos.app'` fallback: a self-hosted
72+
// or air-gapped runtime has no control plane, and sending its users to the
73+
// vendor's SaaS is worse than showing nothing.
74+
expect(await urlFor('')).toBe('');
75+
});
76+
});

‎packages/app-shell/src/console/marketplace/marketplaceApi.ts‎

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -415,22 +415,49 @@ export async function listInstallableOrgIds(): Promise<Set<string>> {
415415
return ids;
416416
}
417417

418-
export function cloudInstallDeepLink(packageId: string): string {
419-
const base = getCloudBase() || 'https://cloud.objectos.app';
420-
return `${base}/apps/cloud-control/sys_package/${encodeURIComponent(packageId)}`;
421-
}
422-
423418
/**
424-
* Deep-link to the cloud upgrade entry point: the environments list, where each
425-
* environment's "Upgrade Plan" action opens Stripe checkout. Surfaced from the
426-
* tenant SPA when an AI quota refusal (429) offers an upgrade / top-up CTA.
427-
* Centralized so the target can be re-pointed (dedicated pricing or credit-pack
428-
* page) as the cloud billing UI evolves. Same `cloud-control` app slug as
429-
* cloudInstallDeepLink above.
419+
* The upstream control plane's front door — the cloud base URL the RUNTIME
420+
* told us about (`/api/v1/runtime/config` → `cloudUrl`), with NO path appended.
421+
* `''` when this runtime has no upstream cloud, which callers MUST read as
422+
* "render no link at all".
423+
*
424+
* ## Why nothing is appended (objectui#7253)
425+
*
426+
* This used to compose `${base}/apps/cloud-control/sys_environment` (upgrade)
427+
* and `${base}/apps/cloud-control/sys_package/<id>` (install). Both were dead:
428+
* on the rig the upgrade CTA landed on the control plane's API 404,
429+
* `{"success":false,"error":{"code":"ENDPOINT_NOT_FOUND"}}`. The composition
430+
* guessed THREE control-plane-owned facts and got all three wrong —
431+
*
432+
* - the console's MOUNT: the SPA is served under `/_console/`, injected by
433+
* the host; a path starting at the origin hits the API router instead.
434+
* - the app SLUG: the Cloud app's `name` is `cloud_control`, not
435+
* `cloud-control`.
436+
* - the ROUTE: the plan/billing entry is a Page, not the `sys_environment`
437+
* object list.
438+
*
439+
* None of these are knowable from a tenant runtime: they are properties of the
440+
* deployment that serves the CONTROL PLANE's console, and the only thing the
441+
* runtime config tells us about it is its origin. Composing them here is the
442+
* same class of guess whichever page we aim at, so this returns the origin and
443+
* stops. That origin is a real destination: the console mount claims `/` and
444+
* 302s to `/_console/` (objectos-runtime `mountConsoleStatic`, `rootRedirect`
445+
* default on), landing the user in the Cloud app whose nav carries Billing.
446+
*
447+
* ⛔ Do NOT re-add a path here "temporarily". The durable fix is a
448+
* control-plane-DECLARED URL — the pattern this repo already uses for the one
449+
* cloud route it does navigate to, `CloudOnboardingNext`'s `environmentsRoute`,
450+
* which arrives from cloud page metadata. Until the control plane publishes an
451+
* equivalent for the tenant SPA (reported alongside this fix), the origin is
452+
* the most specific target we are entitled to name.
453+
*
454+
* The former `|| 'https://cloud.objectos.app'` default is gone with it: a
455+
* runtime with no upstream cloud has no control plane to send anyone to, and
456+
* bouncing a self-hosted or air-gapped user to the vendor's SaaS is a worse
457+
* answer than showing no link.
430458
*/
431-
export function cloudPricingDeepLink(): string {
432-
const base = getCloudBase() || 'https://cloud.objectos.app';
433-
return `${base}/apps/cloud-control/sys_environment`;
459+
export function cloudConsoleUrl(): string {
460+
return getCloudBase();
434461
}
435462

436463
/**

0 commit comments

Comments
 (0)