From 3606be3b9991fb1bca84ddb0c2db9ed1b98a977e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 09:17:09 +0000 Subject: [PATCH 1/9] wip(app-shell): Installed Apps update badge, folded modules, admin columns Work in progress; not yet type-checked or tested. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .../src/views/metadata-admin/PackagesPage.tsx | 348 +++++++++++++++++- 1 file changed, 341 insertions(+), 7 deletions(-) diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx index afc0aab5c64..68e54b58996 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx @@ -36,6 +36,9 @@ import { Pencil, Eye, MoreHorizontal, + ChevronDown, + ChevronRight, + Info, } from 'lucide-react'; import { Button, @@ -89,8 +92,15 @@ import { emitMetadataRefresh } from '../../assistant/assistantBus.js'; import { duplicatePackage, forgetPackageListReads, isSpecPackageId } from '../studio-design/packages-io.js'; import { PackageIdInput } from '../studio-design/PackageIdInput.js'; import { useWorkspaceAdminStatus } from '@object-ui/auth'; -import { getRuntimeConfig } from '../../runtime-config.js'; -import { readMarketplaceInstalls, type LocalInstallEntry } from '../../console/marketplace/marketplaceApi.js'; +import { getRuntimeConfig, isMarketplaceEnabled } from '../../runtime-config.js'; +import { + getMarketplacePackage, + readMarketplaceInstalls, + type LocalInstallEntry, +} from '../../console/marketplace/marketplaceApi.js'; +import { updateTarget } from '../../console/marketplace/installState.js'; +import { UpdateAvailableBadge } from '../../console/marketplace/UpdateAvailableBadge.js'; +import { useMarketplaceNamespace } from '@object-ui/i18n/namespaces/marketplace'; import { MarketplaceNotLoaded, MarketplaceRowActions } from '../../console/marketplace/MarketplaceRowActions.js'; import { useDependencyMissingText } from '../../console/marketplace/dependencyMissing.js'; import { useProtocolCheckSkippedText } from '../../console/marketplace/protocolCheckSkipped.js'; @@ -137,6 +147,8 @@ export interface PackageManifestRow { type?: string; scope?: 'cloud' | 'system' | 'project'; description?: string; + /** The packages this one declares (ADR-0141 D1): a module names the app it extends here. */ + dependencies?: Record; [key: string]: unknown; } @@ -418,6 +430,142 @@ function rowActionEntry(row: PackageListRow): LocalInstallEntry | null { return row.source === 'marketplace' ? row.install : null; } +/* -------------------------------------------------------------------------- */ +/* Installed Apps: one row per app, its modules folded under it */ +/* -------------------------------------------------------------------------- */ + +/** + * One line of the Installed Apps view: an app with the module packages it + * brought (ADR-0130 D2: "the App you installed brought its modules"), or a + * package that is no module of an app in view. + */ +interface InstalledAppGroup { + row: PackageListRow; + modules: PackageListRow[]; +} + +const PLATFORM_SCOPES: ReadonlyArray = ['system', 'cloud']; + +/** + * The app a module row folds under, read from what `/api/v1/packages` serves + * and nothing else: the reading the server's disable door makes for "a module + * of an installed app" (`isDisableableAppModule` in the runtime's packages + * domain). The row is `manifest.type: 'module'`, not of a platform scope, and + * DIRECTLY declares in `manifest.dependencies` (ADR-0141 D1) a row of + * `manifest.type: 'app'` with the same Source. A module that declares no such + * app, or more than one, stays a line of its own: folding it under one would + * hide it from the other. + */ +function appOfModule(row: PackageListRow, apps: ReadonlyMap): string | null { + const manifest = row.pkg?.manifest; + if (manifest?.type !== 'module' || PLATFORM_SCOPES.includes(manifest.scope)) return null; + const declared = manifest.dependencies ? Object.keys(manifest.dependencies) : []; + const parents = declared.filter((id) => id !== row.id && apps.get(id)?.source === row.source); + return parents.length === 1 ? parents[0] : null; +} + +/** Fold each module row under its app ({@link appOfModule}), keeping the rows' order. */ +function groupInstalledApps(rows: readonly PackageListRow[]): InstalledAppGroup[] { + const apps = new Map(); + for (const r of rows) if (r.pkg?.manifest.type === 'app') apps.set(r.id, r); + const modulesOf = new Map(); + const folded = new Set(); + for (const r of rows) { + const app = appOfModule(r, apps); + if (!app) continue; + folded.add(r.id); + modulesOf.set(app, [...(modulesOf.get(app) ?? []), r]); + } + return rows.filter((r) => !folded.has(r.id)).map((r) => ({ row: r, modules: modulesOf.get(r.id) ?? [] })); +} + +/** Whether the search text names a row, by id or name — the list's one rule. */ +function rowMatches(row: PackageListRow, q: string): boolean { + return row.id.toLowerCase().includes(q) || (row.pkg?.manifest.name || '').toLowerCase().includes(q); +} + +/** + * What the marketplace catalog says about the installed apps' versions. + * + * - `reading` — the catalog reads are in flight; + * - `read` — `targets` holds, per row id, the version the row can update to + * (`updateTarget`, the marketplace's own rule) and the app's marketplace + * page; a row missing from it has no newer listed version. `unavailable` + * is true when the catalog could not be read for at least one app: the + * page then says so instead of reading the silence as "up to date". + */ +type UpdateRead = + | { state: 'reading' } + | { state: 'read'; targets: ReadonlyMap; unavailable: boolean }; + +/** An installed app the catalog is asked about: an app row with a loaded marketplace install. */ +interface UpdateCandidate { + id: string; + install: LocalInstallEntry; +} + +/** + * Ask the catalog for each candidate's latest listed version, as the app's + * marketplace page reads it (`latest_version`, else the newest of `versions`), + * through the same door (`getMarketplacePackage`, by the install's + * `packageId`, the id the row's Details action opens the page with). + * + * A `404` means the catalog does not list the app, so it has nothing newer to + * offer. Any other failure, or a runtime with no catalog to ask, is a read that + * did not happen: `unavailable`. + */ +async function readUpdateTargets(candidates: readonly UpdateCandidate[], appBase: string): Promise { + const targets = new Map(); + if (candidates.length === 0) return { state: 'read', targets, unavailable: false }; + if (!isMarketplaceEnabled()) return { state: 'read', targets, unavailable: true }; + let unavailable = false; + const answers = await Promise.allSettled(candidates.map((c) => getMarketplacePackage(c.install.packageId))); + answers.forEach((answer, i) => { + const { id, install } = candidates[i]; + if (answer.status === 'rejected') { + if ((answer.reason as { status?: unknown } | null)?.status !== 404) unavailable = true; + return; + } + const latest = answer.value?.package?.latest_version?.version ?? answer.value?.versions?.[0]?.version ?? null; + const version = updateTarget(install.version, latest); + if (version) { + targets.set(id, { version, href: `${appBase}/system/marketplace/${encodeURIComponent(install.packageId)}` }); + } + }); + return { state: 'read', targets, unavailable }; +} + +/** + * An installed app's Update cell: the marketplace's own "Update available → vX" + * badge and the way to its marketplace page, where the upgrade itself runs. + * + * The badge's words are the lazy `marketplace` namespace's + * (`marketplace.detail.updateAvailable`), so the cell draws only once that + * namespace answers `ready` for the instance's language — the rule + * `MarketplaceNamespaceGate` keeps for the marketplace pages; until then it + * holds a placeholder, and a namespace that cannot be fetched draws nothing. + */ +function InstalledAppUpdateCell({ rowId, read }: { rowId: string; read: UpdateRead }) { + const locale = useMetadataLocale(); + const namespace = useMarketplaceNamespace(); + if (read.state === 'reading' || namespace.status === 'loading') { + return ; + } + const target = read.targets.get(rowId); + if (!target || namespace.status !== 'ready') return null; + return ( + e.stopPropagation()} + className="inline-flex items-center gap-2 text-sm font-medium text-primary hover:underline" + data-testid={`pkg-update-${rowId}`} + > + + {t('engine.packages.installedApps.upgrade', locale)} + + ); +} + /* -------------------------------------------------------------------------- */ /* Create-package dialog */ /* -------------------------------------------------------------------------- */ @@ -1633,9 +1781,69 @@ export function PackagesPage() { // marketplace install its empty state says so, instead of blaming a filter // the administrator never set. "No packages match your filters." stays for // the case where marketplace installs exist and the search hides them. + // + // objectstack#34722 — that view is the administrator's door (ADR-0146 D1: + // Setup carries app installation; Studio is the developer's surface): it + // draws one line per installed app with its modules folded under it, the + // columns an administrator reads (Name, Version, Status, Source, Update), + // and none of the developer's doors — Import, New Package and the platform + // packages switch stay on Studio's Overview → Packages, this same page + // opened without `source` (ruling 甲 on objectstack#25098). const installedAppsView = sourceFilter.value === 'marketplace'; const noMarketplaceInstalls = installedAppsView && !rows.some((r) => r.source === 'marketplace'); + // The Installed Apps lines: grouped over the rows the Source filter keeps, + // then searched — a group is shown when its app or one of its modules + // matches, and a module the search found is shown without a click. + const appGroups = React.useMemo(() => { + if (!installedAppsView) return []; + const q = query.trim().toLowerCase(); + const scoped = rows.filter((r) => { + if (r.source !== 'marketplace') return false; + return !(r.pkg?.manifest.scope === 'system' || r.pkg?.manifest.scope === 'cloud'); + }); + return groupInstalledApps(scoped) + .map((g) => { + if (!q) return { ...g, matchedModules: false }; + const matchedModules = g.modules.some((m) => rowMatches(m, q)); + return rowMatches(g.row, q) || matchedModules ? { ...g, matchedModules } : null; + }) + .filter((g): g is InstalledAppGroup & { matchedModules: boolean } => g !== null); + }, [installedAppsView, rows, query]); + const [expandedApps, setExpandedApps] = React.useState>(() => new Set()); + const toggleApp = (id: string) => + setExpandedApps((prev) => { + const next = new Set(prev); + if (next.has(id)) next.delete(id); + else next.add(id); + return next; + }); + + // The catalog is asked about each installed app's line — never about a + // module, which updates with its app — and only in the Installed Apps view. + // Keyed on the candidates' ids, versions and package ids (primitives), so a + // reload that serves the same installs asks nothing again. + const updateCandidates: UpdateCandidate[] = installedAppsView + ? groupInstalledApps(rows.filter((r) => r.source === 'marketplace')) + .map((g) => g.row) + .filter((r): r is PackageListRow & { install: LocalInstallEntry } => !!r.install && !r.install.notLoaded) + .map((r) => ({ id: r.id, install: r.install })) + : []; + const updateKey = updateCandidates.map((c) => `${c.id}@${c.install.version}@${c.install.packageId}`).join('|'); + const [updateRead, setUpdateRead] = React.useState({ state: 'reading' }); + const updateSeq = React.useRef(0); + React.useEffect(() => { + if (!installedAppsView || loading) return; + const seq = ++updateSeq.current; + setUpdateRead({ state: 'reading' }); + void readUpdateTargets(updateCandidates, appBase).then((read) => { + if (updateSeq.current === seq) setUpdateRead(read); + }); + // `updateKey` spells `updateCandidates`; the array itself is rebuilt each render. + }, [installedAppsView, loading, updateKey, appBase]); + const updateCount = updateRead.state === 'read' ? updateRead.targets.size : 0; + const updatesUnavailable = updateRead.state === 'read' && updateRead.unavailable; + const clearSourceFilter = () => { const next = new URLSearchParams(searchParams); next.delete(PACKAGES_SOURCE_PARAM); @@ -1726,8 +1934,10 @@ export function PackagesPage() { } icon={} refresh={{ onRefresh: () => void load(), label: t('engine.packages.refresh', locale), busy: loading }} + // objectstack#34722 — Import and New Package are developer doors: + // Studio's Packages keeps them, Setup's Installed Apps draws neither. actions={ - <> + installedAppsView ? undefined : <> {importInput} )} - {kernelCount > 0 && ( -
+ {kernelCount > 0 && !installedAppsView && ( +
+ ) : installedAppsView ? ( + // objectstack#34722 — the administrator's columns: Name, Version, + // Status, Source, Update. The package id and the Scope badge are the + // developer's reading, on Studio's Packages. + + + + {t('engine.packages.col.name', locale)} + {t('engine.packages.col.version', locale)} + {t('engine.packages.col.status', locale)} + {t('engine.packages.col.source', locale)} + {t('engine.packages.installedApps.col.update', locale)} + {showActionsColumn && ( + {t('engine.packages.col.actions', locale)} + )} + + + + {appGroups.flatMap(({ row, modules, matchedModules }) => { + const open = matchedModules || expandedApps.has(row.id); + const line = (r: PackageListRow, module: boolean) => { + const { id: rowId, pkg: p, source, install } = r; + const actionEntry = module ? null : rowActionEntry(r); + return ( + openDetail(p) : undefined} + data-testid={`pkg-row-${rowId}`} + data-module-of={module ? row.id : undefined} + > + +
+ {!module && modules.length > 0 ? ( + + ) : null} + {p?.manifest.name || rowId} + {!module && modules.length > 0 && ( + + {modules.length === 1 + ? tFormat('engine.packages.installedApps.modulesOne', locale, { count: modules.length }) + : tFormat('engine.packages.installedApps.modules', locale, { count: modules.length })} + + )} +
+
+ {p?.manifest.version || install?.version || '—'} + + {install?.notLoaded ? ( + + ) : p ? ( + + ) : ( + '—' + )} + + + + + + {module ? null : } + + {showActionsColumn && ( + + {actionEntry && ( + void load()} + /> + )} + + )} +
+ ); + }; + return [line(row, false), ...(open ? modules.map((m) => line(m, true)) : [])]; + })} +
+
) : ( From 936ab3b48df34d1099cfe779221816ea0e0a83bd Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 09:24:21 +0000 Subject: [PATCH 2/9] wip(app-shell,i18n): Installed Apps strings and the hook-gated badge door Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .../marketplaceNamespaceBoundary.test.ts | 73 ++++++++++++++++++- .../src/views/metadata-admin/PackagesPage.tsx | 14 +++- ui/packages/i18n/src/namespaces/studio/en.ts | 9 +++ ui/packages/i18n/src/namespaces/studio/zh.ts | 9 +++ 4 files changed, 99 insertions(+), 6 deletions(-) diff --git a/ui/packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts b/ui/packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts index 9685ebb4e96..7965ff6d219 100644 --- a/ui/packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts +++ b/ui/packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts @@ -21,7 +21,13 @@ * 3. walks every OTHER door's relative imports inside this directory * (transitively) and holds that every `marketplace.*` key those files * spell is in the RESIDENT pack — the package entry's `en`, which holds no - * namespace key. + * namespace key; + * 4. treats a door as gated by its importers only when it is DECLARED in + * {@link HOOK_GATED_DOORS}: every file outside this directory that imports + * it is listed there, and each listed file asks for the namespace itself + * (`useMarketplaceNamespace()`), drawing the door's component only once it + * is ready (objectstack#34722). An undeclared importer makes the door an + * ordinary ungated one again, so step 3 reads its keys. * * TypeScript's own parser reads the sources, so a key or an import written in * a comment is never read as code. @@ -42,6 +48,22 @@ const rel = (file: string) => relative(UI_ROOT, file).split(sep).join('/'); /** The pages behind the frame: what reaches them is gated by construction. */ const GATED_PAGES = ['MarketplacePage.tsx', 'MarketplacePackagePage.tsx'].map((f) => join(MARKETPLACE_DIR, f)); +/** + * Doors whose every outside importer asks for the namespace itself, door by + * door (step 4): the door file, then the files allowed to import it. + */ +const HOOK_GATED_DOORS = new Map([ + [ + join(MARKETPLACE_DIR, 'UpdateAvailableBadge.tsx'), + // Setup → Installed Apps draws the badge in its Update cell (objectstack#34722). + ['packages/app-shell/src/views/metadata-admin/PackagesPage.tsx'], + ], +]); + +/** The namespace module, and the hook a hook-gated importer must call from it. */ +const NAMESPACE_MODULE = '@object-ui/i18n/namespaces/marketplace'; +const NAMESPACE_HOOK = 'useMarketplaceNamespace'; + const isSource = (name: string) => /\.(ts|tsx)$/.test(name) && !/\.(test|spec)\.(ts|tsx)$/.test(name) && !name.endsWith('.d.ts'); @@ -155,10 +177,40 @@ for (const file of allSources()) { } } +/** A declared hook-gated door whose outside importers are all declared for it (step 4). */ +const isHookGated = (file: string) => { + const allowed = HOOK_GATED_DOORS.get(file); + return !!allowed && [...(doors.get(file) ?? [])].every((importer) => allowed.includes(importer)); +}; + +/** Whether `file` imports {@link NAMESPACE_HOOK} from {@link NAMESPACE_MODULE} and calls it. */ +function callsNamespaceHook(file: string): boolean { + const sf = parse(file); + let imported = false; + let called = false; + const visit = (node: ts.Node) => { + if ( + ts.isImportDeclaration(node) && + ts.isStringLiteral(node.moduleSpecifier) && + node.moduleSpecifier.text === NAMESPACE_MODULE && + node.importClause?.namedBindings && + ts.isNamedImports(node.importClause.namedBindings) && + node.importClause.namedBindings.elements.some((e) => e.name.text === NAMESPACE_HOOK && !e.propertyName) + ) { + imported = true; + } else if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === NAMESPACE_HOOK) { + called = true; + } + ts.forEachChild(node, visit); + }; + visit(sf); + return imported && called; +} + /** Every file in this directory reachable from an ungated door, following relative imports inside it. */ const ungated = new Set(); { - const queue = [...doors.keys()].filter((file) => !GATED_PAGES.includes(file)); + const queue = [...doors.keys()].filter((file) => !GATED_PAGES.includes(file) && !isHookGated(file)); while (queue.length > 0) { const file = queue.pop()!; if (ungated.has(file) || GATED_PAGES.includes(file)) continue; @@ -218,6 +270,23 @@ describe('the marketplace namespace boundary (objectstack#30588)', () => { expect(outside).toEqual([]); }); + it.each([...HOOK_GATED_DOORS].map(([door, importers]) => [rel(door), door, importers] as const))( + '%s is drawn only by importers that ask for the namespace themselves (objectstack#34722)', + (_name, door, importers) => { + // Lit control: the door really is imported from outside this directory. + const actual = [...(doors.get(door) ?? [])]; + expect(actual.length).toBeGreaterThan(0); + // Every outside importer is declared for it — an undeclared one would + // draw the door's keys without the namespace. + expect(actual.filter((importer) => !importers.includes(importer))).toEqual([]); + for (const importer of importers) { + expect(callsNamespaceHook(join(UI_ROOT, importer)), `${importer} calls ${NAMESPACE_HOOK}()`).toBe(true); + } + // And the door is outside the resident-key walk only because of this. + expect(ungated.has(door)).toBe(false); + }, + ); + it('the probe key the frame waits on is NOT resident (the pack really is lighter)', () => { expect(lookup(en, 'marketplace.title')).toBeUndefined(); expect(typeof lookup(en, 'marketplace.action.uninstall')).toBe('string'); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx index 68e54b58996..749be9fea04 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx @@ -542,8 +542,10 @@ async function readUpdateTargets(candidates: readonly UpdateCandidate[], appBase * The badge's words are the lazy `marketplace` namespace's * (`marketplace.detail.updateAvailable`), so the cell draws only once that * namespace answers `ready` for the instance's language — the rule - * `MarketplaceNamespaceGate` keeps for the marketplace pages; until then it - * holds a placeholder, and a namespace that cannot be fetched draws nothing. + * `MarketplaceNamespaceGate` keeps for the marketplace pages. Until then the + * cell holds a placeholder, never an empty cell that would read as "up to + * date"; a namespace that cannot be fetched still draws the target version + * and the way to upgrade, without the badge's words. */ function InstalledAppUpdateCell({ rowId, read }: { rowId: string; read: UpdateRead }) { const locale = useMetadataLocale(); @@ -552,7 +554,7 @@ function InstalledAppUpdateCell({ rowId, read }: { rowId: string; read: UpdateRe return ; } const target = read.targets.get(rowId); - if (!target || namespace.status !== 'ready') return null; + if (!target) return null; return ( - + {namespace.status === 'ready' ? ( + + ) : ( + → v{target.version} + )} {t('engine.packages.installedApps.upgrade', locale)} ); diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index f43d7ad5d10..a158be63075 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -1873,6 +1873,15 @@ const STUDIO_EN: Record = { 'engine.packages.installedApps.description': 'The apps installed from the marketplace into this system.', 'engine.packages.installedApps.empty': 'No apps installed from the marketplace yet', 'engine.packages.installedApps.emptyHint': 'Apps you install from the marketplace are listed here.', + 'engine.packages.installedApps.col.update': 'Update', + 'engine.packages.installedApps.upgrade': 'Upgrade', + 'engine.packages.installedApps.updatesSummaryOne': '{count} app has a newer version in the marketplace.', + 'engine.packages.installedApps.updatesSummary': '{count} apps have a newer version in the marketplace.', + 'engine.packages.installedApps.updatesUnavailable': 'Update information can’t be read from the marketplace right now, so this list can’t say which apps have a newer version.', + 'engine.packages.installedApps.modulesOne': '{count} module', + 'engine.packages.installedApps.modules': '{count} modules', + 'engine.packages.installedApps.showModules': 'Show the {count} modules of {name}', + 'engine.packages.installedApps.hideModules': 'Hide the modules of {name}', 'engine.packages.loadFailed': 'Failed to load packages', 'engine.packages.col.name': 'Name', 'engine.packages.col.version': 'Version', diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 4aa83f20d02..673b4759716 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -1660,6 +1660,15 @@ const STUDIO_ZH: Record = { 'engine.packages.installedApps.description': '从应用市场安装到本系统的应用。', 'engine.packages.installedApps.empty': '尚未从应用市场安装任何应用', 'engine.packages.installedApps.emptyHint': '从应用市场安装的应用会列在这里。', + 'engine.packages.installedApps.col.update': '更新', + 'engine.packages.installedApps.upgrade': '去升级', + 'engine.packages.installedApps.updatesSummaryOne': '{count} 个应用在应用市场有新版本。', + 'engine.packages.installedApps.updatesSummary': '{count} 个应用在应用市场有新版本。', + 'engine.packages.installedApps.updatesUnavailable': '暂时读不到应用市场的更新信息,这里无法显示哪些应用有新版本。', + 'engine.packages.installedApps.modulesOne': '{count} 个模块', + 'engine.packages.installedApps.modules': '{count} 个模块', + 'engine.packages.installedApps.showModules': '展开 {name} 的 {count} 个模块', + 'engine.packages.installedApps.hideModules': '收起 {name} 的模块', 'engine.packages.loadFailed': '加载软件包失败', 'engine.packages.col.name': '名称', 'engine.packages.col.version': '版本', From fa2be602bf323df05ef8429664e3991e2b219665 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 09:34:52 +0000 Subject: [PATCH 3/9] test(app-shell): pin the Installed Apps update badge, folding and both doors Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- ...esPage.installedAppsUpdates-34722.test.tsx | 420 ++++++++++++++++++ .../src/views/metadata-admin/PackagesPage.tsx | 1 + 2 files changed, 421 insertions(+) create mode 100644 ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx new file mode 100644 index 00000000000..dd65a76218b --- /dev/null +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx @@ -0,0 +1,420 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * objectstack#34722 — Setup → Installed Apps is the administrator's door to + * this page (`?source=marketplace`), Studio → Packages the developer's (no + * `source`; ADR-0146 D1, ruling 甲 on objectstack#25098). + * + * On the Setup door: + * - an installed app the catalog lists at a higher version draws the + * marketplace's own "Update available → vX" badge (`UpdateAvailableBadge`, + * decided by `updateTarget`), linked to the app's marketplace page, and the + * page says how many apps have a newer version; + * - an app that is up to date, or that the catalog does not list (404), has + * no badge; + * - a catalog that cannot be read — a failed read, or a runtime with no + * marketplace — leaves the list as it is and says the update information + * cannot be read, never drawing silence as "up to date"; + * - the badge's words are the lazy `marketplace` namespace's: while it loads + * the Update cell holds a placeholder, and a namespace that cannot be + * fetched still shows the target version and the way to upgrade; + * - a module package (`type: 'module'` declaring its app in `dependencies`) + * is folded under that app's line and shown on demand; + * - the columns are Name, Version, Status, Source, Update, and the developer + * doors (Import, New Package, the platform switch, the Source chip's + * Show all) are not drawn. + * On the Studio door all of the developer doors and columns stay, and the + * catalog is never asked. + * + * The wire is stubbed (`fetch`), the runtime config is the real module booted + * over a served body, and `marketplaceApi` is not mocked. + */ + +import '@testing-library/jest-dom/vitest'; +import { afterEach, describe, expect, it, vi } from 'vitest'; +import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; +import { MemoryRouter, Route, Routes, useLocation } from 'react-router-dom'; +import { I18nProvider } from '@object-ui/i18n'; + +vi.mock('@object-ui/auth', async (importOriginal) => ({ + ...(await importOriginal>()), + useWorkspaceAdminStatus: () => ({ isAdmin: true, isResolved: true }), +})); + +/** A namespace state a case forces; `null` = the real hook. */ +const namespaceOverride = vi.hoisted(() => ({ state: null as null | { status: 'loading' | 'failed' } })); +vi.mock('@object-ui/i18n/namespaces/marketplace', async (importOriginal) => { + const real = await importOriginal(); + return { + ...real, + useMarketplaceNamespace: () => { + const actual = real.useMarketplaceNamespace(); + return namespaceOverride.state ? { ...namespaceOverride.state, retry: () => {} } : actual; + }, + }; +}); + +import { PackagesPage, type InstalledPackageRow } from './PackagesPage'; +import { t } from './i18n'; +import { initRuntimeConfig, resetRuntimeConfigForTesting } from '../../runtime-config'; +// The designer rows (the page's own strings) and the marketplace catalogue +// (the badge's words) are both fetched on demand; resident before any case so +// a render reads them from its first paint. +import { loadStudioCatalogue } from '@object-ui/i18n/namespaces/studio'; +import { loadMarketplaceCatalogue } from '@object-ui/i18n/namespaces/marketplace'; +await loadStudioCatalogue('zh'); +await loadMarketplaceCatalogue('en'); +await loadMarketplaceCatalogue('zh-Hans'); + +const HOTCRM_ID = 'app.objectstack.hotcrm'; +const MODULE_IDS = ['o2c', 'service', 'marketing', 'cpq'].map((m) => `${HOTCRM_ID}.${m}`); + +const app = (id: string, name: string, version: string, extra: Partial = {}): InstalledPackageRow => ({ + manifest: { id, name, version, type: 'app' }, + enabled: true, + source: 'marketplace', + writable: false, + ...extra, +}); +const moduleOf = (id: string, parents: string[], source: InstalledPackageRow['source'] = 'marketplace'): InstalledPackageRow => ({ + manifest: { + id, + name: `HotCRM ${id.split('.').pop()}`, + version: '6.2.0', + type: 'module', + dependencies: Object.fromEntries(parents.map((p) => [p, '^6.0.0'])), + }, + enabled: true, + source, + writable: false, + disableable: true, +}); + +const HOTCRM = app(HOTCRM_ID, 'HotCRM', '6.2.0'); +const MODULES = MODULE_IDS.map((id) => moduleOf(id, [HOTCRM_ID])); +const TODO = app('com.example.todo', 'Todo', '1.0.0'); +const CODE: InstalledPackageRow = { + manifest: { id: 'com.acme.code', name: 'Code App', version: '1.0.0', type: 'app', scope: 'project' }, + enabled: true, + source: 'code', + writable: false, +}; +const PLATFORM: InstalledPackageRow = { + manifest: { id: 'com.objectstack.platform', name: 'Platform', version: '1.0.0', scope: 'system' }, + enabled: true, + source: 'code', + writable: false, +}; + +const ledger = (manifestId: string, packageId: string, version: string) => ({ + packageId, + versionId: `ver_${packageId}`, + manifestId, + version, + installedAt: '2026-11-01T09:00:00.000Z', +}); +const LEDGER = [ledger(HOTCRM_ID, 'pkg_hotcrm', '6.2.0'), ledger('com.example.todo', 'pkg_todo', '1.0.0')]; + +/** What the catalog's package door answers, by package id: a latest version, or a status. */ +type Catalog = Record; +const LISTED: Catalog = { pkg_hotcrm: { latest: '6.4.0' }, pkg_todo: { latest: '1.0.0' } }; + +const reply = (status: number, body: unknown) => + new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } }); + +let catalogReads: string[] = []; + +/** Boot the real runtime config, then serve the package, install and catalog doors. */ +async function serve({ + packages, + installs = LEDGER, + catalog = LISTED, + marketplace = true, +}: { + packages: InstalledPackageRow[]; + installs?: unknown[]; + catalog?: Catalog; + marketplace?: boolean; +}) { + resetRuntimeConfigForTesting(); + vi.stubGlobal('fetch', vi.fn(async () => reply(200, { features: { installLocal: true, marketplace } }))); + await initRuntimeConfig(); + catalogReads = []; + vi.stubGlobal( + 'fetch', + vi.fn(async (input: unknown, init?: { method?: string }) => { + const path = new URL(String(input), 'http://console.test').pathname; + const method = (init?.method ?? 'GET').toUpperCase(); + if (path === '/api/v1/packages') return reply(200, { success: true, data: { packages } }); + if (path === '/api/v1/cloud-connection/installed') return reply(404, {}); + if (path === '/api/v1/marketplace/install-local' && method === 'GET') { + return reply(200, { success: true, data: { items: installs } }); + } + const listing = /^\/api\/v1\/marketplace\/packages\/([^/]+)$/.exec(path); + if (listing) { + const id = decodeURIComponent(listing[1]); + catalogReads.push(id); + const answer = catalog[id]; + if (!answer) return reply(404, { success: false, error: { code: 'NOT_FOUND', message: `no package ${id}` } }); + if ('status' in answer) return reply(answer.status, { success: false, error: { code: 'UPSTREAM', message: 'down' } }); + return reply(200, { + success: true, + data: { package: { id, latest_version: { version: answer.latest } }, versions: [] }, + }); + } + return reply(404, { success: false, error: { code: 'NOT_FOUND', message: `no route ${method} ${path}` } }); + }), + ); +} + +const SETUP_URL = '/apps/setup/component/developer/packages?source=marketplace'; +const STUDIO_URL = '/apps/studio/component/developer/packages'; + +function Where() { + const { pathname } = useLocation(); + return
{pathname}
; +} + +function renderAt(url: string, lang: 'en' | 'zh' = 'en') { + return render( + + + + } /> + } /> + + + , + ); +} + +const row = (key: string, lang: 'en' | 'zh' = 'en') => t(key, lang === 'en' ? 'en-US' : 'zh-CN'); + +/** Wait for the list and for the catalog reads to settle. */ +async function settled(id = HOTCRM_ID) { + await screen.findByTestId(`pkg-row-${id}`); + await waitFor(() => expect(screen.queryByTestId(`pkg-update-reading-${id}`)).toBeNull()); +} + +afterEach(() => { + cleanup(); + vi.unstubAllGlobals(); + resetRuntimeConfigForTesting(); + namespaceOverride.state = null; +}); + +describe('Setup → Installed Apps: update available (objectstack#34722)', () => { + it('an app the catalog lists at a higher version draws the marketplace badge, linked to its marketplace page', async () => { + await serve({ packages: [HOTCRM, ...MODULES, TODO] }); + renderAt(SETUP_URL); + await settled(); + + const link = screen.getByTestId(`pkg-update-${HOTCRM_ID}`); + expect(link).toHaveTextContent('Update available → v6.4.0'); + expect(link).toHaveAttribute('href', '/apps/setup/system/marketplace/pkg_hotcrm'); + expect(screen.getByTestId('pkg-updates-summary')).toHaveTextContent('1 app has a newer version in the marketplace.'); + expect(screen.queryByTestId('pkg-updates-unavailable')).toBeNull(); + + fireEvent.click(link); + expect(await screen.findByTestId('where')).toHaveTextContent('/apps/setup/system/marketplace/pkg_hotcrm'); + }); + + it('an app that is up to date has no badge, and with none to update there is no summary', async () => { + await serve({ packages: [TODO], installs: [LEDGER[1]] }); + renderAt(SETUP_URL); + await settled('com.example.todo'); + + expect(screen.queryByTestId('pkg-update-com.example.todo')).toBeNull(); + expect(screen.queryByTestId('pkg-updates-summary')).toBeNull(); + expect(screen.queryByTestId('pkg-updates-unavailable')).toBeNull(); + expect(catalogReads).toEqual(['pkg_todo']); + }); + + it('an app the catalog does not list (404) has no badge and is not read as unavailable', async () => { + await serve({ packages: [HOTCRM, TODO], catalog: { pkg_todo: { latest: '1.0.0' } } }); + renderAt(SETUP_URL); + await settled(); + + expect(screen.queryByTestId(`pkg-update-${HOTCRM_ID}`)).toBeNull(); + expect(screen.queryByTestId('pkg-updates-unavailable')).toBeNull(); + }); + + it('counts every app with a newer version', async () => { + await serve({ packages: [HOTCRM, TODO], catalog: { pkg_hotcrm: { latest: '6.4.0' }, pkg_todo: { latest: '1.1.0' } } }); + renderAt(SETUP_URL); + await settled(); + + expect(screen.getByTestId('pkg-updates-summary')).toHaveTextContent('2 apps have a newer version in the marketplace.'); + }); + + it('a catalog that cannot be read leaves the list as it is and says the update information cannot be read', async () => { + await serve({ packages: [HOTCRM, ...MODULES, TODO], catalog: { pkg_hotcrm: { status: 502 }, pkg_todo: { latest: '1.0.0' } } }); + renderAt(SETUP_URL); + await settled(); + + expect(screen.getByTestId(`pkg-row-${HOTCRM_ID}`)).toBeInTheDocument(); + expect(screen.getByTestId('pkg-row-com.example.todo')).toBeInTheDocument(); + expect(screen.getByTestId('pkg-updates-unavailable')).toHaveTextContent( + row('engine.packages.installedApps.updatesUnavailable'), + ); + expect(screen.queryByTestId(`pkg-update-${HOTCRM_ID}`)).toBeNull(); + expect(screen.queryByTestId('pkg-updates-summary')).toBeNull(); + }); + + it('on a runtime with no marketplace the catalog is not asked and the page says so', async () => { + await serve({ packages: [HOTCRM, TODO], marketplace: false }); + renderAt(SETUP_URL); + await settled(); + + expect(catalogReads).toEqual([]); + expect(screen.getByTestId('pkg-updates-unavailable')).toBeInTheDocument(); + expect(screen.queryByTestId(`pkg-update-${HOTCRM_ID}`)).toBeNull(); + }); + + it('asks the catalog about apps only, never about their modules', async () => { + await serve({ packages: [HOTCRM, ...MODULES], installs: [LEDGER[0]] }); + renderAt(SETUP_URL); + await settled(); + + expect(catalogReads).toEqual(['pkg_hotcrm']); + }); + + it('reads in zh-CN: the badge in the marketplace catalogue words, the summary in the designer rows', async () => { + await serve({ packages: [HOTCRM] }); + renderAt(SETUP_URL, 'zh'); + await settled(); + + expect(screen.getByTestId(`pkg-update-${HOTCRM_ID}`)).toHaveTextContent('有可用更新 → v6.4.0'); + const summary = row('engine.packages.installedApps.updatesSummaryOne', 'zh').replace('{count}', '1'); + expect(summary).not.toContain('newer'); + expect(screen.getByTestId('pkg-updates-summary')).toHaveTextContent(summary); + }); +}); + +describe('Setup → Installed Apps: the badge waits on the marketplace namespace (objectstack#34722)', () => { + it('while the namespace loads, the Update cell holds a placeholder, not an empty "up to date" cell', async () => { + namespaceOverride.state = { status: 'loading' }; + await serve({ packages: [HOTCRM], installs: [LEDGER[0]] }); + renderAt(SETUP_URL); + await screen.findByTestId(`pkg-row-${HOTCRM_ID}`); + await waitFor(() => expect(catalogReads).toEqual(['pkg_hotcrm'])); + // The summary is the page's own words and arrives with the catalog read. + await screen.findByTestId('pkg-updates-summary'); + + expect(screen.getByTestId(`pkg-update-reading-${HOTCRM_ID}`)).toBeInTheDocument(); + expect(screen.queryByTestId(`pkg-update-${HOTCRM_ID}`)).toBeNull(); + }); + + it('a namespace that cannot be fetched still shows the target version and the way to upgrade', async () => { + namespaceOverride.state = { status: 'failed' }; + await serve({ packages: [HOTCRM] }); + renderAt(SETUP_URL); + await settled(); + + const link = screen.getByTestId(`pkg-update-${HOTCRM_ID}`); + expect(link).toHaveAttribute('href', '/apps/setup/system/marketplace/pkg_hotcrm'); + expect(within(link).getByTestId(`pkg-update-version-${HOTCRM_ID}`)).toHaveTextContent('→ v6.4.0'); + expect(link).not.toHaveTextContent('Update available'); + }); +}); + +describe('Setup → Installed Apps: an app is one line, its modules folded under it (objectstack#34722)', () => { + it('draws HotCRM as one line by default and its four modules on demand', async () => { + await serve({ packages: [HOTCRM, ...MODULES, TODO] }); + renderAt(SETUP_URL); + await settled(); + + for (const id of MODULE_IDS) expect(screen.queryByTestId(`pkg-row-${id}`)).toBeNull(); + const toggle = screen.getByTestId(`pkg-modules-toggle-${HOTCRM_ID}`); + expect(toggle).toHaveAttribute('aria-expanded', 'false'); + expect(screen.getByTestId(`pkg-row-${HOTCRM_ID}`)).toHaveTextContent('4 modules'); + + fireEvent.click(toggle); + expect(toggle).toHaveAttribute('aria-expanded', 'true'); + for (const id of MODULE_IDS) { + expect(screen.getByTestId(`pkg-row-${id}`)).toHaveAttribute('data-module-of', HOTCRM_ID); + } + // A module updates with its app: no Update cell of its own. + for (const id of MODULE_IDS) expect(screen.queryByTestId(`pkg-update-reading-${id}`)).toBeNull(); + + fireEvent.click(toggle); + for (const id of MODULE_IDS) expect(screen.queryByTestId(`pkg-row-${id}`)).toBeNull(); + }); + + it('a module that declares two apps, or none in view, stays a line of its own', async () => { + const twoApps = moduleOf(`${HOTCRM_ID}.bridge`, [HOTCRM_ID, 'com.example.todo']); + const orphan = moduleOf('com.example.lonely', ['com.example.absent']); + // Its app is a code package: not in the marketplace view, so not folded away. + const ofCodeApp = moduleOf('com.acme.code.extra', ['com.acme.code']); + await serve({ packages: [HOTCRM, TODO, CODE, twoApps, orphan, ofCodeApp] }); + renderAt(SETUP_URL); + await settled(); + + for (const id of [twoApps, orphan, ofCodeApp].map((p) => p.manifest.id)) { + expect(screen.getByTestId(`pkg-row-${id}`)).not.toHaveAttribute('data-module-of'); + } + expect(screen.queryByTestId(`pkg-modules-toggle-${HOTCRM_ID}`)).toBeNull(); + }); + + it('a search that finds a module shows it under its app', async () => { + await serve({ packages: [HOTCRM, ...MODULES, TODO] }); + renderAt(SETUP_URL); + await settled(); + + fireEvent.change(screen.getByPlaceholderText(row('engine.packages.search')), { target: { value: 'cpq' } }); + expect(await screen.findByTestId(`pkg-row-${HOTCRM_ID}.cpq`)).toHaveAttribute('data-module-of', HOTCRM_ID); + expect(screen.getByTestId(`pkg-row-${HOTCRM_ID}`)).toBeInTheDocument(); + expect(screen.queryByTestId('pkg-row-com.example.todo')).toBeNull(); + }); +}); + +describe('the two doors (objectstack#34722)', () => { + const headers = () => screen.getAllByRole('columnheader').map((h) => h.textContent?.trim()); + + it('Setup → Installed Apps draws the administrator columns and none of the developer doors', async () => { + await serve({ packages: [HOTCRM, ...MODULES, TODO, CODE, PLATFORM] }); + renderAt(SETUP_URL); + await settled(); + + expect(headers()).toEqual([ + row('engine.packages.col.name'), + row('engine.packages.col.version'), + row('engine.packages.col.status'), + row('engine.packages.col.source'), + row('engine.packages.installedApps.col.update'), + row('engine.packages.col.actions'), + ]); + expect(screen.queryByRole('button', { name: row('engine.packages.import') })).toBeNull(); + expect(screen.queryByRole('button', { name: row('engine.packages.new') })).toBeNull(); + expect(screen.queryByTestId('pkg-show-platform')).toBeNull(); + expect(screen.queryByTestId('pkg-source-filter')).toBeNull(); + expect(screen.queryByRole('button', { name: row('engine.packages.source.showAll') })).toBeNull(); + expect(screen.queryByTestId('pkg-scope')).toBeNull(); + expect(screen.queryByText(HOTCRM_ID)).toBeNull(); + }); + + it('Studio → Packages keeps Import, New Package, the platform switch and the developer columns, and asks no catalog', async () => { + await serve({ packages: [HOTCRM, ...MODULES, TODO, CODE, PLATFORM] }); + renderAt(STUDIO_URL); + await screen.findByTestId(`pkg-row-${HOTCRM_ID}`); + + expect(screen.getByRole('button', { name: row('engine.packages.import') })).toBeInTheDocument(); + expect(screen.getByRole('button', { name: row('engine.packages.new') })).toBeInTheDocument(); + expect(screen.getByTestId('pkg-show-platform')).toBeInTheDocument(); + expect(headers()).toEqual(expect.arrayContaining(['ID', row('engine.packages.col.scope')])); + expect(headers()).not.toContain(row('engine.packages.installedApps.col.update')); + // Every package is its own line there, modules included. + for (const id of MODULE_IDS) expect(screen.getByTestId(`pkg-row-${id}`)).toBeInTheDocument(); + expect(screen.queryByTestId('pkg-updates-summary')).toBeNull(); + expect(catalogReads).toEqual([]); + }); + + it('Studio → Packages filtered to another Source keeps its Show all chip', async () => { + await serve({ packages: [CODE, HOTCRM] }); + renderAt(`${STUDIO_URL}?source=code`); + await screen.findByTestId('pkg-row-com.acme.code'); + + expect(screen.getByTestId('pkg-source-filter')).toBeInTheDocument(); + expect(screen.getByRole('button', { name: row('engine.packages.source.showAll') })).toBeInTheDocument(); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx index 749be9fea04..5356cfce1ec 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx @@ -76,6 +76,7 @@ import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, + cn, } from '@object-ui/components'; import { useMetadataLocale, t, tFormat } from './i18n.js'; import { useMetadataClient } from './useMetadata.js'; From c49919e24ef9cf6b0565df397766a651748b0be6 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 09:40:13 +0000 Subject: [PATCH 4/9] test(app-shell): the Installed Apps door has no Show all chip; another Source keeps it Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .../PackagesPage.source-12675.test.tsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.source-12675.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.source-12675.test.tsx index ec44de90976..dd3ec2d80c1 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.source-12675.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.source-12675.test.tsx @@ -164,11 +164,23 @@ describe('Packages — marketplace capability present (objectui#12675)', () => { } }); - it('`?source=marketplace` shows only the marketplace rows, and Show all clears it', async () => { + it('`?source=marketplace` shows only the marketplace rows, with no Show all that clears it', async () => { await serve(true, { packages: [CODE, MARKET, AUTHORED], ledger: [LEDGER_TODO] }); renderPackages('?source=marketplace'); expect(await drawnSources()).toEqual({ 'com.example.todo': 'marketplace' }); + // objectstack#34722 — that view is Setup's Installed Apps door, and its + // one click into the unfiltered developer list is gone (ruling 甲 on + // objectstack#25098); `PackagesPage.installedAppsUpdates-34722.test.tsx` + // pins the door. + expect(screen.queryByTestId('pkg-source-filter')).toBeNull(); + }); + + it('another `?source=` shows only its rows, and Show all clears it', async () => { + await serve(true, { packages: [CODE, MARKET, AUTHORED], ledger: [LEDGER_TODO] }); + renderPackages('?source=code'); + + expect(await drawnSources()).toEqual({ 'com.acme.code': 'code' }); fireEvent.click(within(screen.getByTestId('pkg-source-filter')).getByRole('button')); await waitFor(() => expect(screen.getByTestId('location')).toHaveTextContent(new RegExp(`^${PACKAGES_PATH}$`))); expect(Object.keys(await drawnSources())).toHaveLength(3); From 9bf9521f5989617c599f39dcc5a0a878de82212d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 09:44:17 +0000 Subject: [PATCH 5/9] chore(changeset): Installed Apps update badge, folded modules, administrator columns Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .changeset/34722-installed-apps-updates.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .changeset/34722-installed-apps-updates.md diff --git a/.changeset/34722-installed-apps-updates.md b/.changeset/34722-installed-apps-updates.md new file mode 100644 index 00000000000..a41db7df59f --- /dev/null +++ b/.changeset/34722-installed-apps-updates.md @@ -0,0 +1,19 @@ +--- +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +feat(app-shell): Setup › Installed Apps shows which apps have a newer version, links to their upgrade, and folds module packages under their app + +Clause-②: yes (widening — locale keys only) +Metadata-protocol: none + +Setup › Installed Apps (the Packages page opened with `?source=marketplace`) is now the administrator's view of installed apps: + +- **Update available.** When the marketplace lists an app at a higher version than the one installed, the app's line shows the marketplace's own "Update available → vX" badge, decided by the same rule the marketplace pages use. The badge links to the app's marketplace page, where the upgrade runs unchanged. The page also says how many apps have a newer version. An app that is up to date, or that the catalog does not list, has no badge. +- **Catalog unavailable.** When the catalog cannot be read, or the runtime has no marketplace, the list is drawn as before with one line saying the update information cannot be read. It is never drawn as "up to date". +- **One line per app.** A module package (`type: 'module'`) that declares its app in `manifest.dependencies` is folded under that app's line and shown on demand. The tie is the one the server's disable door already reads. No new key is involved. +- **Administrator columns.** The columns are Name, Version, Status, Source and Update. The package id and the Scope badge stay on Studio's Packages. +- **Developer doors stay in Studio.** Import, New Package, the platform packages switch and the Source chip's "Show all" are not drawn on this view. Studio › Overview › Packages, the same page without `source`, keeps all of them. + +The badge's words stay in the lazy `marketplace` namespace, which this view now loads. The console's eager language pack does not grow. Nine new strings are added to the lazy `studio` namespace, in English and Chinese. From 3bb6f336c41fbf02c94d8cef50b71e1d7f5eb0aa Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 10:18:05 +0000 Subject: [PATCH 6/9] test(app-shell): pay the CEL helpers' first load at module top in the two edited suites Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .../PackagesPage.installedAppsUpdates-34722.test.tsx | 5 +++++ .../views/metadata-admin/PackagesPage.source-12675.test.tsx | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx index dd65a76218b..13227fe677a 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.installedAppsUpdates-34722.test.tsx @@ -56,6 +56,11 @@ vi.mock('@object-ui/i18n/namespaces/marketplace', async (importOriginal) => { import { PackagesPage, type InstalledPackageRow } from './PackagesPage'; import { t } from './i18n'; +// The page's package form reaches the CEL authoring helpers, which load these +// two lazily; loaded here so their first load is paid at import, not inside a +// test's clocked window. +import '@objectstack/formula'; +import '@objectstack/lint'; import { initRuntimeConfig, resetRuntimeConfigForTesting } from '../../runtime-config'; // The designer rows (the page's own strings) and the marketplace catalogue // (the badge's words) are both fetched on demand; resident before any case so diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.source-12675.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.source-12675.test.tsx index dd3ec2d80c1..3e2358cc4c9 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.source-12675.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.source-12675.test.tsx @@ -37,6 +37,11 @@ vi.mock('@object-ui/auth', async (importOriginal) => ({ import { PackagesPage, type InstalledPackageRow } from './PackagesPage'; import { PACKAGE_SOURCES } from './packageSource'; +// The page's package form reaches the CEL authoring helpers, which load these +// two lazily; loaded here so their first load is paid at import, not inside a +// test's clocked window. +import '@objectstack/formula'; +import '@objectstack/lint'; import { t, tFormat } from './i18n'; import { initRuntimeConfig, resetRuntimeConfigForTesting } from '../../runtime-config'; From 76fd636d5a83156d567e570f6f0b96e35a52d04b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 10:21:59 +0000 Subject: [PATCH 7/9] test(app-shell): a hook-gated marketplace door is gated only while its importer calls the hook Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .../__tests__/marketplaceNamespaceBoundary.test.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ui/packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts b/ui/packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts index 7965ff6d219..02167387e48 100644 --- a/ui/packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts +++ b/ui/packages/app-shell/src/console/marketplace/__tests__/marketplaceNamespaceBoundary.test.ts @@ -177,10 +177,18 @@ for (const file of allSources()) { } } -/** A declared hook-gated door whose outside importers are all declared for it (step 4). */ +/** + * A declared hook-gated door whose outside importers are all declared for it + * and all call the namespace hook (step 4); anything less leaves it ungated. + */ const isHookGated = (file: string) => { const allowed = HOOK_GATED_DOORS.get(file); - return !!allowed && [...(doors.get(file) ?? [])].every((importer) => allowed.includes(importer)); + return ( + !!allowed && + [...(doors.get(file) ?? [])].every( + (importer) => allowed.includes(importer) && callsNamespaceHook(join(UI_ROOT, importer)), + ) + ); }; /** Whether `file` imports {@link NAMESPACE_HOOK} from {@link NAMESPACE_MODULE} and calls it. */ From 8fc8e215a51f0f82a6117265bad748b32fe0a018 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 10:36:53 +0000 Subject: [PATCH 8/9] fix(app-shell): the Installed Apps name cell stacks its module count; the Update link does not wrap Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- .../src/views/metadata-admin/PackagesPage.tsx | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx index 5356cfce1ec..e5b25b5dd69 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx @@ -560,7 +560,7 @@ function InstalledAppUpdateCell({ rowId, read }: { rowId: string; read: UpdateRe e.stopPropagation()} - className="inline-flex items-center gap-2 text-sm font-medium text-primary hover:underline" + className="inline-flex items-center gap-2 whitespace-nowrap text-sm font-medium text-primary hover:underline" data-testid={`pkg-update-${rowId}`} > {namespace.status === 'ready' ? ( @@ -2157,14 +2157,16 @@ export function PackagesPage() { {open ? : } ) : null} - {p?.manifest.name || rowId} - {!module && modules.length > 0 && ( - - {modules.length === 1 - ? tFormat('engine.packages.installedApps.modulesOne', locale, { count: modules.length }) - : tFormat('engine.packages.installedApps.modules', locale, { count: modules.length })} - - )} +
+ {p?.manifest.name || rowId} + {!module && modules.length > 0 && ( + + {modules.length === 1 + ? tFormat('engine.packages.installedApps.modulesOne', locale, { count: modules.length }) + : tFormat('engine.packages.installedApps.modules', locale, { count: modules.length })} + + )} +
{p?.manifest.version || install?.version || '—'} From 53503c6a2688cf29bb9427f8264dec135e010429 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 10:39:56 +0000 Subject: [PATCH 9/9] docs(marketplace): Installed Apps lists one line per app with its modules folded under it Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufziunkXbDT7wUWqfmWz --- content/docs/deployment/marketplace-handbook.mdx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/content/docs/deployment/marketplace-handbook.mdx b/content/docs/deployment/marketplace-handbook.mdx index de8b511be62..19905b5ae44 100644 --- a/content/docs/deployment/marketplace-handbook.mdx +++ b/content/docs/deployment/marketplace-handbook.mdx @@ -234,7 +234,9 @@ the detail. with `?keepData=true` every row stays, sample rows included, and no door tells them apart any more, so purge first if you want them gone. 7. **Enable and disable.** **Setup → Installed Apps** lists the apps installed - from the marketplace, each package of a suite as its own row. An admin with + from the marketplace, one line per app: a module package that declares + exactly one installed app in its `manifest.dependencies` is folded under + that app's line, and the app's toggle shows it. An admin with `manage_metadata` may disable a writable package, and a **module of an installed app**: a `type: 'module'` package that declares an installed `type: 'app'` package in its `manifest.dependencies` @@ -296,7 +298,7 @@ An app ships extras in one of two shapes: A customer who does not use one of your modules can switch it off, per environment, with `PATCH /api/v1/packages/:id/disable`, and back on with `PATCH /api/v1/packages/:id/enable`. In the Console, the admin opens the -module's row in **Setup → Installed Apps** (or **Setup → Packages** for a suite +module's row under its app's line in **Setup → Installed Apps** (or **Setup → Packages** for a suite booted from code) and presses **Disable**, then confirms. The row's `disableable` key on `GET /api/v1/packages` is the runtime's own answer to whether the disable door accepts the package, and the Console offers